com.adventnet.snmp.mibs
Class MibOperations

com.adventnet.snmp.mibs.MibOperations
All Implemented Interfaces:
java.io.Serializable

public class MibOperations
implements java.io.Serializable

The MibOperations Class provides MIB support for the SNMP libraries. It enables the user to support SNMP operations by using the information in the MIB Modules.

The MibOperations class needs to be instantiated to parse and use MIBs. Instantiate this class to add dynamic MIB support to your SNMP applications. Use the methods of this class to load MIBs and perform MIB related operations

For instance, to use in an application

  
	 MibOperations mibOps = new MibOperations();
	 try {
	    mibOps.loadMibModules("RFC1213-MIB");
	 }catch (Exception ex) { 
	    System.err.println("Error loading MIBs: " + ex);
	 }
    
  

Some methods like getMibNode() are present both in MibModule and in the MibOperations class. If MibOperations.getMibNode() is used, it will search for the node in all the mibs loaded so far whereas if you use MibModule.getMibNode() the search is restricted to that particular Module.

To get a MibModule instance you have to do MibOperations.getMibModule(String name). This will return the MibModule. The argument for getMibModule is the module name specified in the imports.The argument should be case sensitive,that is to say, the case of the argument should match with the case of the module name . To get the enumeration of all the modules loaded, use MibOperations.getMibModules().

In case the module is getting loaded from a http url location, there might be issues related to content-type handling. Specifically, unless the web-server is configured to handle MIB extensions cds and cmi, you can receive errors in loading the MIB. While plain MIB files are in ascii, configuration issues on web-server do not come into the picture. But , the compiled MIB being binary type is affected if the content-type is indicated by the server as text/plain or text/html etc.

See Also:
Serialized Form

Field Summary
static int ALL_MESSAGES
          For printing all the debug messages
static byte CRITICAL
          For setting the critical parsing level
static int CRITICAL_MESSAGES
          For printing all the critical messages
static byte LENIENT
          For setting flexible parsing level
static byte MYSQL
          For setting the MySql database
static byte NORMAL
          For setting normal parsing level.
static byte ORACLE
          For setting the Oracle database
static byte SERIOUS
          For setting the serious parsing level
static int SERIOUS_MESSAGES
          For printing all the serious messages
static int WARNING_MESSAGES
          For printing all the warning messages
 
Constructor Summary
MibOperations()
          This instantiate a new MibOperations instance for MIB operations.
 
Method Summary
 void addChecks(byte[] checks, byte parsingLevel)
          Used to add checks to the existing parsing level.
 void addLabel(java.lang.String addLabel)
          Used to add label which should not be treated as a reserved word by the MIB parser.
 void createCompiledMibs(java.lang.String mibs)
          Used to create compiled mibs namely the cmi and cds files.
 SnmpVarBind createVariableBinding(java.lang.String varName, java.lang.String[] indexes, java.lang.String value)
          Creates an SnmpVarBind instance with the supplied parameters.
 void enableDisplayHint(boolean flag)
          Used to set the displayHint flag.
 java.lang.String encodeInstanceString(java.util.Vector indexValue, java.util.Vector indexMibNodes)
          Encodes an instance string based on the Snmp Type of the indexMibNode.
 byte[] getChecks(byte parsingLevel)
          Used to get the checks available for a particular parsingLevel.
 byte getDatabaseName()
          Gets the name of the Database.
 java.util.Vector getErrorMessages(java.lang.String module)
          Returns Vector of MibErrorMessages object for the module specified.
 java.util.Vector getErrorModuleNames()
          Returns the names of modules which are having parsing errors.
 java.lang.String getErrorString(SnmpPDU pdu)
          Gives a detailed error information on the PDU using information from the loaded MIBs.
 boolean getIgnoreSpecificControlCodes()
          Used to get the value determining whether the new-line characters, tabs and carriage returns are printed or their hex values
 byte getImportsParsingLevel()
          Returns the parsingLevel for the dependency MIB files.
 java.lang.String getInstanceString(SnmpOID oid)
          Gets the Instance portion of OID as a String.
 java.lang.String getInstanceString(SnmpOID oid, MibNode node)
          Gets the Instance portion of OID as a String.
 LeafSyntax getLeafSyntax(SnmpOID oid)
          Gets the syntax for the node corresponding to this oid.
 MibModule getMibModule(MibNode node)
          Gets the MIB Module that contains the specified MibNode.
 MibModule getMibModule(java.lang.String name)
          Gets the MIB Module from list of already loaded MIBs.
 java.util.Enumeration getMibModuleNames()
          Gets the names of the Mib modules loaded.
 java.util.Enumeration getMibModules()
          Gets all the MIB modules loaded in this MibOperations instance.
 MibNode getMibNode(SnmpOID oid)
          Gets the MibNode for this SnmpOID instance by searching all the MIB modules.
 MibNode getMibNode(java.lang.String oidString)
          Gets the node corresponding to this label.
 MibNode getMibNode(java.lang.String nodeLabel, java.lang.String mib)
          Gets the node correspoding to the label in this mib.
 MibNode getMibNode(java.util.Vector oid)
          Gives the MibNode per the Vector of Strings OID argument.
 java.lang.String getMibPath()
          Gets the search Path in which the Mib Parser will search for the MIB modules.
 MibTrap getMibTrap(SnmpOID enterprise, int genericType, int specificType)
          Gets the trap definition matching the given enterprise, generic type and specific type values.
 java.lang.String getModuleNameDefinition(java.lang.String file)
          Lets you know the module name contained in this MIB file.
 java.lang.String[] getModuleNameDefinitions(java.lang.String fileName)
          Gives all the module names contained in this mib file.
 int getModuleSize()
          Returns the number of modules loaded in this MibOperations instance.
 java.lang.String getMultipleRevision()
          Gets the multiple revisions availabe for the MIB.
 MibNode getNearestNode(SnmpOID oid)
          Gets the node corresponding to the oid which is nearest to this SnmpOID instance.
 java.util.Vector getNodesFromNames(java.util.Vector nodes)
          Gets the MibNodes corresponding to the names in the Vector.
 java.util.Vector getNodesFromString(java.lang.String nodeList)
          Gets the MibNodes corresponding to the node names in the nodelist.
 boolean getOverwriteCMI()
          Deprecated. since 4.0, replaced by isOverwriteCMI()
 byte getParsingLevel()
          Returns the parsingLevel.
 java.lang.String getSerializedMibFileName()
          Retrieves the Serialized MIB file name.
 SnmpOID getSnmpOID(java.lang.String s)
          Creates an SnmpOID instance based on the loaded MIBs.
 LeafSyntax getSyntaxByName(java.lang.String name)
          Gets the syntax for the node represented by the String argument.
 boolean getThrowFileNotFound()
          Deprecated.  
 void initJdbcParams(java.lang.String driverName, java.lang.String URL, java.lang.String userName, java.lang.String passWord)
          If you need to use database support, you have to invoke this method to initialize the Jdbc Parameters.
 boolean isDBConnected()
          Used to know whether the Database connection is alive or not.
 boolean isDisplayHintEnabled()
          Used to know whether the displayHint flag is enabled or not.
 boolean isLoadFromCompiledMibs()
          Used to know whether the MIB is loaded from the compiled mibs.
 boolean isLoadFromDatabase()
          Used to know whether the MIB is loaded from the DataBase.
 boolean isLoadFromSerializedMibs()
          Used to know whether the MIB is loaded from serialized mibs.
 boolean isMultipleRevision()
          Used to know whether the multiple revision is set or not.
 boolean isOverwriteCMI()
          Used to know whether the compiled mib files are overwritten.
 boolean isOverwriteDatabase()
          Gets the overwriteDataBase boolean.
 boolean isOverwriteSerializedMibs()
          Used to know whether the serialized mib files are overwritten.
 boolean isReadDesc()
          Used to know whether reading the descriptions from compiled modules is enabled.
 boolean isSerializeMibs()
          Gets the serializeMibs boolean
 boolean isShowImportedIndex()
          Used to know whether the external indices are shown in the Mib tree.
 MibModule loadMibModule(java.applet.Applet applet, java.net.URL url)
          Load a MIB Module from an applet using the URL.
 MibModule loadMibModule(java.lang.String fileName)
          Load a MIB Module from this file.
 void loadMibModules(java.applet.Applet applet, java.lang.String mibs)
          Load a set of MIB Modules from an applet using the string URLs.
 void loadMibModules(java.lang.String mibs)
          Load a set of MIB Modules from files.
 void registerParsingLevel(byte parsingLevel, byte[] checks)
          Used to create an used defined parsing level.
 void removeChecks(byte[] checks, byte parsingLevel)
          Used to remove checks from the existing parsing level.
 void setDatabaseName(byte type)
          Used to set the database.
 void setDebug(boolean debug)
          Defines whether debugging output should be generated to stdout.
