Top Description Fields Constructors Methods
org.eclipse.jgit.nls

public Class NLS

extends Object
Class Inheritance
Imports
java.util.Locale, .Map, java.util.concurrent.ConcurrentHashMap, org.eclipse.jgit.errors.TranslationBundleLoadingException, .TranslationStringMissingException

The purpose of this class is to provide NLS (National Language Support) configurable per thread.

The setLocale(Locale) method is used to configure locale for the calling thread. The locale setting is thread inheritable. This means that a child thread will have the same locale setting as its creator thread until it changes it explicitly.

Example of usage:

NLS.setLocale(Locale.GERMAN);
TransportText t = NLS.getBundleFor(TransportText.class);

Field Summary

Modifier and TypeField and Description
private static final InheritableThreadLocal<NLS>
private final Locale
private final Map<Class<T>, TranslationBundle>
public static final Locale
ROOT_LOCALE

The root locale constant.

Constructor Summary

AccessConstructor and Description
private
NLS(Locale locale)

Method Summary

Modifier and TypeMethod and Description
public static void
clear()

Release resources held by NLS

private <T extends TranslationBundle> T
get(Class<T> type)

public static <
type of the translation bundle
T extends TranslationBundle
>
T

Returns:

an instance of the required bundle type
getBundleFor
(Class<T>
required bundle type
type
)

Returns an instance of the translation bundle of the required type.

public static void
setLocale(Locale
the preferred locale
locale
)

Sets the locale for the calling thread.

private static NLS
public static void
useJVMDefaultLocale()

Sets the JVM default locale as the locale for the calling thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

localback to summary
private static final InheritableThreadLocal<NLS> local
localeback to summary
private final Locale locale
mapback to summary
private final Map<Class<T>, TranslationBundle> map
ROOT_LOCALEback to summary
public static final Locale ROOT_LOCALE

The root locale constant. It is defined here because the Locale.ROOT is not defined in Java 5

Constructor Detail

NLSback to summary
private NLS(Locale locale)

Method Detail

clearback to summary
public static void clear()

Release resources held by NLS

Since
5.8
getback to summary
private <T extends TranslationBundle> T get(Class<T> type)
Annotations
@SuppressWarnings:unchecked
getBundleForback to summary
public static <T extends TranslationBundle> T getBundleFor(Class<T> type)

Returns an instance of the translation bundle of the required type. All public String fields of the bundle instance will get their values injected as described in the org.eclipse.jgit.nls.TranslationBundle.

Parameters
<T>
type of the translation bundle
type:Class<T>

required bundle type

Returns:T

an instance of the required bundle type

Exceptions
TranslationBundleLoadingException:
see org.eclipse.jgit.errors.TranslationBundleLoadingException
TranslationStringMissingException:
see org.eclipse.jgit.errors.TranslationStringMissingException
setLocaleback to summary
public static void setLocale(Locale locale)

Sets the locale for the calling thread.

The getBundleFor(Class) method will honor this setting if it is supported by the provided resource bundle property files. Otherwise, it will use a fall back locale as described in the TranslationBundle

Parameters
locale:Locale

the preferred locale

useJVMDefaultInternalback to summary
private static NLS useJVMDefaultInternal()
useJVMDefaultLocaleback to summary
public static void useJVMDefaultLocale()

Sets the JVM default locale as the locale for the calling thread.

Semantically this is equivalent to NLS.setLocale(Locale.getDefault()).