org.opennms.netmgt.model.events
Class EventUtils

java.lang.Object
  extended by org.opennms.netmgt.model.events.EventUtils

public abstract class EventUtils
extends Object

Abstract EventUtils class.

Version:
$Id: $
Author:
ranger

Constructor Summary
EventUtils()
           
 
Method Summary
static Event createInterfaceDeletedEvent(String source, int nodeId, String ipAddr)
          Construct an interfaceDeleted event for an interface.
static Event createNodeAddedEvent(String source, int nodeId, String nodeLabel, String labelSource)
          createNodeAddedEvent
static Event createNodeDeletedEvent(String source, int nodeId, String hostName, String nodeLabel)
          This method is responsible for generating a nodeDeleted event and sending it to eventd..
static Event createNodeGainedInterfaceEvent(String source, int nodeId, InetAddress ifaddr)
          createNodeGainedInterfaceEvent
static Event createNodeGainedServiceEvent(String source, int nodeId, InetAddress ifaddr, String service, String nodeLabel, String labelSource, String sysName, String sysDescr)
          createNodeGainedServiceEvent
static Event createNodeUpdatedEvent(String source, Integer nodeId, String nodeLabel, String labelSource)
          createNodeUpdatedEvent
static Event createServiceDeletedEvent(String source, int nodeId, String ipAddr, String service)
          Constructs a serviceDeleted Event for the nodeId, ipAddr, serviceName triple
static int getIntParm(Event e, String parmName, int defaultValue)
          Retrieve the value associated with an event parameter and parse it to an int.
static long getLongParm(Event e, String parmName, long defaultValue)
          Retrieve the value associated with an event parameter and parse it to a long.
static String getParm(Event e, String parmName)
          Return the value of an event parameter of null if it does not exist.
static String getParm(Event e, String parmName, String defaultValue)
          Retrieve a parameter from and event, returning defaultValue of the parameter is not set.
static String toString(Event event)
          toString
static String toString(Parms parms)
          toString
static String toString(Snmp snmp)
          toString
static String toString(Value value)
          toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventUtils

public EventUtils()
Method Detail

createNodeAddedEvent

public static Event createNodeAddedEvent(String source,
                                         int nodeId,
                                         String nodeLabel,
                                         String labelSource)

createNodeAddedEvent

Parameters:
source - a String object.
nodeId - a int.
nodeLabel - a String object.
labelSource - a String object.
Returns:
a Event object.

createNodeGainedInterfaceEvent

public static Event createNodeGainedInterfaceEvent(String source,
                                                   int nodeId,
                                                   InetAddress ifaddr)

createNodeGainedInterfaceEvent

Parameters:
source - a String object.
nodeId - a int.
ifaddr - a InetAddress object.
Returns:
a Event object.

createNodeGainedServiceEvent

public static Event createNodeGainedServiceEvent(String source,
                                                 int nodeId,
                                                 InetAddress ifaddr,
                                                 String service,
                                                 String nodeLabel,
                                                 String labelSource,
                                                 String sysName,
                                                 String sysDescr)

createNodeGainedServiceEvent

Parameters:
source - a String object.
nodeId - a int.
ifaddr - a InetAddress object.
service - a String object.
nodeLabel - a String object.
labelSource - a String object.
sysName - a String object.
sysDescr - a String object.
Returns:
a Event object.

createNodeDeletedEvent

public static Event createNodeDeletedEvent(String source,
                                           int nodeId,
                                           String hostName,
                                           String nodeLabel)
This method is responsible for generating a nodeDeleted event and sending it to eventd..

Parameters:
source - A string representing the source of the event
nodeId - Nodeid of the node got deleted.
hostName - the Host server name.
nodeLabel - the node label of the deleted node.
Returns:
a Event object.

createInterfaceDeletedEvent

public static Event createInterfaceDeletedEvent(String source,
                                                int nodeId,
                                                String ipAddr)
Construct an interfaceDeleted event for an interface.

Parameters:
source - the source of the event
nodeId - the nodeId of the node the interface resides in
ipAddr - the ipAdddr of the event
Returns:
an Event represent an interfaceDeleted event for the given interface

createServiceDeletedEvent

public static Event createServiceDeletedEvent(String source,
                                              int nodeId,
                                              String ipAddr,
                                              String service)
Constructs a serviceDeleted Event for the nodeId, ipAddr, serviceName triple

Parameters:
source - the source of the event
nodeId - the nodeId that the service resides on
ipAddr - the interface that the service resides on
service - the name of the service that was deleted
Returns:
an Event that represents the serviceDeleted event for the give triple

getLongParm

public static long getLongParm(Event e,
                               String parmName,
                               long defaultValue)
Retrieve the value associated with an event parameter and parse it to a long. If the value can not be found, return a default value.

Parameters:
e - the Event to retrieve the parameter from
parmName - the name of the parameter to retrieve
defaultValue - the value to return if the paramter can not be retrieved or parsed
Returns:
the value of the parameter as a long

getIntParm

public static int getIntParm(Event e,
                             String parmName,
                             int defaultValue)
Retrieve the value associated with an event parameter and parse it to an int. If the value can not be found, return a default value.

Parameters:
e - the Event to retrieve the parameter from
parmName - the name of the parameter to retrieve
defaultValue - the value to return if the paramter can not be retrieved or parsed
Returns:
the value of the parameter as a long

getParm

public static String getParm(Event e,
                             String parmName,
                             String defaultValue)
Retrieve a parameter from and event, returning defaultValue of the parameter is not set.

Parameters:
e - The Event to retrieve the parameter from
parmName - the name of the parameter to retrieve
defaultValue - the default value to return if the parameter is not set
Returns:
the value of the parameter, or defalutValue if the parameter is not set

getParm

public static String getParm(Event e,
                             String parmName)
Return the value of an event parameter of null if it does not exist.

Parameters:
e - the Event to get the parameter for
parmName - the name of the parameter to retrieve
Returns:
the value of the parameter, or null of the parameter is not set

createNodeUpdatedEvent

public static Event createNodeUpdatedEvent(String source,
                                           Integer nodeId,
                                           String nodeLabel,
                                           String labelSource)

createNodeUpdatedEvent

Parameters:
source - a String object.
nodeId - a Integer object.
nodeLabel - a String object.
labelSource - a String object.
Returns:
a Event object.

toString

public static String toString(Event event)

toString

Parameters:
event - a Event object.
Returns:
a String object.

toString

public static String toString(Parms parms)

toString

Parameters:
parms - a Parms object.
Returns:
a String object.

toString

public static String toString(Value value)

toString

Parameters:
value - a Value object.
Returns:
a String object.

toString

public static String toString(Snmp snmp)

toString

Parameters:
snmp - a Snmp object.
Returns:
a String object.


Copyright © 2011. All Rights Reserved.