Class SessionLocaleResolver
- java.lang.Object
-
- com.aspectran.core.support.i18n.locale.AbstractLocaleResolver
-
- com.aspectran.core.support.i18n.locale.SessionLocaleResolver
-
- All Implemented Interfaces:
LocaleResolver
public class SessionLocaleResolver extends AbstractLocaleResolver
LocaleResolverimplementation that uses a locale attribute in the user's session in case of a custom setting, with a fallback to the specified default locale or the request's accept-header locale.Created: 2016. 3. 13.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLOCALE_SESSION_ATTR_NAMEName of the session attribute that holds the Locale.static java.lang.StringTIME_ZONE_SESSION_ATTR_NAMEName of the session attribute that holds the TimeZone.
-
Constructor Summary
Constructors Constructor Description SessionLocaleResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.LocaleresolveLocale(Translet translet)Resolve the current locale via the given translet.java.util.TimeZoneresolveTimeZone(Translet translet)Resolve the current timezone via the given translet.voidsetLocale(Translet translet, java.util.Locale locale)Set the current locale to the given one.voidsetTimeZone(Translet translet, java.util.TimeZone timeZone)Set the current timezone to the given one.-
Methods inherited from class com.aspectran.core.support.i18n.locale.AbstractLocaleResolver
getDefaultLocale, getDefaultTimeZone, resolveDefaultLocale, resolveDefaultTimeZone, setDefaultLocale, setDefaultLocale, setDefaultTimeZone, setDefaultTimeZone
-
-
-
-
Field Detail
-
LOCALE_SESSION_ATTR_NAME
public static final java.lang.String LOCALE_SESSION_ATTR_NAME
Name of the session attribute that holds the Locale. Only used internally by this implementation. to retrieve the current locale in controllers or views.
-
TIME_ZONE_SESSION_ATTR_NAME
public static final java.lang.String TIME_ZONE_SESSION_ATTR_NAME
Name of the session attribute that holds the TimeZone. Only used internally by this implementation.
-
-
Method Detail
-
resolveLocale
public java.util.Locale resolveLocale(Translet translet)
Description copied from interface:LocaleResolverResolve the current locale via the given translet. Can return a default locale as fallback in any case.- Parameters:
translet- the translet to resolve the locale for- Returns:
- the current locale (never
null)
-
resolveTimeZone
public java.util.TimeZone resolveTimeZone(Translet translet)
Description copied from interface:LocaleResolverResolve the current timezone via the given translet. Can return a default timezone as fallback in any case.- Parameters:
translet- the translet to resolve the timezone for- Returns:
- the current timezone (never
null)
-
setLocale
public void setLocale(Translet translet, java.util.Locale locale)
Description copied from interface:LocaleResolverSet the current locale to the given one.- Specified by:
setLocalein interfaceLocaleResolver- Overrides:
setLocalein classAbstractLocaleResolver- Parameters:
translet- the translet to resolve the locale forlocale- the new locale, ornullto clear the locale
-
setTimeZone
public void setTimeZone(Translet translet, java.util.TimeZone timeZone)
Description copied from interface:LocaleResolverSet the current timezone to the given one.- Specified by:
setTimeZonein interfaceLocaleResolver- Overrides:
setTimeZonein classAbstractLocaleResolver- Parameters:
translet- the translet to resolve the locale fortimeZone- the new timezone, ornullto clear the timezone
-
-