Interface Messages

All Superinterfaces:
Iterable<String>
All Known Implementing Classes:
ResBundleMessages, SubMessages

public interface Messages extends Iterable<String>
Interface for providing messages (and other strings) for a specific locale.

The locale may actually differ from the language of the messages depending on which resource bundles are available and the fallback mechanism of a resource bundle.

  • Method Details

    • getLocale

      Locale getLocale()
      Gets the intended locale of the messages which is also used for MessageFormat.
      Returns:
      The intended locale of the messages .
    • getActualLocale

      Locale getActualLocale()
      Gets the actual locale of this messages. This may be a fallback of the intended locale.
      Returns:
      The actual locale of the messages .
    • containsKey

      boolean containsKey(String key)
      Gets whether this Messages contains the designated key.
      Parameters:
      key - The key to check whether it exists in this Messages.
      Returns:
      Whether this Messages contains the designated key.
    • getString

      String getString(String key, Object... args)
      Gets the string for the designated key formatted using String.format(String, Object...). If the key is not known, the key itself will be returned instead of throwing a MissingResoucreException.
      Parameters:
      key - The key of the localised string.
      args - The arguments for String.format(String, Object...). If this is null or an empty array, formatting will be skipped.
      Returns:
      The formatted string message for the designated key.
    • getFormattedString

      String getFormattedString(String key, Object... args)
      Gets the string for the designated key formatted using Format.format(Object). If the key is not known, the key itself will be returned instead of throwing a MissingResoucreException.
      Parameters:
      key - The key of the localised string.
      args - The arguments for Format.format(Object).
      Returns:
      The formatted string message for the designated key.
    • subMessages

      default Messages subMessages(String prefix)
      Gets a new Messages for the designated prefix, that are all messages of this Message of which the keys start with the designated prefix.
      Parameters:
      prefix - The prefix used for all keys requested from this Messages instance. This need not end with ".".
      Returns:
      Messages of which all the keys have the designated prefix. This may be empty.