net.percederberg.mib
Class MIB

java.lang.Object
  |
  +--net.percederberg.mib.MIB

public class MIB
extends java.lang.Object

A class representing a MIB file. It also serves as a symbol table for the symbols in the MIB file. Each MIB object represents a distinct ASN.1 module, and several objects are thus required to represent multiple modules. An ASN.1 symbol can be uniqely identified by it's MIB (module) and symbol name.

The MIB class also handles the errors

Author:
Per Cederberg, per@percederberg.net

Constructor Summary
MIB(java.io.File file)
          Creates a MIB object by reading and parsing the given file.
MIB(java.lang.String filename)
          Creates a MIB object by reading and parsing the given file.
 
Method Summary
 java.lang.String allMessages()
          Returns a concatenated string with all the messages, ordered by category.
 java.util.Enumeration allSymbols()
          Returns an enumeration of all the symbols in the table.
 void clear()
          Clears the MIB by recursively clearing all the symbols in the tables.
 boolean equals(java.lang.Object obj)
          Checks if this MIB is equal to some other object.
 int errors()
          Returns the number of found errors in this MIB.
 Symbol findSymbol(java.lang.String name)
          Finds a symbol in the symbol table.
 java.lang.String getFilename()
          Returns the MIB filename.
 java.lang.String toString()
          Returns the MIB name.
 int warnings()
          Returns the number of found warnings in this MIB.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MIB

public MIB(java.lang.String filename)
    throws java.lang.Exception
Creates a MIB object by reading and parsing the given file.
Parameters:
filename - the name of a readable MIB file
Throws:
java.lang.Exception - if the file couldn't be parsed correctly

MIB

public MIB(java.io.File file)
    throws java.lang.Exception
Creates a MIB object by reading and parsing the given file.
Parameters:
file - a readable MIB file
Throws:
java.lang.Exception - if the file couldn't be parsed correctly
Method Detail

equals

public boolean equals(java.lang.Object obj)
Checks if this MIB is equal to some other object. The comparison is based on name comparison.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with
Returns:
true if the objects are equal, or false otherwise

toString

public java.lang.String toString()
Returns the MIB name.
Overrides:
toString in class java.lang.Object
Returns:
the MIB name

getFilename

public java.lang.String getFilename()
Returns the MIB filename.
Returns:
the MIB filename

findSymbol

public Symbol findSymbol(java.lang.String name)
Finds a symbol in the symbol table.
Parameters:
name - the symbol name
Returns:
the symbol found, or null if not found

allSymbols

public java.util.Enumeration allSymbols()
Returns an enumeration of all the symbols in the table. The enumeration will return all the symbols in the order in which they were found in the MIB file.
Returns:
an enumeration of all symbols

allMessages

public java.lang.String allMessages()
Returns a concatenated string with all the messages, ordered by category.
Returns:
a string with all parse messages

errors

public int errors()
Returns the number of found errors in this MIB.
Returns:
the number of errors found while parsing

warnings

public int warnings()
Returns the number of found warnings in this MIB.
Returns:
the number of warnings found while parsing

clear

public void clear()
Clears the MIB by recursively clearing all the symbols in the tables. Thereafter resets all the symbol tables to null. This method should be called before disposing the MIB for consistency with other objects in the system.