Package org.apache.logging.log4j.message
Class FormattedMessage
- java.lang.Object
-
- org.apache.logging.log4j.message.FormattedMessage
-
- All Implemented Interfaces:
java.io.Serializable
,Message
public class FormattedMessage extends java.lang.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
Constructors Constructor Description FormattedMessage(java.lang.String messagePattern, java.lang.Object arg)
Constructs with a pattern and a single parameter.FormattedMessage(java.lang.String messagePattern, java.lang.Object... arguments)
Constructs with a pattern and a parameter array.FormattedMessage(java.lang.String messagePattern, java.lang.Object[] arguments, java.lang.Throwable throwable)
Constructs with a pattern, a parameter array, and a throwable.FormattedMessage(java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
Constructs with a pattern and two parameters.FormattedMessage(java.util.Locale locale, java.lang.String messagePattern, java.lang.Object arg)
Constructs with a locale, a pattern and a single parameter.FormattedMessage(java.util.Locale locale, java.lang.String messagePattern, java.lang.Object... arguments)
Constructs with a locale, a pattern and a parameter array.FormattedMessage(java.util.Locale locale, java.lang.String messagePattern, java.lang.Object[] arguments, java.lang.Throwable throwable)
Constructs with a locale, a pattern, a parameter array, and a throwable.FormattedMessage(java.util.Locale locale, java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
Constructs with a locale, a pattern and two parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
java.lang.String
getFormat()
Gets the message pattern.java.lang.String
getFormattedMessage()
Gets the formatted message.java.lang.Object[]
getParameters()
Gets the message parameters.java.lang.Throwable
getThrowable()
Gets the throwable, if any.int
hashCode()
java.lang.String
toString()
-
-
-
Constructor Detail
-
FormattedMessage
public FormattedMessage(java.util.Locale locale, java.lang.String messagePattern, java.lang.Object arg)
Constructs with a locale, a pattern and a single parameter.- Parameters:
locale
- The localemessagePattern
- The message pattern.arg
- The parameter.- Since:
- 2.6
-
FormattedMessage
public FormattedMessage(java.util.Locale locale, java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
Constructs with a locale, a pattern and two parameters.- Parameters:
locale
- The localemessagePattern
- The message pattern.arg1
- The first parameter.arg2
- The second parameter.- Since:
- 2.6
-
FormattedMessage
public FormattedMessage(java.util.Locale locale, java.lang.String messagePattern, java.lang.Object... arguments)
Constructs with a locale, a pattern and a parameter array.- Parameters:
locale
- The localemessagePattern
- The message pattern.arguments
- The parameter.- Since:
- 2.6
-
FormattedMessage
public FormattedMessage(java.util.Locale locale, java.lang.String messagePattern, java.lang.Object[] arguments, java.lang.Throwable throwable)
Constructs with a locale, a pattern, a parameter array, and a throwable.- Parameters:
locale
- The LocalemessagePattern
- The message pattern.arguments
- The parameter.throwable
- The throwable- Since:
- 2.6
-
FormattedMessage
public FormattedMessage(java.lang.String messagePattern, java.lang.Object arg)
Constructs with a pattern and a single parameter.- Parameters:
messagePattern
- The message pattern.arg
- The parameter.
-
FormattedMessage
public FormattedMessage(java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
Constructs with a pattern and two parameters.- Parameters:
messagePattern
- The message pattern.arg1
- The first parameter.arg2
- The second parameter.
-
FormattedMessage
public FormattedMessage(java.lang.String messagePattern, java.lang.Object... arguments)
Constructs with a pattern and a parameter array.- Parameters:
messagePattern
- The message pattern.arguments
- The parameter.
-
FormattedMessage
public FormattedMessage(java.lang.String messagePattern, java.lang.Object[] arguments, java.lang.Throwable throwable)
Constructs with a pattern, a parameter array, and a throwable.- Parameters:
messagePattern
- The message pattern.arguments
- The parameter.throwable
- The throwable
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
getFormat
public java.lang.String getFormat()
Gets the message pattern.
-
getFormattedMessage
public java.lang.String getFormattedMessage()
Gets the formatted message.- Specified by:
getFormattedMessage
in interfaceMessage
- Returns:
- the formatted message.
-
getParameters
public java.lang.Object[] getParameters()
Gets the message parameters.- Specified by:
getParameters
in interfaceMessage
- Returns:
- the message parameters.
-
getThrowable
public java.lang.Throwable getThrowable()
Description copied from interface:Message
Gets the throwable, if any.- Specified by:
getThrowable
in interfaceMessage
- Returns:
- the throwable or null.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-