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.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 the resource bundle of the given name. The loading of the resources bundles in Silverpeas is managed byorg.silverpeas.core.util.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 aMissingResourceException
exception is thrown as defined in theResourceBundle
contract.To handle the general localized resources and those from the given bundle name it uses an instance of
java.util.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:
ResourceBundle
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.ResourceBundle
ResourceBundle.Control
-
-
Field Summary
Fields Modifier and Type Field Description static String
GENERAL_BUNDLE_NAME
-
Fields inherited from class java.util.ResourceBundle
parent
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
LocalizationBundle(String name, Locale locale, BiFunction<String,Locale,ResourceBundle> loader, boolean mandatory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
changeLocale(String locale)
Changes the locale of this localization bundle.void
changeLocale(Locale locale)
Changes the locale of this localization bundle.boolean
containsKey(String key)
Determines whether the givenkey
is contained in thisResourceBundle
or its parent bundles.boolean
exists()
Is this bundle exists?String
getBaseBundleName()
Returns the base name of this bundle, if known, ornull
if unknown.Enumeration<String>
getKeys()
Locale
getLocale()
Returns the locale of this resource bundle.Enumeration<String>
getSpecificKeys()
Gets the specific keys of this bundle.String
getStringWithParams(String resName, Object... params)
protected Object
handleGetObject(String key)
Set<String>
keySet()
Returns aSet
of all keys contained in thisResourceBundle
and its parent bundles.Set<String>
specificKeySet()
Returns aSet
of 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 aSet
of all keys contained in thisResourceBundle
and its parent bundles.- Specified by:
keySet
in interfaceSilverpeasBundle
- Overrides:
keySet
in classResourceBundle
- Returns:
- a
Set
of all keys contained in thisResourceBundle
and its parent bundles. - Since:
- 1.6
-
specificKeySet
public Set<String> specificKeySet()
Returns aSet
of the specific keys contained in thisResourceBundle
. Thekeys
from the general resource bundle aren't taken into account.- Returns:
- a
Set
of specific keys contained in thisResourceBundle
.
-
containsKey
public boolean containsKey(String key)
Determines whether the givenkey
is contained in thisResourceBundle
or its parent bundles.- Specified by:
containsKey
in interfaceSilverpeasBundle
- Overrides:
containsKey
in classResourceBundle
- Parameters:
key
- the resourcekey
- Returns:
true
if the givenkey
is contained in thisResourceBundle
or its parent bundles;false
otherwise.- Throws:
NullPointerException
- ifkey
isnull
- Since:
- 1.6
-
getBaseBundleName
public String getBaseBundleName()
Returns the base name of this bundle, if known, ornull
if unknown.If not null, then this is the value of the
baseName
parameter that was passed to theResourceBundle.getBundle(...)
method when the resource bundle was loaded.- Specified by:
getBaseBundleName
in interfaceSilverpeasBundle
- Overrides:
getBaseBundleName
in 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:
getLocale
in classResourceBundle
- Returns:
- the locale of this resource bundle
-
getKeys
public Enumeration<String> getKeys()
- Specified by:
getKeys
in 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:
exists
in interfaceSilverpeasBundle
- Returns:
- true if this bundle exists, false otherwise.
-
handleGetObject
protected Object handleGetObject(String key)
- Specified by:
handleGetObject
in classResourceBundle
-
-