com.adventnet.snmp.mibs
Class MibModule

com.adventnet.snmp.mibs.MibModule
All Implemented Interfaces:
java.io.Serializable

public class MibModule
implements java.io.Serializable

This class represents a MIB module, and enables operations on MIB modules loaded from MIB files.

Typically one MIB module is specified in an MIB file. This class instance for an MIB module is obtained by loading an MIB through the MibOperations object.

In most cases you will not use the methods in this class, but rather the functions in MibOperations which apply across all loaded MIBs. Use this class to restrict your operation to a specific MIB module. This is not advisable always. Infact, some of the methods will use mibOps to get the appropriate values.

See Also:
Serialized Form

Method Summary
 MibNode getAgentCapabilities()
          Deprecated. since 4.0 . Instead you can use the method getDefinedAgentCapabilities
 AgentCapabilities getAgentCapabilities(java.lang.String acName)
          Returns the AgentCapabilities object present in this module.
 java.util.Enumeration getDefinedAgentCapabilities()
          Returns the Enumeration of AgentCapabilities present in this module.
 java.util.Enumeration getDefinedModuleCompliances()
          Returns the ModuleCompliances present in this module.
 java.util.Enumeration getDefinedNodes()
          Gets all the nodes defined in this module using this method.
 java.util.Enumeration getDefinedNotificationGroups()
          Gets all the NotificationGroup objects defined in this module.
 java.util.Enumeration getDefinedNotifications()
          Gets all the NOTIFICATION-TYPE objects defined in this module.
 java.util.Enumeration getDefinedNotificationTypes()
          Gets all the NotificationType objects defined in this module.
 java.util.Enumeration getDefinedObjectGroups()
          Gets all the ObjectGroup objects defined in this module.
 java.util.Enumeration getDefinedTCs()
          Gets all the TEXTUAL-CONVENTIONS defined in this module.
 java.util.Enumeration getDefinedTraps()
          Gets all the TRAP-TYPE objects defined in this MIB module.
 java.lang.String getFilename()
          Deprecated. since 2.1 . Instead you can use the method getFileName()
 java.lang.String getFileName()
          Gets the filename of this module.
 java.lang.String getImportedModules()
          Gets the names of the modules imported by this module.
 java.util.Hashtable getImports()
          Gets the imported elements in the MIB.
 LeafSyntax getLeafSyntax(SnmpOID oid)
          Gets the syntax of the node corresponding to this oid.
 ModuleIdentity getMibModuleIdentity()
          Gets the ModuleIdentity object for the given name.
 MibNode getMibNode(int[] oid)
          Gets the MibNode corresponding to the int array of OID.
 MibNode getMibNode(SnmpOID oid)
          Gets the MibNode corresponding to the SnmpOID argument
 MibNode getMibNode(java.lang.String oid)
          Gets the MibNode corresponding to the String OID argument.
 MibNode getMibNode(java.util.Vector oid)
          Gets the MibNode per the Vector of Strings OID argument.
 MibNode getMibNodeByName(java.lang.String nodeLabel)
          Gives the MibNode corresponding to the specified nodeLabel
 MibNode getMibNotification(java.lang.String name)
          Gets the NOTIFICATION-TYPE object corresponding to the given name.
 MibTC getMibTC(java.lang.String name)
          Gets the TEXTUAL-CONVENTION corresponding to the given name.
 MibTrap getMibTrap(java.lang.String name)
          Used to get the MibTrap object by giving the trap name.
 boolean getMibVersion()
          Used to know,whether the loaded MIB module is a SMIv1 MIB (Structure of Management Information) or SMIv2 MIB.
 ModuleCompliance getModuleCompliance(java.lang.String mcName)
          Returns the ModuleComplience object corresponding to the given name.
 MibNode getModuleIdentity()
          Gives the MODULE-IDENTITY node defined in the MIB.
 java.lang.String getName()
          Gets the name of this MIB module.
 MibNode getNearestNode(int[] oid)
          Gets the Nearest MibNode corresponding to the int array of OID.
 NotificationGroup getNotificationGroup(java.lang.String name)
          Gets the NotificationGroup object for the given name.
 NotificationType getNotificationType(java.lang.String name)
          Gets the NotificationType object for the given name.
 ObjectGroup getObjectGroup(java.lang.String name)
          Gets the ObjectGroup object for the given name.
 MibNode getRootNode()
          Gets a reference to the root node in this MIB module.
 java.util.Vector getRootNodes()
          Returns a collection of root nodes.
 SnmpOID getSnmpOID(java.lang.String s)
          Creates an SnmpOID instance from the specified string and information from this Module.
 java.lang.String toString()
          Returns the name of this MibModule.
 java.lang.String translateToNames(java.lang.String oid)
          Used for translating numbered OID String to named OID String.
 java.lang.String translateToNumbers(java.lang.String oid)
          Used for translating named OID String to numbered OID String.
 

