com.sap.tc.logging

Class Formatter

java.lang.Object
  extended by com.sap.tc.logging.Formatter
Direct Known Subclasses:
ListFormatter, TraceFormatter, XMLFormatter

public abstract class Formatter
extends Object

Formats log records on behalf of logs the formatter is registered with.

See Also:
Log, LogController

Field Summary
protected static String EOL
           
 
Constructor Summary
protected Formatter()
           
protected Formatter(FormatterType aType)
           
 
Method Summary
 boolean equals(Object obj)
          Compare to Formatter clasess.
abstract  String format(LogRecord rec)
          Formats a log record which is then ready to be written to a log.
 String getFooter(Log log)
          Returns the footer for a set of formatted records.
 String getFormatterName()
          Gets the descriptive name for this formatter.
 FormatterType getFormatterType()
          Returns the type of formatter instance.
 String getHeader(Log log)
          Returns the header for a set of formatted records.
protected  com.sap.tc.logging.messagedepot.MessageAccessor getMessageAccessor()
          Gets a MessageAccessor for this formatter.
 com.sap.tc.logging.interfaces.IMessageBuilder getMessageBuilder()
          Returns the MsgByte object.
 boolean isCompleteMessage(int messageSize, byte[] message, int delimiterSize, int[] delimiter)
          Deprecated. Not Supported any more.
 boolean isCompleteMessage(String msg)
          Determine if the message string reaches the valid end(delimiter) of a complete message record, according to the format defined by the formatter
 boolean isParsable()
          Return true if this formatter supports message parsing formatted with this formatter.
 boolean isStartMessage(String msg)
          Determine if the message string starts with the valid start(delimiter) of a message record, according to the format defined by the formatter
 boolean isStartMsg(int messageSize, byte[] message)
          Deprecated. Not Supported any more.
 LogRecord parseMsg(byte[] msgChunk)
           
 LogRecord parseMsg(com.sap.tc.logging.interfaces.IMessageBuilder message)
           
 LogRecord parseMsg(String completeMsgData)
          Message written with the specific formatter is read as plain string.
 void setFormatterName(String name)
          Sets a descriptive name for this formatter.
 void setMessageAccessor(com.sap.tc.logging.messagedepot.MessageAccessor accessor)
          Sets a MessageAccessor for this formatter.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOL

protected static final String EOL
Constructor Detail

Formatter

protected Formatter()

Formatter

protected Formatter(FormatterType aType)
Method Detail

format

public abstract String format(LogRecord rec)
Formats a log record which is then ready to be written to a log.

Parameters:
rec - Log record to be formatted
Returns:
Formatted log record

getMessageBuilder

public com.sap.tc.logging.interfaces.IMessageBuilder getMessageBuilder()
Returns the MsgByte object.

Returns:
MsgByte

getHeader

public String getHeader(Log log)
Returns the header for a set of formatted records.

Parameters:
log - Target log.
Returns:
Header

getFooter

public String getFooter(Log log)
Returns the footer for a set of formatted records.

Parameters:
log - Target log
Returns:
Footer

setMessageAccessor

public void setMessageAccessor(com.sap.tc.logging.messagedepot.MessageAccessor accessor)
Sets a MessageAccessor for this formatter. MessageAccessor is used for message localization.


getFormatterName

public String getFormatterName()
Gets the descriptive name for this formatter. Can be null.


setFormatterName

public void setFormatterName(String name)
Sets a descriptive name for this formatter. An optional courtesy feature for user to easily refer to a formatter. Highly recommended if logviewer tool will be used to browse the output messages. If no name is specified, nothing will be set and the value is null.


getFormatterType

public final FormatterType getFormatterType()
Returns the type of formatter instance.
If formatter is the predefined classes provided by logging, an explicit formatter type will be returned. See FormatterType for the predefined formatter types used in Logging.
If the formatter is the customized class provided by the users, the full classname will be included with the format type, use getString() to retrieve it.

Returns:
A formatter type

isParsable

public boolean isParsable()
Return true if this formatter supports message parsing formatted with this formatter. Otherwise, return false. See method parseMsg(String).


parseMsg

public LogRecord parseMsg(String completeMsgData)
                   throws ParseException

Message written with the specific formatter is read as plain string. This method parses the content and massages the data into appropriate fields, into a LogRecord structure.

NOTE: UPDATE this method when newer version of format is defined by the formatter.

Parameters:
A - complete message body and its admin data that can span across multiple lines
Returns:
The complete message with its admin data has been broken down and packed in LogRecord. Return Null if formatter does not support parsing.
Throws:
ParseException

parseMsg

public LogRecord parseMsg(byte[] msgChunk)
                   throws ParseException
Throws:
ParseException

parseMsg

public LogRecord parseMsg(com.sap.tc.logging.interfaces.IMessageBuilder message)
                   throws ParseException
Throws:
ParseException

isStartMessage

public boolean isStartMessage(String msg)
Determine if the message string starts with the valid start(delimiter) of a message record, according to the format defined by the formatter


isCompleteMessage

public boolean isCompleteMessage(String msg)
Determine if the message string reaches the valid end(delimiter) of a complete message record, according to the format defined by the formatter


equals

public boolean equals(Object obj)
Compare to Formatter clasess. Return true if: Formatter.getFormatterName() is equal And Formatter.getFormatterType().toString() is equal

Overrides:
equals in class Object

getMessageAccessor

protected com.sap.tc.logging.messagedepot.MessageAccessor getMessageAccessor()
Gets a MessageAccessor for this formatter. MessageAccessor is used for message localization.


isStartMsg

public boolean isStartMsg(int messageSize,
                          byte[] message)
Deprecated. Not Supported any more.


isCompleteMessage

public boolean isCompleteMessage(int messageSize,
                                 byte[] message,
                                 int delimiterSize,
                                 int[] delimiter)
Deprecated. Not Supported any more.

Access Rights

This class can be accessed from:


SC DC
[sap.com] FRAMEWORK [sap.com] tc/ddic/ddicruntime
[sap.com] ENGINEAPI [sap.com] tc/logging
[sap.com] ENGFACADE [sap.com] tc/bl/logging/api
[sap.com] CORE-TOOLS [sap.com] com.sap.engine.client.lib
[sap.com] BRMS-FACADE [sap.com] tc/brms/facade


Copyright 2010 SAP AG Complete Copyright Notice