Class ExtrasPatternParser
java.lang.Object
org.apache.log4j.pattern.ExtrasPatternParser
Most of the work of the
EnhancedPatternLayout class
is delegated to the ExtrasPatternParser class.
It is this class that parses conversion patterns and creates
a chained list of PatternConverters.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classThe class wraps another Map but throws exceptions on any attempt to modify the map. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intIn converter name state.private static final intDot state.private static final charEscape character for format specifier.private static final MapStandard format specifiers for rolling file appenders.private static final intLiteral state.private static final intMax state.private static final intMin state.private static final MapStandard format specifiers for EnhancedPatternLayout. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.apache.log4j.pattern.PatternConvertercreateConverter(String converterId, StringBuffer currentLiteral, Map converterRegistry, Map rules, List options) Creates a new PatternConverter.private static intextractConverter(char lastChar, String pattern, int i, StringBuffer convBuf, StringBuffer currentLiteral) Extract the converter identifier found at position i.private static intextractOptions(String pattern, int i, List options) Extract options.private static intfinalizeConverter(char c, String pattern, int i, StringBuffer currentLiteral, ExtrasFormattingInfo formattingInfo, Map converterRegistry, Map rules, List patternConverters, List formattingInfos) Processes a format specifier sequence.static MapGet standard format specifiers for rolling file appender file specification.static MapGet standard format specifiers for EnhancedPatternLayout.static voidparse(String pattern, List patternConverters, List formattingInfos, Map converterRegistry, Map rules) Parse a format specifier.
-
Field Details
-
ESCAPE_CHAR
private static final char ESCAPE_CHAREscape character for format specifier.- See Also:
-
LITERAL_STATE
private static final int LITERAL_STATELiteral state.- See Also:
-
CONVERTER_STATE
private static final int CONVERTER_STATEIn converter name state.- See Also:
-
DOT_STATE
private static final int DOT_STATEDot state.- See Also:
-
MIN_STATE
private static final int MIN_STATEMin state.- See Also:
-
MAX_STATE
private static final int MAX_STATEMax state.- See Also:
-
PATTERN_LAYOUT_RULES
Standard format specifiers for EnhancedPatternLayout. -
FILENAME_PATTERN_RULES
Standard format specifiers for rolling file appenders.
-
-
Constructor Details
-
ExtrasPatternParser
private ExtrasPatternParser()Private constructor.
-
-
Method Details
-
getPatternLayoutRules
Get standard format specifiers for EnhancedPatternLayout.- Returns:
- read-only map of format converter classes keyed by format specifier strings.
-
getFileNamePatternRules
Get standard format specifiers for rolling file appender file specification.- Returns:
- read-only map of format converter classes keyed by format specifier strings.
-
extractConverter
private static int extractConverter(char lastChar, String pattern, int i, StringBuffer convBuf, StringBuffer currentLiteral) Extract the converter identifier found at position i. After this function returns, the variable i will point to the first char after the end of the converter identifier. If i points to a char which is not a character acceptable at the start of a unicode identifier, the value null is returned.- Parameters:
lastChar- last processed character.pattern- format string.i- current index into pattern format.convBuf- buffer to receive conversion specifier.currentLiteral- literal to be output in case format specifier in unrecognized.- Returns:
- position in pattern after converter.
-
extractOptions
-
parse
public static void parse(String pattern, List patternConverters, List formattingInfos, Map converterRegistry, Map rules) Parse a format specifier.- Parameters:
pattern- pattern to parse.patternConverters- list to receive pattern converters.formattingInfos- list to receive field specifiers corresponding to pattern converters.converterRegistry- map of user-supported pattern converters keyed by format specifier, may be null.rules- map of stock pattern converters keyed by format specifier.
-
createConverter
private static org.apache.log4j.pattern.PatternConverter createConverter(String converterId, StringBuffer currentLiteral, Map converterRegistry, Map rules, List options) Creates a new PatternConverter.- Parameters:
converterId- converterId.currentLiteral- literal to be used if converter is unrecognized or following converter if converterId contains extra characters.converterRegistry- map of user-supported pattern converters keyed by format specifier, may be null.rules- map of stock pattern converters keyed by format specifier.options- converter options.- Returns:
- converter or null.
-
finalizeConverter
private static int finalizeConverter(char c, String pattern, int i, StringBuffer currentLiteral, ExtrasFormattingInfo formattingInfo, Map converterRegistry, Map rules, List patternConverters, List formattingInfos) Processes a format specifier sequence.- Parameters:
c- initial character of format specifier.pattern- conversion patterni- current position in conversion pattern.currentLiteral- current literal.formattingInfo- current field specifier.converterRegistry- map of user-provided pattern converters keyed by format specifier, may be null.rules- map of stock pattern converters keyed by format specifier.patternConverters- list to receive parsed pattern converter.formattingInfos- list to receive corresponding field specifier.- Returns:
- position after format specifier sequence.
-