Package org.logevents.util.pattern
Class PatternConverterSpec
- java.lang.Object
-
- org.logevents.util.pattern.PatternConverterSpec
-
- Direct Known Subclasses:
PatternConverterSpecWithSubpattern
public class PatternConverterSpec extends Object
Used to parse a single conversion forPatternReader
. A conversion is on the format "%[<minlength>][.<maxlength>]<conversion word>[{<parameter>,<parameter>}]".- Author:
- Johannes Brodwall
-
-
Field Summary
Fields Modifier and Type Field Description protected Configuration
configuration
protected StringScanner
scanner
-
Constructor Summary
Constructors Constructor Description PatternConverterSpec(Configuration configuration, StringScanner scanner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Configuration
getConfiguration()
String
getConversionWord()
The function represented is represented by the conversion word.Optional<Integer>
getIntParameter(int i)
Optional<Integer>
getMaxLength()
If the resulting string is longer than abs(min)-length, it should be truncated.Optional<Integer>
getMinLength()
If the resulting string is shorter than abs(min)-length, it should be padded.Optional<String>
getParameter(int i)
List<String>
getParameters()
A list of parameters specified in curly brackets after the conversion word.BiFunction<Throwable,Optional<Integer>,String>
getThrowableFormatter()
void
readConversion()
void
readParameters()
String
toString()
-
-
-
Field Detail
-
configuration
protected final Configuration configuration
-
scanner
protected StringScanner scanner
-
-
Constructor Detail
-
PatternConverterSpec
public PatternConverterSpec(Configuration configuration, StringScanner scanner)
-
-
Method Detail
-
readConversion
public void readConversion()
-
getMinLength
public Optional<Integer> getMinLength()
If the resulting string is shorter than abs(min)-length, it should be padded. If minLength is negative, the string should be right-padded, otherwise, it should be left padded. If minLength isOptional.empty()
, output will not be padded.
-
getMaxLength
public Optional<Integer> getMaxLength()
If the resulting string is longer than abs(min)-length, it should be truncated. If maxLength is negative, the string should be truncated on the right, otherwise, it should be truncated on the left. If maxLength isOptional.empty()
, output will not be truncated.
-
getConversionWord
public String getConversionWord()
The function represented is represented by the conversion word. The full list of conversion words are given inPatternLogEventFormatter.getConversionWords()
-
getParameters
public List<String> getParameters()
A list of parameters specified in curly brackets after the conversion word. The parameters are separated by , and can optionally by quoted with single quotes ('). For example %date{ 'HH:mm:ss,SSS', Europe/Oslo} has the parameters "HH:mm:ss,SSS" and "Europe/Oslo"
-
readParameters
public void readParameters()
-
getThrowableFormatter
public BiFunction<Throwable,Optional<Integer>,String> getThrowableFormatter()
-
getConfiguration
public Configuration getConfiguration()
-
-