org.apache.logging.log4j.message

Class ReusableSimpleMessage

    • Constructor Detail

      • ReusableSimpleMessage

        public ReusableSimpleMessage()
    • Method Detail

      • set

        public void set(String message)
      • getFormattedMessage

        public String getFormattedMessage()
        Description copied from interface: Message
        Gets the Message formatted as a String. Each Message implementation determines the appropriate way to format the data encapsulated in the Message. Messages that provide more than one way of formatting the Message will implement MultiformatMessage.

        This method will not be called for Messages that implement the StringBuilderFormattable interface: instead, the formatTo(StringBuilder) method will be called so the Message can format its contents without creating intermediate String objects.

        Specified by:
        getFormattedMessage in interface Message
        Returns:
        The message String.
      • getFormat

        public String getFormat()
        Description copied from interface: Message
        Gets the format portion of the Message.
        Specified by:
        getFormat in interface Message
        Returns:
        The message format. Some implementations, such as ParameterizedMessage, will use this as the message "pattern". Other Messages may simply return an empty String. TODO Do all messages have a format? What syntax? Using a Formatter object could be cleaner. (RG) In SimpleMessage the format is identical to the formatted message. In ParameterizedMessage and StructuredDataMessage it is not. It is up to the Message implementer to determine what this method will return. A Formatter is inappropriate as this is very specific to the Message implementation so it isn't clear to me how having a Formatter separate from the Message would be cleaner.
      • getParameters

        public Object[] getParameters()
        Description copied from interface: Message
        Gets parameter values, if any.
        Specified by:
        getParameters in interface Message
        Returns:
        An array of parameter values or null.
      • getThrowable

        public Throwable getThrowable()
        Description copied from interface: Message
        Gets the throwable, if any.
        Specified by:
        getThrowable in interface Message
        Returns:
        the throwable or null.
      • 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
      • getParameterCount

        public short getParameterCount()
        This message does not have any parameters so this method always returns zero.
        Specified by:
        getParameterCount in interface ReusableMessage
        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 interface ReusableMessage
        Returns:
        an immutable snapshot of this message
      • charAt

        public char charAt(int index)
        Specified by:
        charAt in interface CharSequence

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