Class 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 by org.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 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 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
    • Method Detail

      • keySet

        public Set<String> keySet()
        Returns a Set of all keys contained in this ResourceBundle and its parent bundles.
        Specified by:
        keySet in interface SilverpeasBundle
        Overrides:
        keySet in class ResourceBundle
        Returns:
        a Set of all keys contained in this ResourceBundle and its parent bundles.
        Since:
        1.6
      • specificKeySet

        public Set<String> specificKeySet()
        Returns a Set of the specific keys contained in this ResourceBundle. The keys from the general resource bundle aren't taken into account.
        Returns:
        a Set of specific keys contained in this ResourceBundle.
      • containsKey

        public boolean containsKey​(String key)
        Determines whether the given key is contained in this ResourceBundle or its parent bundles.
        Specified by:
        containsKey in interface SilverpeasBundle
        Overrides:
        containsKey in class ResourceBundle
        Parameters:
        key - the resource key
        Returns:
        true if the given key is contained in this ResourceBundle or its parent bundles; false otherwise.
        Throws:
        NullPointerException - if key is null
        Since:
        1.6
      • 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 class ResourceBundle
        Returns:
        the locale of this resource bundle
      • 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 interface SilverpeasBundle
        Returns:
        true if this bundle exists, false otherwise.
      • getStringWithParams

        public String getStringWithParams​(String resName,
                                          Object... params)