Package org.silverpeas.kernel.bundle
Class XmlSettingBundle
java.lang.Object
org.silverpeas.kernel.bundle.XmlSettingBundle
- All Implemented Interfaces:
SilverpeasBundle
- Direct Known Subclasses:
XmlSettingBundle.SettingSection
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:
- mmoquillon
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedXmlSettingBundle(String name, Function<String, InputStream> loader) -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(String key) Is this bundle contains the specified parameter?booleanexists()Is this bundle exists?getAllSettingSection(String path) Gets all the setting sections in this XML setting bundle that are all located at the specified path.What is the fully qualified name of this bundle.protected NodegetSettingSection(String path) Gets the first setting section in this XML setting bundle that is identified by the specified path.Gets the value as a String of the parameter identified by the specified key.String[]getStringArray(String key) Gets all the values as a String of the parameter identified by the specified key.keySet()Gets a set of all the parameter names defined in this bundle.Methods 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
getStringList, getStringList
-
Constructor Details
-
XmlSettingBundle
-
-
Method Details
-
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 nameddriveris defined in a sectionfooitself defined in the root nodeconfiguration, then the fully qualified parameter will beconfiguration.toto.driver.- Specified by:
keySetin interfaceSilverpeasBundle- Returns:
- a set of keys.
-
containsKey
Is this bundle contains the specified parameter?- Specified by:
containsKeyin interfaceSilverpeasBundle- 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 nameddriveris defined in a sectionfooitself defined in the current root nodeconfiguration, then the unique name will be either the absolute oneconfiguration.toto.driveror the relative onetoto.driver.- Returns:
- true if this bundle has the specified parameter, false otherwise.
-
getBaseBundleName
What is the fully qualified name of this bundle.- Specified by:
getBaseBundleNamein interfaceSilverpeasBundle- Returns:
- the base bundle name (that is to say without the hierarchy path name that is handled by
org.silverpeas.core.util.ResourceLocator).
-
getString
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 ajava.util.MissingResourceExceptionexception is thrown.- Specified by:
getStringin interfaceSilverpeasBundle- 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 nameddriveris defined in a sectionfooitself defined in the root nodeconfiguration, then the unique name will be either the absolute oneconfiguration.toto.driveror the relative onetoto.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#getStringArraymethod. - Throws:
MissingResourceException- if either the bundle doesn't exist or the key isn't defined in the bundle.
-
getStringArray
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 ajava.util.MissingResourceExceptionexception 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 nameddriveris defined in a sectionfooitself defined in the root nodeconfiguration, then the unique name will be either the absolute oneconfiguration.toto.driveror the relative onetoto.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:
existsin interfaceSilverpeasBundle- Returns:
- true if this bundle exists, false otherwise.
-
getSettingSection
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 ajava.util.MissingResourceExceptionexception 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 sectionservicesin a nodefooitself defined in the current root nodeconfiguration, then path could be either the absolute oneconfiguration.toto.servicesor the relative onetoto.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
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 ajava.util.MissingResourceExceptionexception 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 sectionsservicein a nodeservicesitself defined in the current root nodeconfiguration, then the path could be either the absolute oneconfiguration.services.serviceor the relative oneservices.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
-