org.slf4j.ext

Class EventData

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

Field Summary
static StringEVENT_DATETIME
static StringEVENT_ID
static StringEVENT_MESSAGE
static StringEVENT_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
Serializableget(String name)
Retrieve an event attribute.
Iterator<Entry<String,Object>>getEntrySetIterator()
Returns an Iterator over all the entries in the EventDAta.
DategetEventDateTime()
Retrieve the date and time the event occurred.
StringgetEventId()
Retrieve the event identifier.
Map<String,Object>getEventMap()
Retrieve all the attributes in the EventData as a Map.
StringgetEventType()
Retrieve the type of the event.
StringgetMessage()
Retrieve the message text associated with this event, if any.
intgetSize()
Returns the number of attributes in the EventData.
voidput(String name, Serializable obj)
Add arbitrary attributes about the event.
voidputAll(Map<String,Object> data)
Populate the event data from a Map.
voidsetEventDateTime(Date eventDateTime)
Set the date and time the event occurred in case it is not the same as when the event was logged.
voidsetEventId(String eventId)
Set the event identifier.
voidsetEventType(String eventType)
Set the type of event that occurred.
voidsetMessage(String message)
Set the message text associated with this event.
StringtoXML()
Serialize all the EventData items into an XML representation.
static StringtoXML(Map<String,Object> map)
Serialize all the EventData items into an XML representation.

Field Detail

EVENT_DATETIME

public static final String EVENT_DATETIME

EVENT_ID

public static final String EVENT_ID

EVENT_MESSAGE

public static final String EVENT_MESSAGE

EVENT_TYPE

public static final String EVENT_TYPE

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

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.

getEntrySetIterator

public Iterator<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.

getEventDateTime

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

Returns: The Date associated with the event.

getEventId

public String getEventId()
Retrieve the event identifier.

Returns: The event identifier

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.

getEventType

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

Returns: The event type.

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.

getSize

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

Returns: the number of attributes in the EventData.

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.

putAll

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

Parameters: data The Map to copy.

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.

setEventId

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

Parameters: eventId The event identifier.

setEventType

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

Parameters: eventType The type of the event.

setMessage

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

Parameters: message The message text.

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.

Returns: an XML String containing all the EventDAta items.

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