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.
-
API
- The api to which this module should be added
-
applet
- When an applet instantiates the MibModule, the reference to the applet object is stored in this
-
DEBUG
- Whether printing should be enabled while parsing
-
filename
- To report parse errors.
-
fstr
- This is if we need to bypass tokenizer.
-
inModule
- In case we get new DEFINITIONS.
-
macroList
- Supported macros, only OBJECT_TYPE and TRAP-TYPE supported.
-
mibFileDir
- To store the directory in which the mib file is stored.
-
name
- The name of this MIB module, e.g.
-
nodeList
- List of MIB nodes in this module
-
root
- A reference to the root node in this MIB module
-
rootOID
- The OID number array of the root node in this MIB module
-
rootOIDString
- The OID name array of the root node in this MIB module
-
syntaxList
- List of syntaxes defined in this module.Textual Conventions are added to this list while parsing.
-
trapList
- List of traps defined in this module
-
MibModule(InputStream, SnmpAPI, boolean)
- Second constructor requires a valid InputStream (useful for applets).
-
MibModule(InputStream, SnmpAPI, boolean, Applet)
- Third constructor requires a valid InputStream (useful for applets).
-
MibModule(String, SnmpAPI, boolean)
- First constructor requires a valid MIB module file, else throws SnmpException.
-
errorToken(String, StreamTokenizer)
- An error printing convenience while getting Tokens.
-
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)
-
getNode(long[])
- Return the MibNode corresponding to the int[] OID argument.
-
getNode(String)
- Return the MibNode corresponding to the String OID argument
-
getNode(Vector)
- Return the MibNode per the Vector of Strings OID argument
-
getToken(StreamTokenizer)
- Returns the next word/word-pair token we can categorize.
-
initMacros()
- Initialize the basic macros and put into the macroList.
-
initNodes()
- This is needed to ensure parent nodes are always found.
-
initSyntaxes()
- Initialize the basic syntaxes and put into the syntaxList.
-
isLabel(String, StreamTokenizer)
- used to check for reserved words.
-
nextToken(StreamTokenizer)
- Returns the next token from the input stream.
-
parseImports(Vector, String)
- Parse the imports to get from moduleName.
-
parseMibModule(StreamTokenizer)
-
This is where the real work is done, i.e.
-
parseOID(StreamTokenizer)
- Parse the OID and return Vector of string ids/names.
-
parseSequence(StreamTokenizer)
- Parse a SEQUENCE and return String[] of column names ?
API users need not use this method.
-
parseSyntax(StreamTokenizer)
- parse Syntax from the stream.
-
translateToNames(String)
- A utility for translating numbered OID String to a named OID String.
-
translateToNumbers(String)
- A utility for translating named OID String to a numbered OID String.
name
public String name
- The name of this MIB module, e.g. rfc1271-RMON
rootOID
public long rootOID[]
- The OID number array of the root node in this MIB module
rootOIDString
public String rootOIDString[]
- The OID name array of the root node in this MIB module
root
public MibNode root
- A reference to the root node in this MIB module
macroList
public Hashtable macroList
- Supported macros, only OBJECT_TYPE and TRAP-TYPE supported.
nodeList
public static Hashtable nodeList
- List of MIB nodes in this module
syntaxList
public Hashtable syntaxList
- List of syntaxes defined in this module.Textual Conventions are added to this list while parsing.
trapList
public Hashtable trapList
- List of traps defined in this module
filename
protected String filename
- To report parse errors. API users need not use this variable
inModule
protected boolean inModule
- In case we get new DEFINITIONS. API users need not use this variable
fstr
protected InputStream fstr
- This is if we need to bypass tokenizer. API users need not use this variable
DEBUG
protected boolean DEBUG
- Whether printing should be enabled while parsing
API
protected SnmpAPI API
- The api to which this module should be added
applet
protected Applet applet
- When an applet instantiates the MibModule, the reference to the applet object is stored in this
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
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.
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.
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.
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.
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
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
getNode
public MibNode getNode(String oid)
- Return the MibNode corresponding to the String OID argument
getNode
public MibNode getNode(Vector oid)
- Return the MibNode per the Vector of Strings OID argument
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
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)
initSyntaxes
protected void initSyntaxes()
- Initialize the basic syntaxes and put into the syntaxList. Api users need not use this method.
initMacros
protected void initMacros()
- Initialize the basic macros and put into the macroList. API users need
not use this method.
initNodes
protected void initNodes()
- This is needed to ensure parent nodes are always found. Api Users need not use this method.
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.
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.
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.
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.
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
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.
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.
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