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.


Field Summary
(package private)  java.lang.String agentDefn
           
(package private)  java.applet.Applet applet
           
(package private)  java.lang.String categoryDefn
           
(package private)  java.lang.String color
           
(package private)  java.lang.String currentName
           
(package private)  java.util.Properties currentParserVal
           
(package private)  java.lang.String customOIDDefn
           
(package private)  java.lang.String enterprise
           
(package private)  java.util.Vector eventListeners
           
(package private) static java.lang.String fileName
           
(package private)  int GT
           
(package private)  java.lang.String helpDefn
           
(package private)  boolean loading
           
(package private)  MibOperations mibOps
           
(package private)  java.util.Vector parserNameVec
           
(package private)  java.util.Vector parserPropVec
           
(package private)  int severity
           
(package private)  java.lang.String snmpTrapOID
           
(package private)  int ST
           
(package private)  java.lang.String systemUpTime
           
(package private)  java.lang.String textDefn
           
(package private)  java.util.Vector trapParsers
           
(package private)  java.lang.String version
           
 
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(TrapParser tp, SnmpPDU pdu)
           
(package private)  TrapParser createParser(java.lang.String key, MibNode notification)
           
(package private)  TrapParser createParser(java.lang.String key, MibTrap trap)
          create a parser from MibTrap
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.
(package private)  void logErrorMessage(java.lang.String error)
           
(package private)  void logInfoMessage(java.lang.String info)
           
 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
 

Field Detail

applet

java.applet.Applet applet

trapParsers

java.util.Vector trapParsers

eventListeners

java.util.Vector eventListeners

parserNameVec

java.util.Vector parserNameVec

parserPropVec

java.util.Vector parserPropVec

currentParserVal

java.util.Properties currentParserVal

currentName

java.lang.String currentName

fileName

static java.lang.String fileName

enterprise

java.lang.String enterprise

GT

int GT

ST

int ST

severity

int severity

color

java.lang.String color

textDefn

java.lang.String textDefn

categoryDefn

java.lang.String categoryDefn

helpDefn

java.lang.String helpDefn

customOIDDefn

java.lang.String customOIDDefn

agentDefn

java.lang.String agentDefn

version

java.lang.String version

snmpTrapOID

java.lang.String snmpTrapOID

systemUpTime

java.lang.String systemUpTime

loading

boolean loading

mibOps

MibOperations mibOps
Constructor Detail

TrapParserBean

public TrapParserBean()
Instantiates the bean.

TrapParserBean

public TrapParserBean(java.applet.Applet a)
Instantiates the bean with the applet.
Parameters:
applet - from which this bean is instantiated.
Method Detail

addParserListener

public void addParserListener(TrapParserListener listener)
Adds the specified TrapParserListener object to receive ParsedTrapEvents from this bean
Parameters:
Listener - instance to notify when trap is parsed successfully.

removeParserListener

public void removeParserListener(TrapParserListener listener)
Removes the TrapParserListener object for ParsedTrapEvents from this bean
Parameters:
Listener - instance to remove the trap.

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.
Parameters:
Parser - fileName or mib name.

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.
Parameters:
array - of parserFiles.

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.
Parameters:
takes - String array or Vector.

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.
Parameters:
name - of the parser file.
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.
Parameters:
new - MibOperations object to be set.

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.
type - of encoding to be used.

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.
Parameters:
mib - file name from which the trap are loaded.

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

createParser

TrapParser createParser(java.lang.String key,
                        MibTrap trap)
create a parser from MibTrap

createParser

TrapParser createParser(java.lang.String key,
                        MibNode notification)

parseEvtAndFire

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

checkForAgentMatch

public boolean checkForAgentMatch(TrapParser tp,
                                  SnmpPDU pdu)

logErrorMessage

void logErrorMessage(java.lang.String error)

logInfoMessage

void logInfoMessage(java.lang.String info)