Class LanguageCache
java.lang.Object
com.helger.commons.locale.language.LanguageCache
- All Implemented Interfaces:
IHasConditionalLogger
@ThreadSafe
@Singleton
public final class LanguageCache
extends Object
implements IHasConditionalLogger
This is a global cache for language objects to avoid too many objects flowing
around.
This cache is application independent.
This cache is application independent.
- Since:
- v9.1.3
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsLanguage(String sLanguage) Check if the passed language is known.booleancontainsLanguage(Locale aLanguage) Check if the passed language is known.static LanguageCachegetLanguage(String sLanguage) Resolve the language from the provided string.
Note: this method may be invoked recursively, if the language code contains a locale separator char.getLanguage(Locale aLanguage) The normed language locale associated with the provided locale.getLanguageExt(String sLanguage, LocaleCache.IMissingLocaleHandler aMissingHandler) Resolve the language from the provided string.
Note: this method may be invoked recursively, if the language code contains a locale separator char.getLanguageExt(Locale aLanguage, LocaleCache.IMissingLocaleHandler aMissingHandler) The normed language locale associated with the provided locale.static booleanstatic booleanvoidReset the cache to the initial state.static booleansetSilentMode(boolean bSilentMode) Enable or disable certain regular log messages.
-
Method Details
-
isSilentMode
public static boolean isSilentMode()- Returns:
trueif logging is disabled,falseif it is enabled.- Since:
- 9.4.0
-
setSilentMode
public static boolean setSilentMode(boolean bSilentMode) Enable or disable certain regular log messages.- Parameters:
bSilentMode-trueto disable logging,falseto enable logging- Returns:
- The previous value of the silent mode.
- Since:
- 9.4.0
-
isInstantiated
public static boolean isInstantiated() -
getInstance
-
getLanguage
The normed language locale associated with the provided locale.- Parameters:
aLanguage- Source locale. May benull.- Returns:
nullif the source locale isnullor if the source locale does not contain language information.
-
getLanguageExt
@Nullable public Locale getLanguageExt(@Nullable Locale aLanguage, @Nullable LocaleCache.IMissingLocaleHandler aMissingHandler) The normed language locale associated with the provided locale.- Parameters:
aLanguage- Source locale. May benull.aMissingHandler- The missing locale handler to be passed toLocaleCache. May benullto useLocaleCachedefault handler.- Returns:
nullif the source locale isnullor if the source locale does not contain language information.- Since:
- 9.4.2
-
getLanguage
Resolve the language from the provided string.
Note: this method may be invoked recursively, if the language code contains a locale separator char.- Parameters:
sLanguage- The language code. May benullor empty.- Returns:
nullif the provided language code isnullor empty.
-
getLanguageExt
@Nullable public Locale getLanguageExt(@Nullable String sLanguage, @Nullable LocaleCache.IMissingLocaleHandler aMissingHandler) Resolve the language from the provided string.
Note: this method may be invoked recursively, if the language code contains a locale separator char.- Parameters:
sLanguage- The language code. May benullor empty.aMissingHandler- The missing locale handler to be passed toLocaleCache. May benullto useLocaleCachedefault handler.- Returns:
nullif the provided language code isnullor empty.- Since:
- 9.4.2
-
getAllLanguages
- Returns:
- a set with all contained languages. Never
null.
-
getAllLanguageLocales
- Returns:
- a set with all contained language locales. Never
null.
-
containsLanguage
Check if the passed language is known.- Parameters:
aLanguage- The language to check. May benull.- Returns:
trueif the passed language is contained,falseotherwise.
-
containsLanguage
Check if the passed language is known.- Parameters:
sLanguage- The language to check. May benull.- Returns:
trueif the passed language is contained,falseotherwise.
-
reinitialize
public void reinitialize()Reset the cache to the initial state.
-