org.x4juli.formatter.pattern
Class NameAbbreviator

java.lang.Object
  extended byorg.x4juli.formatter.pattern.NameAbbreviator
Direct Known Subclasses:
NameAbbreviator.MaxElementAbbreviator, NameAbbreviator.NOPAbbreviator, NameAbbreviator.PatternAbbreviator

public abstract class NameAbbreviator
extends java.lang.Object

NameAbbreviator generates abbreviated logger and class names.

Logging API as a whole was originally done for Apache log4j. Juli is a port of main parts of that to complete the Java Logging APIs. All credits for initial idea, design, implementation, documentation belong to the log4j crew. This file was originally published by Curt Arnold. Please use exclusively the appropriate mailing lists for questions, remarks and contribution.

Since:
0.5
Author:
Boris Unckel

Nested Class Summary
private static class NameAbbreviator.MaxElementAbbreviator
          Abbreviator that drops starting path elements.
private static class NameAbbreviator.NOPAbbreviator
          Abbreviator that simply appends full name to buffer.
private static class NameAbbreviator.PatternAbbreviator
          Pattern abbreviator.
private static class NameAbbreviator.PatternAbbreviatorFragment
          Fragment of an pattern abbreviator.
 
Field Summary
private static NameAbbreviator DEFAULT
          Default (no abbreviation) abbreviator.
 
Constructor Summary
NameAbbreviator()
           
 
Method Summary
abstract  void abbreviate(int nameStart, java.lang.StringBuffer buf)
          Abbreviates a name in a StringBuffer.
static NameAbbreviator getAbbreviator(java.lang.String pattern)
          Gets an abbreviator.
static NameAbbreviator getDefaultAbbreviator()
          Gets default abbreviator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

private static final NameAbbreviator DEFAULT
Default (no abbreviation) abbreviator.

Constructor Detail

NameAbbreviator

public NameAbbreviator()
Method Detail

getAbbreviator

public static NameAbbreviator getAbbreviator(java.lang.String pattern)
Gets an abbreviator. For example, "%logger{2}" will output only 2 elements of the logger name, "%logger{1.}" will output only the first character of the non-final elements in the name, "%logger(1~.2~} will output the first character of the first element, two characters of the second and subsequent elements and will use a tilde to indicate abbreviated characters.

Parameters:
pattern - abbreviation pattern.
Returns:
abbreviator, will not be null.
Since:
0.5

getDefaultAbbreviator

public static NameAbbreviator getDefaultAbbreviator()
Gets default abbreviator.

Returns:
default abbreviator.
Since:
0.5

abbreviate

public abstract void abbreviate(int nameStart,
                                java.lang.StringBuffer buf)
Abbreviates a name in a StringBuffer.

Parameters:
nameStart - starting position of name in buf.
buf - buffer, may not be null.
Since:
0.5


${license_html}