Class RiskscapeMessageSource

java.lang.Object
nz.org.riskscape.engine.i18n.RiskscapeMessageSource
All Implemented Interfaces:
nz.org.riskscape.engine.i18n.MessageSource

public class RiskscapeMessageSource extends Object implements nz.org.riskscape.engine.i18n.MessageSource

MessageSource implementation that will resolve messages: - from many ResourceBundle baseNames - will merge property files with the same base name across a classpath using MergedPropertiesResourceBundle - will fallback through locales for values using built-in ResourceBundle parenting logic

For a given message key bundle base names are searched in reverse. E.g the last base name added is searched first.

  • Field Details

    • MESSAGE_FORMAT_DETECTOR

      @Deprecated public static final Pattern MESSAGE_FORMAT_DETECTOR
      Deprecated.
      detecting if the message is a format is only necessary for backwards compatibility with Problems which is a MessageKey but default messages for problems may contain { or }. This handling should be removed.

      Pattern used to detect if a message contains and MessageFormat format specifiers.

      If no format specifiers are found then the message can be returned without performing any unnecessary formatting.

  • Constructor Details

  • Method Details

    • getBundle

      public static ResourceBundle getBundle(String baseName, Locale locale, ClassLoader classLoader)

      Gets a resource bundle using riskscape's customized ResourceBundle.Control rules.

      See Also:
    • getMessage

      public String getMessage(nz.org.riskscape.engine.i18n.MessageKey resolvable)
      Specified by:
      getMessage in interface nz.org.riskscape.engine.i18n.MessageSource
    • getMessage

      public String getMessage(nz.org.riskscape.engine.i18n.MessageKey resolvable, Locale locale)
      Specified by:
      getMessage in interface nz.org.riskscape.engine.i18n.MessageSource
    • getMessage

      public String getMessage(String code, Object... args)
      Specified by:
      getMessage in interface nz.org.riskscape.engine.i18n.MessageSource
    • getMessage

      public String getMessage(String code, Object[] args, Locale locale)
      Specified by:
      getMessage in interface nz.org.riskscape.engine.i18n.MessageSource
    • getMessage

      public String getMessage(String code, Object[] args, String defaultMessage, Locale locale)
      Specified by:
      getMessage in interface nz.org.riskscape.engine.i18n.MessageSource
    • getBundle

      public ResourceBundle getBundle(Locale l)
    • getMessageFactory

      public <T extends nz.org.riskscape.engine.i18n.MessageFactory> T getMessageFactory(Class<T> factory, Locale locale)

      Returns an implementation of the given factory class that resolves messages against the given locale and message source. Defers to MessageFactoryProxy.

      Specified by:
      getMessageFactory in interface nz.org.riskscape.engine.i18n.MessageSource