Class LocalizationSetterImpl
- java.lang.Object
-
- org.apache.tapestry5.internal.services.LocalizationSetterImpl
-
- All Implemented Interfaces:
LocalizationSetter
public class LocalizationSetterImpl extends java.lang.Object implements LocalizationSetter
Given a set of supported locales, for a specified desired locale, sets the current thread's locale to a supported locale that is closest to the desired.
-
-
Constructor Summary
Constructors Constructor Description LocalizationSetterImpl(Request request, PersistentLocale persistentLocale, ThreadLocale threadLocale, java.lang.String localeNames)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.util.Locale>getSupportedLocales()Returns a list of supported locales, as per theSymbolConstants.SUPPORTED_LOCALESsymbol.SelectModelgetSupportedLocalesModel()Returns the supported locales packaged as a model.booleanisSupportedLocaleName(java.lang.String localeName)Checks to see if the indicated locale name is a supported locale name (that may have been incorporated into a request path).booleansetLocaleFromLocaleName(java.lang.String localeName)Determines if the provided potential locale name (presumably, extracted from a request URL) is a supported locale name.voidsetNonPersistentLocaleFromLocaleName(java.lang.String localeName)Allows the locale to be set from a specified locale name (which may be narrowed or defaulted to a support locale).voidsetNonPersistentLocaleFromRequest(Request request)Allows the locale to be set from the locale of the client as determined from the request headers (which may be narrowed or defaulted to a supported locale).java.util.LocaletoLocale(java.lang.String localeName)Converts a locale name into a Locale.
-
-
-
Constructor Detail
-
LocalizationSetterImpl
public LocalizationSetterImpl(Request request, PersistentLocale persistentLocale, ThreadLocale threadLocale, @Symbol("tapestry.supported-locales") java.lang.String localeNames)
-
-
Method Detail
-
toLocale
public java.util.Locale toLocale(java.lang.String localeName)
Description copied from interface:LocalizationSetterConverts a locale name into a Locale. The result is cached.- Specified by:
toLocalein interfaceLocalizationSetter
-
setLocaleFromLocaleName
public boolean setLocaleFromLocaleName(java.lang.String localeName)
Description copied from interface:LocalizationSetterDetermines if the provided potential locale name (presumably, extracted from a request URL) is a supported locale name. A call to this method will always set theThreadLocale(either to the provided locale, if supported, or to the default locale). If the locale name is supported, it will also set thePersistentLocale(which may affect how page and event links are generated, to persist the selected locale across requests). Note that locale names are case sensitive.- Specified by:
setLocaleFromLocaleNamein interfaceLocalizationSetter- Parameters:
localeName- name of locale to check (which may be blank or not a locale name)- Returns:
- true if the locale name is supported and the
PersistentLocalewas set
-
setNonPersistentLocaleFromLocaleName
public void setNonPersistentLocaleFromLocaleName(java.lang.String localeName)
Description copied from interface:LocalizationSetterAllows the locale to be set from a specified locale name (which may be narrowed or defaulted to a support locale). Does not set the persistent locale.- Specified by:
setNonPersistentLocaleFromLocaleNamein interfaceLocalizationSetter- Parameters:
localeName- locale in effect for this request
-
setNonPersistentLocaleFromRequest
public void setNonPersistentLocaleFromRequest(Request request)
Description copied from interface:LocalizationSetterAllows the locale to be set from the locale of the client as determined from the request headers (which may be narrowed or defaulted to a supported locale). Does not set the persistent locale.- Specified by:
setNonPersistentLocaleFromRequestin interfaceLocalizationSetter- Parameters:
request- incoming request
-
getSupportedLocales
public java.util.List<java.util.Locale> getSupportedLocales()
Description copied from interface:LocalizationSetterReturns a list of supported locales, as per theSymbolConstants.SUPPORTED_LOCALESsymbol.- Specified by:
getSupportedLocalesin interfaceLocalizationSetter
-
isSupportedLocaleName
public boolean isSupportedLocaleName(java.lang.String localeName)
Description copied from interface:LocalizationSetterChecks to see if the indicated locale name is a supported locale name (that may have been incorporated into a request path). This is an important part of decoding a request.- Specified by:
isSupportedLocaleNamein interfaceLocalizationSetter
-
getSupportedLocalesModel
public SelectModel getSupportedLocalesModel()
Description copied from interface:LocalizationSetterReturns the supported locales packaged as a model. The label for each locale comes fromLocale.getDisplayName(Locale)(in that locale).- Specified by:
getSupportedLocalesModelin interfaceLocalizationSetter
-
-