Class CountryCache
java.lang.Object
com.helger.commons.locale.country.CountryCache
- All Implemented Interfaces:
IHasConditionalLogger
This is a global cache for country objects to avoid too many object flowing
around.
This cache is application independent.
This cache is application independent.
- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsCountry(String sCountry) Check if the passed country is known.booleancontainsCountry(Locale aCountry) Check if the passed country is known.getCountry(String sCountry) Resolve the country from the provided string.
Note: this method may be invoked recursively, if the country code contains a locale separator char.getCountry(Locale aCountry) The normed country locale associated with the provided locale.getCountryExt(String sCountry, LocaleCache.IMissingLocaleHandler aMissingHandler) Resolve the country from the provided string.
Note: this method may be invoked recursively, if the country code contains a locale separator char.getCountryExt(Locale aCountry, LocaleCache.IMissingLocaleHandler aMissingHandler) The normed country locale associated with the provided locale.static CountryCachestatic booleanstatic booleanfinal voidReset the cache to the initial state.static booleansetSilentMode(boolean bSilentMode) Enable or disable certain regular log messages.
-
Constructor Details
-
CountryCache
protected CountryCache()
-
-
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
- Returns:
- The one and only global instances. Never
null.
-
getCountry
The normed country locale associated with the provided locale.- Parameters:
aCountry- Source locale. May benull.- Returns:
nullif the source locale isnullor if the source locale does not contain country information.
-
getCountryExt
@Nullable public Locale getCountryExt(@Nullable Locale aCountry, @Nullable LocaleCache.IMissingLocaleHandler aMissingHandler) The normed country locale associated with the provided locale.- Parameters:
aCountry- 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 country information.- Since:
- 9.4.2
-
getCountry
Resolve the country from the provided string.
Note: this method may be invoked recursively, if the country code contains a locale separator char.- Parameters:
sCountry- The country code. May benullor empty.- Returns:
nullif the provided country code isnullor empty.
-
getCountryExt
@Nullable public Locale getCountryExt(@Nullable String sCountry, @Nullable LocaleCache.IMissingLocaleHandler aMissingHandler) Resolve the country from the provided string.
Note: this method may be invoked recursively, if the country code contains a locale separator char.- Parameters:
sCountry- The country code. May benullor empty.aMissingHandler- The missing locale handler to be passed toLocaleCache. May benullto useLocaleCachedefault handler.- Returns:
nullif the provided country code isnullor empty.- Since:
- 9.4.2
-
getAllCountries
- Returns:
- a set with all contained countries. Never
null.
-
getAllCountryLocales
- Returns:
- a set with all contained country locales. Never
null.
-
containsCountry
Check if the passed country is known.- Parameters:
aCountry- The country to check. May benull.- Returns:
trueif the passed country is contained,falseotherwise.
-
containsCountry
Check if the passed country is known.- Parameters:
sCountry- The country to check. May benull.- Returns:
trueif the passed country is contained,falseotherwise.
-
reinitialize
public final void reinitialize()Reset the cache to the initial state.
-