net.percederberg.mibble
Class Mib

java.lang.Object
  extended by net.percederberg.mibble.Mib
All Implemented Interfaces:
MibContext

public class Mib
extends java.lang.Object
implements MibContext

An SNMP MIB module. This class contains all the information from a single MIB module, including all defined types and values. Note that a single MIB file may contain several such modules, although that is not very common. MIB files are loaded through a MIB loader.

Since:
2.0
See Also:
RFC 3411 - An Architecture for Describing SNMP Management Frameworks

Method Summary
 boolean equals(java.lang.Object obj)
          Compares this MIB to another object.
 MibSymbol findSymbol(java.lang.String name, boolean expanded)
          Searches for a named MIB symbol.
 java.util.Collection getAllImports()
          Returns all MIB import references.
 java.util.Collection getAllSymbols()
          Returns all symbols in this MIB.
 java.io.File getFile()
          Returns the MIB file.
 java.lang.String getFooterComment()
          Returns the MIB file footer comment.
 java.lang.String getHeaderComment()
          Returns the MIB file header comment.
 Mib[] getImportingMibs()
          Finds all MIB:s that are dependant on this one.
 MibLoader getLoader()
          Returns the MIB loader used when loading this MIB.
 MibLoaderLog getLog()
          Returns the loader log used when loading this MIB.
 java.lang.String getName()
          Returns the MIB name.
 MibValueSymbol getRootSymbol()
          Returns the root MIB value symbol.
 int getSmiVersion()
          Returns the SMI version used for defining this MIB.
 MibSymbol getSymbol(java.lang.String name)
          Returns a symbol from this MIB.
 MibValueSymbol getSymbolByOid(java.lang.String oid)
          Returns a value symbol from this MIB.
 MibValueSymbol getSymbolByValue(MibValue value)
          Returns a value symbol from this MIB.
 MibValueSymbol getSymbolByValue(java.lang.String value)
          Returns a value symbol from this MIB.
 int hashCode()
          Returns the hash code value for the object.
 boolean isLoaded()
          Checks if this MIB module has been explicitly loaded.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

equals

public boolean equals(java.lang.Object obj)
Compares this MIB to another object. This method will return true if the object is a string containing the MIB name, a file containing the MIB file, or a Mib having the same name.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with
Returns:
true if the objects are equal, or false otherwise

hashCode

public int hashCode()
Returns the hash code value for the object. This method is reimplemented to fulfil the contract of returning the same hash code for objects that are considered equal.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code value for the object
Since:
2.6

isLoaded

public boolean isLoaded()
Checks if this MIB module has been explicitly loaded. A MIB module is considered explicitly loaded if the file or resource containing the MIB definition was loaded by a direct call to the MIB loader. Implictly loaded MIB modules are loaded as a result of import statements in explicitly loaded MIBs.

Returns:
true if this MIB module was explicitly loaded, or false otherwise
Since:
2.7

getName

public java.lang.String getName()
Returns the MIB name. This is sometimes also referred to as the MIB module name.

Returns:
the MIB name

getFile

public java.io.File getFile()
Returns the MIB file.

Returns:
the MIB file

getLoader

public MibLoader getLoader()
Returns the MIB loader used when loading this MIB.

Returns:
the loader used

getLog

public MibLoaderLog getLog()
Returns the loader log used when loading this MIB.

Returns:
the loader log used

getSmiVersion

public int getSmiVersion()
Returns the SMI version used for defining this MIB. This number can be either 1 (for SMIv1) or 2 (for SMIv2). It is set based on which macros are used in the MIB file.

Returns:
the SMI version used for defining the MIB
Since:
2.6

getHeaderComment

public java.lang.String getHeaderComment()
Returns the MIB file header comment.

Returns:
the MIB file header comment, or null if no comment was present
Since:
2.6

getFooterComment

public java.lang.String getFooterComment()
Returns the MIB file footer comment.

Returns:
the MIB file footer comment, or null if no comment was present
Since:
2.6

getAllImports

public java.util.Collection getAllImports()
Returns all MIB import references.

Returns:
a collection of all imports
Since:
2.6
See Also:
MibImport

getImportingMibs

public Mib[] getImportingMibs()
Finds all MIB:s that are dependant on this one. The search will iterate through all loaded MIB:s and return those that import this one.

Returns:
the array of MIB:s importing this one
Since:
2.7
See Also:
MibLoader

getAllSymbols

public java.util.Collection getAllSymbols()
Returns all symbols in this MIB.

Returns:
a collection of the MIB symbols
See Also:
MibSymbol

getSymbol

public MibSymbol getSymbol(java.lang.String name)
Returns a symbol from this MIB.

Parameters:
name - the symbol name
Returns:
the MIB symbol, or null if not found

getSymbolByValue

public MibValueSymbol getSymbolByValue(java.lang.String value)
Returns a value symbol from this MIB.

Parameters:
value - the symbol value
Returns:
the MIB value symbol, or null if not found

getSymbolByValue

public MibValueSymbol getSymbolByValue(MibValue value)
Returns a value symbol from this MIB.

Parameters:
value - the symbol value
Returns:
the MIB value symbol, or null if not found

getSymbolByOid

public MibValueSymbol getSymbolByOid(java.lang.String oid)
Returns a value symbol from this MIB. The search is performed by using the strictly numerical OID value specified. Differing from the getSymbolByValue() methods, this method may return a symbol with only a partial OID match. If an exact match for the OID is present in the MIB, this method will always return the same result as getSymbolByValue(). Otherwise, the symbol with the longest matching OID will be returned, making it possible to identify a MIB symbol from an OID containing table row indices or similar.

Parameters:
oid - the numeric OID value
Returns:
the MIB value symbol, or null if not found
Since:
2.5

getRootSymbol

public MibValueSymbol getRootSymbol()
Returns the root MIB value symbol. This value symbol is normally the module identifier (in SMIv2), but may also be just the base object identifier in the MIB.

Returns:
the root MIB value symbol
Since:
2.6

findSymbol

public MibSymbol findSymbol(java.lang.String name,
                            boolean expanded)
Searches for a named MIB symbol. This method is required to implement the MibContext interface but returns the same results as getSymbol(String).

NOTE: This is an internal method that should only be called by the MIB loader.

Specified by:
findSymbol in interface MibContext
Parameters:
name - the symbol name
expanded - the expanded scope flag
Returns:
the MIB symbol, or null if not found
Since:
2.4

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this object