org.slf4j.ext
Class EventData

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

public class EventData
extends Object
implements 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 String EVENT_DATETIME
           
static String EVENT_ID
           
static String EVENT_MESSAGE
           
static String EVENT_TYPE
           
 
Constructor Summary
EventData()
          Default Constructor
EventData(Map<String,Object> map)
          Constructor to create event data from a Map.
EventData(String xml)
          Construct from a serialized form of the Map containing the RequestInfo elements
 
Method Summary
 boolean equals(Object o)
          Compare two EventData objects for equality.
 Serializable get(String name)
          Retrieve an event attribute.
 Iterator<Map.Entry<String,Object>> getEntrySetIterator()
          Returns an Iterator over all the entries in the EventDAta.
 Date getEventDateTime()
          Retrieve the date and time the event occurred.
 String getEventId()
          Retrieve the event identifier.
 Map<String,Object> getEventMap()
          Retrieve all the attributes in the EventData as a Map.
 String getEventType()
          Retrieve the type of the event.
 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(String name, Serializable obj)
          Add arbitrary attributes about the event.
 void putAll(Map<String,Object> data)
          Populate the event data from a Map.
 void setEventDateTime(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(String eventId)
          Set the event identifier.
 void setEventType(String eventType)
          Set the type of event that occurred.
 void setMessage(String message)
          Set the message text associated with this event.
 String toString()
          Convert the EventData to a String.
 String toXML()
          Serialize all the EventData items into an XML representation.
static String toXML(Map<String,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 String EVENT_MESSAGE
See Also:
Constant Field Values

EVENT_TYPE

public static final String EVENT_TYPE
See Also:
Constant Field Values

EVENT_DATETIME

public static final String EVENT_DATETIME
See Also:
Constant Field Values

EVENT_ID

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

EventData

public EventData()
Default Constructor


EventData

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

Parameters:
map - The event data.

EventData

public EventData(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 String toXML()
Serialize all the EventData items into an XML representation.

Returns:
an XML String containing all the EventDAta items.

toXML

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

Parameters:
map - the Map to transform
Returns:
an XML String containing all the EventDAta items.

getEventId

public String getEventId()
Retrieve the event identifier.

Returns:
The event identifier

setEventId

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

Parameters:
eventId - The event identifier.

getMessage

public 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(String message)
Set the message text associated with this event.

Parameters:
message - The message text.

getEventDateTime

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

Returns:
The Date associated with the event.

setEventDateTime

public void setEventDateTime(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(String eventType)
Set the type of event that occurred.

Parameters:
eventType - The type of the event.

getEventType

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

Returns:
The event type.

put

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

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

get

public Serializable get(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(Map<String,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 Iterator<Map.Entry<String,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 Map<String,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 String toString()
Convert the EventData to a String.

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

equals

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

Overrides:
equals in class 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 Object
Returns:
The hashcode for this EventData instance.


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