public class PatternLayoutAdapter<E> extends Object
PatternLayoutBase
to allow writing the pattern into a supplied StringBuilder
instead of returning a String.
The adapter also throws an IllegalArgumentException
upon start when the configured pattern is not a
valid pattern layout instead of simply emitting an ERROR status.Constructor and Description |
---|
PatternLayoutAdapter(PatternLayoutBase<E> layout) |
Modifier and Type | Method and Description |
---|---|
String |
getConstantValue()
Get the constant value of the pattern or throw an
IllegalStateException if the pattern
is not constant. |
boolean |
isConstant()
Indicate whether the
PatternLayoutBase always generates the same constant value independent of
the event it is given. |
void |
setContext(Context context)
Set the
Context |
void |
setPattern(String pattern)
Set the layout pattern
|
void |
start()
Start the underlying PatternLayoutBase and throw an
IllegalArgumentException if the
configured pattern is not a valid PatternLayout. |
void |
writeTo(StringBuilder strBuilder,
E event)
Apply the PatternLayout to the event and write result into the supplied
StringBuilder . |
public PatternLayoutAdapter(PatternLayoutBase<E> layout)
public void setContext(Context context)
Context
context
- the contextpublic void setPattern(String pattern)
pattern
- the layout patternpublic void start() throws IllegalArgumentException
IllegalArgumentException
if the
configured pattern is not a valid PatternLayout.IllegalArgumentException
- thrown when the configured pattern is not a valid PatternLayoutpublic void writeTo(StringBuilder strBuilder, E event)
StringBuilder
.strBuilder
- the StringBuilder
to write the result of applying the PatternLayout on the eventevent
- the event to apply the pattern topublic boolean isConstant()
PatternLayoutBase
always generates the same constant value independent of
the event it is given.public String getConstantValue()
IllegalStateException
if the pattern
is not constant.isConstant()
Copyright © 2013–2021. All rights reserved.