Log4j 1.3alpha-1

org.apache.log4j.pattern
Class PatternConverter

java.lang.Object
  |
  +--org.apache.log4j.pattern.PatternConverter
Direct Known Subclasses:
DatePatternConverter, FileLocationPatternConverter, FullLocationPatternConverter, LevelPatternConverter, LineLocationPatternConverter, LineSeparatorPatternConverter, LiteralPatternConverter, MessagePatternConverter, MethodLocationPatternConverter, org.apache.log4j.pattern.NamedPatternConverter, NDCPatternConverter, PropertiesPatternConverter, RelativeTimePatternConverter, SequenceNumberPatternConverter, ThreadPatternConverter, ThrowableInformationPatternConverter

public abstract class PatternConverter
extends java.lang.Object

PatternConverter is an abtract class that provides the formatting functionality that derived classes need.

Conversion specifiers in a conversion patterns are parsed to individual PatternConverters. Each of which is responsible for converting a logging event in a converter specific manner.

Since:
0.8.2
Author:
James P. Cakalic, Ceki Gülcü, Chris Nokes

Field Summary
 PatternConverter next
           
 
Constructor Summary
protected PatternConverter()
           
protected PatternConverter(FormattingInfo fi)
           
 
Method Summary
static boolean chainHandlesThrowable(PatternConverter head)
          This method computes whether a chain of converters handles exceptions or not.
protected abstract  java.lang.StringBuffer convert(LoggingEvent event)
          Derived pattern converters must override this method in order to convert conversion specifiers in the correct way.
 void format(java.io.Writer output, LoggingEvent e)
          A template method for formatting in a converter specific way.
abstract  java.lang.String getName()
          This method returns the name of the conversion pattern.
 java.lang.String getOption()
           
abstract  java.lang.String getStyleClass(LoggingEvent e)
          This method returns the CSS style class that should be applied to the LoggingEvent passed as parameter, which can be null.
 boolean handlesThrowable()
          Normally pattern converters are now meant to handle Exceptions although few pattern converters might.
 void setFormattingInfo(FormattingInfo fi)
           
 void setOption(java.lang.String string)
           
 void spacePad(java.io.Writer output, int length)
          Fast space padding method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

next

public PatternConverter next
Constructor Detail

PatternConverter

protected PatternConverter()

PatternConverter

protected PatternConverter(FormattingInfo fi)
Method Detail

setFormattingInfo

public void setFormattingInfo(FormattingInfo fi)

convert

protected abstract java.lang.StringBuffer convert(LoggingEvent event)
Derived pattern converters must override this method in order to convert conversion specifiers in the correct way. IMPORTANT: Note that an implementing class may always return the same StringBuffer instance in order to avoid superflous object creation.


format

public void format(java.io.Writer output,
                   LoggingEvent e)
            throws java.io.IOException
A template method for formatting in a converter specific way.

java.io.IOException

spacePad

public void spacePad(java.io.Writer output,
                     int length)
              throws java.io.IOException
Fast space padding method.

java.io.IOException

getOption

public java.lang.String getOption()

setOption

public void setOption(java.lang.String string)

getName

public abstract java.lang.String getName()
This method returns the name of the conversion pattern. The name can be useful to certain Layouts such as HTMLLayout.

Returns:
the name of the conversion pattern

getStyleClass

public abstract java.lang.String getStyleClass(LoggingEvent e)
This method returns the CSS style class that should be applied to the LoggingEvent passed as parameter, which can be null. This information is currently used only by HTMLLayout.

Parameters:
e - null values are accepted
Returns:
the name of the conversion pattern

handlesThrowable

public boolean handlesThrowable()
Normally pattern converters are now meant to handle Exceptions although few pattern converters might. By examining the return values for this methd, the containing layout will determine whether it handles throwables or not.

Returns:
true if this PatternConverter handles throwables

chainHandlesThrowable

public static boolean chainHandlesThrowable(PatternConverter head)
This method computes whether a chain of converters handles exceptions or not.

Parameters:
head - The first element of the chain
Returns:
true if can handle the throwable contained in logging events

Log4j 1.3alpha-1

Copyright 2000-2003 Apache Software Foundation.