Class Message

java.lang.Object
com.atlassian.confluence.util.i18n.Message

public final class Message extends Object
A user interface message consisting of a message key with optional arguments.

Typically, messages will be presented to the user by looking up their value in a properties file (or "bundle"), and applying MessageFormat to the value with any optional arguments. However, this class does not stipulate how the values held by this object might be used.

This class is immutable and thread-safe.

  • Method Details

    • getInstance

      public static Message getInstance(String key)
      Constructs and returns an instance of a message with the given key and no arguments.
      Parameters:
      key - the i18n message key
      Returns:
      a new immutable Message instance
    • getInstance

      public static Message getInstance(String key, Object... arguments)
      Constructs and returns an instance of a message with the given key and arguments.
      Parameters:
      key - the i18n message key
      arguments - the arguments which will be interpolated in the message value, like with MessageFormat
      Returns:
      a new immutable Message instance
    • getInstance

      public static Message getInstance(String key, List arguments)
      Constructs and returns an instance of a message with the given key and arguments.
      Parameters:
      key - the i18n message key
      arguments - the arguments which will be interpolated in the message value, like with MessageFormat
      Returns:
      a new immutable Message instance
    • getKey

      public String getKey()
      Returns the message key, used for looking up the message in a localisation bundle.
    • getArguments

      public Object[] getArguments()
      Returns the arguments to the message. These arguments might be interpolated in the message using MessageFormat, for instance.

      Returns null if the message has no arguments.

    • hasArguments

      public boolean hasArguments()
      Returns true if the message has arguments defined, otherwise false.
    • toString

      public String toString()
      Overrides:
      toString in class Object