Class LocalizedMessages

java.lang.Object
com.adobe.epubcheck.messages.LocalizedMessages

public class LocalizedMessages extends Object
Manages storage, caching and retrieval of default localized messages.
  • Field Details

  • Constructor Details

    • LocalizedMessages

      public LocalizedMessages(Locale locale)
      Typical pattern for instantiation should use the static getInstance() methods to ensure that cached objects are used. If that behavior isn't desired, direct instantiation is also an option using this constructor.
      Parameters:
      locale - The locale used to localize the messages, or default.
  • Method Details

    • getInstance

      public static LocalizedMessages getInstance()
      Provides messages for the default locale.
      Returns:
      Localized messages.
    • getInstance

      public static LocalizedMessages getInstance(Locale locale)
      Provides messages for the given locale.
      Parameters:
      locale - The locale. If null or unsupported, will use the default locale instead.
      Returns:
      Localized messages.
    • getMessage

      public Message getMessage(MessageId id)
      Gets the message for the given id.
      Parameters:
      id -
      Returns:
      A Message object, using the localized string if necessary.
    • getStringFromBundle

      private String getStringFromBundle(String id)
    • getMessageAsString

      private String getMessageAsString(MessageId id)
    • getSuggestion

      public String getSuggestion(MessageId id)
      Returns the suggestion message for the given message ID. In other words, for a message ID of `XXX_NNN`, returns the bundle message named `XXX_NNN_SUG`.
      Parameters:
      id - a message ID
      Returns:
      the associated suggestion, or the empty string if there's none.
    • getSuggestion

      public String getSuggestion(MessageId id, String key)
      Returns the suggestion message for the given message ID and key. In other words, for a message ID of `XXX_NNN`, and a key `key`, returns the bundle message named `XXX_NNN_SUG.key`. If the suggestion key is not found, returns the bundle message named `XXX_NNN_SUG.default`. If this latter is not found, returns the bundle message nameed `XXX_NNN_SUG`.
      Parameters:
      id - a message ID
      key - the key of a specific suggestion string
      Returns:
      the associated suggestion string