Method Detail

getMibVersion

public boolean getMibVersion()
Used to know,whether the loaded MIB module is a SMIv1 MIB (Structure of Management Information) or SMIv2 MIB. It will be set to true if this module contains any SMIv2 macro constructs. If the MibModule contains any one of the following Macro constructs, this module will be treated as the SMIv2 MIB. AGENT-CAPABILITIES MODULE-COMPLIANCE MODULE-IDENTITY OBJECT-IDENTITY NOTIFICATION-TYPE NOTIFICATION-GROUP OBJECT-GROUP OBJECT-IDENTITY TEXTUAL-CONVENTION
Returns:
true if this MibModule is a SMIv2 MIB.
false, this MibModule is a SMIv1 MIB.

getName

public java.lang.String getName()
Gets the name of this MIB module. The module name begins with an upper-case letter and continues with zero or more letters, digits, or hyphens, except that a hyphen can not be the last character, nor can there be two consecutive hyphens. For example, RFC1213-MIB

toString

public java.lang.String toString()
Returns the name of this MibModule. This method is same as the getName() method.
See Also:
getName()

getRootNode

public MibNode getRootNode()
Gets a reference to the root node in this MIB module. This method will create a root node by getting the common ancestor node of all the nodes present in this module. If a module has more than one root node this method will return null. So we can use the getRootNodes() to get all the root nodes.
Returns:
MibNode. The root node if there is a single root node.
else return null.
See Also:
getRootNodes()

getRootNodes

public java.util.Vector getRootNodes()
Returns a collection of root nodes.
In case of a module containing a single root node, both the getRootNode() and getRootNodes() methods will return the root node. In case of module containing more than one root nodes like iso and ccitt, the getRootNode() will return null and the getRootNodes() will return a collection of root nodes.
Returns:
Vector of MibNodes representing the root set, if multiple rootnodes present in this module.
null, when a module contains only TEXUAL-CONVENTIONs and TRAP-TYPE macro types but no OBJECT-TYPE node objects.
See Also:
getRootNode()

getDefinedTraps

public java.util.Enumeration getDefinedTraps()
Gets all the TRAP-TYPE objects defined in this MIB module.
Returns:
Enumeration of MibTrap objects, if present in this module
Otherwise, returns Enumeration object with zero entries.
See Also:
getMibTrap(java.lang.String)

getMibTrap

public MibTrap getMibTrap(java.lang.String name)
Used to get the MibTrap object by giving the trap name.
Parameters:
name - the name of the trap
Returns:
MibTrap object if defined in this module, else return null.
See Also:
MibOperations.getMibTrap(com.adventnet.snmp.snmp2.SnmpOID, int, int)

getDefinedNotifications

public java.util.Enumeration getDefinedNotifications()
Gets all the NOTIFICATION-TYPE objects defined in this module.
Returns:
Enumeration of MibNodes. These MibNode objects contain all the information about the NOTIFICATION-TYPE objects.
See Also:
getMibNotification(java.lang.String)

getMibNotification

public MibNode getMibNotification(java.lang.String name)
Gets the NOTIFICATION-TYPE object corresponding to the given name.
Parameters:
name - label of the node whose macro-type is NOTIFICATION-TYPE
Returns:
MibNode corresponding to the name of the NOTIFICATION-TYPE, if present in this module
else return null.

getDefinedNodes

public java.util.Enumeration getDefinedNodes()
Gets all the nodes defined in this module using this method.
Returns:
Enumeration of MibNodes.

getFileName

public java.lang.String getFileName()
Gets the filename of this module.
Returns:
the name of the file in which this module is defined.

getFilename

public java.lang.String getFilename()
Deprecated. since 2.1 . Instead you can use the method getFileName()

See Also:
getFileName()

getModuleIdentity

public MibNode getModuleIdentity()
Gives the MODULE-IDENTITY node defined in the MIB. In an SMIv1 MIB, the MODULE-IDENTITY node will not be present.
Returns:
the MODULE-IDENTITY node.
null if not available.

getAgentCapabilities

public MibNode getAgentCapabilities()
Deprecated. since 4.0 . Instead you can use the method getDefinedAgentCapabilities

Gets the node corresponding to AgentCapabilities for this module.
Returns:
the AGENT-CAPABILITIES node in the MIB.
null, if not available.

