Class XmlSettingBundle

  • All Implemented Interfaces:
    SilverpeasBundle
    Direct Known Subclasses:
    XmlSettingBundle.SettingSection

    public class XmlSettingBundle
    extends Object
    implements SilverpeasBundle
    A bundle of settings in XML used to configure some features in Silverpeas or the behaviour of an application.

    The settings in a such bundle are structured into a tree of setting sections and are schema or DTD free. Each non-leave node defines a setting section and the only constrain is how each setting is defined: by the XML element param that must be made up of the following leaf XML elements.

     param = param-name param-description? param-value+
     
    with ? meaning zero element or more and + meaning at least one element.

    The content of an XML bundle is cached but there is no expiration-based mechanism of this cache.

    If the XML content of the bundle is malformed, then a java.util.MissingResourceException exception is thrown.

    Author:
    miguel
    • Method Detail

      • keySet

        public Set<String> keySet()
        Gets a set of all the parameter names defined in this bundle. Each parameter name is fully qualified: it is made up of the complete path from the root node down to the parameter, each node name separated by a dot. For example, if a param named driver is defined in a section foo itself defined in the root node configuration, then the fully qualified parameter will be configuration.toto.driver.
        Specified by:
        keySet in interface SilverpeasBundle
        Returns:
        a set of keys.
      • containsKey

        public boolean containsKey​(String key)
        Is this bundle contains the specified parameter?
        Specified by:
        containsKey in interface SilverpeasBundle
        Parameters:
        key - the absolute or relative fully qualified name of the parameter. It is made up of the path from the root node down to the parameter with the given name, each node separated by a dot. For example, if a parameter named driver is defined in a section foo itself defined in the current root node configuration, then the unique name will be either the absolute one configuration.toto.driver or the relative one toto.driver.
        Returns:
        true if this bundle has the specified parameter, false otherwise.
      • getBaseBundleName

        public String getBaseBundleName()
        What is the fully qualified name of this bundle.
        Specified by:
        getBaseBundleName in interface SilverpeasBundle
        Returns:
        the base bundle name (that is to say without the hierarchy path name that is handled by org.silverpeas.core.util.ResourceLocator).
      • getString

        public String getString​(String key)
        Gets the value as a String of the parameter identified by the specified key. The key is the fully qualified name of a parameter and should exist in the bundle otherwise a java.util.MissingResourceException exception is thrown.
        Specified by:
        getString in interface SilverpeasBundle
        Parameters:
        key - the unique name of the parameter in this bundle. It is made up of the absolute or relative path from the root node down to the parameter, each node name separated by a dot. For example, if a parameter named driver is defined in a section foo itself defined in the root node configuration, then the unique name will be either the absolute one configuration.toto.driver or the relative one toto.driver.
        Returns:
        the value of the data as a string of characters. If several values are defined for the specified parameter, then returns null. In that case, use the org.silverpeas.core.util.XmlSettingBundle#getStringArray method.
        Throws:
        MissingResourceException - if either the bundle doesn't exist or the key isn't defined in the bundle.
      • getStringArray

        public String[] getStringArray​(String key)
        Gets all the values as a String of the parameter identified by the specified key. The key is the fully qualified name of a parameter and should exist in the bundle otherwise a java.util.MissingResourceException exception is thrown.
        Parameters:
        key - the unique name of the parameter in this bundle. It is made up of the absolute or relative path from the root node down to the parameter, each node name separated by a dot. For example, if a parameter named driver is defined in a section foo itself defined in the root node configuration, then the unique name will be either the absolute one configuration.toto.driver or the relative one toto.driver.
        Returns:
        the value of the data as a string of characters. If several values are defined for the specified parameter, then returns null.
        Throws:
        MissingResourceException - if either the bundle doesn't exist or the key isn't defined in the bundle.
      • exists

        public boolean exists()
        Is this bundle exists?
        Specified by:
        exists in interface SilverpeasBundle
        Returns:
        true if this bundle exists, false otherwise.
      • getSettingSection

        public XmlSettingBundle.SettingSection getSettingSection​(String path)
        Gets the first setting section in this XML setting bundle that is identified by the specified path. The section is itself an XML setting bundle whose the root node is set to the node located at the specified path. All the parameter queries will be then done from this new root node (id est from the section). The path must identify a section and not a parameter otherwise a java.util.MissingResourceException exception could be thrown.
        Parameters:
        path - the path of an XML node that represents a configuration section that can contain subsections and parameters. The path is either absolute or relative to the current root node down to the node to return, each node name separated by a dot. For example, to get a section services in a node foo itself defined in the current root node configuration, then path could be either the absolute one configuration.toto.services or the relative one toto.services.
        Returns:
        the asked XML setting section.
        Throws:
        MissingResourceException - if the specified node doesn't exist in the XML setting bundle or if the specified node represents a parameter and not a section.
      • getAllSettingSection

        public List<XmlSettingBundle.SettingSection> getAllSettingSection​(String path)
        Gets all the setting sections in this XML setting bundle that are all located at the specified path. The sections are themselves an XML setting bundle whose the root node is set to a node located at the specified path. All the parameter queries will be then done from this new root node (id est from the section). The path must identify a section and not a parameter otherwise a java.util.MissingResourceException exception could be thrown.
        Parameters:
        path - the path of the XML nodes that represent each of them a configuration section that can contain subsections and parameters. The path is either absolute or relative to the current root node down to the nodes to return, each node name separated by a dot. For example, to get all the sections service in a node services itself defined in the current root node configuration, then the path could be either the absolute one configuration.services.service or the relative one services.service.
        Returns:
        a list of the asked XML setting sections.
        Throws:
        MissingResourceException - if no nodes at the specified path are found in the XML setting bundle or if the specified node represents a parameter and not a section.
      • getCurrentRootNode

        protected Node getCurrentRootNode()