com.adventnet.snmp.mibs
Class MibNode
com.adventnet.snmp.mibs.MibNode
- All Implemented Interfaces:
- java.io.Serializable
- public class MibNode
- implements java.io.Serializable
This class represents an MIB node in the MIB module tree.
It is derived from parsing an MIB module which contains
references to its parents,children and the dependents.
- See Also:
- Serialized Form
Method Summary |
SnmpVarBind |
createSnmpVarBind(java.util.Vector indexes,
SnmpVar value,
java.util.Vector indexMibNodes)
Creates an SnmpVarBind instance with supplied parameters. |
SnmpVar |
decodeDefval()
Gives the decoded value of the DEFVAL field. |
int |
getAccess()
Gets the access value for this node. |
java.util.Vector |
getAgentCapabilities()
Gets the various clauses in AGENT-CAPABILITIES as a Vector of AgentCapabilitiesModule |
MibNode |
getAugments()
Gets the augmented table entry. |
MibNode |
getChild(int subId)
Gets the child node corresponding to the particular sub-id. |
MibNode |
getChild(long subOid)
Gets the child node corresponding to the suboid. |
java.util.Vector |
getChildList()
Gets the child nodes. |
MibNode |
getCommonAncestorWith(MibNode node)
Gives the common ancestor node for this node and the specified node. |
java.lang.String |
getContactinfo()
Gets the value of CONTACT-INFO clause in MODULE-IDENTITY macro |
java.lang.String |
getDefval()
The defval for this node can be obtained using this method. |
java.lang.String |
getDescription()
Gets the description for this node |
java.util.Vector |
getExternalIndices()
Gets the external indices present in the table entry |
java.lang.String |
getImpliedNode()
Gives the implied node name present in the INDEX list of this MIB node. |
java.lang.String |
getImportedModuleName()
Gets the name of the module from where this node is imported. |
java.util.Vector |
getIndexes(MibOperations mibs)
Gives the indexes as a Vector of MibNodes. |
java.util.Vector |
getIndexNames()
Gives the index names defined for this node. |
boolean |
getIsAugmented()
Used to know whether the entry node contains the AUGMENTS clause. |
java.lang.String |
getLabel()
Gets the name of this MIB Node. |
java.lang.String |
getLastupdated()
Gets the value of the LAST-UPDATED clause in MODULE-IDENTITY macro |
java.lang.String |
getMacroType()
Gets the macro-type of this node. |
java.util.Vector |
getModuleCompliance()
Gets the various clauses in MODULE-COMPLIANCE macro. |
java.lang.String |
getModuleName()
Gets the name of the module this node is defined
return the module name e.g. |
MibNode |
getNextLeafNode()
Gives the next leaf node by searching through the current
module. |
java.lang.String |
getNotificationsNames()
Gets the NOTIFICATIONS clause names in NOTIFICATION-GROUP macro |
java.lang.String |
getNumberedOIDString()
Gives the numbered OID string of the node. |
java.lang.String |
getObjectNames()
Deprecated. use the getObjects method instead. |
java.util.Vector |
getObjects()
Gets the OBJECT clause names in OBJECT-GROUP and NOTIFICATION-TYPE macro. |
int[] |
getOID()
Gives the numbered OID of the node as an array of ints. |
java.lang.String |
getOIDString()
Gives the named OID of the node. |
java.util.Vector |
getOIDVector()
Gets the named OID of the node as a Vector. |
java.util.Vector |
getOIDVectorIds()
Gives the numbered OID of the node as a Vector of Integer objects. |
java.lang.String |
getOrganization()
Gets the value of ORGANIZATION clause in MODULE-IDENTITY macro |
MibNode |
getParent()
We can make use this method to get the parent of this node. |
java.lang.String |
getProductrelease()
Get the value of PRODUCT-RELEASE clause in AGENT-CAPABILITIES macro |
java.lang.String |
getReference()
Gets string reference for this node. |
java.lang.String |
getRevdescription()
Deprecated. since 4.0. Instead you can use the method getRevisionDescriptions() |
java.lang.String |
getRevision()
Deprecated. since 4.0. Instead you can use the method getRevisions() |
java.util.Vector |
getRevisionDescriptions()
Gives the revision descriptions as a vector of String Elements. |
java.util.Vector |
getRevisions()
Gives the revisions as a Vector of String Elements. |
java.lang.String |
getRowName()
Gets the name of the row sequence. |
java.lang.String |
getStatus()
Gets the status value of this node. |
int |
getSubid()
Deprecated. since 4.0. Instead you can use the method getSubID() |
long |
getSubID()
Gives the sub-identifier of this node's object-identifier. |
LeafSyntax |
getSyntax()
Gives the syntax associated with this node. |
java.util.Vector |
getTableItems()
Will give the names of the items in the row sequence. |
java.lang.String |
getTableSequence()
Gets the name in the SEQUENCE OF "name" item |
java.lang.String |
getUnits()
Gets the value of UNITS clause in OBJECT-TYPE macro |
boolean |
isAncestorOf(MibNode node)
Used to know whether this node is an ancestor of the specified node. |
boolean |
isDescendentOf(MibNode node)
Using this method we can find whether this node is descendent of the specified node. |
boolean |
isImplied()
Used to find whether the INDEX clause contains an Implied statement |
boolean |
isImportedNode()
Used to find whether this is an imported node. |
boolean |
isInCurrentTable(java.lang.String nodeLabel)
Used to find whether the given node is a column of the current table. |
boolean |
isIndex()
Using this method we can find whether this is an index node. |
boolean |
isLeaf()
Used to know whether this is a leaf node. |
boolean |
isReadable()
Used to know whether this node is readable. |
boolean |
isScalar()
Using this method we can find whether this node is Scalar or not. |
boolean |
isTable()
Used to know whether this is a table node. |
boolean |
isTableColumn()
Used to know whether this node is a table column or not. |
boolean |
isTableEntry()
Used to find whether this node is a table entry. |
boolean |
isWriteable()
Used to know whether this node is writeable. |
java.lang.String |
printAccess()
Gives the access value as a string. |
java.lang.String |
printDescription()
Returns the Description string |
java.util.Vector |
printIndex()
The names of the index nodes can be obtained using this method. |
java.lang.String |
printReference()
Returns the Reference string |
java.lang.String |
printStatus()
Returns the status value as a string. |
void |
setDefval(java.lang.String defval)
Sets the defval as defined in the MIB. |
java.lang.String |
toString()
Gives the name of thiiss node. |
java.lang.String |
toTagString()
We can get more details on the node, much like the MIB definition itself. |
isImportedNode
public boolean isImportedNode()
- Used to find whether this is an imported node.
- Returns:
- true if the node is imported from other MIB Module
false otherwise.
getSubid
public int getSubid()
- Deprecated. since 4.0. Instead you can use the method getSubID()
- Gets the subid of this MIB Node.
For example, the subid for the node sysName with OID .1.3.6.1.2.1.1.5 will be 5
- Returns:
- int. The subid for this node.
- See Also:
getSubID()
getSubID
public long getSubID()
- Gives the sub-identifier of this node's object-identifier.
The ObjectIdentifier have the 128 sub-identifiers, each
sub-identifier can have the value ranges from 0 to 4294967295.
getChildList
public java.util.Vector getChildList()
- Gets the child nodes.
e.g, For the node system in RFC1213-MIB, the childList
returned by this method will be the following MibNodes -
sysDescr, sysObjectId, sysUpTime, sysContact, sysName,
sysLocation, sysServices.
- Returns:
- Vector of child nodes
empty Vector if there is no children.
getChild
public MibNode getChild(int subId)
- Gets the child node corresponding to the particular sub-id.
The child node could be in another MIB.
- Parameters:
subId
- The child sub-oid e.g the subId of sysDescr will be 1.
So that getChild on system Node with 1 will result in returning the sysDescr node.- Returns:
- the child node corresponding to the sub-id.
null if no node with that sub-id occurs in the child list.
getChild
public MibNode getChild(long subOid)
- Gets the child node corresponding to the suboid.
The child node could be in another MIB.
- Parameters:
subOid
- The child sub-oid e.g the subId of sysDescr will be 1.
So that getChild on system Node with 1 will result in returning the sysDescr node.- Returns:
- the child node corresponding to the sub-id.
null if no node with that sub-id occurs in the child list.
getAugments
public MibNode getAugments()
- Gets the augmented table entry.
- Returns:
- the augmented MibNode
null, if the table does not uses augmented table entry.
toString
public java.lang.String toString()
- Gives the name of thiiss node. similar to the getLabel() method.
- Returns:
- String. The name of this node, i.e. label
- See Also:
getLabel()
toTagString
public java.lang.String toTagString()
- We can get more details on the node, much like the MIB definition itself.
This also includes the complete definition of the node.
- Returns:
- the node details e.g.,
Node OID: .iso.org...
Syntax: INTEGER,
Access: read-only,etc..
getOID
public int[] getOID()
- Gives the numbered OID of the node as an array of ints.
- Returns:
- the int array containing the OID elements. e.g [1,3,6,1,...]
getOIDString
public java.lang.String getOIDString()
- Gives the named OID of the node.
- Returns:
- named OID of the node as a String. e.g. .iso.org.
getNumberedOIDString
public java.lang.String getNumberedOIDString()
- Gives the numbered OID string of the node.
- Returns:
- numbered OID string of the node. e.g. .1.3.6...
getOIDVector
public java.util.Vector getOIDVector()
- Gets the named OID of the node as a Vector.
- Returns:
- Vector of named OID of the node.
getOIDVectorIds
public java.util.Vector getOIDVectorIds()
- Gives the numbered OID of the node as a Vector of Integer objects.
- Returns:
- Vector of numbered OID of the node.
printIndex
public java.util.Vector printIndex()
- The names of the index nodes can be obtained using this method.
- Returns:
- Vector of the Index Names.
null if the node is not a table entry.
isImplied
public boolean isImplied()
- Used to find whether the INDEX clause contains an Implied statement
- Returns:
- true if the IMPLIED keyword is present in the INDEX clause.
else returns false.
getNextLeafNode
public MibNode getNextLeafNode()
- Gives the next leaf node by searching through the current
module. This is useful for agents looking for the OID or label for the
next MIB node for the getnext requests. This assumes the MIB module
file objects were defined in the desired order. And, it also it spans
multiple modules.
- Returns:
- the next node in the tree - if the node exists,
null - if end of the MIB tree is reached.
createSnmpVarBind
public SnmpVarBind createSnmpVarBind(java.util.Vector indexes,
SnmpVar value,
java.util.Vector indexMibNodes)
- Creates an SnmpVarBind instance with supplied parameters.
Used for creating SNMP OIDs with instance values for tables.
Supply the value when using for SNMP set.
if value is null, SnmpNull is used as needed by get requests.
- Parameters:
indexes
- The ordered list of index values which
can be SnmpVar values. Parameter can
be null for non-tabular columnsvalue
- The SnmpVar value to be used for creating the SnmpVarBind instanceindexMibNodes
- The index nodes for this node's parent- Returns:
- the SnmpVarbind instance
isTableColumn
public boolean isTableColumn()
- Used to know whether this node is a table column or not.
- Returns:
- true if this node is a table column
false otherwise.
isInCurrentTable
public boolean isInCurrentTable(java.lang.String nodeLabel)
- Used to find whether the given node is a column of the current table.
- Parameters:
nodeLabel
- the name of the node which is to be checked whether it is in this table.- Returns:
- true if the node is a column of the current table.
false otherwise.
isReadable
public boolean isReadable()
- Used to know whether this node is readable.
A node is considered readable if the ACCESS clause specifies the access to read-only, read-write or read-create.
- Returns:
- true if the node is readable.
false if not readable or if the node is not a leaf node. - See Also:
isWriteable()
,
isLeaf()
isWriteable
public boolean isWriteable()
- Used to know whether this node is writeable.
A mib variable is writeable if the access specifies it to read-write,write-only or read-create type.
A writeable access in the MIB does not ensure that a Set will succeed on this variable.
Factors contributing to failure could be agent
implementation dependent(certain device capabilities) or
access control on agent ( which could e.g., be community based )
- Returns:
- true if this node is writeable.
false if not writable or if the node is not a leaf node. - See Also:
isReadable()
,
isLeaf()
isScalar
public boolean isScalar()
- Using this method we can find whether this node is Scalar or not.
- Returns:
- true if the node is a Scalar variable.
false otherwise. - See Also:
isLeaf()
isTable
public boolean isTable()
- Used to know whether this is a table node.
A table is defined in terms of a SEQUENCE of MibNodes
forming the table. In case a table AUGMENTS another table
the children of the table getting augmented will not be
part of the tableItems of this node.
A table node will usually have only one child node corresponding
to the tableEntry node. A tableEntry node will contain
information pertaining to the INDEX columns for the table
or the reference to the Augmented tableEntry from which the
index for this table can be derived.
- Returns:
- true if this node is the root of a table.
false otherwise. - See Also:
isTableEntry()
isTableEntry
public boolean isTableEntry()
- Used to find whether this node is a table entry.
A table entry is identified by the fact that there is an INDEX
component defined for it or an AUGMENTS clause defined in it.
- Returns:
- true if this node is a table entry e.g. ifEntry
false otherwise and also in case of table e.g ifTable. - See Also:
isTable()
isLeaf
public boolean isLeaf()
- Used to know whether this is a leaf node. A leaf node is either a scalar object
or a columnar object and always associated with a syntax.
- Returns:
- true if this node is leaf.
false otherwise.
- See Also:
isScalar()
getIndexes
public java.util.Vector getIndexes(MibOperations mibs)
- Gives the indexes as a Vector of MibNodes.
- Parameters:
mibs
- The MibOperations instance.- Returns:
- Vector of Index MibNodes.
null if not a table column.
Vector element will be null if the MibNode is not found.
decodeDefval
public SnmpVar decodeDefval()
throws MibException,
SnmpException
- Gives the decoded value of the DEFVAL field.
SnmpOID is supported for only numbered format, eg {{N N N}}
This method decodes the DEFVAL value that is being defined for this node in the
MIB, creates and returns the corresponding SnmpVar object.
- Returns:
- the Defval as SnmpVar
null if the OID is in label format
empty String if there is no DEFVAL field - Throws:
MibException
- is thrown if syntax type is not one of the standard types.SnmpException
- is thrown on format errors.
getRevisions
public java.util.Vector getRevisions()
- Gives the revisions as a Vector of String Elements.
- Returns:
- the revision strings in a Vector.
The elements will be null,if setReadDesc(boolean) is set to false.
The size of the Vector denotes the number of revisions. Applicable to module-identity.
getRevisionDescriptions
public java.util.Vector getRevisionDescriptions()
- Gives the revision descriptions as a vector of String Elements.
- Returns:
- the revision descriptions string in a Vector.
The elements will be null, if setReadDesc(boolean) is set to false.
The size of the Vector denotes the number of revisions. Applicable to module-identity.
getObjects
public java.util.Vector getObjects()
- Gets the OBJECT clause names in OBJECT-GROUP and NOTIFICATION-TYPE macro.
- Returns:
- Vector containing the String objects.
null, if the macro-type is other than OBJECT-GROUP and NOTIFICATION-TYPE.
getModuleName
public java.lang.String getModuleName()
- Gets the name of the module this node is defined
return the module name e.g. RFC1213-MIB
getMacroType
public java.lang.String getMacroType()
- Gets the macro-type of this node.
- Returns:
- String corresponding to the type. The values
are OBJECT-TYPE,OBJECT-IDENTITY,MODULE-IDENTITY etc.
getLabel
public java.lang.String getLabel()
- Gets the name of this MIB Node.
This method is same as toString().
- See Also:
toString()
getParent
public MibNode getParent()
- We can make use this method to get the parent of this node.
- See Also:
getChild(int subId)
,
getChildList()
getSyntax
public LeafSyntax getSyntax()
- Gives the syntax associated with this node.
- Returns:
- LeafSyntax object, if the syntax is basic.
MibTC object, if the syntax is a TC.
getAccess
public int getAccess()
- Gets the access value for this node.
The following are the return values, which are mapped as
not-accessible - SnmpAPI.NOACCESS
read-only - SnmpAPI.RONLY
read-write - SnmpAPI.RWRITE
write-only - SnmpAPI.WONLY
read-create - SnmpAPI.RCREATE
accessible-for-notify - SnmpAPI.ACCESSFORNOTIFY
getStatus
public java.lang.String getStatus()
- Gets the status value of this node.
getDescription
public java.lang.String getDescription()
- Gets the description for this node
getReference
public java.lang.String getReference()
- Gets string reference for this node. This clause specifies the source
of the definition e.g documents from standards organization
or a document for a proprietary system.
getIndexNames
public java.util.Vector getIndexNames()
- Gives the index names defined for this node.
These are the names that is defined in the INDEX field of
table entry node.
- Returns:
- Vector of the index names.
null, if the node is not a table entry.
getDefval
public java.lang.String getDefval()
- The defval for this node can be obtained using this method.
- Returns:
- The defval for the node if present.
empty String if there is no DEFVAL field.
setDefval
public void setDefval(java.lang.String defval)
- Sets the defval as defined in the MIB.
The value set is not reflected in the MIB.
To check whether the value is set, the getDefval() method can be used.
- Parameters:
defval
- the value to be set.- See Also:
getDefval()
getTableSequence
public java.lang.String getTableSequence()
- Gets the name in the SEQUENCE OF "name" item
- Returns:
- the name of the SEQUENCE.
null, if not a table node.
getRowName
public java.lang.String getRowName()
- Gets the name of the row sequence.
- Returns:
- the name of the SEQUENCE.
null, if not a table entry
getTableItems
public java.util.Vector getTableItems()
- Will give the names of the items in the row sequence.
- Returns:
- the columnar fields of the table as a Vector.
null, if not a table node.
getIsAugmented
public boolean getIsAugmented()
- Used to know whether the entry node contains the AUGMENTS clause.
- Returns:
- true if the AUGMENTS clause is present in the entry node.
false otherwise.
getUnits
public java.lang.String getUnits()
- Gets the value of UNITS clause in OBJECT-TYPE macro
- Returns:
- the value present in the UNITS clause
empty String if the UNITS clause is not present.
getLastupdated
public java.lang.String getLastupdated()
- Gets the value of the LAST-UPDATED clause in MODULE-IDENTITY macro
- Returns:
- the value of LAST-UPDATED clause
null if the macro-type is not MODULE-IDENTITY
getOrganization
public java.lang.String getOrganization()
- Gets the value of ORGANIZATION clause in MODULE-IDENTITY macro
- Returns:
- the value of ORGANIZATION clause
null, if the macro-type is not MODULE-IDENTITY
getContactinfo
public java.lang.String getContactinfo()
- Gets the value of CONTACT-INFO clause in MODULE-IDENTITY macro
- Returns:
- the value of the CONTACT-INFO clause
null, if the macro-type is not MODULE-IDENTITY
getRevision
public java.lang.String getRevision()
- Deprecated. since 4.0. Instead you can use the method getRevisions()
- Gets the value of REVISION clause in MODULE-IDENTITY macro
- Returns:
- the value of REVISION clause
null, if the macro-type is not MODULE-IDENTITY - See Also:
getRevisions()
getRevdescription
public java.lang.String getRevdescription()
- Deprecated. since 4.0. Instead you can use the method getRevisionDescriptions()
- Gets the value of DESCRIPTION field under REVISION clause in MODULE-IDENTITY macro
- Returns:
- the DESCRIPTION value
null, if the macro-type is not MODULE-IDENTITY - See Also:
getRevisionDescriptions()
getModuleCompliance
public java.util.Vector getModuleCompliance()
- Gets the various clauses in MODULE-COMPLIANCE macro.
The Vector contains all the clauses in the MODULE-COMPLIANCE macro (MODULE, OBJECTS, GROUPS etc.)
- Returns:
- Vector of MibModuleCompliance object
empty vector, if the macro-type is not MODULE-COMPLIANCE
getAgentCapabilities
public java.util.Vector getAgentCapabilities()
- Gets the various clauses in AGENT-CAPABILITIES as a Vector of AgentCapabilitiesModule
- Returns:
- Vector of AgentCapabilities object
empty Vector if the macro-type is not AGENT-CAPABILITIES
getObjectNames
public java.lang.String getObjectNames()
- Deprecated. use the getObjects method instead.
- Gets the OBJECT clause names in OBJECT-GROUP and NOTIFICATION-TYPE macro
- See Also:
getObjects()
getNotificationsNames
public java.lang.String getNotificationsNames()
- Gets the NOTIFICATIONS clause names in NOTIFICATION-GROUP macro
- Returns:
- the value present in the NOTIFICATIONS clause.
null, if the macro-type is not NOTIFICATION-GROUP
getProductrelease
public java.lang.String getProductrelease()
- Get the value of PRODUCT-RELEASE clause in AGENT-CAPABILITIES macro
- Returns:
- the value of PRODUCT-RELEASE clause.
null, if the macro-type is not AGENT-CAPABILITIES.
isAncestorOf
public boolean isAncestorOf(MibNode node)
- Used to know whether this node is an ancestor of the specified node.
- Parameters:
node
- the MibNode object.- Returns:
- true if the node is ancestor of the specified node.
false otherwise.
isDescendentOf
public boolean isDescendentOf(MibNode node)
- Using this method we can find whether this node is descendent of the specified node.
- Parameters:
node
- the MibNode object- Returns:
- true if this node is descendent of the specified node.
false otherwise.
getCommonAncestorWith
public MibNode getCommonAncestorWith(MibNode node)
- Gives the common ancestor node for this node and the specified node.
- Parameters:
node
- the MibNode object- Returns:
- the parent node which is common to both the nodes.
null, if there are no common ancestor
eg: for the nodes one under iso root and the other under ccitt root, this method will return null.
printAccess
public java.lang.String printAccess()
- Gives the access value as a string.
- Returns:
- the access string (read-only, write-only, read-write,
not-accessible, read-create, accessible-for-notify)
null, if none of these.
printStatus
public java.lang.String printStatus()
- Returns the status value as a string.
printDescription
public java.lang.String printDescription()
- Returns the Description string
printReference
public java.lang.String printReference()
- Returns the Reference string
getImpliedNode
public java.lang.String getImpliedNode()
- Gives the implied node name present in the INDEX list of this MIB node.
- Returns:
- The implied node name, if the IMPLIED keyword is present
null otherwise.
isIndex
public boolean isIndex()
- Using this method we can find whether this is an index node.
- Returns:
- true if this is an index node
false otherwise.
getExternalIndices
public java.util.Vector getExternalIndices()
- Gets the external indices present in the table entry
- Returns:
- Vector of node names which is imported from the other table entry
empty vector if not a tableEntry or if the node doesn't contain external indices.
getImportedModuleName
public java.lang.String getImportedModuleName()
- Gets the name of the module from where this node is imported.
The standard nodes and TCs are not imported since they are predefined.
Copyright (c)AdventNet Inc., 1996-2004