Package nl.talsmasoftware.context.locale
Class LocaleContextManager
- java.lang.Object
-
- nl.talsmasoftware.context.locale.LocaleContextManager
-
- All Implemented Interfaces:
ContextManager<Locale>
public final class LocaleContextManager extends Object implements ContextManager<Locale>
Manager for aLocalebound to the current thread.- Author:
- Sjoerd Talsma
-
-
Constructor Summary
Constructors Constructor Description LocaleContextManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidclear()Unconditionally removes the active context (and any parents).Context<Locale>getActiveContext()The currently active context, ornullif no context is active.static LocalegetCurrentLocale()static LocalegetCurrentLocaleOrDefault()Context<Locale>initializeNewContext(Locale value)StringtoString()
-
-
-
Method Detail
-
getCurrentLocale
public static Locale getCurrentLocale()
- Returns:
- The
Localefor the current thread, ornullif no context was initialized. - See Also:
getCurrentLocaleOrDefault()
-
getCurrentLocaleOrDefault
public static Locale getCurrentLocaleOrDefault()
- Returns:
- The
Localefor the current thread, orLocale.getDefault()if no context was initialized. - See Also:
Locale.getDefault()
-
initializeNewContext
public Context<Locale> initializeNewContext(Locale value)
Registers the given Locale value as the current Locale for the active thread until the returned context isclosedagain.- Specified by:
initializeNewContextin interfaceContextManager<Locale>- Parameters:
value- The new current Locale.- Returns:
- The context to be closed again by the caller to remove this locale as current locale.
-
getActiveContext
public Context<Locale> getActiveContext()
Description copied from interface:ContextManagerThe currently active context, ornullif no context is active.- Specified by:
getActiveContextin interfaceContextManager<Locale>- Returns:
- The active
Localecontext ornullif no such context is active in the current thread.
-
clear
public static void clear()
Unconditionally removes the active context (and any parents).This is useful for boundary filters, whose Threads may be returned to some threadpool.
-
-