OpenNMS API 1.2.3

org.opennms.netmgt.eventd
Class EventUtil

java.lang.Object
  extended byorg.opennms.netmgt.eventd.EventUtil

public final class EventUtil
extends java.lang.Object

EventUtil is used primarily for the event parm expansion - has methods used by all the event components to send in the event and the element to expanded and have the 'expanded' value sent back

Author:
Sowmya Kumaraswamy , Brain Weaver , OpenNMS

Field Summary
(package private) static char ATTRIB_DELIM
          The values and the corresponding attributes of an element are added delimited by ATTRIB_DELIM
(package private) static char NAME_VAL_DELIM
          For expansion of the '%parms[all]%' - the parm name and value are added as delimiter separated list of ' = ' strings
(package private) static java.lang.String NUM_PARMS_STR
          The string that should be expanded to the number of parms
(package private) static java.lang.String PARM_BEGIN
          The string that starts the expansion for a parm - used to lookup values of parameters by their names
(package private) static int PARM_BEGIN_LENGTH
          The length of PARM_BEGIN
(package private) static java.lang.String PARM_END_SUFFIX
          The string that ends the expansion of a parm
(package private) static java.lang.String PARM_NUM_PREFIX
          The string that starts a parm number - used to lookup values of parameters by their position
(package private) static int PARM_NUM_PREFIX_LENGTH
          The length of PARM_NUM_PREFIX
(package private) static java.lang.String PARMS_ALL
          The string that should be expanded to a list of all parms
(package private) static java.lang.String PARMS_NAMES
          The string that should be expanded to a list of all parm names
(package private) static java.lang.String PARMS_VALUES
          The string that should be expanded to a list of all parm values
(package private) static char PERCENT
          The '%' sign used to indicate parms to be expanded
(package private) static char SPACE_DELIM
           
(package private) static java.lang.String TAG_EVENT_DB_ID
          The Event ID xml
(package private) static java.lang.String TAG_HOST
          The event host xml tag
(package private) static java.lang.String TAG_IFALIAS
          The reverse DNS lookup of the interface
(package private) static java.lang.String TAG_INTERFACE
          The event interface xml tag
(package private) static java.lang.String TAG_INTERFACE_RESOLVE
          The reverse DNS lookup of the interface
(package private) static java.lang.String TAG_MOUSEOVERTEXT
          The event mouseovertext xml tag
(package private) static java.lang.String TAG_NODEID
          The event nodeid xml tag
(package private) static java.lang.String TAG_NODELABEL
          The event nodeid xml tag
(package private) static java.lang.String TAG_OPERINSTR
          The event operinstruct xml tag
(package private) static java.lang.String TAG_SERVICE
          The event service xml tag
(package private) static java.lang.String TAG_SEVERITY
          The event severity xml tag
(package private) static java.lang.String TAG_SNMP
          The SNMP xml tag
(package private) static java.lang.String TAG_SNMP_COMMUNITY
          The event snmp community xml tag
(package private) static java.lang.String TAG_SNMP_GENERIC
          The event snmp generic xml tag
(package private) static java.lang.String TAG_SNMP_ID
          The event snmp id xml tag
(package private) static java.lang.String TAG_SNMP_IDTEXT
          The event snmp idtext xml tag
(package private) static java.lang.String TAG_SNMP_SPECIFIC
          The event snmp specific xml tag
(package private) static java.lang.String TAG_SNMP_VERSION
          The event snmp version xml tag
(package private) static java.lang.String TAG_SNMPHOST
          The event snmp host xml tag
(package private) static java.lang.String TAG_SOURCE
          The event source xml tag
(package private) static java.lang.String TAG_TIME
          The event time xml tag
(package private) static java.lang.String TAG_UEI
          The UEI xml tag
 
Constructor Summary
EventUtil()
           
 
Method Summary
static java.lang.String escape(java.lang.String inStr, char delimchar)
           This method is used to escape required values from strings that may contain those values.
