com.sap.tc.logging

Class Formatter

java.lang.Object
  extended bycom.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.
 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(String completeMsgData)
          Message written with the specific formatter is read as plain string.
 void setFormatterName(String name)
          Sets a descriptive name 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 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

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.

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

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


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.



Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.