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
LocaleResolver
implementation 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.String
LOCALE_SESSION_ATTRIBUTE_NAME
Name of the session attribute that holds the Locale.static java.lang.String
TIME_ZONE_SESSION_ATTRIBUTE_NAME
Name 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.Locale
resolveLocale(Translet translet)
Resolve the current locale via the given translet.java.util.TimeZone
resolveTimeZone(Translet translet)
Resolve the current timezone via the given translet.void
setLocale(Translet translet, java.util.Locale locale)
Set the current locale to the given one.void
setTimeZone(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_ATTRIBUTE_NAME
public static final java.lang.String LOCALE_SESSION_ATTRIBUTE_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_ATTRIBUTE_NAME
public static final java.lang.String TIME_ZONE_SESSION_ATTRIBUTE_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:LocaleResolver
Resolve 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:LocaleResolver
Resolve 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:LocaleResolver
Set the current locale to the given one.- Specified by:
setLocale
in interfaceLocaleResolver
- Overrides:
setLocale
in classAbstractLocaleResolver
- Parameters:
translet
- the translet to resolve the locale forlocale
- the new locale, ornull
to clear the locale
-
setTimeZone
public void setTimeZone(Translet translet, java.util.TimeZone timeZone)
Description copied from interface:LocaleResolver
Set the current timezone to the given one.- Specified by:
setTimeZone
in interfaceLocaleResolver
- Overrides:
setTimeZone
in classAbstractLocaleResolver
- Parameters:
translet
- the translet to resolve the locale fortimeZone
- the new timezone, ornull
to clear the timezone
-
-