org.apache.logging.log4j.message
Class FormattedMessage

java.lang.Object
  extended by org.apache.logging.log4j.message.FormattedMessage
All Implemented Interfaces:
Serializable, Message

public class FormattedMessage
extends Object
implements Message

Handles messages that contain a format String. Dynamically determines if the format conforms to MessageFormat or String.format and if not then uses ParameterizedMessage to format.

See Also:
Serialized Form

Constructor Summary
FormattedMessage(String messagePattern, Object arg)
          Constructor with a pattern and a single parameter.
FormattedMessage(String messagePattern, Object[] arguments)
           
FormattedMessage(String messagePattern, Object[] arguments, Throwable throwable)
           
FormattedMessage(String messagePattern, Object arg1, Object arg2)
          Constructor with a pattern and two parameters.
 
Method Summary
 boolean equals(Object o)
           
 String getFormat()
          Returns the message pattern.
 String getFormattedMessage()
          Returns the formatted message.
protected  Message getMessage(String msgPattern, Object[] args, Throwable throwable)
           
 Object[] getParameters()
          Returns the message parameters.
 Throwable getThrowable()
          Always returns null.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormattedMessage

public FormattedMessage(String messagePattern,
                        Object[] arguments,
                        Throwable throwable)

FormattedMessage

public FormattedMessage(String messagePattern,
                        Object[] arguments)

FormattedMessage

public FormattedMessage(String messagePattern,
                        Object arg)
Constructor with a pattern and a single parameter.

Parameters:
messagePattern - The message pattern.
arg - The parameter.

FormattedMessage

public FormattedMessage(String messagePattern,
                        Object arg1,
                        Object arg2)
Constructor with a pattern and two parameters.

Parameters:
messagePattern - The message pattern.
arg1 - The first parameter.
arg2 - The second parameter.
Method Detail

getFormattedMessage

public String getFormattedMessage()
Returns the formatted message.

Specified by:
getFormattedMessage in interface Message
Returns:
the formatted message.

getFormat

public String getFormat()
Returns the message pattern.

Specified by:
getFormat in interface Message
Returns:
the message pattern.

getParameters

public Object[] getParameters()
Returns the message parameters.

Specified by:
getParameters in interface Message
Returns:
the message parameters.

getMessage

protected Message getMessage(String msgPattern,
                             Object[] args,
                             Throwable throwable)

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()
Always returns null.

Specified by:
getThrowable in interface Message
Returns:
null


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