org.slf4j.ext
Class EventData

java.lang.Object
  extended by org.slf4j.ext.EventData
All Implemented Interfaces:
java.io.Serializable

public class EventData
extends java.lang.Object
implements java.io.Serializable

Base class for Event Data. Event Data contains data to be logged about an event. Users may extend this class for each EventType they want to log.

Author:
Ralph Goers
See Also:
Serialized Form

Field Summary
static java.lang.String EVENT_DATETIME
           
static java.lang.String EVENT_ID
           
static java.lang.String EVENT_MESSAGE
           
static java.lang.String EVENT_TYPE
           
 
Constructor Summary
EventData()
          Default Constructor
EventData(java.util.Map<java.lang.String,java.lang.Object> map)
          Constructor to create event data from a Map.
EventData(java.lang.String xml)
          Construct from a serialized form of the Map containing the RequestInfo elements
 
Method Summary
 boolean equals(java.lang.Object o)
          Compare two EventData objects for equality.
 java.io.Serializable get(java.lang.String name)
          Retrieve an event attribute.
 java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.Object>> getEntrySetIterator()
          Returns an Iterator over all the entries in the EventDAta.
 java.util.Date getEventDateTime()
          Retrieve the date and time the event occurred.
 java.lang.String getEventId()
          Retrieve the event identifier.
 java.util.Map<java.lang.String,java.lang.Object> getEventMap()
          Retrieve all the attributes in the EventData as a Map.
 java.lang.String getEventType()
          Retrieve the type of the event.
 java.lang.String getMessage()
          Retrieve the message text associated with this event, if any.
 int getSize()
          Returns the number of attributes in the EventData.
 int hashCode()
          Compute the hashCode for this EventData instance.
 void put(java.lang.String name, java.io.Serializable obj)
          Add arbitrary attributes about the event.
 void putAll(java.util.Map<java.lang.String,java.lang.Object> data)
          Populate the event data from a Map.
 void setEventDateTime(java.util.Date eventDateTime)
          Set the date and time the event occurred in case it is not the same as when the event was logged.
 void setEventId(java.lang.String eventId)
          Set the event identifier.
 void setEventType(java.lang.String eventType)
          Set the type of event that occurred.
 void setMessage(java.lang.String message)
          Set the message text associated with this event.
 java.lang.String toString()
          Convert the EventData to a String.
 java.lang.String toXML()
          Serialize all the EventData items into an XML representation.
static java.lang.String toXML(java.util.Map<java.lang.String,java.lang.Object> map)
          Serialize all the EventData items into an XML representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EVENT_MESSAGE

public static final java.lang.String EVENT_MESSAGE
See Also:
Constant Field Values

EVENT_TYPE

public static final java.lang.String EVENT_TYPE
See Also:
Constant Field Values

EVENT_DATETIME

public static final java.lang.String EVENT_DATETIME
See Also:
Constant Field Values

EVENT_ID

public static final java.lang.String EVENT_ID
See Also:
Constant Field Values
Constructor Detail

EventData

public EventData()
Default Constructor


EventData

public EventData(java.util.Map<java.lang.String,java.lang.Object> map)
Constructor to create event data from a Map.

Parameters:
map - The event data.

EventData

public EventData(java.lang.String xml)
Construct from a serialized form of the Map containing the RequestInfo elements

Parameters:
xml - The serialized form of the RequestInfo Map.
Method Detail

toXML

public java.lang.String toXML()
Serialize all the EventData items into an XML representation.

Returns:
an XML String containing all the EventDAta items.

toXML

public static java.lang.String toXML(java.util.Map<java.lang.String,java.lang.Object> map)
Serialize all the EventData items into an XML representation.

Returns:
an XML String containing all the EventDAta items.

getEventId

public java.lang.String getEventId()
Retrieve the event identifier.

Returns:
The event identifier

setEventId

public void setEventId(java.lang.String eventId)
Set the event identifier.

Parameters:
eventId - The event identifier.

getMessage

public java.lang.String getMessage()
Retrieve the message text associated with this event, if any.

Returns:
The message text associated with this event or null if there is none.

setMessage

public void setMessage(java.lang.String message)
Set the message text associated with this event.

Parameters:
message - The message text.

getEventDateTime

public java.util.Date getEventDateTime()
Retrieve the date and time the event occurred.

Returns:
The Date associated with the event.

setEventDateTime

public void setEventDateTime(java.util.Date eventDateTime)
Set the date and time the event occurred in case it is not the same as when the event was logged.

Parameters:
eventDateTime - The event Date.

setEventType

public void setEventType(java.lang.String eventType)
Set the type of event that occurred.

Parameters:
eventType - The type of the event.

getEventType

public java.lang.String getEventType()
Retrieve the type of the event.

Returns:
The event type.

put

public void put(java.lang.String name,
                java.io.Serializable obj)
Add arbitrary attributes about the event.

Parameters:
name - The attribute's key.
obj - The data associated with the key.

get

public java.io.Serializable get(java.lang.String name)
Retrieve an event attribute.

Parameters:
name - The attribute's key.
Returns:
The value associated with the key or null if the key is not present.

putAll

public void putAll(java.util.Map<java.lang.String,java.lang.Object> data)
Populate the event data from a Map.

Parameters:
data - The Map to copy.

getSize

public int getSize()
Returns the number of attributes in the EventData.

Returns:
the number of attributes in the EventData.

getEntrySetIterator

public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.Object>> getEntrySetIterator()
Returns an Iterator over all the entries in the EventDAta.

Returns:
an Iterator that can be used to access all the event attributes.

getEventMap

public java.util.Map<java.lang.String,java.lang.Object> getEventMap()
Retrieve all the attributes in the EventData as a Map. Changes to this map will be reflected in the EventData.

Returns:
The Map of attributes in this EventData instance.

toString

public java.lang.String toString()
Convert the EventData to a String.

Overrides:
toString in class java.lang.Object
Returns:
The EventData as a String.

equals

public boolean equals(java.lang.Object o)
Compare two EventData objects for equality.

Overrides:
equals in class java.lang.Object
Parameters:
o - The Object to compare.
Returns:
true if the objects are the same instance or contain all the same keys and their values.

hashCode

public int hashCode()
Compute the hashCode for this EventData instance.

Overrides:
hashCode in class java.lang.Object
Returns:
The hashcode for this EventData instance.


Copyright © 2005-2011 QOS.ch. All Rights Reserved.