com.outbackinc.services.protocol.snmp.mib
Class SimpleMIBDictionary

java.lang.Object
  |
  +--com.outbackinc.services.protocol.snmp.mib.SimpleMIBDictionary
All Implemented Interfaces:
SnmpMIBDictionary

public class SimpleMIBDictionary
extends java.lang.Object
implements SnmpMIBDictionary

A basic implementation of a SnmpMIBDictionary. SimpleMIBDictionary takes either a simple file-based mib format (.jmib) or MIB file (IF-MIB.my), and maintains an in-memory dictionary of mib names, OIDs, descriptions, types, access, status, and enumeration values. Users may resolve names to OIDs (& vice-versa), get description, type, access, and status strings from OIDs and names, as well as lookup the integer and string values associated with enumerations.

Usage: The following code snippet provides an example of its use:

      // Create the service
      SnmpMIBService cSnmpMIBService = SnmpLocalInterfaces.getMIBService();
 
      // Load the IF-MIB MIB file into the service
      InputStream cInputStream = jMIBC.loadMib("IF-MIB.my");
      cSnmpMIBService.loadMIB("IF-MIB", cInputStream);

      // Or alternately, load the IF-MIB jMIB file into the service
      //cSnmpMIBService.loadMIB("IF-MIB", new FileInputStream("IF-MIB.jmib"));
 
      // Get a handle to the mib dictionary for the MIB
      SnmpMIBDictionary cSnmpMIBDictionary = service.getMIBDictionary("IF-MIB");
 
      // Resolve name to OID (will return 1.3.6.1.2.1.2.2.1.10):
      String szOid = cSnmpMIBDictionary.resolveName("ifInOctets");
      
      // Resolve name to OID (will return 1.3.6.1.2.1.2.2.1.10.1):
      szOid = cSnmpMIBDictionary.resolveName("ifInOctets.1");

      // Resolve OID to name (will return ifInOctets):
      String szName = cSnmpMIBDictionary.resolveOID("1.3.6.1.2.1.2.2.1.10");
 
      // Resolve OID to name (will return ifInOctets.1):
      szName = cSnmpMIBDictionary.resolveOID("1.3.6.1.2.1.2.2.1.10.1");

      // Resolve name to name description (will return "The total number ...")
      String szDescription = cSnmpMIBDictionary.resolveNameDescription("ifInOctets");
 
      // Resolve OID to OID description (will return "The total number ...")
      szDescription = cSnmpMIBDictionary.resolveOIDDescription("1.3.6.1.2.1.2.2.1.10");
 
      // Resolve name to name type (will return "Counter")
      String szType = cSnmpMIBDictionary.resolveNameType("ifInOctets");
 
      // Resolve OID to OID type (will return "Counter")
      szType = cSnmpMIBDictionary.resolveOIDType("1.3.6.1.2.1.2.2.1.10");
 
      // Resolve name to name access (will return "read-only")
      String szAccess = cSnmpMIBDictionary.resolveNameAccess("ifInOctets");
 
      // Resolve OID to OID access (will return "read-only")
      szAccess = cSnmpMIBDictionary.resolveOIDAccess("1.3.6.1.2.1.2.2.1.10");
 
      // Resolve name to name status (will return "mandatory")
      String szStatus = cSnmpMIBDictionary.resolveNameStatus("ifInOctets");
 
      // Resolve OID to OID status (will return "mandatory")
      szStatus = cSnmpMIBDictionary.resolveOIDStatus("1.3.6.1.2.1.2.2.1.10");
 
      // Find enum string for enum int value (will return ethernetCsmacd):
      String szEnum = cSnmpMIBDictionary.resolveEnum("ifType", 6);

      // Find enum int for enum string value (wil return 6):
      int iEnum = cSnmpMIBDictionary.resolveEnumDisplayString("ifType",
                                                  "ethernetCsmacd");
 


Constructor Summary
SimpleMIBDictionary(java.lang.String szMibName, java.io.InputStream cInputStream)
          Create a new MIB dictionary based upon formatted input.
 
