com.adventnet.snmp.ui
Class TrapParserBean

java.lang.Object
  |
  +--com.adventnet.snmp.ui.TrapParserBean

public class TrapParserBean
extends java.lang.Object

Filters traps according to the Trap Parser File. This class checks if the trap received has the same match criteria defined in the parser file.

The Trap parser file contains the match criteria and the output events to be displayed when the trap is matched. A parser file can contain more than one trap parser criteria. The match criteria in a parser determine whether a specific trap matches a trap parser. The search for matching any one of the trap parsers is done from the trap parsers list starting at the top. Once a matching trap parser is found, an event is generated and no other trap parsers will be used on that trap. The Trap Parser Bean gets trap event from Snmp Trap Receiver. When a trap matchs any one of the match criteria defined in the parser file, a ParsedTrapEvent is generated by this component.


Constructor Summary
TrapParserBean()
          Instantiates the bean.
TrapParserBean(java.applet.Applet a)
          Instantiates the bean with the applet.
 
Method Summary
 void addParserListener(TrapParserListener listener)
          Adds the specified TrapParserListener object to receive ParsedTrapEvents from this bean
 boolean checkForAgentMatch(com.adventnet.snmp.ui.TrapParser tp, SnmpPDU pdu)
           
protected  void fileWrite(java.lang.String fileName)
           
 java.util.Vector getAllParsers()
           
 java.lang.String getCharacterEncoding()
          Gets the Character Encoding being used.
 java.util.Vector getEditParser()
          Gets the details required for Custom Trap Editor Bean.
 java.lang.String getFileName()
          Gets the filename parser file name
 MibOperations getMibOperations()
          Gets the MibOperations object.
 java.util.Vector getParserContentsVec(java.util.Properties p)
           
 java.lang.String[] getParserName()
          Gets names of the parsers in the loaded TrapParser file
 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 for mibs, this method should be invoked to initialize the Jdbc Parameters.
 boolean isLoadMibsFromDatabase()
          Returns whether mib will be loaded from database or not.
 boolean isOverwriteMibsInDatabase()
          Returns whether mibs in database will be overwritten or not.
 boolean isParserLoaded()
          Determines if the parser file is loaded or not.
 void loadDefinedTraps()
          load the traps defined in the loaded mibs
 boolean loadParsers(java.lang.String file)
          To load the parsers from a file/URL.
 void loadParsersFromMib(java.lang.String mibs)
          Load the traps defined in the mib file.
 boolean parseEvtAndFire(TrapEvent evt)
          this takes TrapEvent and generates ParsedTrapEvent
 void removeParserListener(TrapParserListener listener)
          Removes the TrapParserListener object for ParsedTrapEvents from this bean
 void setCharacterEncoding(java.lang.String enc)
          Set the Character Encoding to be used.
 void setEditParser(java.lang.Object o)
          Sets the details required for Custom Trap Editor Bean.
 void setFileName(java.lang.String fileName)
          Set the filename which contains the set of parser details.
 void setLoadMibsFromDatabase(boolean flag)
          Defines whether to load mib from DataBase.
 void setMibOperations(MibOperations mibOperations)
          Sets MibOperations object.
 void setOverwriteMibsInDatabase(boolean overWrite)
          Defines whether to overwrite the MIB in the DataBase.
 void setParserName(java.lang.String[] str)
          Sets the name of the parsers in the Trap Parser file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrapParserBean

public TrapParserBean()
Instantiates the bean.


TrapParserBean

public TrapParserBean(java.applet.Applet a)
Instantiates the bean with the applet.

Method Detail

addParserListener

public void addParserListener(TrapParserListener listener)
Adds the specified TrapParserListener object to receive ParsedTrapEvents from this bean


removeParserListener

public void removeParserListener(TrapParserListener listener)
Removes the TrapParserListener object for ParsedTrapEvents from this bean


getFileName

public java.lang.String getFileName()
Gets the filename parser file name

Returns:
file name string.

setFileName

