org.opennms.bb.dp.events
Class Event

java.lang.Object
  |
  +--org.opennms.bb.dp.events.EventBase
        |
        +--org.opennms.bb.dp.events.Event
All Implemented Interfaces:
Serializable

public class Event
extends EventBase

Version:
CVS $Revision: 1.6 $
Author:
Brian Weaver, OpenNMS
See Also:
Serialized Form

Field Summary
private  String m_host
          The host that generated the event
private  String m_interface
          The interface name
private  String m_nodeid
          The node identifier.
private  List m_parms
          The EventParameter objects
private  String m_service
          The service name
private  String m_snmphost
          The snmp host that generated the trap
private  String m_source
          The source of the event, this is a required field
private  Calendar m_time
          The time of the event.
 
Fields inherited from class org.opennms.bb.dp.events.EventBase
m_autoaction, m_descr, m_forward, m_loggroup, m_logmsg, m_mouseovertext, m_notification, m_operaction, m_operinstruct, m_severity, m_snmp, m_tticket, m_uei
 
Constructor Summary
Event()
          Constructs a new event object with all the default values.
Event(Event second)
          Constucts a new event object that is a duplicate of the current event.
Event(String source)
          Construct a new event from the specific source.
 
Method Summary
 void addParm(EventParameter parm)
          Adds a new parameter value to the currently defined list.
 String getHost()
          Returns the currently defined host for the event.
 String getInterface()
          Returns the currently defined interface for the event.
 String getNodeID()
          Returns the current node identifier for the event.
 EventParameter getParm(int which)
          Returns the parameter at the specific index.
 List getParms()
          returns the current list of parameters for the event.
 int getParmsSize()
          Returns the current number of parameters in the list.
 String getService()
          Returns the current service for the event.
 String getSnmpHost()
          Returns the snmphost for the event, if any.
 String getSource()
          Returns the source for the event.
 Calendar getTime()
          Returns the current time associataed with the event.
 boolean hasHost()
          Returns true if a host is currently defined for the event.
 boolean hasInterface()
          Returns true if the interface is currently set for the event.
 boolean hasNodeID()
          Returns true if the node identification is currently set for the event.
 boolean hasParms()
          Returns true if the event has at least one parameter defined for the event.
 boolean hasService()
          Returns true if there is a service currently defined for the event.
 boolean hasSnmpHost()
          Returns true if the snmphost for the event is set.
 boolean hasTime()
          Returns true if the event has a time associated with the event.
(package private)  void serializeToXML(PrintStream ps)
          Writes self to event stream.
 void setHost(String host)
          Sets the host for the event.
 void setInterface(String iface)
          Sets the current interface for the event
 void setNodeID(String id)
          Sets the node identifier for the current service.
 void setService(String service)
          Sets the current service for the event.
 void setSnmpHost(String host)
          Sets the current snmp host for the event.
 void setSource(String source)
          Sets the current source string for the event.
 void setTime(Calendar time)
          Sets the time for the event to be equal to the passed time.
 void setTime(Date time)
          Sets the current time for the event.
 void setTime(long time)
          Sets the current time based on the epoch time passed to the call.
 
Methods inherited from class org.opennms.bb.dp.events.EventBase
addAutoAction, addForward, addLogGroup, addNotification, addOperatorAction, getAutoAction, getAutoActions, getAutoActionsSize, getDescription, getForward, getForwards, getForwardsSize, getLogGroup, getLogGroups, getLogGroupsSize, getLogMessage, getMouseOverText, getNotification, getNotifications, getNotificationsSize, getOperatorAction, getOperatorActions, getOperatorActionsSize, getOperatorInstruction, getSeverity, getSnmpInfo, getTroubleTicket, getUEI, hasAutoActions, hasDescription, hasForwards, hasLogGroups, hasLogMessage, hasMouseOverText, hasNotifications, hasOperatorActions, hasOperatorInstruction, hasSeverity, hasSnmpInfo, hasTroubleTicket, hasUEI, serializeToXML, serializeToXML, setAutoActions, setDescription, setForwards, setLogGroups, setLogMessage, setMouseOverText, setNotifications, setOperatorActions, setOperatorInstruction, setSeverity, setSnmpInfo, setTroubleTicket, setUEI
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_source

