org.glite.ce.monitorapij.sensor
Class SensorEvent

java.lang.Object
  extended byorg.glite.ce.monitorapij.types.EventBase
      extended byorg.glite.ce.monitorapij.types.Event
          extended byorg.glite.ce.monitorapij.sensor.SensorEvent
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class SensorEvent
extends Event
implements java.lang.Cloneable

This class represents an event generated by a Sensor. It is characterized by the Sensor source of this event, the referring time, an identifying String, a Hashtable of parameters and the SensorOutputDataFormat which is applied.

Author:
Luigi Zangrando (zangrando@pd.infn.it)
See Also:
Serialized Form

Constructor Summary
SensorEvent(Sensor source, int eventID)
          Creates a new SensorEvent object specifying the source Sensor and an identifying id.
SensorEvent(Sensor source, int eventID, java.util.Calendar when)
          Creates a new SensorEvent object specifying the source Sensor, an identifying id and the referring time of the event.
 
Method Summary
 void addParameter(java.lang.String name, java.lang.Object value)
          Add a parameter specifying name and value.
 void applyFormat(SensorOutputDataFormat dataformat)
          Apply a format to this event specifying the SensorOutputDataFormat.
 void applyFormat(java.lang.String format)
          Apply a format to this event.
 java.lang.Object clone()
          Get an event identical to this one.
 java.lang.Object getParameter(java.lang.String name)
          Get the paramenter named as specified.
 java.util.Hashtable getParameters()
          Get the all parameters of this event.
 SensorOutputDataFormat getSensorOutputDataFormatApplied()
          Get the SensorOutputDataFormat applied to this event.
 Sensor getSource()
          Get the source Sensor, i.e.
 void setParameters(java.util.Hashtable parameters)
          Set the all parameters of this event.
 
Methods inherited from class org.glite.ce.monitorapij.types.EventBase
equals, getDeserializer, getID, getMessage, getMessage, getProducer, getSerializer, getTimestamp, getTypeDesc, hashCode, setID, setMessage, setMessage, setProducer, setTimestamp
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SensorEvent

public SensorEvent(Sensor source,
                   int eventID)
Creates a new SensorEvent object specifying the source Sensor and an identifying id. The referfing time of the event is set to the current time.

Parameters:
source - The source Sensor.
eventID - An int identifying this event.

SensorEvent

public SensorEvent(Sensor source,
                   int eventID,
                   java.util.Calendar when)
Creates a new SensorEvent object specifying the source Sensor, an identifying id and the referring time of the event.

Parameters:
source - The source Sensor.
eventID - An int identifying this event.
when - The referring time of this event.
Method Detail

getSensorOutputDataFormatApplied

public SensorOutputDataFormat getSensorOutputDataFormatApplied()
Get the SensorOutputDataFormat applied to this event.

Returns:
The SensorOutputDataFormat applied to this event.

getParameter

public java.lang.Object getParameter(java.lang.String name)
Get the paramenter named as specified.

Parameters:
name - The name of the searched parameter.
Returns:
The searched parameter or null if this does not exist.

addParameter

public void addParameter(java.lang.String name,
                         java.lang.Object value)
Add a parameter specifying name and value.

Parameters:
name - The name of the parameter.
value - The value of the parameter.

setParameters

public void setParameters(java.util.Hashtable parameters)
Set the all parameters of this event.

Parameters:
parameters - A Hashtable containing the pairs name-value of all the parameters.

getParameters

public java.util.Hashtable getParameters()
Get the all parameters of this event.

Returns:
The Hashtable containing the pairs name-value of all the parameters.

applyFormat

public void applyFormat(java.lang.String format)
                 throws SensorException
Apply a format to this event. This format is a SensorOutputDataFormat specified by its name and must be supported by the Sensor. If specified format name is null or "default", the default format of the Sensor will be applied.

Parameters:
format - The format name.
Throws:
SensorException

applyFormat

public void applyFormat(SensorOutputDataFormat dataformat)
                 throws SensorException
Apply a format to this event specifying the SensorOutputDataFormat. The must be supported by the Sensor.

Parameters:
dataformat - The SensorOutputDataFormat to apply.
Throws:
SensorException - An exception is thrown if the specified SensorOutputDataFormat is null or is not supported by the source Sensor.

getSource

public Sensor getSource()
Get the source Sensor, i.e. the sensor which generated this event.

Returns:
The source Sensor.

clone

public java.lang.Object clone()
Get an event identical to this one.

Overrides:
clone in class Event
Returns:
The cloned event.