Class DefaultMessages

java.lang.Object
nz.org.riskscape.engine.i18n.DefaultMessages
All Implemented Interfaces:
nz.org.riskscape.engine.i18n.Messages

public class DefaultMessages extends Object implements nz.org.riskscape.engine.i18n.Messages
  • Field Details

  • Constructor Details

  • Method Details

    • getCode

      public static String getCode(nz.org.riskscape.engine.Identified object, String... parts)

      Construct an i18n code for looking up messages belonging to an identified object based on its id.

    • getShortCode

      public static String getShortCode(nz.org.riskscape.engine.Identified object, String... parts)

      Same as getCode(Identified, String...) except it strips off the package-name and just uses the class's simple name. As the Identified object should already have a unique ID, the package-name is a bit unnecessary.

    • getCode

      public static String getCode(String className, String id, String... parts)

      Construct an i18n code for looking up messages belonging to an identified object based on its id. Keys take the form nz.org.riskscape.engine.${API_CLASS}.by-id.${ID}.${part¹}.${part²}.... For a model, this might look like nz.org.riskscape.engine.model.Model.by-id.default.param.filter.

    • newMessageSource

      public RiskscapeMessageSource newMessageSource(String baseName)
      Specified by:
      newMessageSource in interface nz.org.riskscape.engine.i18n.Messages
    • getResourceBundle

      public ResourceBundle getResourceBundle(String baseName, Locale locale)

      Shortcut for newMessageSource(baseName).getBundle(locale)

    • getMessage

      public Optional<String> getMessage(nz.org.riskscape.engine.i18n.MessageSource msgs, Locale locale, @NonNull @NonNull Object owner, String... parts)
      Specified by:
      getMessage in interface nz.org.riskscape.engine.i18n.Messages
    • getDetailedMessage

      public List<String> getDetailedMessage(nz.org.riskscape.engine.i18n.MessageSource msgs, Locale locale, Object owner, String... parts)
      Specified by:
      getDetailedMessage in interface nz.org.riskscape.engine.i18n.Messages
    • getKnownBundleNames

      public Set<String> getKnownBundleNames(nz.org.riskscape.engine.plugin.ExtensionPoints eps)
      Returns:
      a set of resource bundle names that are either well known riskscape bundles (such as help) or ones that have been registered via a plugin with the HasMessages feature interface.
    • renderObject

      public String renderObject(Object object, Locale locale)
      Specified by:
      renderObject in interface nz.org.riskscape.engine.i18n.Messages
    • renderProblem

      public nz.org.riskscape.engine.i18n.RenderedProblem renderProblem(nz.org.riskscape.problem.Problem problem, Locale locale)
      Specified by:
      renderProblem in interface nz.org.riskscape.engine.i18n.Messages
    • addPluginResources

      public void addPluginResources(nz.org.riskscape.engine.plugin.Plugin plugin)
      Specified by:
      addPluginResources in interface nz.org.riskscape.engine.i18n.Messages
    • getClassLoader

      public I18nClassLoader getClassLoader()
    • getControl

      public ResourceBundleControl getControl()
    • getHelp

      public RiskscapeMessageSource getHelp()
      Specified by:
      getHelp in interface nz.org.riskscape.engine.i18n.Messages
    • getLabels

      public RiskscapeMessageSource getLabels()
      Specified by:
      getLabels in interface nz.org.riskscape.engine.i18n.Messages
    • getProblems

      public RiskscapeMessageSource getProblems()
      Specified by:
      getProblems in interface nz.org.riskscape.engine.i18n.Messages
    • getDefaultLocale

      public Locale getDefaultLocale()
      Specified by:
      getDefaultLocale in interface nz.org.riskscape.engine.i18n.Messages
    • setDefaultLocale

      public void setDefaultLocale(Locale defaultLocale)