Class LocalizationBundle
- java.lang.Object
-
- java.util.ResourceBundle
-
- org.silverpeas.core.util.LocalizationBundle
-
- All Implemented Interfaces:
SilverpeasBundle
public class LocalizationBundle extends ResourceBundle implements SilverpeasBundle
A resource bundle that contains the localized resources defined under a fully qualified name in Silverpeas. These resources can be messages, icons, and so one.It decorates
java.util.ResourceBundleto suit the peculiar use of the resource bundles in Silverpeas. It wraps in a transparent way both the Silverpeas general resource bundle and the resource bundle of the given name. The loading of the resources bundles in Silverpeas is managed byorg.silverpeas.core.util.ResourceLocatoritself. If no bundle exists with the given fully qualified name (the bundle base name) or if a given key isn't defined in the bundle, then aMissingResourceExceptionexception is thrown as defined in theResourceBundlecontract.To handle the general localized resources and those from the given bundle name it uses an instance of
java.util.ResourceBundlefor each of them. So, it profits then of the bundle content access policy implemented by this class: the content is cached in memory with an expiration trigger.- See Also:
ResourceBundle
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control
-
-
Field Summary
Fields Modifier and Type Field Description static StringGENERAL_BUNDLE_NAME-
Fields inherited from class java.util.ResourceBundle
parent
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLocalizationBundle(String name, Locale locale, BiFunction<String,Locale,ResourceBundle> loader, boolean mandatory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeLocale(String locale)Changes the locale of this localization bundle.voidchangeLocale(Locale locale)Changes the locale of this localization bundle.booleancontainsKey(String key)Determines whether the givenkeyis contained in thisResourceBundleor its parent bundles.booleanexists()Is this bundle exists?StringgetBaseBundleName()Returns the base name of this bundle, if known, ornullif unknown.Enumeration<String>getKeys()LocalegetLocale()Returns the locale of this resource bundle.Enumeration<String>getSpecificKeys()Gets the specific keys of this bundle.StringgetStringWithParams(String resName, Object... params)protected ObjecthandleGetObject(String key)Set<String>keySet()Returns aSetof all keys contained in thisResourceBundleand its parent bundles.Set<String>specificKeySet()Returns aSetof the specific keys contained in thisResourceBundle.-
Methods inherited from class java.util.ResourceBundle
clearCache, clearCache, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getObject, getString, getStringArray, handleKeySet, setParent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.util.SilverpeasBundle
getString, getStringList, getStringList
-
-
-
-
Field Detail
-
GENERAL_BUNDLE_NAME
public static final String GENERAL_BUNDLE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LocalizationBundle
protected LocalizationBundle(String name, Locale locale, BiFunction<String,Locale,ResourceBundle> loader, boolean mandatory)
-
-
Method Detail
-
keySet
public Set<String> keySet()
Returns aSetof all keys contained in thisResourceBundleand its parent bundles.- Specified by:
keySetin interfaceSilverpeasBundle- Overrides:
keySetin classResourceBundle- Returns:
- a
Setof all keys contained in thisResourceBundleand its parent bundles. - Since:
- 1.6
-
specificKeySet
public Set<String> specificKeySet()
Returns aSetof the specific keys contained in thisResourceBundle. Thekeysfrom the general resource bundle aren't taken into account.- Returns:
- a
Setof specific keys contained in thisResourceBundle.
-
containsKey
public boolean containsKey(String key)
Determines whether the givenkeyis contained in thisResourceBundleor its parent bundles.- Specified by:
containsKeyin interfaceSilverpeasBundle- Overrides:
containsKeyin classResourceBundle- Parameters:
key- the resourcekey- Returns:
trueif the givenkeyis contained in thisResourceBundleor its parent bundles;falseotherwise.- Throws:
NullPointerException- ifkeyisnull- Since:
- 1.6
-
getBaseBundleName
public String getBaseBundleName()
Returns the base name of this bundle, if known, ornullif unknown.If not null, then this is the value of the
baseNameparameter that was passed to theResourceBundle.getBundle(...)method when the resource bundle was loaded.- Specified by:
getBaseBundleNamein interfaceSilverpeasBundle- Overrides:
getBaseBundleNamein classResourceBundle- Returns:
- The base name of the resource bundle, as provided to and expected
by the
ResourceBundle.getBundle(...)methods. - Since:
- 1.8
- See Also:
ResourceBundle.getBundle(String, Locale, ClassLoader)
-
getLocale
public Locale getLocale()
Returns the locale of this resource bundle. This method can be used after a call to getBundle() to determine whether the resource bundle returned really corresponds to the requested locale or is a fallback.- Overrides:
getLocalein classResourceBundle- Returns:
- the locale of this resource bundle
-
getKeys
public Enumeration<String> getKeys()
- Specified by:
getKeysin classResourceBundle
-
getSpecificKeys
public Enumeration<String> getSpecificKeys()
Gets the specific keys of this bundle. The keys from the general resource bundle aren't taken into account.- Returns:
- an enumaration with the specific keys of this bundle.
-
changeLocale
public void changeLocale(String locale)
Changes the locale of this localization bundle. The bundle content will be loaded for the specified locale.- Parameters:
locale- the new locale.
-
changeLocale
public void changeLocale(Locale locale)
Changes the locale of this localization bundle. The bundle content will be loaded for the specified locale.- Parameters:
locale- the new locale.
-
exists
public boolean exists()
Is this bundle exists?- Specified by:
existsin interfaceSilverpeasBundle- Returns:
- true if this bundle exists, false otherwise.
-
handleGetObject
protected Object handleGetObject(String key)
- Specified by:
handleGetObjectin classResourceBundle
-
-