All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Snmp.MibModule

java.lang.Object
   |
   +----Snmp.MibModule

public class MibModule
extends Object
This class is used to parse and store a MIB module.

The constructor parses a MIB file as a module, and creates a MIB tree. Allows the user to specify the MIB module file as an argument, or an InputStream object, which is useful for applets reading URLs.

Handles definitions in SNMPv1 MIB modules, i.e. imports, textual conventions, OBJECT-TYPE and TRAP-TYPE macros, OBJECT IDENTIFIERS and SEQUENCES.

Each MIB Module is associated with a MibModule instance, which is built from parsing a MIB file. The root in a module is the highest node defined in the given module file, e.g. mgmt in rfc1213, or rmon in rfc1271-RMON. However, the parent nodes including "iso" are nodes in the module nodeList.

Once parsed, the MIB module is attached to the SnmpAPI instance so subsequent operations will make use of the MIB definitions.


Variable Index

 o API
The api to which this module should be added
 o applet
When an applet instantiates the MibModule, the reference to the applet object is stored in this
 o DEBUG
Whether printing should be enabled while parsing
 o filename
To report parse errors.
 o fstr
This is if we need to bypass tokenizer.
 o inModule
In case we get new DEFINITIONS.
 o macroList
Supported macros, only OBJECT_TYPE and TRAP-TYPE supported.
 o mibFileDir
To store the directory in which the mib file is stored.
 o name
The name of this MIB module, e.g.
 o nodeList
List of MIB nodes in this module
 o root
A reference to the root node in this MIB module
 o rootOID
The OID number array of the root node in this MIB module
 o rootOIDString
The OID name array of the root node in this MIB module
 o syntaxList
List of syntaxes defined in this module.Textual Conventions are added to this list while parsing.
 o trapList
List of traps defined in this module

Constructor Index

 o MibModule(InputStream, SnmpAPI, boolean)
Second constructor requires a valid InputStream (useful for applets).
 o MibModule(InputStream, SnmpAPI, boolean, Applet)
Third constructor requires a valid InputStream (useful for applets).
 o MibModule(String, SnmpAPI, boolean)
First constructor requires a valid MIB module file, else throws SnmpException.

Method Index

 o errorToken(String, StreamTokenizer)
An error printing convenience while getting Tokens.
 o getNearestNode(long[])
Return the Nearest MibNode corresponding to the int[] OID argument Even if it is not a leaf node (when there are more oid numbers than the node we could find)
 o getNode(long[])
Return the MibNode corresponding to the int[] OID argument.
 o getNode(String)
Return the MibNode corresponding to the String OID argument
 o getNode(Vector)
Return the MibNode per the Vector of Strings OID argument
 o getToken(StreamTokenizer)
Returns the next word/word-pair token we can categorize.
 o initMacros()
Initialize the basic macros and put into the macroList.
 o initNodes()
This is needed to ensure parent nodes are always found.
 o initSyntaxes()
Initialize the basic syntaxes and put into the syntaxList.
 o isLabel(String, StreamTokenizer)
used to check for reserved words.
 o nextToken(StreamTokenizer)
Returns the next token from the input stream.
 o parseImports(Vector, String)
Parse the imports to get from moduleName.
 o parseMibModule(StreamTokenizer)
This is where the real work is done, i.e.
 o parseOID(StreamTokenizer)
Parse the OID and return Vector of string ids/names.
 o parseSequence(StreamTokenizer)
Parse a SEQUENCE and return String[] of column names ? API users need not use this method.
 o parseSyntax(StreamTokenizer)
parse Syntax from the stream.
 o translateToNames(String)
A utility for translating numbered OID String to a named OID String.
 o translateToNumbers(String)
A utility for translating named OID String to a numbered OID String.

Variables

 o name
 public String name
The name of this MIB module, e.g. rfc1271-RMON

 o rootOID
 public long rootOID[]
The OID number array of the root node in this MIB module

 o rootOIDString
 public String rootOIDString[]
The OID name array of the root node in this MIB module

 o root
 public MibNode root
A reference to the root node in this MIB module

 o macroList
 public Hashtable macroList
Supported macros, only OBJECT_TYPE and TRAP-TYPE supported.

 o nodeList
 public static Hashtable nodeList
List of MIB nodes in this module

 o syntaxList
 public Hashtable syntaxList
List of syntaxes defined in this module.Textual Conventions are added to this list while parsing.

 o trapList
 public Hashtable trapList
List of traps defined in this module

 o filename
 protected String filename
To report parse errors. API users need not use this variable

 o inModule
 protected boolean inModule
In case we get new DEFINITIONS. API users need not use this variable

 o fstr
 protected InputStream fstr
This is if we need to bypass tokenizer. API users need not use this variable

 o DEBUG
 protected boolean DEBUG
Whether printing should be enabled while parsing

 o API
 protected SnmpAPI API
The api to which this module should be added

 o applet
 protected Applet applet
When an applet instantiates the MibModule, the reference to the applet object is stored in this

 o mibFileDir
 protected String mibFileDir
To store the directory in which the mib file is stored. Got from either the filename passed or as an applet parameter MIBS_DIR

Constructors

 o MibModule
 public MibModule(String file,
                  SnmpAPI api,
                  boolean debug) throws MibException, IOException, FileNotFoundException
First constructor requires a valid MIB module file, else throws SnmpException. The second argument is the SnmpAPI inst. to attach to (necessary!) The third argument indicated whether debugging output is required

Throws: MibException
is thrown upon parse errors.
Throws: IOException
is thrown upon IO errors.
Throws: FileNotFoundException
is thrown if the file is not found.
 o MibModule
 public MibModule(InputStream stream,
                  SnmpAPI api,
                  boolean debug) throws MibException, IOException
Second constructor requires a valid InputStream (useful for applets). The second argument is the SnmpAPI inst. to attach to (necessary!) The third argument indicated whether debugging output is required This is not the preffered way. Use the constructor with the Applet argument instead.

Throws: MibException
is thrown upon parse errors.
Throws: IOException
is thrown upon IO errors.
 o MibModule
 public MibModule(InputStream stream,
                  SnmpAPI api,
                  boolean debug,
                  Applet app) throws MibException, IOException
Third constructor requires a valid InputStream (useful for applets). The second argument is the SnmpAPI inst. to attach to (necessary!) The third argument indicated whether debugging output is required The fourth argument is the applet itself so that This can have access to the url This constructor is preffered over the one without the Applet argument. If automatic loading of Mib Modules from the imports clause is desired, then use this constructor and specify the mibs directory (relative to the applet html directory) in the applet html file as parameter MIBS_DIR.

Throws: MibException
is thrown upon parse errors.
Throws: IOException
is thrown upon IO errors.

Methods

 o parseMibModule
 protected void parseMibModule(StreamTokenizer tok) throws MibException, IOException, FileNotFoundException
This is where the real work is done, i.e. looking for sytaxes we can understand, and passing off to separate parsers. API users need not use this method.

Throws: MibException
is thrown upon parse errors.
Throws: IOException
is thrown upon IO errors.
Throws: FileNotFoundException
upon File not being found.
 o translateToNames
 public String translateToNames(String oid)
A utility for translating numbered OID String to a named OID String. Returns null if node is not found in module

 o translateToNumbers
 public String translateToNumbers(String oid)
A utility for translating named OID String to a numbered OID String. Returns null if node is not found in module

 o getNode
 public MibNode getNode(String oid)
Return the MibNode corresponding to the String OID argument

 o getNode
 public MibNode getNode(Vector oid)
Return the MibNode per the Vector of Strings OID argument

 o getNode
 public MibNode getNode(long oid[])
Return the MibNode corresponding to the int[] OID argument. This returns only leaf node if there are more oid numbers than the node we could find

 o getNearestNode
 public MibNode getNearestNode(long oid[])
Return the Nearest MibNode corresponding to the int[] OID argument Even if it is not a leaf node (when there are more oid numbers than the node we could find)

 o initSyntaxes
 protected void initSyntaxes()
Initialize the basic syntaxes and put into the syntaxList. Api users need not use this method.

 o initMacros
 protected void initMacros()
Initialize the basic macros and put into the macroList. API users need not use this method.

 o initNodes
 protected void initNodes()
This is needed to ensure parent nodes are always found. Api Users need not use this method.

 o parseOID
 protected Vector parseOID(StreamTokenizer tok) throws MibException, IOException
Parse the OID and return Vector of string ids/names. API users need not use this method.

Throws: MibException
is thrown upon parse errors.
Throws: IOException
is thrown upon IO errors.
 o parseSequence
 protected Vector parseSequence(StreamTokenizer tok) throws MibException, IOException
Parse a SEQUENCE and return String[] of column names ? API users need not use this method.

Throws: MibException
is thrown upon parse errors.
Throws: IOException
is thrown upon IO errors.
 o parseSyntax
 protected Vector parseSyntax(StreamTokenizer tok) throws MibException, IOException
parse Syntax from the stream. API users need not use the method.

Throws: MibException
is thrown upon parse errors.
Throws: IOException
is thrown upon IO errors.
 o isLabel
 protected boolean isLabel(String s,
                           StreamTokenizer tok) throws MibException, IOException
used to check for reserved words. API users need not use this method.

Throws: MibException
is thrown upon parse errors.
Throws: IOException
is thrown upon IO errors.
 o parseImports
 protected void parseImports(Vector imports,
                             String moduleName) throws MibException
Parse the imports to get from moduleName. API users need not use this method.

Throws: MibException
is thrown upon parse errors
 o getToken
 protected String getToken(StreamTokenizer tok) throws MibException, IOException
Returns the next word/word-pair token we can categorize. API users need not use this method.

Throws: MibException
is thrown upon parse errors.
Throws: IOException
is thrown upon IO errors.
 o nextToken
 protected String nextToken(StreamTokenizer tok) throws MibException, IOException
Returns the next token from the input stream. API users need not use this method.

Throws: MibException
is thrown upon parse errors.
Throws: IOException
is thrown upon IO errors.
 o errorToken
 protected String errorToken(String s,
                             StreamTokenizer tok) throws MibException
An error printing convenience while getting Tokens. API users need not use this method.

Throws: MibException
is thrown upon parse errors.

All Packages  Class Hierarchy  This Package  Previous  Next  Index