com.ibm.ras
Class RASFormatter

java.lang.Object
  |
  +--com.ibm.ras.RASObject
        |
        +--com.ibm.ras.RASFormatter
Direct Known Subclasses:
RASMessageFormatter, RASTraceFormatter

public abstract class RASFormatter
extends RASObject
implements RASIFormatter

RASFormatter is the parent of all classes which format RAS events for display. RAS formatters are used by those RAS handlers which generate human-readable RAS events.

This class provides functions to format the date and time at which a RAS event was created. If not specified, the default SimpleDateFormat pattern used to format the date is "yyyy.MM.dd" and the pattern used for the time is "HH:mm:ss.SSS". These defaults can be changed by the setDateFormat and setTimeFormat methods.

Programming Note: classes which extend RASFormatter should, in their constructors, call the addEventClass method to register the RASIEvent classes which the formatter supports.

See Also:
RASMessageFormatter, RASTraceFormatter, RASHandler

Constructor Summary
RASFormatter()
          Creates a RASFormatter.
 
Method Summary
 void addEventClass(java.lang.String name)
          Adds the name of a RASIEvent class which this formatter can process.
abstract  java.lang.String format(RASIEvent event)
          Formats the RAS event.
 java.lang.String getDate(long timeStamp)
          Gets the date on which this event was created.
 java.text.SimpleDateFormat getDateFormat()
          Gets the SimpleDateFormat object used to format the date at which the event was created.
 java.util.Enumeration getEventClasses()
          Gets the set of RASIEvent classes which this formatter can process.
 java.lang.String getSeparator()
          Gets the String used to separate fields in the formatted output.
 java.lang.String getTime(long timeStamp)
          Gets the time at which this event was created.
 java.text.SimpleDateFormat getTimeFormat()
          Gets the SimpleDateFormat object used to format the time at which the event was created.
 void removeEventClass(java.lang.String name)
          Removes the name of a RASIEvent class from the list of classes which this formatter can process.
 void setDateFormat(java.text.SimpleDateFormat format)
          Sets the SimpleDateFormat object used to format the date at which the event was created.
 void setSeparator(java.lang.String sep)
          Sets the String used to separate fields in the formatted output.
 void setTimeFormat(java.text.SimpleDateFormat format)
          Sets the SimpleDateFormat object used to format the time at which the event was created.
 
Methods inherited from class com.ibm.ras.RASObject
getConfig, getDescription, getName, setConfig, setDescription, setName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RASFormatter

public RASFormatter()
Creates a RASFormatter.
Method Detail

getSeparator

public java.lang.String getSeparator()
Gets the String used to separate fields in the formatted output.
Returns:
The separator String, whose default value is " ".

setSeparator

public void setSeparator(java.lang.String sep)
Sets the String used to separate fields in the formatted output.
Parameters:
sep - The separator String. If the separator is null, the current separator is not changed.

getDateFormat

public java.text.SimpleDateFormat getDateFormat()
Gets the SimpleDateFormat object used to format the date at which the event was created.
Returns:
The date format.

setDateFormat

public void setDateFormat(java.text.SimpleDateFormat format)
Sets the SimpleDateFormat object used to format the date at which the event was created.
Parameters:
format - The date format. If the format is null, the current format is not changed.

getTimeFormat

public java.text.SimpleDateFormat getTimeFormat()
Gets the SimpleDateFormat object used to format the time at which the event was created.
Returns:
The time format.

setTimeFormat

public void setTimeFormat(java.text.SimpleDateFormat format)
Sets the SimpleDateFormat object used to format the time at which the event was created.
Parameters:
format - The time format. If the format is null, the current format is not changed.

getDate

public java.lang.String getDate(long timeStamp)
Gets the date on which this event was created.
Parameters:
timeStamp - The timestamp at which the event was created, as formed by System.currentTimeMillis.
Returns:
The event date, formatted for display.

getTime

public java.lang.String getTime(long timeStamp)
Gets the time at which this event was created.
Parameters:
timeStamp - The timestamp at which the event was created, as formed by System.currentTimeMillis.
Returns:
The event time, formatted for display.

addEventClass

public void addEventClass(java.lang.String name)
Adds the name of a RASIEvent class which this formatter can process. If the event class is null or is already registered, this method does nothing.
Specified by:
addEventClass in interface RASIFormatter
Parameters:
name - The event class name.

removeEventClass

public void removeEventClass(java.lang.String name)
Removes the name of a RASIEvent class from the list of classes which this formatter can process. If the event class is null or is not registered, this method does nothing.
Specified by:
removeEventClass in interface RASIFormatter
Parameters:
name - The event class name.

getEventClasses

public java.util.Enumeration getEventClasses()
Gets the set of RASIEvent classes which this formatter can process.
Specified by:
getEventClasses in interface RASIFormatter
Returns:
An Enumeration of RAS event class names. If no event classes are registered, the Enumeration is empty.

format

public abstract java.lang.String format(RASIEvent event)
Formats the RAS event.
Specified by:
format in interface RASIFormatter
Parameters:
event - The event to format.
Returns:
The formatted event.