Method Summary
 java.lang.String getMIBDictionaryName()
          Get the name of the MIB Dictionary object.
 java.lang.String resolveEnum(java.lang.String szName, int iValue)
          Resolve an enumerated value (as an integer) to the corresponding displayable name.
 int resolveEnumDisplayString(java.lang.String szName, java.lang.String szValue)
          Get the numeric value of a given string of an enumerated type.
 java.lang.String resolveName(java.lang.String szName)
          Find the Object ID for a given object name.
 java.lang.String resolveNameAbstractType(java.lang.String szName)
          Find the 'abstract' type for a given object name.
 java.lang.String resolveNameAccess(java.lang.String szName)
          Find the access for a given object name.
 java.lang.String resolveNameDescription(java.lang.String szName)
          Find the description for a given object name.
 java.lang.String resolveNameStatus(java.lang.String szName)
          Find the status for a given object name.
 java.lang.String resolveNameType(java.lang.String szName)
          Find the type for a given object name.
 java.lang.String resolveOID(java.lang.String szOid)
          Resolve an Object ID to its corresponding name.
 java.lang.String resolveOIDAbstractType(java.lang.String szOid)
          Resolve an Object ID to its corresponding 'abstract' type.
 java.lang.String resolveOIDAccess(java.lang.String szOid)
          Resolve an Object ID to its corresponding access.
 java.lang.String resolveOIDDescription(java.lang.String szOid)
          Resolve an Object ID to its corresponding description.
 java.lang.String resolveOIDStatus(java.lang.String szOid)
          Resolve an Object ID to its corresponding status.
 java.lang.String resolveOIDType(java.lang.String szOid)
          Resolve an Object ID to its corresponding type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleMIBDictionary

public SimpleMIBDictionary(java.lang.String szMibName,
                           java.io.InputStream cInputStream)
Create a new MIB dictionary based upon formatted input.
Parameters:
szMibName - The name to assign to the mib
cInputStream - An input stream used to read in the raw mib definition

The raw InputStream mib import one key/value mapping per line. The mappings are in the form 'key=value'. Valid keys can be object names, OIDs, and 'objectname.attribute' entries.

