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).
-
-
Constructor Summary
Constructors Constructor Description WCombinedLocalizedStrings()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(WLocalizedStrings resolver)Adds a string resolver.java.util.List<WLocalizedStrings>getItems()voidhibernate()Purges memory resources, if possible.voidinsert(int index, WLocalizedStrings resolver)Inserts a string resolver.voidremove(WLocalizedStrings resolver)Removes a string resolver.LocalizedStringresolveKey(java.util.Locale locale, java.lang.String key)Resolves a key in the given locale.LocalizedStringresolvePluralKey(java.util.Locale locale, java.lang.String key, long amount)Resolves the plural form of a key in the given locale.-
Methods inherited from class eu.webtoolkit.jwt.WLocalizedStrings
evaluatePluralExpression
-
-
-
-
Method Detail
-
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:
add(WLocalizedStrings resolver)
-
remove
public void remove(WLocalizedStrings resolver)
Removes a string resolver.- See Also:
add(WLocalizedStrings resolver)
-
getItems
public java.util.List<WLocalizedStrings> getItems()
-
hibernate
public void hibernate()
Description copied from class:WLocalizedStringsPurges 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:
hibernatein classWLocalizedStrings
-
resolveKey
public LocalizedString resolveKey(java.util.Locale locale, java.lang.String key)
Description copied from class:WLocalizedStringsResolves a key in the given locale.This method is used by
WStringto obtain the UTF-8 value corresponding to a key in the given locale.Returns a successful
LocalizedStringif the key could be resolved.- Specified by:
resolveKeyin classWLocalizedStrings- See Also:
WString.tr(String key)
-
resolvePluralKey
public LocalizedString resolvePluralKey(java.util.Locale locale, java.lang.String key, long amount)
Description copied from class:WLocalizedStringsResolves the plural form of a key in the given locale.This method is used by
WStringto 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 theamountpassed.Throws a std::logic_error if the underlying implementation does not provide support for plural internationalized strings.
Returns a successful
LocalizedStringif the key could be resolved.- Overrides:
resolvePluralKeyin classWLocalizedStrings
-
-