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.

This class also stores all the errors, warnings and messages output during the MIB file reading. The MIB file parsing will only be interrupted by a critical error (syntax) error.

Version:
1.1
Author:
Per Cederberg, per@percederberg.net

Constructor Summary
Mib(java.io.File file)
          Creates a MIB by reading and parsing the specified file.
Mib(java.lang.String filename)
          Creates a MIB by reading and parsing the specified file.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Checks if this MIB is equal to some other object.
 java.lang.String getAllMessages()
          Returns a string with all the parse message.
 java.util.Enumeration getAllSymbols()
          Returns an enumeration of all the symbols in this MIB.
 java.lang.String getError(int index)
          Returns a specified error message.
 int getErrorCount()
          Returns the number of parse errors in this MIB.
 java.io.File getFile()
          Returns the MIB file.
 java.lang.String getMessage(int index)
          Returns a specified parse message.
 int getMessageCount()
          Returns the number of parse messages in this MIB.
 java.lang.String getName()
          Returns the MIB name.
 Symbol getSymbol(int index)
          Returns a specified symbol in this MIB.
 Symbol getSymbol(java.lang.String name)
          Returns a specified symbol in this MIB.
 int getSymbolCount()
          Returns the number of symbols in this MIB.
 java.lang.String getWarning(int index)
          Returns a specified warning message.
 int getWarningCount()
          Returns the number of parse warnings in this MIB.
 java.lang.String toString()
          Returns the MIB name.
 
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.io.FileNotFoundException,
           ParseException
Creates a MIB by reading and parsing the specified file.

Parameters:
filename - the name of a the MIB file to read
Throws:
java.io.FileNotFoundException - if the file couldn't be found
ParseException - if the file couldn't be parsed correctly

Mib

public Mib(java.io.File file)
    throws java.io.FileNotFoundException,
           ParseException
Creates a MIB by reading and parsing the specified file.

Parameters:
file - the MIB file to read
Throws:
java.io.FileNotFoundException - if the file couldn't be found
ParseException - 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. This method compares the name of the MIB with the string representation of the specified object.

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

getFile

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

Returns:
the MIB file

getName

public java.lang.String getName()
Returns the MIB name.

Returns:
the MIB name

getSymbolCount

public int getSymbolCount()
Returns the number of symbols in this MIB.

Returns:
the number of symbols in this MIB

getSymbol

public Symbol getSymbol(int index)
Returns a specified symbol in this MIB. The symbol index is specified in the range from 0 to getSymbolCount() - 1.

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

getSymbol

public Symbol getSymbol(java.lang.String name)
Returns a specified symbol in this MIB. The symbol name should be specified in a case-sensitive manner.

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

getAllSymbols

public java.util.Enumeration getAllSymbols()
Returns an enumeration of all the symbols in this MIB. The symbols will appear in the same order as in the MIB file.

Returns:
an enumeration with all the symbols in this MIB

getErrorCount

public int getErrorCount()
Returns the number of parse errors in this MIB.

Returns:
the number of parse errors in this MIB

getError

public java.lang.String getError(int index)
Returns a specified error message. The index is specified in the range from 0 to getErrorCount() - 1.

Parameters:
index - the error index
Returns:
the error message, or null if not found

getWarningCount

public int getWarningCount()
Returns the number of parse warnings in this MIB.

Returns:
the number of parse warnings in this MIB

getWarning

public java.lang.String getWarning(int index)
Returns a specified warning message. The index is specified in the range from 0 to getWarningCount() - 1.

Parameters:
index - the warning index
Returns:
the warning message, or null if not found

getMessageCount

public int getMessageCount()
Returns the number of parse messages in this MIB.

Returns:
the number of parse messages in this MIB

getMessage

public java.lang.String getMessage(int index)
Returns a specified parse message. The index is specified in the range from 0 to getMessageCount() - 1.

Parameters:
index - the message index
Returns:
the parse message, or null if not found

getAllMessages

public java.lang.String getAllMessages()
Returns a string with all the parse message. The messages will be ordered by category.

Returns:
a string with all parse messages