static void setDebugMessageLevel(int level)
          Sets the debug message level.
 void setIgnoreSpecificControlCodes(boolean specConCode)
          Used to set the value determining whether the new-line characters, tabs and carriage returns are printed as they are or their hex values.
 void setImportsParsingLevel(byte parsingLevel)
          Used to set the level of parsing for the dependency MIB files.
 void setLoadFromCompiledMibs(boolean flag)
          Defines whether to load mib from compiled MIBs.
 void setLoadFromDatabase(boolean flag)
          Defines whether to load the MIB from DataBase.
 void setLoadFromSerializedMibs(boolean flag)
          Defines whether to load mib from serialized MIB file.
 void setMibFileExtension(java.lang.String extension)
          Registers the extensions with which the MIB file is to be searched.
 void setMibPath(java.lang.String path)
          Sets the search Path in which the Mib Parser will search for the MIB modules.
 void setMultipleRevision(java.lang.String revisionFileName)
          Sets the Multiple revision for the MIB.
 void setOverwriteCMI(boolean overWrite)
          Defines whether to overwrite the existing compiled files.
 void setOverwriteDatabase(boolean overWrite)
          Defines whether to overwrite the existing database files.
 void setOverwriteSerializedMibs(boolean flag)
          Defines whether to overwrite the existing serialized MIB files.
 void setParsingLevel(byte parsingLevel)
          Used to set the level of parsing.
 void setReadDesc(boolean readFlag)
          Sets the flag for reading the descriptions from compiled mib modules.
 void setSerializedMibFileName(java.lang.String fileName)
          Defines the name with which the serialized MIB file is to be stored.
 void setSerializeMibs(boolean flag)
          Defines whether to serialize the MibModule.
 void setShowImportedIndex(boolean flag)
          Sets the showImportedIndex boolean value.
 void setThrowFileNotFound(boolean value)
          Deprecated.  
 java.lang.String toByteString(SnmpPDU pdu)
          Returns the byte representation of the SnmpPDU using the MIB information.
 java.lang.String toByteString(SnmpVarBind varBind)
          Returns the byte representation of SnmpVarbind using the MIB information.
 java.lang.String toByteString(SnmpVar var, SnmpOID oid)
          Gives a translated value for the SnmpVar instance using the MIB information.
 java.lang.String toShortString(SnmpOID oid)
          Provides the short translated name representation for the SnmpOID instance.
 java.lang.String toString(SnmpOID oid)
          Provides the translated name representation for the SnmpOID instance if found in loaded Mibs.
 java.lang.String toString(SnmpPDU pdu)
          Returns the string value of the pdu using the MIB information
 java.lang.String toString(SnmpVarBind varbind)
          Provides a translated value for an SNMP variable binding using information from the loaded MIBs.
 java.lang.String toString(SnmpVar var, SnmpOID oid)
          Provides a translated value for an SNMP variable using information from the loaded MIBs.
 java.lang.String toTagString(SnmpVarBind varbind)
          Provides a translated value for an SNMP variable binding using information from the loaded MIBs.
 void unloadAllMibModules()
          Unload all the loaded MibModules.
 boolean unloadMibModule(MibModule module)
          Unloads the MibModule from the modules table.
 MibModule unloadMibModule(java.lang.String name)
          Unloads the MibModule from the MibModules loaded in this instance.
 java.lang.String varBindsToString(SnmpPDU pdu)
          Gets variable bindings in the PDU, using the information from loaded MIBs.
 

Field Detail

ALL_MESSAGES

public static final int ALL_MESSAGES
For printing all the debug messages

WARNING_MESSAGES

public static final int WARNING_MESSAGES
For printing all the warning messages

SERIOUS_MESSAGES

public static final int SERIOUS_MESSAGES
For printing all the serious messages

CRITICAL_MESSAGES

public static final int CRITICAL_MESSAGES
For printing all the critical messages

MYSQL

public static final byte MYSQL
For setting the MySql database

ORACLE

public static final byte ORACLE
For setting the Oracle database

LENIENT

public static final byte LENIENT
For setting flexible parsing level

NORMAL

public static final byte NORMAL
For setting normal parsing level. This is the default parsing level.

SERIOUS

public static final byte SERIOUS
For setting the serious parsing level

CRITICAL

public static final byte CRITICAL
For setting the critical parsing level
Constructor Detail

MibOperations

public MibOperations()
This instantiate a new MibOperations instance for MIB operations. Also sets up basic syntax elements for the ASN Types for use. This also sets up the starting root nodes corresponding to iso, ccitt and joint-iso-ccitt.
Method Detail

setMibFileExtension

