- java.lang.Object
-
- com.aoapps.lang.i18n.ThreadLocale
-
public final class ThreadLocale extends Object
Keeps track of the user's locale on a per-thread basis.- Author:
- AO Industries, Inc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceThreadLocale.Supplier<T>Deprecated.Please useSupplierdirectly.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <V> Vcall(Locale locale, CallableE<? extends V,? extends RuntimeException> callable)Changes the current thread locale then calls the Callable.static <V,Ex extends Throwable>
Vcall(Locale locale, Class<? extends Ex> exClass, CallableE<? extends V,? extends Ex> callable)Changes the current thread locale then calls the Callable.static Localeget()Gets the current thread's locale or the system default if not yet set.static <Ex extends Throwable>
voidrun(Locale locale, Class<? extends Ex> exClass, RunnableE<? extends Ex> runnable)Changes the current thread locale then runs the RunnableE.static voidrun(Locale locale, Runnable runnable)Changes the current thread locale then runs the Runnable.static voidset(Locale locale)Sets the current thread's locale.static <V,Ex extends Exception>
Vset(Locale locale, CallableE<V,Ex> callable)Deprecated.static <V> Vset(Locale locale, ThreadLocale.Supplier<V> supplier)Deprecated.static <V> Vset(Locale locale, Callable<V> callable)Deprecated.static <V> Vset(Locale locale, Supplier<V> supplier)Deprecated.
-
-
-
Method Detail
-
get
public static Locale get()
Gets the current thread's locale or the system default if not yet set.
-
set
public static void set(Locale locale)
Sets the current thread's locale. The locale is not automatically restored and should be restored in a try/finally or equivalent.
-
call
public static <V> V call(Locale locale, CallableE<? extends V,? extends RuntimeException> callable)
Changes the current thread locale then calls the Callable. The locale is automatically restored.
-
set
@Deprecated public static <V> V set(Locale locale, Callable<V> callable) throws Exception
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 Ex extends Throwable
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 extends Throwable
-
set
@Deprecated public static <V,Ex extends Exception> V set(Locale locale, CallableE<V,Ex> callable) throws Ex extends Exception
Deprecated.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 extends Exception
-
run
public static void run(Locale locale, Runnable runnable)
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 extends Throwable
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 extends Throwable
-
set
@Deprecated public static <V> V set(Locale locale, Supplier<V> supplier)
Deprecated.Changes the current thread locale then gets the result from the Supplier. The locale is automatically restored.
-
set
@Deprecated public static <V> V set(Locale locale, ThreadLocale.Supplier<V> supplier)
Deprecated.
-
-