com.ibm.ras
Class RASEvent

java.lang.Object
  |
  +--com.ibm.ras.RASEvent
All Implemented Interfaces:
RASConstants, RASIEvent, java.io.Serializable
Direct Known Subclasses:
RASMessageEvent, RASTraceEvent

public class RASEvent
extends java.lang.Object
implements RASIEvent, RASConstants

RASEvent is the parent of all RASMessageEvent and RASTraceEvent objects. These classes are used within this RAS system to encapsulate the message and trace data created by an application. An application should not need to use them. They would only be used by a RAS implementation that wishes to extend the function of this RAS Toolkit.

RASEvent contains the following information:

See Also:
RASLogger, Serialized Form

Fields inherited from interface com.ibm.ras.RASConstants
KEY_CLASS_NAME, KEY_CLIENT, KEY_COMPONENT, KEY_DATE_FORMAT, KEY_DEFAULT_HANDLERS, KEY_DEFAULT_MESSAGE_HANDLERS, KEY_DEFAULT_TRACE_HANDLERS, KEY_DESCRIPTION, KEY_ENCODING, KEY_EXCEPTION, KEY_EXCEPTION_TRACE, KEY_FILE_NAME, KEY_FORMATTER_NAMES, KEY_GROUP, KEY_HANDLER_NAMES, KEY_HEX_DATA, KEY_IS_CIRCULAR, KEY_IS_LOGGING, KEY_IS_SYNC, KEY_LOGGER, KEY_LOGGING_CLASS, KEY_LOGGING_METHOD, KEY_MAX_FILE_SIZE, KEY_MAX_FILES, KEY_MAX_QUEUE_SIZE, KEY_MESSAGE_EVENT_CLASSES, KEY_MESSAGE_FILE, KEY_MESSAGE_MASK, KEY_NAME, KEY_ORGANIZATION, KEY_PRODUCT, KEY_RETRY_INTERVAL, KEY_SEPARATOR, KEY_SERVER, KEY_SOCKET_PORT, KEY_SOCKET_SERVER, KEY_SUPPRESSED_KEYS, KEY_THREAD_ID, KEY_TIME_FORMAT, KEY_TRACE_EVENT_CLASSES, KEY_TRACE_MASK, RAS_VERSION
 
Constructor Summary
RASEvent()
          Creates a RASEvent.
RASEvent(long type, java.lang.String text, java.lang.Object[] parms)
          Creates a RASEvent.
RASEvent(long type, java.lang.String text, java.lang.String[] parms)
          Deprecated. Use RASEvent instead.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Gets an attribute that is saved as part of a RAS event.
 java.lang.String[] getParameters()
          Gets the text parameters: Strings to be displayed with the message text.
 java.util.Hashtable getSupportedTypes()
          Gets the complete set of event types supported by this class.
 java.lang.String getText()
          Gets the event text.
 long getTimeStamp()
          Gets the time at which this event was created.
 long getType()
          Gets the type of event: "informational message," for example.
 boolean isMessageEvent()
          Determines if this object is a message event or a trace event.
 long maskLongValue(java.lang.String types)
          Converts a String representation of a message or trace mask to its long equivalent.
 java.lang.String maskToString(long types)
          Converts a long containing the logical OR of one or more event types to its String equivalent.
protected static java.lang.String[] objectsToStrings(java.lang.Object[] parms)
          Converts an array of Objects to an array of equivalent Strings.
 void setAttribute(java.lang.String name, java.lang.Object attrib)
          Sets an attribute, saving it as part of a RAS event.
 void setMessageEvent(boolean flag)
          Sets a flag that indicates whether this object is classified as a message event or a trace event.
 void setParameters(java.lang.String[] parms)
          Gets the text parameters: Strings to be displayed with the message text.
 void setText(java.lang.String text)
          Sets the event text.
 void setTimeStamp(long timeStamp)
          Sets the time at which this event was created.
 void setType(long type)
          Sets the type of event: "informational message," for example.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RASEvent

public RASEvent()
Creates a RASEvent. The time stamp is generated at this time.
Parameters:
source - The Object which created this event.

RASEvent

public RASEvent(long type,
                java.lang.String text,
                java.lang.Object[] parms)
Creates a RASEvent.
Parameters:
type - The message type.
text - The message text, or a message key if the message file is not null.
parms - An array of Objects to be displayed with the message.

RASEvent

public RASEvent(long type,
                java.lang.String text,
                java.lang.String[] parms)
Deprecated. Use RASEvent instead.