public void setMibFileExtension(java.lang.String extension)
Registers the extensions with which the MIB file is to be searched. This method is useful only in case of loading mibs in applets and from the jar file. Multiple extensions can be given which is comma or space separated. The default extensions set are .mib,.txt,.my and the extension name should not be .cmi or .cds, since these are our proprietary extensions for the compiled MIBs. This extension will be added to the default extensions set.

The file will be searched with the name of the module with this extension. So the MIB filename should be same as the modulename with this extension.

for example, MibOperations mibOps = new MibOperations(); mibOps.setMibFileExtension("mi2,abc"); mibOps.loadMibModule("RFC1213-MIB"); The file will be searched in the following sequence Without the extension With the extension which we set. With the default extensions In this case, it searches for the file in the following order RFC1213-MIB, RFC1213-MIB.mi2, RFC1213-MIB.abc, RFC1213-MIB.mib, RFC1213-MIB.txt, RFC1213-MIB.my

In case of applications, it also searches for the MIB module in all the files, present in that directory.

Parameters:
extension - Extension of the MIB file.

setThrowFileNotFound

public void setThrowFileNotFound(boolean value)
Deprecated.  

Throws a file not found exception if the corresponding import module is not found in the search path.
Parameters:
value - the boolean value

getThrowFileNotFound

public boolean getThrowFileNotFound()
Deprecated.  

Returns the status of the import exception for files that are not found.
Returns:
true if the boolean value in setThrowFileNotFound(boolean) method is set.
false if the boolean is not set or if set to false.

setDebug

public void setDebug(boolean debug)
Defines whether debugging output should be generated to stdout.
Parameters:
debug - the boolean value. The debugging output is generated to stdout if the boolean is set to true.

setSerializeMibs

public void setSerializeMibs(boolean flag)
Defines whether to serialize the MibModule. This flag should be set before loading the MIBs. If this is set to true it will serialize the loaded MIBs. By default, this flag is set to false for example, if RMON2-MIB is loaded, it will serialize this module along with the Imported Modules viz ., RFC1271-MIB,RFC1213-MIB,TOKEN-RING-RMON and saves it in a single file. MibOperations mibOps = new MibOperations(); mibOps.setSerializeMibs(true); try { mibOps.loadMibModules("RMON2-MIB.mib"); }catch(Exception ex) { System.out.println(ex); } By default, the serialized file name will be saved with the filename along with ".ser" extension. In this case, if the filename is RMON2-MIB.mib the serialized file will be saved as RMON2-MIB.ser. The serialized file can be created with any other name using the method setSerializedMibFileName() Serialization is not supported in applets.
Parameters:
flag - the boolean value
See Also:
setSerializedMibFileName(java.lang.String), setLoadFromSerializedMibs(boolean)

isSerializeMibs

public boolean isSerializeMibs()
Gets the serializeMibs boolean
Returns:
true, if the boolean in the method setSerializeMibs(boolean flag) is set to true.
false otherwise.
See Also:
setSerializeMibs(boolean)

setLoadFromSerializedMibs

public void setLoadFromSerializedMibs(boolean flag)
Defines whether to load mib from serialized MIB file. This flag should be set to true before loading the MIBs from serialized file. The serialized file should already exist in the file path. The method setSerializeMibs() can be used to create the serialized MIB file
Parameters:
flag - the boolean value.
See Also:
setSerializeMibs(boolean)

isLoadFromSerializedMibs

public boolean isLoadFromSerializedMibs()
Used to know whether the MIB is loaded from serialized mibs.
Returns:
true if the boolean value in the method setLoadFromSerializedMibs(boolean flag)is set to true.
false otherwise.
See Also:
setLoadFromSerializedMibs(boolean)

setSerializedMibFileName

public void setSerializedMibFileName(java.lang.String fileName)
Defines the name with which the serialized MIB file is to be stored. The Serialized MIB file will be saved with this filename with ".ser" as extension in the same directory from which the mib is loaded. If the fileName contains any other extension, that extension is removed and the serialized file will be created with ".ser" extension.

For example, if the fileName is ifMib.txt, then the serialized file will be created with the file name of ifMib.ser

Parameters:
fileName - the name of the file in which the serialized file is to be stored.
See Also:
setLoadFromSerializedMibs(boolean), loadMibModule(String), loadMibModules(Applet,String), loadMibModule(Applet,URL)

getSerializedMibFileName

public java.lang.String getSerializedMibFileName()
Retrieves the Serialized MIB file name.
Returns:
the filename set by the method setSerializedMibFileName(String fileName).
empty string, if the filename is not set.
See Also:
setSerializedMibFileName(java.lang.String)

setOverwriteSerializedMibs

public void setOverwriteSerializedMibs(boolean flag)
Defines whether to overwrite the existing serialized MIB files. By default the overwrite flag is set to false. If set to true, then the serialized MIB files will be overwritten.

After loading the MIB file as a serialized MIB file, if you do any changes in the MIB file and load it again it will not get reflected in the loaded MIB file. So at that time, this method has to be called, to overwrite the serialized MIB files and get the latest changes.

Setting this boolean to true is recommended only if you have changed the contents of the MIB file. Otherwise, this will unnecessarily increase the loading time of the MIB's. NOTE: This applies only when the setLoadFromSerializedMibs is set to true.

Parameters:
overWrite - the boolean value

isOverwriteSerializedMibs

public boolean isOverwriteSerializedMibs()
Used to know whether the serialized mib files are overwritten.
Returns:
true if the overwrite boolean in the method setOverwriteSerializedMibs(boolean flag) is set to true.
false if the boolean is not set, or if the boolean is set to false.
See Also:
setOverwriteSerializedMibs(boolean)

setLoadFromCompiledMibs

public void setLoadFromCompiledMibs(boolean flag)
Defines whether to load mib from compiled MIBs. This flag should be set before loading the MIBs, if we want to load the MIB from compiled mibs. By default it is set to false. If this flag is set to true, it will load from compiled file( i.e; .cmi and .cds files).

For example, RFC1213-MIB is loaded, it will automatically load RFC1213-MIB.cmi if it exists. Otherwise it creates compiled files by parsing the MIB and then loads from it. This is in case of application. In case of applets, due to the restriction imposed for writing the files, it cannot create compiled files.

So in case of applets, the MIBs can be loaded from compiled files only if they are already present. We can create the compiled MIB files by using the method createCompiledMibs(String). This is slightly slower than loading from precompiled mibs.

If both loadFromSerializedMibs and loadFromCompiledMibs is set to true, it will just try to load the MIB as a serialized file.

Parameters:
flag - the boolean value
See Also:
createCompiledMibs(java.lang.String)

isLoadFromCompiledMibs

public boolean isLoadFromCompiledMibs()
Used to know whether the MIB is loaded from the compiled mibs.
Returns:
true if the flag in setLoadFromCompiledMibs(boolean flag) is set to true.
false otherwise.
See Also:
setLoadFromCompiledMibs(boolean)

setOverwriteCMI

