Class WCombinedLocalizedStrings

java.lang.Object
eu.webtoolkit.jwt.WLocalizedStrings
eu.webtoolkit.jwt.WCombinedLocalizedStrings

public class WCombinedLocalizedStrings extends WLocalizedStrings
A localized string resolver that bundles multiple string resolvers.

This class implements the localized strings interface and delegates WString#tr() string resolution to one or more string resolvers. You will typically use this class if you want to combine different methods of string resolution (e.g. some from files, and other strings using a database).

See Also:
  • Constructor Details

    • WCombinedLocalizedStrings

      public WCombinedLocalizedStrings()
      Constructor.
  • Method Details

    • add

      public void add(WLocalizedStrings resolver)
      Adds a string resolver.

      The order in which string resolvers are added is significant: resolveKey() will consult each string resolver in the order they have been added, until a match is found.

    • insert

      public void insert(int index, WLocalizedStrings resolver)
      Inserts a string resolver.

      See Also:
    • remove

      public void remove(WLocalizedStrings resolver)
      Removes a string resolver.

      See Also:
    • getItems

      public List<WLocalizedStrings> getItems()
    • hibernate

      public void hibernate()
      Description copied from class: WLocalizedStrings
      Purges memory resources, if possible.

      This is called afer event handling, and is an opportunity to conserve memory inbetween events, by freeing memory used for cached key/value bindings, if applicable.

      The default implementation does nothing.

      Overrides:
      hibernate in class WLocalizedStrings
    • resolveKey

      public LocalizedString resolveKey(Locale locale, String key)
      Description copied from class: WLocalizedStrings
      Resolves a key in the given locale.

      This method is used by WString to obtain the UTF-8 value corresponding to a key in the given locale.

      Returns a successful LocalizedString if the key could be resolved.

      Specified by:
      resolveKey in class WLocalizedStrings
      See Also:
    • resolvePluralKey

      public LocalizedString resolvePluralKey(Locale locale, String key, long amount)
      Description copied from class: WLocalizedStrings
      Resolves the plural form of a key in the given locale.

      This method is used by WString to obtain the UTF-8 value corresponding to a key in the current locale, taking into account the possibility of multiple plural forms, and chosing the right plural form based on the amount passed.

      Throws a std::logic_error if the underlying implementation does not provide support for plural internationalized strings.

      Returns a successful LocalizedString if the key could be resolved.

      Overrides:
      resolvePluralKey in class WLocalizedStrings