FileDocCategorySizeDatePackage
MyPatternParser.javaAPI DocApache log4j 1.2.152338Sat Aug 25 00:09:34 BST 2007org.apache.log4j

MyPatternParser

public class MyPatternParser extends PatternParser
Example showing how to extend PatternParser to recognize additional conversion characters. The examples shows that minimum and maximum width and alignment settings apply for "extension" conversion characters just as they do for PatternLayout recognized characters.

In this case MyPatternParser recognizes %# and outputs the value of an internal counter which is also incremented at each call. See source code for more details.

see
org.apache.log4j.examples.MyPatternLayout
see
org.apache.log4j.helpers.PatternParser
see
org.apache.log4j.PatternLayout
author
Anders Kristensen

Fields Summary
int
counter
Constructors Summary
public MyPatternParser(String pattern)


  
    
    super(pattern);
  
Methods Summary
public voidfinalizeConverter(char c)

    if (c == '#") {
      addConverter(new UserDirPatternConverter(formattingInfo));
      currentLiteral.setLength(0);
    } else {
      super.finalizeConverter(c);
    }