public void setOverwriteCMI(boolean overWrite)
Defines whether to overwrite the existing compiled files. By default the overwrite flag is set to false. If set to true, then the compiled MIB files will be overwritten.

After loading the MIB file as a compiled MIB file, if you do any changes in the MIB file and load it again it will not get reflected in the loaded MIB file. So at that time, this method has to be called, to overwrite the compiled MIB files and get the latest changes.

Setting this boolean to true is recommended only if you have changed the contents of the MIB file. Otherwise, this will unnecessarily increase the loading time of the MIB's. NOTE: This applies only when the setLoadFromCompiledMibs is set to true.

Parameters:
overWrite - the boolean value

getOverwriteCMI

public boolean getOverwriteCMI()
Deprecated. since 4.0, replaced by isOverwriteCMI()

Gets the overwrite compiled mibs boolean.
Returns:
true if the overwrite boolean in the method setOverwriteCMI(boolean overWrite) is set to true.
false if the boolean is not set, or if the boolean is set to false.
See Also:
setOverwriteCMI(boolean)

isOverwriteCMI

public boolean isOverwriteCMI()
Used to know whether the compiled mib files are overwritten.
Returns:
true if the overwrite boolean in the method setOverwriteCMI(boolean overWrite) is set to true.
false if the boolean is not set, or if the boolean is set to false.
See Also:
setOverwriteCMI(boolean)

setMibPath

public void setMibPath(java.lang.String path)
Sets the search Path in which the Mib Parser will search for the MIB modules. Multiple paths can be specified using the pipe (|) as a separator.

The MIB file is searched in the current working directory, or from the directory where the MIB file is loaded. If the search path is set, the MIB file will be searched in addition to this directories.

Parameters:
searchPath - String specifying the search path, for multiple paths separate the paths by the pipe (|) symbol.

getMibPath

public java.lang.String getMibPath()
Gets the search Path in which the Mib Parser will search for the MIB modules.
Returns:
String containing the path which will be searched for the MIBs.
null if the searchPath has not been set previously.
See Also:
setMibPath(java.lang.String)

loadMibModules

public void loadMibModules(java.lang.String mibs)
                    throws MibException,
                           java.io.IOException,
                           java.io.FileNotFoundException
Load a set of MIB Modules from files. The files can be seperated by a space, tab, new line, carriage return and pipe symbol. mibOps.loadMibModules("../mibs/RFC1213-MIB ../mibs/IF-MIB"); MIBs can also be loaded from string URLs. In case of loading the files from space seperated directories, the whole String should be given within the double quotes. for e.g. if the MIB file is present in the directory 'Program Files', loadMibModules("\"../../mibs/Program Files/RFC1213-MIB\"") The MIB file can be loaded in the following options, Loading MIB's directly ( from a file, URL or a jar ) Loading from Serialized files Loading Compiled MIB's Loading from Database If the mib file is present is different directories, the search path can be set using the method setMibPath(). The mib file will be searched in the order in which the path specified. The parsingLevel can be set using the method setParsingLevel(). The default parsingLevel is NORMAL. If a MIB imports the dependency MIB file. In case of application, the dependency files are searched in the following manner: The imported MIB file searched with the name of the MIB module, if it not exist, it search the file in the directory which contains the MIB module. Otherwise, the IMPORTS failed error will be given. In case of applet, the file name will be searched with the module name with the extension. The default extension of the file name may be .mib,.txt,.my. In case of applications, mib file with any extensions is loaded. But in case of loading the mib from jar, url, applet if the extension is other than .mib,.txt,.my, then the method setMibFileExtension() has to be used. For loading the mibs from applets, the method loadMibModules(Applet applet, String mibs) can be used.
Parameters:
mibs - list of file names seperated by a space,tab, new line, carriage return and pipe symbol.
Throws:
MibException - is thrown upon parse errors.
java.io.IOException - is thrown upon IO errors.
java.io.FileNotFoundException - is thrown if the file is not found.
See Also:
setLoadFromSerializedMibs(boolean), setLoadFromCompiledMibs(boolean), setLoadFromDatabase(boolean), setMibFileExtension(java.lang.String), loadMibModules(Applet, String), setMibPath(java.lang.String), setParsingLevel(byte), setImportsParsingLevel(byte)

loadMibModules

public void loadMibModules(java.applet.Applet applet,
                           java.lang.String mibs)
                    throws MibException,
                           java.io.IOException,
                           java.io.FileNotFoundException
Load a set of MIB Modules from an applet using the string URLs. The URLs are specified by a space separated list of string URLs. The URLs can be absolute or relative to the applet document base.
Parameters:
applet - applet from which the mib is loaded.
mibs - space seperated list of mib files.
Throws:
MibException - is thrown upon parse errors.
java.io.IOException - is thrown upon IO errors.
java.io.FileNotFoundException - is thrown if the file is not found.

loadMibModule

public MibModule loadMibModule(java.applet.Applet applet,
                               java.net.URL url)
                        throws MibException,
                               java.io.IOException,
                               java.io.FileNotFoundException
Load a MIB Module from an applet using the URL.
Parameters:
applet - applet from which the mib is loaded.
url - the name of the URL
Throws:
MibException - is thrown upon parse errors.
java.io.IOException - is thrown upon IO errors.
java.io.FileNotFoundException - is thrown if the file is not found.

loadMibModule

public MibModule loadMibModule(java.lang.String fileName)
                        throws MibException,
                               java.io.IOException,
                               java.io.FileNotFoundException
Load a MIB Module from this file.
Parameters:
fileName - the name of the mib file to be loaded.
Throws:
MibException - is thrown upon parse errors.
java.io.IOException - is thrown upon IO errors.
java.io.FileNotFoundException - is thrown if the file is not found.

createCompiledMibs

public void createCompiledMibs(java.lang.String mibs)
                        throws MibException,
                               java.io.IOException,
                               java.io.FileNotFoundException
Used to create compiled mibs namely the cmi and cds files. Compiled mibs can be created for a single file or for a directory of mibs. When a file is being compiled, it tries to compile the imported modules. In this process if it finds the cmi file existing for the imported module it skips the compilation for that module. So before creating compiled mibs for a directory of mibs, you should make sure that no compiled mibs (i.e; cmi and cds files) exist in that directory, inorder to recompile all the mibs in that directory.
Parameters:
mibs - the space seperated list of mib files for which the compiled mib files is to be generated.
Throws:
MibException - is thrown upon parse errors.
java.io.IOException - is thrown upon IO errors.
java.io.FileNotFoundException - is thrown if the file is not found.

getMibModule

