Class 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 Detail

      • FormattedMessage

        public FormattedMessage​(Locale locale,
                                String messagePattern,
                                Object arg)
        Constructs with a locale, a pattern and a single parameter.
        Parameters:
        locale - The locale
        messagePattern - The message pattern.
        arg - The parameter.
        Since:
        2.6
      • FormattedMessage

        public FormattedMessage​(Locale locale,
                                String messagePattern,
                                Object arg1,
                                Object arg2)
        Constructs with a locale, a pattern and two parameters.
        Parameters:
        locale - The locale
        messagePattern - The message pattern.
        arg1 - The first parameter.
        arg2 - The second parameter.
        Since:
        2.6
      • FormattedMessage

        public FormattedMessage​(Locale locale,
                                String messagePattern,
                                Object... arguments)
        Constructs with a locale, a pattern and a parameter array.
        Parameters:
        locale - The locale
        messagePattern - The message pattern.
        arguments - The parameter.
        Since:
        2.6
      • FormattedMessage

        public FormattedMessage​(Locale locale,
                                String messagePattern,
                                Object[] arguments,
                                Throwable throwable)
        Constructs with a locale, a pattern, a parameter array, and a throwable.
        Parameters:
        locale - The Locale
        messagePattern - The message pattern.
        arguments - The parameter.
        throwable - The throwable
        Since:
        2.6
      • FormattedMessage

        public FormattedMessage​(String messagePattern,
                                Object arg)
        Constructs with a pattern and a single parameter.
        Parameters:
        messagePattern - The message pattern.
        arg - The parameter.
      • FormattedMessage

        public FormattedMessage​(String messagePattern,
                                Object arg1,
                                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​(String messagePattern,
                                Object... arguments)
        Constructs with a pattern and a parameter array.
        Parameters:
        messagePattern - The message pattern.
        arguments - The parameter.
      • FormattedMessage

        public FormattedMessage​(String messagePattern,
                                Object[] arguments,
                                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

      • getFormat

        public String getFormat()
        Gets the message pattern.
        Specified by:
        getFormat in interface Message
        Returns:
        the message pattern.
      • getFormattedMessage

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

        public Object[] getParameters()
        Gets the message parameters.
        Specified by:
        getParameters in interface Message
        Returns:
        the message parameters.
      • 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object