org.apache.logging.log4j.message

Class ReusableObjectMessage

    • Constructor Detail

      • ReusableObjectMessage

        public ReusableObjectMessage()
    • Method Detail

      • set

        public void set(Object object)
      • 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.
      • 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.
      • getParameterCount

        public short getParameterCount()
        This message has exactly one parameter (the object), so always returns one.
        Specified by:
        getParameterCount in interface ReusableMessage
        Returns:
        1
      • forEachParameter

        public <S> void forEachParameter(ParameterConsumer<S> action,
                                         S state)
        Description copied from interface: ParameterVisitable
        Performs the given action for each parameter until all values have been processed or the action throws an exception.

        The 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.

        Specified by:
        forEachParameter in interface ParameterVisitable
        Type Parameters:
        S - type of the third parameter
        Parameters:
        action - The action to be performed for each key-value pair in this collection
        state - the object to be passed as the third parameter to each invocation on the specified ParameterConsumer.
      • 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 interface ReusableMessage
        Returns:
        an immutable snapshot of this message
      • clear

        public void clear()
        Resets the object to a clean state.

Copyright © 1999-2023 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.