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

pack-priv Class GlobalBundleCache

extends Object
Class Inheritance
Imports
java.lang.reflect.InvocationTargetException, java.util.HashMap, .Locale, .Map, org.eclipse.jgit.errors.TranslationBundleLoadingException, .TranslationStringMissingException

Global cache of translation bundles.

Every translation bundle will be cached here when it gets loaded for the first time from a thread. Another lookup for the same translation bundle (same locale and type) from the same or a different thread will return the cached one.

Note that NLS instances maintain per-thread Map of loaded translation bundles. Once a thread accesses a translation bundle it will keep reference to it and will not call lookupBundle(Locale, Class) again for the same translation bundle as long as its locale doesn't change.

Field Summary

Modifier and TypeField and Description
private static final Map<Locale, Map<Class<T>, TranslationBundle>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
pack-priv static synchronized <
required bundle type
T extends TranslationBundle
>
T

Returns:

an instance of the required bundle type
lookupBundle
(Locale
the preferred locale
locale
,
Class<T>
required bundle type
type
)

Looks up for a translation bundle in the global cache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cachedBundlesback to summary
private static final Map<Locale, Map<Class<T>, TranslationBundle>> cachedBundles

Constructor Detail

GlobalBundleCacheback to summary
pack-priv GlobalBundleCache()

Method Detail

clearback to summary
pack-priv static void clear()
lookupBundleback to summary
pack-priv static synchronized <T extends TranslationBundle> T lookupBundle(Locale locale, Class<T> type)

Looks up for a translation bundle in the global cache. If found returns the cached bundle. If not found creates a new instance puts it into the cache and returns it.

Parameters
<T>
required bundle type
locale:Locale

the preferred locale

type:Class<T>

required bundle type

Returns:T

an instance of the required bundle type

Annotations
@SuppressWarnings:unchecked
Exceptions
TranslationBundleLoadingException:
see TranslationBundle#load(Locale)
TranslationStringMissingException:
see TranslationBundle#load(Locale)