net.logAnalyzer.converters
Class LAConverter

java.lang.Object
  extended bynet.logAnalyzer.converters.LAConverter
Direct Known Subclasses:
DateConverter, DoubleConverter, IntegerConverter, StringConverter

public abstract class LAConverter
extends java.lang.Object

This class implements a Log4J pattern converter. It is used to parse or convert a log messageLabel part.

Version:
0.1
Author:
Karim REFEYTON

Constructor Summary
LAConverter(ConverterDefinition definition, java.lang.String literal)
          Constructs a new converter from a converter definition.
 
Method Summary
 java.lang.String getLabel()
          Returns the converter label.
 java.lang.String getLiteral()
          Returns the literal value identifying the literal in the Log4J pattern.
 LAConverter getNext()
          Returns the next converter.
 java.lang.String getOption()
          Returns the option string of the converter.
abstract  java.lang.Class getValueClass()
          Returns the class of the values affected to the column (for example java.lang.String or java.lang.Double).
 boolean isLiteral()
          Returns true if the converter is a literal.
 boolean isMessage()
          Returns true if the converter is a messageLabel converter.
abstract  java.lang.Object parse(java.lang.String value)
          Parse a string value to the value class as returned by getValueClass().
 java.lang.Object parse(java.lang.StringBuffer message, LALogHandler handler)
          Parses the message string to extract a value.
 void setNext(LAConverter next)
          Sets the next converter.
 void setOption(java.lang.String option)
          Sets the option string of the converter.
 java.lang.String toString()
          Returns the converter label.
abstract  java.lang.String toString(java.lang.Object value)
          Returns a string representation of the value calling toString().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LAConverter

public LAConverter(ConverterDefinition definition,
                   java.lang.String literal)
Constructs a new converter from a converter definition.

Parameters:
definition - Definition of the converter.
literal - Literal value identifying the converter.
Method Detail

getLabel

public java.lang.String getLabel()
Returns the converter label.

Returns:
LAConverter label.

isLiteral

public boolean isLiteral()
Returns true if the converter is a literal.

Returns:
true if the converter is a literal.

getLiteral

public java.lang.String getLiteral()
Returns the literal value identifying the literal in the Log4J pattern.

Returns:
Literal value.

isMessage

public boolean isMessage()
Returns true if the converter is a messageLabel converter.

A messageLabel is a special field which could be extended during parsing process.

For example, if you log a Java exception, the exception may be written on more than one line, so the parsing process has to concat several lines to get the complete messageLabel.

Returns:
true if the converter is used to parse a messageLabel; false otherwise.

getOption

public java.lang.String getOption()
Returns the option string of the converter.

Returns:
Option string.

setOption

public void setOption(java.lang.String option)
Sets the option string of the converter. LAConverter may parse this string.

Parameters:
option - LAConverter option

getNext

public LAConverter getNext()
Returns the next converter.

Returns:
Next converter or null.

setNext

public void setNext(LAConverter next)
Sets the next converter. Warning : no control is made on loops !

Parameters:
next - Next converter.

getValueClass

public abstract java.lang.Class getValueClass()
Returns the class of the values affected to the column (for example java.lang.String or java.lang.Double).

Returns:
Value class.

parse

public java.lang.Object parse(java.lang.StringBuffer message,
                              LALogHandler handler)
                       throws ParsingException
Parses the message string to extract a value. Message is truncated by the previous converters.

Parameters:
message - String to parse.
handler - Log handler parsing.
Returns:
Parsed value
Throws:
ParsingException - If can't parse messageLabel.

parse

public abstract java.lang.Object parse(java.lang.String value)
                                throws ParsingException
Parse a string value to the value class as returned by getValueClass().

Parameters:
value - String value to parse.
Returns:
Parsed value.
Throws:
ParsingException - If value can't be parsed.

toString

public abstract java.lang.String toString(java.lang.Object value)
Returns a string representation of the value calling toString().

Parameters:
value - Value to convert as String.
Returns:
String representation of the value.

toString

public java.lang.String toString()
Returns the converter label.

Returns:
LAConverter label.


Copyright © 2006 null. All Rights Reserved.