Class LocalizationBundle
- All Implemented Interfaces:
SilverpeasBundle
It decorates ResourceBundle to suit the peculiar use of the resource bundles in
Silverpeas. It wraps in a transparent way both the Silverpeas general resource bundle and any
another peculiar resource bundle. The loading of the resources bundles in Silverpeas is managed
by ResourceLocator itself. 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 a MissingResourceException exception is thrown as defined in the
ResourceBundle contract.
To handle the general localized resources and those from the given bundle name it uses an
instance of ResourceBundle for 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:
- API Note:
- A general resource bundle is expected at
GENERAL_BUNDLE_NAME
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe Silverpeas l10n bundle for general translations.Fields inherited from class java.util.ResourceBundle
parent -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLocalizationBundle(String name, Locale locale, BiFunction<String, Locale, ResourceBundle> loader, boolean mandatory) -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeLocale(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?Returns the base name of this bundle, if known, ornullif unknown.getKeys()Returns the actual locale of this resource bundle.Gets the specific keys of this bundle.getStringWithParams(String resName, Object... params) protected ObjecthandleGetObject(String key) keySet()Returns aSetof all keys contained in thisResourceBundleand its parent bundles.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, setParentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.silverpeas.kernel.bundle.SilverpeasBundle
getString, getStringList, getStringList
-
Field Details
-
GENERAL_BUNDLE_NAME
The Silverpeas l10n bundle for general translations. It is both the default and base bundle that is always loaded along any other specific bundles. This Bundle has to be provided and available for Silverpeas.- See Also:
-
-
Constructor Details
-
LocalizationBundle
protected LocalizationBundle(String name, Locale locale, BiFunction<String, Locale, ResourceBundle> loader, boolean mandatory)
-
-
Method Details
-
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
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
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
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(String)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:
-
getLocale
Returns the actual locale of this resource bundle. This method can be used to determine whether the resource bundle returned really corresponds to the requested locale or is a fallback to the default locale.- Overrides:
getLocalein classResourceBundle- Returns:
- the locale of this resource bundle
-
getKeys
- Specified by:
getKeysin classResourceBundle
-
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
Changes the locale of this localization bundle. The bundle content will be loaded for the specified locale.- Parameters:
locale- the new locale.
-
changeLocale
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.
-
getStringWithParams
-
handleGetObject
- Specified by:
handleGetObjectin classResourceBundle
-