public MibModule getMibModule(java.lang.String name)
Gets the MIB Module from list of already loaded MIBs. The module name always startswith uppercase letter. While loading the MIB files, the MIB will be loaded with its dependent MibModules. The individual MibModule can be obtained using this method. If we want to get all the loaded MIB modules, the getMibModules() method will be used.
Parameters:
name - the MibModule name identified in the DEFINITIONS clause of the MIB. The name is not identified by the filename of the MIB.
Returns:
MibModule object with the specified name.
null if the MIB is not loaded.
See Also:
getMibModules()

getModuleNameDefinition

public java.lang.String getModuleNameDefinition(java.lang.String file)
                                         throws MibException,
                                                java.io.IOException,
                                                java.io.FileNotFoundException
Lets you know the module name contained in this MIB file. It checks for syntactical semantics only upto the the MIB module definiton and then stops parsing the MIB.

In most cases API users would not require this method as they would only need to load MIBs. This method is used to get the module name of the MIB module present in the MIB file without loading the MIB file. This method will return the first module name present in this MIB file. If the multiple MIB module, present in this MIB file, the getMibModuleDefintions method will be used to retrieve all the MIB modules present in this MIB file.

Parameters:
file - name of the file containing the MIB module.
Returns:
MIB module label, null if no MIB file is present.
Throws:
MibException - is thrown upon parse errors.
java.io.IOException - is thrown upon IO errors.
java.io.FileNotFoundException - is thrown if the file is not found.
See Also:
getModuleNameDefinitions(java.lang.String)

getMibModule

public MibModule getMibModule(MibNode node)
Gets the MIB Module that contains the specified MibNode.
Parameters:
node - the node which is present in the required module.
Returns:
MibModule containing the MibNode.
null if the node is not null.

getMibModules

public java.util.Enumeration getMibModules()
Gets all the MIB modules loaded in this MibOperations instance.
Returns:
Enumeration of loaded MibModule objects.
See Also:
getMibModule(java.lang.String)

setDebugMessageLevel

public static void setDebugMessageLevel(int level)
Sets the debug message level.
Parameters:
level - the various debug levels as mentioned below
The available debug levels are
  • ALL_MESSAGES
  • WARNING_MESSAGES
  • SERIOUS_MESSAGES
  • CRITICAL_MESSAGES
By default it is set to SERIOUS_MESSAGES.

createVariableBinding

public SnmpVarBind createVariableBinding(java.lang.String varName,
                                         java.lang.String[] indexes,
                                         java.lang.String value)
                                  throws java.lang.IllegalArgumentException,
                                         SnmpException