public void setFileName(java.lang.String fileName)
Set the filename which contains the set of parser details. Parser file name must be end with ".parser" extension. File name without ".parser" extension are loaded as mibs to load the parsers from mib. If the empty string is passed, filters traps according to the those defined in the MibOperations object.


getParserName

public java.lang.String[] getParserName()
Gets names of the parsers in the loaded TrapParser file

Returns:
array of parser file names.

setParserName

public void setParserName(java.lang.String[] str)
Sets the name of the parsers in the Trap Parser file. The order of the parser file names in the array is important.


getEditParser

public java.util.Vector getEditParser()
Gets the details required for Custom Trap Editor Bean. Returns the details of the trap parser loaded. First element contains the parser file name. Second element contains the parser name vector. Last element contains the vector of all the trap parser in the parser file.

Returns:
Vector of parser Details.

getAllParsers

public java.util.Vector getAllParsers()

setEditParser

public void setEditParser(java.lang.Object o)
Sets the details required for Custom Trap Editor Bean.


fileWrite

protected void fileWrite(java.lang.String fileName)

getParserContentsVec

public java.util.Vector getParserContentsVec(java.util.Properties p)

isParserLoaded

public boolean isParserLoaded()
Determines if the parser file is loaded or not.

Returns:
true if file is loaded, else false.

loadParsers

public boolean loadParsers(java.lang.String file)
To load the parsers from a file/URL. First try to load the file from jar. If the file is not found then load from the classpath. For applets it will try to load from codebase, documentbase, server_root directory and SASusers directory.

Returns:
true if loaded successfully, else false.

getMibOperations

public MibOperations getMibOperations()
Gets the MibOperations object.

Returns:
MibOperations object

setMibOperations

public void setMibOperations(MibOperations mibOperations)
Sets MibOperations object.


setCharacterEncoding

public void setCharacterEncoding(java.lang.String enc)
Set the Character Encoding to be used. The encoding specified will be used internally to convert String <--> byte[]. The Default value is ISO8859_1.

Parameters:
enc - The name of a character encoding. All the string encoding will be done base on this encoding.

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Gets the Character Encoding being used. This encoding scheme will be used internally to convert String <--> byte[]. The Default value is ISO8859_1.

Returns:
The character encoding used.

loadParsersFromMib

public void loadParsersFromMib(java.lang.String mibs)
Load the traps defined in the mib file. The trap parameters defined in the mib file are taking a the match criteria for parsing traps.


initJdbcParams

public 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 for mibs, this method should be invoked to initialize the Jdbc Parameters.

Parameters:
URL - URL pointing to the DataBase file name
userName - userName
passWord - password

setLoadMibsFromDatabase

public void setLoadMibsFromDatabase(boolean flag)
Defines whether to load mib from DataBase. The Jdbc Parameters should be set, using the initJdbcParams(), before calling this method. This flag should be set before loading the MIBs (By default it is set to false). If this flag is set to true, it will parse the mibs,and store it in the database. For ex: RMON2-MIB is loaded, it will parse the mib and store it in the database.

Parameters:
flag - boolean
See Also:
initJdbcParams(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

setOverwriteMibsInDatabase

public void setOverwriteMibsInDatabase(boolean overWrite)
Defines whether to overwrite the MIB in the DataBase. NOTE: This applies only when the setLoadFromDataBase is set to true.


isOverwriteMibsInDatabase

public boolean isOverwriteMibsInDatabase()
Returns whether mibs in database will be overwritten or not. NOTE: This applies only when the setLoadFromDataBase is set to true.


isLoadMibsFromDatabase

public boolean isLoadMibsFromDatabase()
Returns whether mib will be loaded from database or not.


loadDefinedTraps

public void loadDefinedTraps()
load the traps defined in the loaded mibs


parseEvtAndFire

public boolean parseEvtAndFire(TrapEvent evt)
this takes TrapEvent and generates ParsedTrapEvent


checkForAgentMatch

public boolean checkForAgentMatch(com.adventnet.snmp.ui.TrapParser tp,
                                  SnmpPDU pdu)


Copyright (c)ZOHO Corp. 1996-2012