static java.lang.String expandParms(java.lang.String inp, Event event)
          Expand the value if it has parms in one of the following formats - %element% values are expanded to have the value of the element where 'element' is an element in the event DTD - %parm[values-all]% is expanded to a delimited list of all parmblock values - %parm[names-all]% is expanded to a list of all parm names - %parm[all]% is expanded to a full dump of all parmblocks - %parm[name]% is expanded to the value of the parameter named 'name' - %parm[ ]% is replaced by the value of the parameter named 'name', if present - %parm[# ]% is replaced by the value of the parameter number 'num', if present - %parm[##]% is replaced by the number of parameters
private static java.lang.String getIfAlias(long nodeId, java.lang.String ipaddr)
          Retrieve ifAlias from the snmpinterface table of the database given a particular nodeId and ipAddr.
private static java.lang.String getNodeLabel(long nodeId)
          Retrieve nodeLabel from the node table of the database given a particular nodeId.
static java.lang.String getValueAsString(Value pvalue)
          Converts the value of a parm ('Value') of the instance to a string
static java.lang.String getValueOfParm(java.lang.String parm, Event event)
          Get the value of the parm for the event
private static java.text.DateFormat ThreadCategory(java.lang.Class class1)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_EVENT_DB_ID

static final java.lang.String TAG_EVENT_DB_ID
The Event ID xml

See Also:
Constant Field Values

TAG_UEI

static final java.lang.String TAG_UEI
The UEI xml tag

See Also:
Constant Field Values

TAG_SOURCE

static final java.lang.String TAG_SOURCE
The event source xml tag

See Also:
Constant Field Values

TAG_TIME

static final java.lang.String TAG_TIME
The event time xml tag

See Also:
Constant Field Values

TAG_NODEID

static final java.lang.String TAG_NODEID
The event nodeid xml tag

See Also:
Constant Field Values

TAG_NODELABEL

static final java.lang.String TAG_NODELABEL
The event nodeid xml tag

See Also:
Constant Field Values

TAG_HOST

static final java.lang.String TAG_HOST
The event host xml tag

See Also:
Constant Field Values

TAG_INTERFACE

static final java.lang.String TAG_INTERFACE
The event interface xml tag

See Also:
Constant Field Values

TAG_INTERFACE_RESOLVE

static final java.lang.String TAG_INTERFACE_RESOLVE
The reverse DNS lookup of the interface

See Also:
Constant Field Values

TAG_IFALIAS

static final java.lang.String TAG_IFALIAS
The reverse DNS lookup of the interface

See Also:
Constant Field Values

TAG_SNMP_ID

static final java.lang.String TAG_SNMP_ID
The event snmp id xml tag

See Also:
Constant Field Values

TAG_SNMP

static final java.lang.String TAG_SNMP
The SNMP xml tag

See Also:
Constant Field Values

TAG_SNMP_IDTEXT

static final java.lang.String TAG_SNMP_IDTEXT
The event snmp idtext xml tag

See Also:
Constant Field Values

TAG_SNMP_VERSION

static final java.lang.String TAG_SNMP_VERSION
The event snmp version xml tag

See Also:
Constant Field Values

TAG_SNMP_SPECIFIC

static final java.lang.String TAG_SNMP_SPECIFIC
The event snmp specific xml tag

See Also:
Constant Field Values

TAG_SNMP_GENERIC

static final java.lang.String TAG_SNMP_GENERIC
The event snmp generic xml tag

See Also:
Constant Field Values

TAG_SNMP_COMMUNITY

static final java.lang.String TAG_SNMP_COMMUNITY
The event snmp community xml tag

See Also:
Constant Field Values

TAG_SNMPHOST

static final java.lang.String TAG_SNMPHOST
The event snmp host xml tag

See Also:
Constant Field Values

TAG_SERVICE

static final java.lang.String TAG_SERVICE
The event service xml tag

See Also:
Constant Field Values

TAG_SEVERITY

static final java.lang.String TAG_SEVERITY
The event severity xml tag

See Also:
Constant Field Values

TAG_OPERINSTR

static final java.lang.String TAG_OPERINSTR
The event operinstruct xml tag

See Also:
Constant Field Values

TAG_MOUSEOVERTEXT

static final java.lang.String TAG_MOUSEOVERTEXT
The event mouseovertext xml tag

See Also:
Constant Field Values

PERCENT

static final char PERCENT
The '%' sign used to indicate parms to be expanded

See Also:
Constant Field Values

PARMS_NAMES

static final java.lang.String PARMS_NAMES
The string that should be expanded to a list of all parm names

See Also:
Constant Field Values

PARMS_VALUES

static final java.lang.String PARMS_VALUES
The string that should be expanded to a list of all parm values

See Also:
Constant Field Values

PARMS_ALL

static final java.lang.String PARMS_ALL
The string that should be expanded to a list of all parms

See Also:
Constant Field Values

PARM_BEGIN

static final java.lang.String PARM_BEGIN
The string that starts the expansion for a parm - used to lookup values of parameters by their names

See Also:
Constant Field Values

PARM_BEGIN_LENGTH

static final int PARM_BEGIN_LENGTH
The length of PARM_BEGIN

See Also:
Constant Field Values

NUM_PARMS_STR

static final java.lang.String NUM_PARMS_STR
The string that should be expanded to the number of parms

See Also:
Constant Field Values

PARM_NUM_PREFIX

static final java.lang.String PARM_NUM_PREFIX
The string that starts a parm number - used to lookup values of parameters by their position

See Also:
Constant Field Values

PARM_NUM_PREFIX_LENGTH

static final int PARM_NUM_PREFIX_LENGTH
The length of PARM_NUM_PREFIX

See Also:
Constant Field Values

PARM_END_SUFFIX

static final java.lang.String PARM_END_SUFFIX
The string that ends the expansion of a parm

See Also:
Constant Field Values

NAME_VAL_DELIM

static final char NAME_VAL_DELIM
For expansion of the '%parms[all]%' - the parm name and value are added as delimiter separated list of ' = ' strings

See Also:
Constant Field Values

SPACE_DELIM

static final char SPACE_DELIM
See Also:
Constant Field Values

ATTRIB_DELIM

static final char ATTRIB_DELIM
The values and the corresponding attributes of an element are added delimited by ATTRIB_DELIM

See Also:
Constant Field Values
Constructor Detail

EventUtil

public EventUtil()
Method Detail

getValueAsString

public static java.lang.String getValueAsString(Value pvalue)
Converts the value of a parm ('Value') of the instance to a string


escape

public static java.lang.String escape(java.lang.String inStr,
                                      char delimchar)

This method is used to escape required values from strings that may contain those values. If the passed string contains the passed value then the character is reformatted into its %dd format.

Parameters:
inStr - string that might contain the delimiter
delimchar - delimiter to escape
Returns:
The string with the delimiter escaped as in URLs
See Also:
ATTRIB_DELIM

getValueOfParm

public static java.lang.String getValueOfParm(java.lang.String parm,
                                              Event event)
Get the value of the parm for the event

Parameters:
parm - the parm for which value is needed from the event
event - the event whose parm value is required
Returns:
value of the event parm/element

ThreadCategory

private static java.text.DateFormat ThreadCategory(java.lang.Class class1)

expandParms

public static java.lang.String expandParms(java.lang.String inp,
                                           Event event)
Expand the value if it has parms in one of the following formats - %element% values are expanded to have the value of the element where 'element' is an element in the event DTD - %parm[values-all]% is expanded to a delimited list of all parmblock values - %parm[names-all]% is expanded to a list of all parm names - %parm[all]% is expanded to a full dump of all parmblocks - %parm[name]% is expanded to the value of the parameter named 'name' - %parm[ ]% is replaced by the value of the parameter named 'name', if present - %parm[# ]% is replaced by the value of the parameter number 'num', if present - %parm[##]% is replaced by the number of parameters

Parameters:
inp - the input string in which parm values are to be expanded
Returns:
expanded value if the value had any parameter to expand, null otherwise

getNodeLabel

private static java.lang.String getNodeLabel(long nodeId)
                                      throws java.sql.SQLException
Retrieve nodeLabel from the node table of the database given a particular nodeId.

Parameters:
nodeId - Node identifier
Returns:
nodeLabel Retreived nodeLabel
Throws:
java.sql.SQLException - if database error encountered

getIfAlias

private static java.lang.String getIfAlias(long nodeId,
                                           java.lang.String ipaddr)
                                    throws java.sql.SQLException
Retrieve ifAlias from the snmpinterface table of the database given a particular nodeId and ipAddr.

Parameters:
nodeId - Node identifier
Returns:
ifAlias Retreived ifAlias
Throws:
java.sql.SQLException - if database error encountered

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.