Class WCombinedLocalizedStrings
public class WCombinedLocalizedStrings extends WLocalizedStrings
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
Modifier and Type Method Description void
add(WLocalizedStrings resolver)
Adds a string resolver.java.util.List<WLocalizedStrings>
getItems()
Returns the list of resolvers.void
hibernate()
Purges memory resources, if possible.void
insert(int index, WLocalizedStrings resolver)
Inserts a string resolver.void
refresh()
Rereads the message resources.void
remove(WLocalizedStrings resolver)
Removes a string resolver.java.lang.String
resolveKey(java.lang.String key)
Resolves a key in the current locale.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
WCombinedLocalizedStrings
public WCombinedLocalizedStrings()Constructor.
-
-
Method Details
-
add
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
Inserts a string resolver.- See Also:
add(WLocalizedStrings resolver)
-
remove
Removes a string resolver.- See Also:
add(WLocalizedStrings resolver)
-
getItems
Returns the list of resolvers. -
refresh
public void refresh()Description copied from class:WLocalizedStrings
Rereads the message resources.Purge any cached key/values, if applicable.
The default implementation does nothing.
- Overrides:
refresh
in classWLocalizedStrings
-
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 classWLocalizedStrings
-
resolveKey
public java.lang.String resolveKey(java.lang.String key)Description copied from class:WLocalizedStrings
Resolves a key in the current locale.This method is used by
WString
to obtain the UTF8 value corresponding to a key in the current locale.Returns the value if the key could be resolved. Returns
null
otherwise.- Specified by:
resolveKey
in classWLocalizedStrings
- See Also:
WApplication.getLocale()
,WString.tr(String key)
-