java.lang.Object
com.aoapps.lang.i18n.ThreadLocale
Keeps track of the user's locale on a per-thread basis.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> V
call
(Locale locale, CallableE<? extends V, ? extends RuntimeException> callable) Changes the current thread locale then calls the Callable.static <V,
Ex extends Throwable>
VChanges the current thread locale then calls the Callable.static Locale
get()
Gets the current thread's locale or the system default if not yet set.static <Ex extends Throwable>
voidChanges the current thread locale then runs the RunnableE.static void
Changes the current thread locale then runs the Runnable.static void
Sets the current thread's locale.static <V,
Ex extends Exception>
VDeprecated.static <V> V
set
(Locale locale, ThreadLocale.Supplier<V> supplier) Deprecated.static <V> V
Deprecated.static <V> V
Deprecated.
-
Method Details
-
get
Gets the current thread's locale or the system default if not yet set. -
set
Sets the current thread's locale. The locale is not automatically restored and should be restored in a try/finally or equivalent. -
call
Changes the current thread locale then calls the Callable. The locale is automatically restored. -
set
Deprecated.Changes the current thread locale then calls the Callable. The locale is automatically restored.- Throws:
Exception
-
call
public static <V,Ex extends Throwable> V call(Locale locale, Class<? extends Ex> exClass, CallableE<? extends V, ? extends Ex> callable) throws ExChanges the current thread locale then calls the Callable. The locale is automatically restored.- Type Parameters:
Ex
- An arbitrary exception type that may be thrown- Throws:
Ex
-
set
@Deprecated public static <V,Ex extends Exception> V set(Locale locale, CallableE<V, Ex> callable) throws ExDeprecated.Changes the current thread locale then calls the Callable. The locale is automatically restored.- Type Parameters:
Ex
- An arbitrary exception type that may be thrown- Throws:
Ex
-
run
Changes the current thread locale then runs the Runnable. The locale is automatically restored. -
run
public static <Ex extends Throwable> void run(Locale locale, Class<? extends Ex> exClass, RunnableE<? extends Ex> runnable) throws Ex Changes the current thread locale then runs the RunnableE. The locale is automatically restored.- Type Parameters:
Ex
- An arbitrary exception type that may be thrown- Throws:
Ex
-
set
Deprecated.Changes the current thread locale then gets the result from the Supplier. The locale is automatically restored. -
set
Deprecated.
-
Supplier
directly.