The following snippet provides an example:

      sysDescr=1.3.6.1.2.1.1.1
      sysDescr.TYPE=OctetString
      sysDescr.ABSTRACTTYPE=DisplayString
      sysDescr.ACCESS=read-only
      sysDescr.STATUS=mandatory
      sysDescr.DESCRIPTION=A textual description of the entity. This value should include the full name and version identification of the system's hardware type, software operating-system, and networking software. It is mandatory that this only contain printable ASCII characters.
      ifType=1.3.6.1.2.1.2.2.1.3
      ifType.TYPE=Enum
      ifType.ABSTRACTTYPE=INTEGER
      ifType.ACCESS=read-only
      ifType.STATUS=mandatory
      ifType.DESCRIPTION=The type of interface, distinguished according to the physical/link protocol(s) immediately `below' the network layer in the protocol stack.
      ifType.other=1
      ifType.1=other
      ifType.regular1822=2
      ifType.2=regular1822
      ifType.hdh1822=3
      ifType.3=hdh1822
      ifType.ddn-x25=4
      ifType.4=ddn-x25
 
Normally, the InputStream is is derived from a MIB using the com.outbackinc.services.protocol.snmp.mib.jMIBC.loadMib() method.

The following code snippet provides an example:

      SimpleMIBDictionary cSimpleMIBDictionary = null;
      try
      {
          InputStream istream = jMIBC.loadMib("HOST-RESOURCES-MIB.my");
          cSimpleMIBDictionary = new SimpleMIBDictionary("HOST-RESOURCES-MIB", istream);
      }
      catch( Exception e )
      {
          System.out.println("Couldn't load the HOST-RESOURCES-MIB MIB ... " + e.getMessage() + ".\n");
      }
 
Alternately, .jmib files (constructed by jSNMP Enterprises' MIB compiler jMIBC or from the Extended MOSY output generated by a MIB complier such as SMICng) may be used for the InputStream.

The following code snippet provides an example:

      SimpleMIBDictionary cSimpleMIBDictionary = null;
      try
      {
          cSimpleMIBDictionary = new SimpleMIBDictionary("rfc2233", new FileInputStream("rfc2233.jmib"));
      }
      catch( Exception e )
      {
          System.out.println("Couldn't load the HOST-RESOURCES-MIB MIB ... " + e.getMessage() + ".\n");
      }
 
Method Detail

getMIBDictionaryName

public java.lang.String getMIBDictionaryName()
Description copied from interface: SnmpMIBDictionary
Get the name of the MIB Dictionary object.
Specified by:
getMIBDictionaryName in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Returns:
name of the MIB Dictionary object

resolveName

public java.lang.String resolveName(java.lang.String szName)
Description copied from interface: SnmpMIBDictionary
Find the Object ID for a given object name. Is capable of handling name with or without a suffix (ifType/ifType.0).
Specified by:
resolveName in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szName - Object name to resolve to its OID
Returns:
OID for the given object name, or null if not found

resolveOID

public java.lang.String resolveOID(java.lang.String szOid)
Description copied from interface: SnmpMIBDictionary
Resolve an Object ID to its corresponding name.
Specified by:
resolveOID in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szOid - Object ID to resolve
Returns:
Object Name for the given OID or null if not found

resolveNameDescription

public java.lang.String resolveNameDescription(java.lang.String szName)
Description copied from interface: SnmpMIBDictionary
Find the description for a given object name. Is capable of handling name with or without a suffix (ifType/ifType.0).
Specified by:
resolveNameDescription in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szName - Object name to resolve to its OID
Returns:
Description for the given object name, or null if not found

resolveOIDDescription

public java.lang.String resolveOIDDescription(java.lang.String szOid)
Description copied from interface: SnmpMIBDictionary
Resolve an Object ID to its corresponding description.
Specified by:
resolveOIDDescription in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szOid - Object ID to resolve
Returns:
Description for the given OID or null if not found

resolveNameType

public java.lang.String resolveNameType(java.lang.String szName)
Description copied from interface: SnmpMIBDictionary
Find the type for a given object name. Is capable of handling name with or without a suffix (ifType/ifType.0).
Specified by:
resolveNameType in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szName - Object name to resolve to its OID
Returns:
Type for the given object name, or null if not found

resolveOIDType

public java.lang.String resolveOIDType(java.lang.String szOid)
Description copied from interface: SnmpMIBDictionary
Resolve an Object ID to its corresponding type.
Specified by:
resolveOIDType in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szOid - Object ID to resolve
Returns:
Type for the given OID or null if not found

resolveNameAbstractType

public java.lang.String resolveNameAbstractType(java.lang.String szName)
Description copied from interface: SnmpMIBDictionary
Find the 'abstract' type for a given object name. Is capable of handling name with or without a suffix (ifType/ifType.0).
Specified by:
resolveNameAbstractType in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szName - Object name to resolve to its OID
Returns:
Type for the given object name, or null if not found

resolveOIDAbstractType

public java.lang.String resolveOIDAbstractType(java.lang.String szOid)
Description copied from interface: SnmpMIBDictionary
Resolve an Object ID to its corresponding 'abstract' type.
Specified by:
resolveOIDAbstractType in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szOid - Object ID to resolve
Returns:
Type for the given OID or null if not found

resolveNameAccess

public java.lang.String resolveNameAccess(java.lang.String szName)
Description copied from interface: SnmpMIBDictionary
Find the access for a given object name. Is capable of handling name with or without a suffix (ifType/ifType.0).
Specified by:
resolveNameAccess in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szName - Object name to resolve to its OID
Returns:
Access for the given object name, or null if not found

resolveOIDAccess

public java.lang.String resolveOIDAccess(java.lang.String szOid)
Description copied from interface: SnmpMIBDictionary
Resolve an Object ID to its corresponding access.
Specified by:
resolveOIDAccess in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szOid - Object ID to resolve
Returns:
Access for the given OID or null if not found

resolveNameStatus

public java.lang.String resolveNameStatus(java.lang.String szName)
Description copied from interface: SnmpMIBDictionary
Find the status for a given object name. Is capable of handling name with or without a suffix (ifType/ifType.0).
Specified by:
resolveNameStatus in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szName - Object name to resolve to its OID
Returns:
Status for the given object name, or null if not found

resolveOIDStatus

public java.lang.String resolveOIDStatus(java.lang.String szOid)
Description copied from interface: SnmpMIBDictionary
Resolve an Object ID to its corresponding status.
Specified by:
resolveOIDStatus in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szOid - Object ID to resolve
Returns:
Status for the given OID or null if not found

resolveEnum

public java.lang.String resolveEnum(java.lang.String szName,
                                    int iValue)
Description copied from interface: SnmpMIBDictionary
Resolve an enumerated value (as an integer) to the corresponding displayable name.
Specified by:
resolveEnum in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szName - object name (or OID)
iValue - current (integer) value
Returns:
displayable name corresponding to the supplied value

resolveEnumDisplayString

public int resolveEnumDisplayString(java.lang.String szName,
                                    java.lang.String szValue)
Description copied from interface: SnmpMIBDictionary
Get the numeric value of a given string of an enumerated type.
Specified by:
resolveEnumDisplayString in interface SnmpMIBDictionary
Following copied from interface: com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
Parameters:
szName - object name (or OID)
szValue - displayable string value for the object
Returns:
integer value corresponding to the given displayable string value


Home  Services  Products  Purchase  Contact Us  About Us  Legal  Ceramics
Copyright © 2003-2008 jSNMP Enterprises All rights reserved.