eu.webtoolkit.jwt
Class WCombinedLocalizedStrings

java.lang.Object
  extended by eu.webtoolkit.jwt.WLocalizedStrings
      extended by 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:
WApplication.setLocalizedStrings(WLocalizedStrings translator)

Constructor Summary
WCombinedLocalizedStrings()
          Constructor.
 
Method Summary
 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)
           
 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 Detail

WCombinedLocalizedStrings

public WCombinedLocalizedStrings()
Constructor.

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)

remove

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

See Also:
add(WLocalizedStrings resolver)

getItems

public java.util.List<WLocalizedStrings> getItems()
Returns the list of resolvers.

See Also:
add(WLocalizedStrings resolver), remove(WLocalizedStrings resolver)

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 class WLocalizedStrings

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 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 class WLocalizedStrings
See Also:
WApplication.getLocale(), WString.tr(String key)