Creates a RASEvent.
Parameters:
type - The message type.
text - The message text, or a message key if the message file is not null.
parms - An array of Strings to be displayed with the message.
Method Detail

objectsToStrings

protected static java.lang.String[] objectsToStrings(java.lang.Object[] parms)
Converts an array of Objects to an array of equivalent Strings.
Parameters:
parms - An array of objects to be converted to strings.
Returns:
The equivalent array of strings.

getTimeStamp

public long getTimeStamp()
Gets the time at which this event was created.
Specified by:
getTimeStamp in interface RASIEvent
Parameters:
timeStamp - The event time stamp, as generated by System.currentTimeMillis.

setTimeStamp

public void setTimeStamp(long timeStamp)
Sets the time at which this event was created. This value is expected to be of the format returned by System.currentTimeMillis.
Specified by:
setTimeStamp in interface RASIEvent
Parameters:
timeStamp - The event time stamp.

getType

public long getType()
Gets the type of event: "informational message," for example. Specific types are defined by the classes which extend RASEvent. If a type is not defined, the default value of zero is returned.
Specified by:
getType in interface RASIEvent
Returns:
The event type.

setType

public void setType(long type)
Sets the type of event: "informational message," for example. Specific types are defined by the classes which extend RASEvent.
Specified by:
setType in interface RASIEvent
Parameters:
type - The event type.

getText

public java.lang.String getText()
Gets the event text.
Specified by:
getText in interface RASIEvent
Returns:
The event text.

setText

public void setText(java.lang.String text)
Sets the event text. If the text is null, the current text is not changed.
Specified by:
setText in interface RASIEvent
Parameters:
text - The event text.

getParameters

public java.lang.String[] getParameters()
Gets the text parameters: Strings to be displayed with the message text. If no parameters have been set, null is returned.
Specified by:
getParameters in interface RASIEvent
Returns:
The text parameters.

setParameters

public void setParameters(java.lang.String[] parms)
Gets the text parameters: Strings to be displayed with the message text.
Specified by:
setParameters in interface RASIEvent
Parameters:
parms - The text parameters.

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Gets an attribute that is saved as part of a RAS event.
Specified by:
getAttribute in interface RASIEvent
Parameters:
name - The name of the attribute.
Returns:
The attribute associated with the name or null if the named attribute was not found.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object attrib)
Sets an attribute, saving it as part of a RAS event. If the name or the attribute are null, nothing is saved.
Specified by:
setAttribute in interface RASIEvent
Parameters:
name - The name of the attribute.
attrib - The attribute associated with the name.

setMessageEvent

public void setMessageEvent(boolean flag)
Sets a flag that indicates whether this object is classified as a message event or a trace event.
Specified by:
setMessageEvent in interface RASIEvent
Parameters:
flag - A boolean set true if this object is a message event and false if it is a trace event.

isMessageEvent

public boolean isMessageEvent()
Determines if this object is a message event or a trace event.
Specified by:
isMessageEvent in interface RASIEvent
Returns:
true if this object is a message event and false if it is a trace event.

getSupportedTypes

public java.util.Hashtable getSupportedTypes()
Gets the complete set of event types supported by this class.

This method can be used by a graphical log manager to display the set of types and allow a user to select those to be monitored. Every extending class should override this method to add the types it supports to the Hashtable returned by its parent.

Specified by:
getSupportedTypes in interface RASIEvent
Returns:
A Hashtable containing the values of all of the event types. The names of the types are used as keys and are returned in the current locale. The type values, normally kept as ints, are returned as Integers because of the Hashtable requirement that all elements be Objects.

maskLongValue

public long maskLongValue(java.lang.String types)
Converts a String representation of a message or trace mask to its long equivalent. The string must have the following format:
 String types = "TYPE_INFO TYPE_WARN";
 
Unknown values in the String are ignored.
Specified by:
maskLongValue in interface RASIEvent
Parameters:
types - The blank-delimited String to be converted.
Returns:
The long equivalent of the String, formed by the logical OR of each element in the String.

maskToString

public java.lang.String maskToString(long types)
Converts a long containing the logical OR of one or more event types to its String equivalent. The string will have the following format:
 String types = "TYPE_INFO TYPE_WARN";
 
Every extending class should override this method to add the types it supports to the value returned by its parent.

Unknown values in the long are ignored.

Specified by:
maskToString in interface RASIEvent
Parameters:
types - The message or trace mask.
Returns:
The blank-delimited String equivalent of the mask.