org.araneaframework.framework
Interface LocalizationContext

All Superinterfaces:
Serializable
All Known Subinterfaces:
SpringLocalizationContext
All Known Implementing Classes:
SpringLocalizationFilterService, StandardLocalizationFilterService

public interface LocalizationContext
extends Serializable

A context for providing localization via exposing the current Locale and ResourceBundles. The ResourceBundle of a different Locale can be accessed without chaning the current Locale with getResourceBundle(Locale). The current Locale can be changed with setLocale(Locale) and all subsequent request to getResourceBundle() will use the new current Locale.

Author:
"Toomas Römer" , Jevgeni Kabanov (ekabanov at araneaframework dot org)

Nested Class Summary
static interface LocalizationContext.LocaleChangeListener
           
 
Method Summary
 void addLocaleChangeListener(LocalizationContext.LocaleChangeListener listener)
           
 Locale getLocale()
          Returns the current session locale.
 String getMessage(String code, Object[] args)
          Localizes the code and uses it to format the message with the passed arguments.
 String getMessage(String code, Object[] args, String defaultMessage)
          Localizes the code and uses it to format the message with the passed arguments.
 ResourceBundle getResourceBundle()
          Returns a resource bundle corresponding to the current locale.
 ResourceBundle getResourceBundle(Locale locale)
          Returns a resource bundle corresponding to arbitrary locale.
 String localize(String key)
          Localizes a string returning one that corresponds to the current locale.
 boolean removeLocaleChangeListener(LocalizationContext.LocaleChangeListener listener)
           
 void setLocale(Locale locale)
          Sets the current session locale.
 

Method Detail

getLocale

public Locale getLocale()
Returns the current session locale.


setLocale

public void setLocale(Locale locale)
Sets the current session locale.


localize

public String localize(String key)
Localizes a string returning one that corresponds to the current locale.


getResourceBundle

public ResourceBundle getResourceBundle()
Returns a resource bundle corresponding to the current locale.


getResourceBundle

public ResourceBundle getResourceBundle(Locale locale)
Returns a resource bundle corresponding to arbitrary locale.


getMessage

public String getMessage(String code,
                         Object[] args,
                         String defaultMessage)
Localizes the code and uses it to format the message with the passed arguments. The format of the localized message should be acceptable by java.text.MessageFormat. If the localized message cannot be resolved uses defaultMessage instead.


getMessage

public String getMessage(String code,
                         Object[] args)
Localizes the code and uses it to format the message with the passed arguments. The format of the localized message should be acceptable by java.text.MessageFormat.


addLocaleChangeListener

public void addLocaleChangeListener(LocalizationContext.LocaleChangeListener listener)
Since:
1.1

removeLocaleChangeListener

public boolean removeLocaleChangeListener(LocalizationContext.LocaleChangeListener listener)
Since:
1.1