Class ObjectMessage

java.lang.Object
org.apache.logging.log4j.message.ObjectMessage
All Implemented Interfaces:
Serializable, Message, StringBuilderFormattable

public class ObjectMessage extends Object implements Message, StringBuilderFormattable
Handles messages that contain an Object.
See Also:
  • Constructor Details

    • ObjectMessage

      public ObjectMessage(Object obj)
      Creates the ObjectMessage.
      Parameters:
      obj - The Object to format.
  • Method Details

    • getFormattedMessage

      public String getFormattedMessage()
      Returns the formatted object message.
      Specified by:
      getFormattedMessage in interface Message
      Returns:
      the formatted object message.
    • formatTo

      public void formatTo(StringBuilder buffer)
      Description copied from interface: StringBuilderFormattable
      Writes a text representation of this object into the specified StringBuilder, ideally without allocating temporary objects.
      Specified by:
      formatTo in interface StringBuilderFormattable
      Parameters:
      buffer - the StringBuilder to write into
    • getFormat

      public String getFormat()
      Returns the object formatted using its toString method.
      Specified by:
      getFormat in interface Message
      Returns:
      the String representation of the object.
    • getParameter

      public Object getParameter()
      Returns the object parameter.
      Returns:
      The object.
      Since:
      2.7
    • getParameters

      public Object[] getParameters()
      Returns the object as if it were a parameter.
      Specified by:
      getParameters in interface Message
      Returns:
      The object.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getThrowable

      public Throwable getThrowable()
      Gets the message if it is a throwable.
      Specified by:
      getThrowable in interface Message
      Returns:
      the message if it is a throwable.