com.adobe.epubcheck.messages.LocaleHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of epubcheck Show documentation
Show all versions of epubcheck Show documentation
EPUBCheck is a tool to validate the conformance of EPUB publications against
the EPUB specifications. EPUBCheck can be run as a standalone command-line tool or used
as a Java library.
package com.adobe.epubcheck.messages;
import java.util.Locale;
/**
* Holds the "currently used" {@code Locale} in a static thread-local variable.
*
* Pieces of code that set or change the locale used in the application runtime
* should update the static locale stored in this class. See for instance how it
* is done in the {@code MasterReport} implementation.
*
*/
public final class LocaleHolder
{
private static final ThreadLocal current = new InheritableThreadLocal();
public static void set(final Locale locale)
{
current.set(locale);
}
public static Locale get()
{
Locale locale = current.get();
if (locale == null)
{
locale = Locale.getDefault();
}
return locale;
}
private LocaleHolder()
{
}
}