Package org.apache.logging.log4j.message
Class ReusableObjectMessage
- java.lang.Object
-
- org.apache.logging.log4j.message.ReusableObjectMessage
-
- All Implemented Interfaces:
java.io.Serializable
,Message
,ReusableMessage
,StringBuilderFormattable
public class ReusableObjectMessage extends java.lang.Object implements ReusableMessage
Mutable Message wrapper around an Object message.- Since:
- 2.6
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ReusableObjectMessage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
formatTo(java.lang.StringBuilder buffer)
Writes a text representation of this object into the specifiedStringBuilder
, ideally without allocating temporary objects.java.lang.String
getFormat()
Returns the object formatted using its toString method.java.lang.String
getFormattedMessage()
Returns the formatted object message.java.lang.Object
getParameter()
Returns the object parameter.short
getParameterCount()
This message does not have any parameters so this method always returns zero.java.lang.Object[]
getParameters()
Returns the object as if it were a parameter.java.lang.Throwable
getThrowable()
Gets the message if it is a throwable.Message
memento()
Returns an immutable snapshot of the current internal state of this reusable message.void
set(java.lang.Object object)
java.lang.Object[]
swapParameters(java.lang.Object[] emptyReplacement)
This message does not have any parameters, so this method returns the specified array.java.lang.String
toString()
-
-
-
Method Detail
-
set
public void set(java.lang.Object object)
-
getFormattedMessage
public java.lang.String getFormattedMessage()
Returns the formatted object message.- Specified by:
getFormattedMessage
in interfaceMessage
- Returns:
- the formatted object message.
-
formatTo
public void formatTo(java.lang.StringBuilder buffer)
Description copied from interface:StringBuilderFormattable
Writes a text representation of this object into the specifiedStringBuilder
, ideally without allocating temporary objects.- Specified by:
formatTo
in interfaceStringBuilderFormattable
- Parameters:
buffer
- the StringBuilder to write into
-
getFormat
public java.lang.String getFormat()
Returns the object formatted using its toString method.
-
getParameter
public java.lang.Object getParameter()
Returns the object parameter.- Returns:
- The object.
- Since:
- 2.7
-
getParameters
public java.lang.Object[] getParameters()
Returns the object as if it were a parameter.- Specified by:
getParameters
in interfaceMessage
- Returns:
- The object.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getThrowable
public java.lang.Throwable getThrowable()
Gets the message if it is a throwable.- Specified by:
getThrowable
in interfaceMessage
- Returns:
- the message if it is a throwable.
-
swapParameters
public java.lang.Object[] swapParameters(java.lang.Object[] emptyReplacement)
This message does not have any parameters, so this method returns the specified array.- Specified by:
swapParameters
in interfaceReusableMessage
- Parameters:
emptyReplacement
- the parameter array to return- Returns:
- the specified array
- See Also:
ReusableMessage.getParameterCount()
-
getParameterCount
public short getParameterCount()
This message does not have any parameters so this method always returns zero.- Specified by:
getParameterCount
in interfaceReusableMessage
- Returns:
- 0 (zero)
-
memento
public Message memento()
Description copied from interface:ReusableMessage
Returns an immutable snapshot of the current internal state of this reusable message. The returned snapshot will not be affected by subsequent modifications of this reusable message.- Specified by:
memento
in interfaceReusableMessage
- Returns:
- an immutable snapshot of this message
-
-