getDefinedAgentCapabilities

public java.util.Enumeration getDefinedAgentCapabilities()
Returns the Enumeration of AgentCapabilities present in this module.
Returns:
the Enumeration containing AgentCapabilities object.
empty Enumeration , if AgentCapabilities object not available.

getAgentCapabilities

public AgentCapabilities getAgentCapabilities(java.lang.String acName)
Returns the AgentCapabilities object present in this module.
Returns:
the AgentCapabilities object if present else
returns null.

getDefinedModuleCompliances

public java.util.Enumeration getDefinedModuleCompliances()
Returns the ModuleCompliances present in this module.
Returns:
the Enumeration containing ModuleCompliance object.
empty Enumeration, if ModuleCompliance is not present in this Module.

getModuleCompliance

public ModuleCompliance getModuleCompliance(java.lang.String mcName)
Returns the ModuleComplience object corresponding to the given name.
Returns:
the ModuleCompliance object if present
else returns null.

getImportedModules

public java.lang.String getImportedModules()
Gets the names of the modules imported by this module.
Returns:
space separated list of imported module names.
null, if there are no imported modules.
See Also:
getImports()

translateToNames

public java.lang.String translateToNames(java.lang.String oid)
Used for translating numbered OID String to named OID String. In case the oid not starting with a dot, it will append the standard prefix .1.3.6.1.2.1 and the return the OID String.
Parameters:
oid - numbered OID string(e.g. .1.3.6.)
Returns:
the named oid String
null if the node is not found in this module

translateToNumbers

public java.lang.String translateToNumbers(java.lang.String oid)
Used for translating named OID String to numbered OID String. In case the oid not starting with a dot, it will append the standard prefix .1.3.6.1.2.1 and the return the OID String.
Parameters:
oid - OID String( e.g. .iso.org.dod)
Returns:
the numbered oid String
null if the node is not found in this module

getMibNodeByName

public MibNode getMibNodeByName(java.lang.String nodeLabel)
Gives the MibNode corresponding to the specified nodeLabel
Parameters:
nodeLabel - the name of the node
Returns:
MibNode object if the node is present in the module.
null otherwise

getMibNode

public MibNode getMibNode(java.lang.String oid)
Gets the MibNode corresponding to the String OID argument. This method will accept the OID string in following formats: 1. numbered OID string. MibNode node = module.getMibNode(".1.3.6.1.2.1.1.1"); 2. named OID string. MibNode node = module.getMibNode(".iso.org.dod.internet.mgmt.mib-2.snmp.sysDescr"); MibNode node = module.getMibNode("interfaces.ifTable.ifEntry.ifType"); MibNode node = module.getMibNode("system.sysDescr"); MibNode node = module.getMibNode("system.sysDescr"); MibNode node = module.getMibNode("sysDescr"); 3. numbered oid string without standard prefix. If the oid string not startswith the dot (".") the standard_prefix .1.3.6.1.2.1 will be prepended with the given oid string. MibNode node = module.getMibNode("1.1"); 4. combination of numbered and named OID string oid format. MibNode node = module.getMibNode(".1.3.6.1.2.1.system.1"); MibNode node = module.getMibNode(".iso.3.dod.2.mgmt.1.system.1"); MibNode node = module.getMibNode("interfaces.2.1.ifType"); The oid string can be given with the instance string in case of the leaf node. The leaf node objects are scalar or columnar node. MibNode node = module.getMibNode("1.1.0"); or MibNode node = module.getMibNode("sysDescr.0");
Parameters:
oid - String OID
Returns:
MibNode, if the node corresponding to the oid is present
null if the node is not present in this module or the instance present in the the non-leaf nodes.

getLeafSyntax

public LeafSyntax getLeafSyntax(SnmpOID oid)
Gets the syntax of the node corresponding to this oid. This does a search of the node in the module and returns the syntax for this SnmpOID instance.
Parameters:
oid - the SnmpOID instance of the node
Returns:
LeafSyntax object.
null if this node is not a leaf node

getMibNode

public MibNode getMibNode(SnmpOID oid)
Gets the MibNode corresponding to the SnmpOID argument
Parameters:
oid - an instance of SnmpOID
Returns:
MibNode, if the node is present. null otherwise.

getMibNode

