All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.epubcheck.messages.LocaleHolder Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 5.1.0
Show newest version
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()
  {
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy