FileDocCategorySizeDatePackage
SnmpOidTableSupport.javaAPI DocJava SE 5 API6705Fri Aug 26 14:55:04 BST 2005com.sun.jmx.snmp

SnmpOidTableSupport

public class SnmpOidTableSupport extends Object implements com.sun.jmx.snmp.SnmpOidTable
Contains metadata definitions for MIB variables. A name can be resolved against a table of MIB variables. Each entry in the table is an SnmpOidRecord object that contains a name, a dot-separated OID string, and the corresponding SMI type of the variable.

If you need to load a specific SnmpOidTable, just call the static method {@link com.sun.jmx.snmp.SnmpOid#setSnmpOidTable SnmpOid.setSnmpOidTable(myOidTable)}.

This API is a Sun Microsystems internal API and is subject to change without notice.

see
com.sun.jmx.snmp.SnmpOidRecord
version
1.18 12/19/03
author
Sun Microsystems, Inc

Fields Summary
String
dbgTag
private Hashtable
oidStore
private String
myName
Constructors Summary
public SnmpOidTableSupport(String name)
Creates an SnmpOidTableSupport with the specified name. This name identifies the MIB to which belong the MIB variables contained in this SnmpOidTableSupport object.

param
name The OID table name.

	
        myName=name;
    
Methods Summary
voiddebug(java.lang.String clz, java.lang.String func, java.lang.String info)

        Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_SNMP, clz, func, info);
    
voiddebug(java.lang.String func, java.lang.String info)

        debug(dbgTag, func, info);
    
public booleanequals(java.lang.Object object)
Checks if the specified Object is equal to this SnmpOidTableSupport.

param
object The Object to be compared.
return
true if object is an SnmpOidTableSupport instance and equals to this, false otherwise.


        if (!(object instanceof SnmpOidTableSupport)) {
            return false;
        }
        SnmpOidTableSupport val = (SnmpOidTableSupport) object;  
        return myName.equals(val.getName());     
    
public java.util.VectorgetAllEntries()
Returns a list that can be used to traverse all the entries in this SnmpOidTable.

return
A vector of {@link com.sun.jmx.snmp.SnmpOidRecord} objects.


        Vector elementsVector = new Vector();
        // get the locally defined elements ...
        for (Enumeration e = oidStore.elements();
             e.hasMoreElements(); ) {
            elementsVector.addElement(e.nextElement());
        }
        return elementsVector ;
    
public java.lang.StringgetName()
Returns the name identifying this SnmpOidTableSupport object.

return
The OID table name.

        return myName;
    
booleanisDebugOn()

        return Trace.isSelected(Trace.LEVEL_DEBUG, Trace.INFO_SNMP);
    
booleanisTraceOn()

        return Trace.isSelected(Trace.LEVEL_TRACE, Trace.INFO_SNMP);
    
public synchronized voidloadMib(com.sun.jmx.snmp.SnmpOidRecord[] mibs)
Loads a list of variables into the storage area, which is kept in memory. If you have new MIB variables, this method can be called to load them.

param
mibs The list of variables to load.

        try {
            for (int i = 0; ; i++) {
                SnmpOidRecord s = mibs[i] ;
                if (isTraceOn()) {
                    trace("loadMib", "load " + s.getName());
                }
                oidStore.put(s.getName(), s) ;
            }
        } catch (ArrayIndexOutOfBoundsException e) {
        }
    
public com.sun.jmx.snmp.SnmpOidRecordresolveVarName(java.lang.String name)
Searches for a MIB variable given its logical name and returns an {@link com.sun.jmx.snmp.SnmpOidRecord} object containing information on the variable.

param
name The name of the MIB variable.
return
The SnmpOidRecord object containing information on the variable.
exception
SnmpStatusException If the variable is not found.


        SnmpOidRecord var  = (SnmpOidRecord)oidStore.get(name) ;	
        if (var != null) {
            return var;
        } else {
            throw new SnmpStatusException("Variable name <" + name + "> not found in Oid repository") ;
        }
    
public com.sun.jmx.snmp.SnmpOidRecordresolveVarOid(java.lang.String oid)
Searches for a MIB variable given its OID and returns an {@link com.sun.jmx.snmp.SnmpOidRecord} object containing information on the variable.

param
oid The OID of the MIB variable.
return
The SnmpOidRecord object containing information on the variable.
exception
SnmpStatusException If the variable is not found.


        // Try to see if the variable name is actually an OID to resolve.
        //
        int index = oid.indexOf('.") ;
        if (index < 0) {
            throw new SnmpStatusException("Variable oid <" + oid + "> not found in Oid repository") ;
        }
        if (index == 0) {
            // The oid starts with a '.' ala CMU.
            //
            oid= oid.substring(1, oid.length());
        }
      
        // Go through the oidStore ... Good luck !
        //
        for(Enumeration list= oidStore.elements(); list.hasMoreElements(); ) {
            SnmpOidRecord element= (SnmpOidRecord) list.nextElement();
            if (element.getOid().equals(oid))
                return element;
        }

        throw new SnmpStatusException("Variable oid <" + oid + "> not found in Oid repository") ;
    
voidtrace(java.lang.String func, java.lang.String info)

        trace(dbgTag, func, info);
    
voidtrace(java.lang.String clz, java.lang.String func, java.lang.String info)

        Trace.send(Trace.LEVEL_TRACE, Trace.INFO_SNMP, clz, func, info);