public MibNode getMibNode(java.util.Vector oid)
Gets the MibNode per the Vector of Strings OID argument. For something like system.1 it will return sysDescr and if the vector contains sysDescr and nothing else, it will return the node for sysDescr This method always tries to retrieve a leaf node. If it matches a non-leaf node, then that node is returned only if the match of oid elements is exact(i.e no undefined child components, should exist in that system. If not so the system.1 will fail to return a node if loaded MIB does not contain sysDescr node But mib-2.1 will return system if the system node is available).
Parameters:
oid - Vector of Strings OID
Returns:
the MibNode per the Vector of Strings OID argument
null, if the node is not found

getMibNode

public MibNode getMibNode(int[] oid)
Gets the MibNode corresponding to the int array of OID. If there are more oid numbers than the node we could find then this method returns only the leaf node
Parameters:
oid - Integer array of the OID
Returns:
MibNode, if the node is present, null otherwise.

getNearestNode

public MibNode getNearestNode(int[] oid)
Gets the Nearest MibNode corresponding to the int array of OID. This method returns the nearest node even if it is not a leaf node (when there are more oid numbers than the node we could find).
Parameters:
oid - Integer array of the OID
Returns:
MibNode if the node is present, null otherwise.

getSnmpOID

public SnmpOID getSnmpOID(java.lang.String s)
Creates an SnmpOID instance from the specified string and information from this Module. It requires the first argument to be an OID of the form .N.N.N..., or N.N.N..., in which case the static Standard_Prefix in the SnmpAPI class is used. N can be a number or a name.
Parameters:
s - String OID(e.g. .1.3.6 or .iso.org.dod)
Returns:
the SnmpOID instance if found
else return null.

getDefinedTCs

public java.util.Enumeration getDefinedTCs()
Gets all the TEXTUAL-CONVENTIONS defined in this module.
Returns:
Enumeration of MibTC objects, if present in this module.
Enumeration object with zero entries, if not present. These MibTC objects contain all the information about the TEXTUAL-CONVENTION.
See Also:
getMibTC(java.lang.String)

getMibTC

public MibTC getMibTC(java.lang.String name)
Gets the TEXTUAL-CONVENTION corresponding to the given name.
Parameters:
name - the label of the TEXTUAL-CONVENTION
Returns:
MibTC object corresponding to the name of the TC, if present in this module. null otherwise.

getImports

public java.util.Hashtable getImports()
Gets the imported elements in the MIB. The Hashtable contains the key as MIB module name and the value containing the Vector of the names of the imported elements.
Returns:
Hashtable of Imported elements.

getDefinedNotificationTypes

public java.util.Enumeration getDefinedNotificationTypes()
Gets all the NotificationType objects defined in this module.
Returns:
Enumeration of NotificationType object. These NotificationType objects contain all the information about this NOTIFICATION-TYPE macro.
See Also:
getNotificationType(java.lang.String), getDefinedNotifications()

getNotificationType

public NotificationType getNotificationType(java.lang.String name)
Gets the NotificationType object for the given name.
Parameters:
name - label of the node whose macro-type is NOTIFICATION-TYPE
Returns:
NotificationType object corresponding to the name, if present in this module
else return null.
See Also:
getMibNotification(java.lang.String)

getDefinedNotificationGroups

public java.util.Enumeration getDefinedNotificationGroups()
Gets all the NotificationGroup objects defined in this module.
Returns:
Enumeration of NotificationGroup object. These NotificationGroup objects contain all the information about this NOTIFICATION-GROUP macro.
See Also:
getNotificationGroup(java.lang.String)

getNotificationGroup

public NotificationGroup getNotificationGroup(java.lang.String name)
Gets the NotificationGroup object for the given name.
Parameters:
name - label of the node whose macro-type is NOTIFICATION-GROUP
Returns:
NotificationGroup object corresponding to the name, if present in this module
else return null.

getDefinedObjectGroups

public java.util.Enumeration getDefinedObjectGroups()
Gets all the ObjectGroup objects defined in this module.
Returns:
Enumeration of ObjectGroup object. These ObjectGroup objects contain all the information about this OBJECT-GROUP macro.
See Also:
getObjectGroup(java.lang.String)

getObjectGroup

public ObjectGroup getObjectGroup(java.lang.String name)
Gets the ObjectGroup object for the given name.
Parameters:
name - label of the node whose macro-type is OBJECT-GROUP
Returns:
ObjectGroup object corresponding to the name, if present in this module
else return null.

getMibModuleIdentity

public ModuleIdentity getMibModuleIdentity()
Gets the ModuleIdentity object for the given name.
Parameters:
name - label of the node whose macro-type is MODULE-IDENTITY
Returns:
ModuleIdentity object corresponding to the name, if present in this module
else return null.


Copyright (c)AdventNet Inc., 1996-2004