private String m_source
The source of the event, this is a required field

m_time

private Calendar m_time
The time of the event.

m_host

private String m_host
The host that generated the event

m_snmphost

private String m_snmphost
The snmp host that generated the trap

m_nodeid

private String m_nodeid
The node identifier.

m_service

private String m_service
The service name

m_interface

private String m_interface
The interface name

m_parms

private List m_parms
The EventParameter objects
Constructor Detail

Event

public Event()
Constructs a new event object with all the default values.

Event

public Event(Event second)
Constucts a new event object that is a duplicate of the current event. This is a shallow copy and if a list in second event is modified, then that change will also appear in this copy.
Parameters:
second - The event to copy into self.

Event

public Event(String source)
Construct a new event from the specific source.
Parameters:
source - The source of the event.
Method Detail

getSource

public String getSource()
Returns the source for the event. As defined in the DTD an event must have a source, but if one has not be defined for the event object then a null is returned.

setSource

public void setSource(String source)
Sets the current source string for the event. If a source was previously defined then it is lost.
Parameters:
source - The new source for the event.

hasTime

public boolean hasTime()
Returns true if the event has a time associated with the event.

getTime

public Calendar getTime()
Returns the current time associataed with the event. If the time was not set for this event then a null value is returned to the caller.

setTime

public void setTime(Calendar time)
Sets the time for the event to be equal to the passed time.
Parameters:
time - The new time for the event.

setTime

public void setTime(Date time)
Sets the current time for the event.
Parameters:
time - The time for the event.

setTime

public void setTime(long time)
Sets the current time based on the epoch time passed to the call.
Parameters:
time - The epoch time for the event.

hasHost

public boolean hasHost()
Returns true if a host is currently defined for the event.

getHost

public String getHost()
Returns the currently defined host for the event. If no host is defined for the event then a null is returned to the caller.

setHost

public void setHost(String host)
Sets the host for the event.
Parameters:
host - The host for the event.

hasSnmpHost

public boolean hasSnmpHost()
Returns true if the snmphost for the event is set.

getSnmpHost

public String getSnmpHost()
Returns the snmphost for the event, if any. If no snmphost is defined for the event then a null is returned.

setSnmpHost

public void setSnmpHost(String host)
Sets the current snmp host for the event.
Parameters:
host - The snmp host information

hasNodeID

public boolean hasNodeID()
Returns true if the node identification is currently set for the event.

getNodeID

public String getNodeID()
Returns the current node identifier for the event.

setNodeID

public void setNodeID(String id)
Sets the node identifier for the current service.
Parameters:
id - The new node identification.

hasService

public boolean hasService()
Returns true if there is a service currently defined for the event.

getService

public String getService()
Returns the current service for the event. If no service is currently defined then a null is returned to the caller.

setService

public void setService(String service)
Sets the current service for the event.
Parameters:
service - The new service for the event.

hasInterface

public boolean hasInterface()
Returns true if the interface is currently set for the event.

getInterface

public String getInterface()
Returns the currently defined interface for the event. If no interface has been defined then a null will be returned to the caller.

setInterface

public void setInterface(String iface)
Sets the current interface for the event
Parameters:
iface - The new interface for the event.

hasParms

public boolean hasParms()
Returns true if the event has at least one parameter defined for the event.

getParms

public List getParms()
returns the current list of parameters for the event. If there are no parameters defined then a null may be returned by this call.

getParmsSize

public int getParmsSize()
Returns the current number of parameters in the list.

getParm

public EventParameter getParm(int which)
Returns the parameter at the specific index. If the index is out of range then an IndexOutOfBoundsException will be generated.
Parameters:
which - The index of the desired parameter.
Returns:
The indexed parameter.
Throws:
IndexOutOfBoundsException - Thrown if the index is greater than the size of the list.

addParm

public void addParm(EventParameter parm)
Adds a new parameter value to the currently defined list. If this is the first parameter then a list will be allocated internally to store the new parameter, and any subsequent ones.
Parameters:
parm - THe parameter to add to the list.

serializeToXML

void serializeToXML(PrintStream ps)

Writes self to event stream. This implementation is based upon the format of an event object in the event.dtd.

Overrides:
serializeToXML in class EventBase
Parameters:
ps - The print stream to serialize to.