Creates an SnmpVarBind instance with the supplied parameters. Handy for creating SNMP Requests which need encoding of instance values for tables. Supply the Snmp variable value when using for SNMP set. if value is null, SnmpNull is used as needed by get requests.
Parameters:
varName - The name, or numeric object ID, of MIB variable for which this request is being created
indexes - The ordered list of index values (of type String or SnmpVar values. Parameter can be null for non-tabular columns
value - The SnmpVar value to use for sets. The value is null for gets.
indexMibNodes - The index nodes for this node's parent
Returns:
SnmpVarBind instance for the given parameters.
Throws:
SnmpException - is thrown upon variable creation errors.
java.lang.IllegalArgumentException - is thrown if arguments are invalid.

getSnmpOID

public SnmpOID getSnmpOID(java.lang.String s)
Creates an SnmpOID instance based on the loaded MIBs. This does the search of MIB modules of the SnmpAPI specified and fills in the MibNode for the SnmpOID instance. Also supports simple "label" or "label.N" strings to create OIDs, where label is the label of a node in the MIB tree (and is a leaf node in the latter case).
Parameters:
s - String OID of the form .N.N.N..., or N.N.N..., in which case the static Standard_Prefix in the SnmpAPI class is used. N can be a number or a name.
Returns:
the SnmpOID instance for the given string oid

getLeafSyntax

public LeafSyntax getLeafSyntax(SnmpOID oid)
Gets the syntax for the node corresponding to this oid. This method used to get the syntax of the node corresponding to this SnmpOID. We can also, get the syntax of this OID as follows: MibOperations mibOps = new MibOperations(); mibOps.loadMibModule("RFC1213-MIB"); MibNode node = mibOps.getMibNode(new SnmpOID(".1.3.6.1.2.1.1.1")); LeafSyntax leaf = node.getSyntax();
Parameters:
oid - SnmpOID object.
Returns:
LeafSyntax object for this SnmpOID instance if found
null if the node is not a leaf node.

getMibNode

public MibNode getMibNode(java.util.Vector oid)
Gives the MibNode per the Vector of Strings OID argument. For something like system.1 it will return sysDescr and if the vector contains sysDescr and nothing else, then it will return the node for sysDescr. This method always tries to retrieve a leaf node. If it matches a non-leaf node, then that node is returned only if the match of oid elements is exact( i.e. no undefined child components, so that system.1 will fail to return a Node if loaded MIB does not contain sysDescr node. But mib-2.1 will return system if the system node is available). This searches the available mibs successively and is not suited for large number of MIBs.
Parameters:
oid - Vector of String OIDs
Returns:
MibNode per the Vector of Strings OID argument
null if the node is not found.

varBindsToString

public java.lang.String varBindsToString(SnmpPDU pdu)
Gets variable bindings in the PDU, using the information from loaded MIBs.
Parameters:
pdu - the SnmpPDU instance
Returns:
String representation of the variable bindings.

getErrorString

public java.lang.String getErrorString(SnmpPDU pdu)
Gives a detailed error information on the PDU using information from the loaded MIBs.
Parameters:
pdu - the SnmpPDU instance
Returns:
the error string containing the errored variable bindings

toByteString

public java.lang.String toByteString(SnmpPDU pdu)
Returns the byte representation of the SnmpPDU using the MIB information. Same as the toString(SnmpPDU pdu) method.
Parameters:
pdu - the SnmpPDU instance
Returns:
the byte representation of the SnmpPDU instance value.
See Also:
toString(SnmpPDU)

toByteString

public java.lang.String toByteString(SnmpVarBind varBind)
Returns the byte representation of SnmpVarbind using the MIB information. Same as the toString(SnmpVarBind varBind) method
Parameters:
varBind - the SnmpVarBind instance
Returns:
the byte representation of the SnmpVarBind
See Also:
toString(SnmpVarBind)

toByteString

public java.lang.String toByteString(SnmpVar var,
                                     SnmpOID oid)
Gives a translated value for the SnmpVar instance using the MIB information. This method is same as the toString(SnmpVar var, SnmpOID oid) method
Returns:
the byte representation of the SnmpVar instance value
See Also:
toString(SnmpVar,SnmpOID)

toString

public java.lang.String toString(SnmpPDU pdu)
Returns the string value of the pdu using the MIB information
Parameters:
pdu - the SnmpPDU instance
Returns:
the string representation of the SnmpPDU instance.

toString

public java.lang.String toString(SnmpVarBind varbind)
Provides a translated value for an SNMP variable binding using information from the loaded MIBs. For e.g. if MIB-II is loaded, for the node ifType, this method will return "ethernet(2)" instead of the "2" returned by SnmpVar.toString().
Parameters:
varbind - the SnmpVarBind instance
Returns:
the string representation such as "sysDescr.0:Adv Snmp Agent".

toTagString

public java.lang.String toTagString(SnmpVarBind varbind)
Provides a translated value for an SNMP variable binding using information from the loaded MIBs. For e.g. if MIB-II is loaded, for the node ifType this method will return "ethernet(2)" instead of the "2" returned by SnmpVar.toString(). The return values are tagged.
Parameters:
varbind - the SnmpVarBind instance
Returns:
the detailed description of the SnmpVarBind instance as a string

toString

public java.lang.String toString(SnmpVar var,
                                 SnmpOID oid)
Provides a translated value for an SNMP variable using information from the loaded MIBs. For e.g. if MIB-II is loaded, for the node ifType this method will return "ethernet(2)" instead of the "2" returned by SnmpVar.toString(). The two parameters will usually comprise a varbind.
Parameters:
var - the SnmpVar object for the oid.
oid - the oid whose value needs to be printed.
Returns:
String representation for the SnmpOID instance value if found in loaded Mibs.
If node is not found this method always returns a printable ascii string.

toString

public java.lang.String toString(SnmpOID oid)
Provides the translated name representation for the SnmpOID instance if found in loaded Mibs. For e.g. for the oid .1.3, this method will return .iso.org
Parameters:
oid - the SnmpOID instance value
Returns:
the numbered oid string

toShortString

public java.lang.String toShortString(SnmpOID oid)
Provides the short translated name representation for the SnmpOID instance. This does not perform stringification of index components of columnar elements to their normal types. So if the oid corresponds to a columnar object "alpha" with a string index component "beta", then the output will be alpha.98.101.116.97 (not alpha.beta) For simple scalar nodes this will return values as mentioned earlier i.e sysUpTime.0 for the oid 1.3.0
Parameters:
oid - the SnmpOID instance
Returns:
the short form of the node string corresponding to the oid.(node label only, e.g. sysDescr.0)
the numeric oid if no corresponding node found.

getInstanceString

public java.lang.String getInstanceString(SnmpOID oid)
Gets the Instance portion of OID as a String. e.g. ".0" for a scalar. The instance component is a .0 for scalar leaf nodes such as sysDescr,sysName etc. Instances of scalar objects are identified by the OID value of the object suffixed with the number 0. Instances of columnar objects (table objects) are identified by their OID values suffixed by their index components. The index component is formed from the encoding of the index values in a predefined manner based on the types of the index columns.
Parameters:
oid - the SnmpOID for which the instance component is required.
Returns:
the instance component of the oid.
null, if the corresponding node is not found.
See Also:
LeafSyntax.decodeInstanceString(java.lang.String, java.util.Vector), LeafSyntax.encodeInstanceString(java.util.Vector, java.util.Vector)

getInstanceString

public java.lang.String getInstanceString(SnmpOID oid,
                                          MibNode node)
Gets the Instance portion of OID as a String. e.g. ".0" for a scalar. This version avoids having to search for node if already available.
Parameters:
oid - the SnmpOID instance
node - the MibNode object corresponding to the oid.
Returns:
the instance string if the node is found and it is matched with the oid.
null if node and oid are mismatched.

Please note that this verification is not comprehensive for sake of efficiency. So it is not ensured that a null will be returned for a mismatched node. This returns the sub-string corresponding to the instance. For cases such as MibNode being system and OID as sysDescr the return value will start with the sub-id of mib-2. The intersection of the node oid and the given oid are eliminated from the returned oid string.


getMibNode

public MibNode getMibNode(SnmpOID oid)
Gets the MibNode for this SnmpOID instance by searching all the MIB modules. If a node is not a leaf, then the oid should match exactly. So MibNode for system will be returned if the exact oid for system is given. But for leaf nodes such as ifDescr, MibNode is returned even if the oid is ifDescr.1 The instance component of the oid is not necessary for a match.
Parameters:
oid - the SnmpOID instance
Returns:
the MibNode corresponding to the oid.

getNearestNode

public MibNode getNearestNode(SnmpOID oid)
Gets the node corresponding to the oid which is nearest to this SnmpOID instance. This does a search of all MIB modules loaded in this MibOperations instance and returns the oid if found. The mib node need not be a leaf node.
Parameters:
oid - the SnmpOID instance
Returns:
the node nearest to this oid.
If there is no node successive to this oid, it returns the node corresponding to this oid.

getMibTrap

public MibTrap getMibTrap(SnmpOID enterprise,
                          int genericType,
                          int specificType)
Gets the trap definition matching the given enterprise, generic type and specific type values. If the enterprise value is `snmp' (.1.3.6.1.2.1.11), the trap number is compared with the generic type. Else if the generic type value is 6, the specific type value is compared with the trap number.
Parameters:
enterprise - the enterprise value of the trap-type
genericType - the integer value
specificType - the integer value
Returns:
the MibTrap object if the exact match is found.
null otherwise.

getMibNode

public MibNode getMibNode(java.lang.String oidString)
Gets the node corresponding to this label. The node is searched in all the loaded modules.
Parameters:
oidString - the name of the node
Returns:
MibNode Object corresponding to the node.
null if the node is not found.
See Also:
MibModule.getMibNode(String)

getMibNode

public MibNode getMibNode(java.lang.String nodeLabel,
                          java.lang.String mib)
Gets the node correspoding to the label in this mib. This method searches for the node only in the specified mib.
Parameters:
nodeLabel - the name of the MibNode
mib - the MIB name in which the node is being searched.
Returns:
the MibNode if the node is found in the mib specified.
null otherwise.

getNodesFromNames

public java.util.Vector getNodesFromNames(java.util.Vector nodes)
Gets the MibNodes corresponding to the names in the Vector. This is useful for converting node lists stored as names.
Parameters:
nodes - Vector of the node names.
Returns:
Vector of MibNodes. The Vector element will be null if the particular MibNode is not found.

getNodesFromString

public java.util.Vector getNodesFromString(java.lang.String nodeList)
Gets the MibNodes corresponding to the node names in the nodelist. This method searches for the specified MIB nodes given in the String argument. This is useful for converting index lists, object names lists, etc.
Parameters:
nodeList - list of the node names separated by space or comma.
Returns:
Vector of MibNodes. The Vector element will be null if the particular MibNode is not found.

getSyntaxByName

public LeafSyntax getSyntaxByName(java.lang.String name)
Gets the syntax for the node represented by the String argument.
NOTE - For TCs , you can get the syntax only if the corresponding MIB is loaded.
Parameters:
name - the name of the syntax or TC
Returns:
the LeafSyntax associated with this name.
null, if there is no syntax associated with the name.

getModuleSize

public int getModuleSize()
Returns the number of modules loaded in this MibOperations instance.

unloadMibModule

public boolean unloadMibModule(MibModule module)
Unloads the MibModule from the modules table.
Parameters:
module - the nstance of the MibModule to be unloaded.
Returns:
true if module is unloaded, false otherwise.

unloadMibModule

public MibModule unloadMibModule(java.lang.String name)
Unloads the MibModule from the MibModules loaded in this instance.
Parameters:
name - the name of the module to be unloaded.
Returns:
the MibModule instance, if the module is unloaded.

unloadAllMibModules

public void unloadAllMibModules()
Unload all the loaded MibModules.

addLabel

public void addLabel(java.lang.String addLabel)
Used to add label which should not be treated as a reserved word by the MIB parser. So if a particular reserved word in MIB is to be used in a different manner, then the conflict can be resolved by using this method. The addLabel should be invoked before loading the MIB file. Some MIB modules contains the reserved word as the identifier. For example, Unsigned32 ::= INTEGER(0 .. 2147483647) MibOperations mibOps = new MibOperations(); mibOps.addLabel("Unsigned32"); mibOps.loadMibModules("mibFile"); The following are the RESERVED key words "ABSENT ACCESS AGENT-CAPABILITIES ANY APPLICATION AUGMENTS BEGIN BIT BITS BOOLEAN BY CHOICE COMPONENT COMPONENTS CONTACT-INFO CREATION-REQUIRES Counter32 Counter64 DEFAULT DEFINED DEFINITIONS DEFVAL DESCRIPTION DISPLAY-HINT END ENUMERATED ENTERPRISE EXPLICIT EXPORTS EXTERNAL FALSE FROM GROUP Gauge32 IDENTIFIER IMPLICIT IMPLIED IMPORTS INCLUDES INDEX INTEGER Integer32 IpAddress LAST-UPDATED MANDATORY-GROUPS MAX MAX-ACCESS MIN MIN-ACCESS MINUS-INFINITY MODULE MODULE-COMPLIANCE MODULE-IDENTITY NOTIFICATION-GROUP NOTIFICATION-TYPE NOTIFICATIONS NULL OBJECT OBJECT-GROUP OBJECT-IDENTITY OBJECT-TYPE OBJECTS OCTET OF OPTIONAL ORGANIZATION Opaque PLUS-INFINITY PRESENT PRIVATE PRODUCT-RELEASE REAL REFERENCE REVISION SEQUENCE SET SIZE STATUS STRING SUPPORTS SYNTAX TAGS TEXTUAL-CONVENTION TRAP-TYPE TRUE TimeTicks UNITS UNIVERSAL Unsigned32 VARIABLES VARIATION WITH WRITE-SYNTAX"
Parameters:
addLabel - the word which should not be treated as a reserved word.

getIgnoreSpecificControlCodes

public boolean getIgnoreSpecificControlCodes()
Used to get the value determining whether the new-line characters, tabs and carriage returns are printed or their hex values
Returns:
true when the boolean in the method setIgnoreSpecificControlCodes(boolean specConCode) is set to true.
false when the boolean is not set, or if the boolean is set to false.
See Also:
setIgnoreSpecificControlCodes(boolean)

setIgnoreSpecificControlCodes

public void setIgnoreSpecificControlCodes(boolean specConCode)
Used to set the value determining whether the new-line characters, tabs and carriage returns are printed as they are or their hex values.
Parameters:
specConCode - the boolean value
Ifset to true then they are printed as they are, else their hex value is printed.

setReadDesc

public void setReadDesc(boolean readFlag)
Sets the flag for reading the descriptions from compiled mib modules. The .cds file contains the description, comments and reference of the node objects present in the MibModule. For the fast loading, or if we don't need the information like, description and reference we can omit the loading of this .cds file by setting this flag false. The default value is true. NOTE: This applies only when the setLoadFromCompiledMibs is set to true.
Parameters:
readFlag - the boolean value

isReadDesc

public boolean isReadDesc()
Used to know whether reading the descriptions from compiled modules is enabled.
Returns:
false if the readFlag in the method setReadDesc(boolean readFlag) is set to false.
true if the boolean is not set or if the boolean is set to true.

getMibModuleNames

public java.util.Enumeration getMibModuleNames()
Gets the names of the Mib modules loaded.
Returns:
Enumeration of loaded MibModules.
Enumeration object with zero entries if no MIB is loaded.

encodeInstanceString

public java.lang.String encodeInstanceString(java.util.Vector indexValue,
                                             java.util.Vector indexMibNodes)
                                      throws java.lang.NumberFormatException
Encodes an instance string based on the Snmp Type of the indexMibNode. This encoded instance string should be concatenated to the node oid to get the complete oid. For example, in atTable(RFC1213-MIB) the indexMibNodes are atIfIndex and atIfNetAddress. The encoded instance String for the atPhysAddress (.1.3.6.1.2.1.3.1.1.2) can be obtained as follows. The indexValue ["1","192.168.1.1"] where "1" is for atIfIndex and "192.168.1.1" for atIfNetAddress respectively. It will return the encoded string value as "1.1.192.168.1.1". It should append with atIfPhysAddress oid to get the complete OID (.1.3.6.1.2.1.3.1.1.2.1.1.192.168.1.1).
Parameters:
indexValue - Vector of String values.
indexMibNodes - Vector of indexMibNodes corresponding to the indexValue
Returns:
String representation of the instance value.

initJdbcParams

public void initJdbcParams(java.lang.String driverName,
                           java.lang.String URL,
                           java.lang.String userName,
                           java.lang.String passWord)
                    throws MibException
If you need to use database support, you have to invoke this method to initialize the Jdbc Parameters. This method used to instantiate the connection with the database. The setLoadFromDatabase should be invoked to use the database operations. The default database we used is MySQL. If we want to use some other database, the setDatabaseName(byte) will be used to select the database. Currently we are supporting the databases MySQL and Oracle.
Parameters:
driverName - Name of the DataBase driver.
URL - URL pointing to the DataBase file name
userName - userName
passWord - password
Throws:
MibException - if any SQLException is thrown.

setLoadFromDatabase

public void setLoadFromDatabase(boolean flag)
Defines whether to load the MIB from DataBase. If set to true the MIB is loaded from the Database. The MIB can be loaded from the database as follows: MibOperations mibOps = new MibOperations(); mibOps.initJdbcParams("driverName", "URL","userName","passWord"); mibOps.setLoadFromDatabase(true); mibOps.loadMibModules("mibFile"); The initJdbcParams method should be used to get the database connection. The default database we support is MySQL. If you need to use other database, the setDatabaseName() method should be used.
Parameters:
flag - the boolean value.
See Also:
initJdbcParams(java.lang.String, java.lang.String, java.lang.String, java.lang.String), setDatabaseName(byte)

isLoadFromDatabase

public boolean isLoadFromDatabase()
Used to know whether the MIB is loaded from the DataBase.
Returns:
true if the boolean in the method setLoadFromDatabase(boolean flag) is set to true.
false if the boolean is not set, or if the bolean is set to false.
See Also:
setLoadFromDatabase(boolean flag)

setOverwriteDatabase

public void setOverwriteDatabase(boolean overWrite)
Defines whether to overwrite the existing database files. NOTE: This applies only when the setLoadFromDataBase is set to true.
Parameters:
overWrite - the boolean value
If set to true the database is overwritten.

isOverwriteDatabase

public boolean isOverwriteDatabase()
Gets the overwriteDataBase boolean. NOTE: This applies only when the setLoadFromDataBase is set to true.
Returns:
true if the overWrite boolean in the setOverwriteDatabase(boolean overWrite) is set to true.
false if the boolean is not set or if the boolean is set to false.
See Also:
setOverwriteDatabase(boolean overWrite)

setDatabaseName

public void setDatabaseName(byte type)
Used to set the database. The default database ia mysql.
Parameters:
type - the byte value (e.g. MibOperations.ORACLE )

getDatabaseName

public byte getDatabaseName()
Gets the name of the Database.
Returns:
the database set by the method setDatabaseName(byte type).
If not set, returns the default value MibOperations.MYSQL
See Also:
setDatabaseName(byte type)

setMultipleRevision

public void setMultipleRevision(java.lang.String revisionFileName)
Sets the Multiple revision for the MIB.
Parameters:
revisionFileName - the name of the files containing different Revisions of the MibModule. The file names can be seperated by space or pipe(|) symbol.

getMultipleRevision

public java.lang.String getMultipleRevision()
Gets the multiple revisions availabe for the MIB.
Returns:
the multiple revision set by the method setMultipleRevision.
If not set, returns empty string.

isMultipleRevision

public boolean isMultipleRevision()
Used to know whether the multiple revision is set or not.
Returns:
true if the Multiple revision is set. false otherwise.

setShowImportedIndex

public void setShowImportedIndex(boolean flag)
Sets the showImportedIndex boolean value.
Parameters:
flag - the boolean value.
If set to true,the imported index nodes will appear in the Mibtree. By default, the value is set to false.

isShowImportedIndex

public boolean isShowImportedIndex()
Used to know whether the external indices are shown in the Mib tree.
Returns:
true if the showImportedIndex boolean in the method setShowImportedIndex(boolean flag) is set to true.
false if not set, or if the boolean is set to false.

getModuleNameDefinitions

public java.lang.String[] getModuleNameDefinitions(java.lang.String fileName)
                                            throws java.io.FileNotFoundException,
                                                   MibException,
                                                   java.io.IOException
Gives all the module names contained in this mib file. The MIB file can have multiple MIB modules. This method is used to retrieve all the module names present in the MIB file without loading the MIB file. If the MIB file contains only a single MIB module, the getModuleNameDefinition can be used.
Parameters:
fileName - name of the file containing the MIB module.
Returns:
String array of the module names, null if not a valid MIB file.
See Also:
getModuleNameDefinition(java.lang.String)

setParsingLevel

public void setParsingLevel(byte parsingLevel)
Used to set the level of parsing.
Parameters:
level - the various parsing levels as mentioned below
The available parsing levels are
  • LENIENT
  • NORMAL
  • SERIOUS
  • CRITICAL
By default it is set to NORMAL.

setImportsParsingLevel

public void setImportsParsingLevel(byte parsingLevel)
Used to set the level of parsing for the dependency MIB files.
Parameters:
parsingLevel - the various parsing levels as mentioned below
The available parsing levels are
  • LENIENT
  • NORMAL
  • SERIOUS
  • CRITICAL
By default it is set to NORMAL.

registerParsingLevel

public void registerParsingLevel(byte parsingLevel,
                                 byte[] checks)
Used to create an used defined parsing level.
Parameters:
parsingLevel - the byte value other than 0,1,2,3
checks - the checks to be included in this new parsing level

addChecks

public void addChecks(byte[] checks,
                      byte parsingLevel)
Used to add checks to the existing parsing level. If the checks to be added is not present in this parsing level, then these checks are added to this parsing level.
Parameters:
checks - the byte array of checks to be added.
parsingLevel - the parsinglevel in which the checks are added.

removeChecks

public void removeChecks(byte[] checks,
                         byte parsingLevel)
Used to remove checks from the existing parsing level. If the checks to be removed are present in this parsing level, then the checks are removed.
Parameters:
checks - the byte array of checks to be removed.
parsingLevel - the parsinglevel from which the checks are removed.

getParsingLevel

public byte getParsingLevel()
Returns the parsingLevel. If not set returns the default value, MibOperations.NORMAL
Returns:
byte - the parsing level.
See Also:
setParsingLevel(byte)

getImportsParsingLevel

public byte getImportsParsingLevel()
Returns the parsingLevel for the dependency MIB files. If not set returns the default value, MibOperations.NORMAL
Returns:
byte - the imports parsing level.
See Also:
setParsingLevel(byte)

getChecks

public byte[] getChecks(byte parsingLevel)
Used to get the checks available for a particular parsingLevel.
Parameters:
parsingLevel - the parsingLevel
Returns:
the byte array of checks available for this parsing level. null, if the parsingLevel doesn't exist.

getErrorModuleNames

public java.util.Vector getErrorModuleNames()
Returns the names of modules which are having parsing errors.
Returns:
Vector of errored modules
empty Vector, if there is no error in any modules.
See Also:
getErrorMessages(java.lang.String)

getErrorMessages

public java.util.Vector getErrorMessages(java.lang.String module)
Returns Vector of MibErrorMessages object for the module specified. From this MibErrorMessages object the error number and the error message associated with this parsing error can be obtained.
Returns:
Vector of MibErrorMessages object
empty Vector, if there is no error in the specified module.
See Also:
getErrorModuleNames()

enableDisplayHint

public void enableDisplayHint(boolean flag)
Used to set the displayHint flag. If this flag is set to true, then the values will be printed according to the DISPLAY-HINT, provided the syntax contains DISPLAY-HINT clause. If the flag is set to false or if the DISPLAY-HINT is absent the ascii values are printed.
Parameters:
flag - the boolean value

isDisplayHintEnabled

public boolean isDisplayHintEnabled()
Used to know whether the displayHint flag is enabled or not.
Returns:
true if the boolean in the method enableDisplayHint(boolean) is set to true.
false if the boolean is not set, or if the boolean is set to false.

isDBConnected

public boolean isDBConnected()
Used to know whether the Database connection is alive or not.
Returns:
true, if the database connection is alive. false, otherwise.


Copyright (c)AdventNet Inc., 1996-2004