public class ReusableParameterizedMessage extends Object implements ReusableMessage, ParameterVisitable
ParameterizedMessage,
Serialized Form| Constructor and Description |
|---|
ReusableParameterizedMessage()
Creates a reusable message.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Resets the object to a clean state.
|
<S> void |
forEachParameter(ParameterConsumer<S> action,
S state)
Performs the given action for each parameter until all values
have been processed or the action throws an exception.
|
void |
formatTo(StringBuilder builder)
Writes a text representation of this object into the specified
StringBuilder, ideally without allocating
temporary objects. |
String |
getFormat()
Returns the message pattern.
|
String |
getFormattedMessage()
Returns the formatted message.
|
short |
getParameterCount()
Returns the number of parameters that was used to initialize this reusable message for the current content.
|
Object[] |
getParameters()
Returns the message parameters.
|
Throwable |
getThrowable()
Returns the Throwable that was given as the last argument, if any.
|
Message |
memento()
Returns an immutable snapshot of the current internal state of this reusable message.
|
Object[] |
swapParameters(Object[] emptyReplacement)
Returns the parameter array that was used to initialize this reusable message and replaces it with the specified
array.
|
String |
toString() |
public ReusableParameterizedMessage()
public Object[] swapParameters(Object[] emptyReplacement)
ReusableMessageReusableMessages that have no parameters return the specified array.
This method is used by asynchronous loggers to pass the parameter array to a background thread without
allocating new objects.
The actual number of parameters in the returned array can be determined with ReusableMessage.getParameterCount().
swapParameters in interface ReusableMessageemptyReplacement - the parameter array that can be used for subsequent uses of this reusable message.
This replacement array must have at least 10 elements (the number of varargs supported by the Logger
API).ReusableMessage.getParameterCount()public short getParameterCount()
ReusableMessage
The parameter array returned by ReusableMessage.swapParameters(Object[]) may be larger than the actual number of
parameters. Callers should use this method to determine how many elements the array contains.
getParameterCount in interface ReusableMessagepublic <S> void forEachParameter(ParameterConsumer<S> action, S state)
ParameterVisitableThe second parameter lets callers pass in a stateful object to be modified with the key-value pairs, so the TriConsumer implementation itself can be stateless and potentially reusable.
forEachParameter in interface ParameterVisitableS - type of the third parameteraction - The action to be performed for each key-value pair in this collectionstate - the object to be passed as the third parameter to each invocation on the
specified ParameterConsumer.public Message memento()
ReusableMessagememento in interface ReusableMessagepublic Object[] getParameters()
getParameters in interface Messagepublic Throwable getThrowable()
getThrowable in interface Messagepublic String getFormattedMessage()
getFormattedMessage in interface Messagepublic void formatTo(StringBuilder builder)
StringBuilderFormattableStringBuilder, ideally without allocating
temporary objects.formatTo in interface StringBuilderFormattablebuilder - the StringBuilder to write intopublic void clear()
Copyright © 1999-1969 The Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.