| java.lang.Object org.jivesoftware.util.XMLProperties
XMLProperties | public class XMLProperties (Code) | | Provides the the ability to use simple XML property files. Each property is
in the form X.Y.Z, which would map to an XML snippet of:
<X>
<Y>
<Z>someValue</Z>
</Y>
</X>
The XML file is passed in to the constructor and must be readable and
writtable. Setting property values will automatically persist those value
to disk. The file encoding used is UTF-8.
author: Derek DeMoro author: Iain Shigeoka |
XMLProperties | public XMLProperties(String fileName) throws IOException(Code) | | Creates a new XMLPropertiesTest object.
Parameters: fileName - the full path the file that properties should be read fromand written to. throws: IOException - if an error occurs loading the properties. |
XMLProperties | public XMLProperties(InputStream in) throws IOException(Code) | | Loads XML properties from a stream.
Parameters: in - the input stream of XML. throws: IOException - if an exception occurs when reading the stream. |
XMLProperties | public XMLProperties(File file) throws IOException(Code) | | Creates a new XMLPropertiesTest object.
Parameters: file - the file that properties should be read from and written to. throws: IOException - if an error occurs loading the properties. |
deleteProperty | public synchronized void deleteProperty(String name)(Code) | | Deletes the specified property.
Parameters: name - the property to delete. |
getAttribute | public String getAttribute(String name, String attribute)(Code) | | Returns the value of the attribute of the given property name or null
if it doesn't exist. Note, this
Parameters: name - the property name to lookup - ie, "foo.bar" Parameters: attribute - the name of the attribute, ie "id" the value of the attribute of the given property or null ifit doesn't exist. |
getChildProperties | public Iterator getChildProperties(String name)(Code) | | Return all values who's path matches the given property
name as a String array, or an empty array if the if there
are no children. This allows you to retrieve several values
with the same property name. For example, consider the
XML file entry:
<foo>
<bar>
<prop>some value</prop>
<prop>other value</prop>
<prop>last value</prop>
</bar>
</foo>
If you call getProperties("foo.bar.prop") will return a string array containing
{"some value", "other value", "last value"}.
Parameters: name - the name of the property to retrieve all child property values for the given node name. |
getChildrenProperties | public String[] getChildrenProperties(String parent)(Code) | | Return all children property names of a parent property as a String array,
or an empty array if the if there are no children. For example, given
the properties X.Y.A, X.Y.B, and X.Y.C, then
the child properties of X.Y are A, B, and
C.
Parameters: parent - the name of the parent property. all child property values for the given parent. |
getProperties | public String[] getProperties(String name)(Code) | | Return all values who's path matches the given property
name as a String array, or an empty array if the if there
are no children. This allows you to retrieve several values
with the same property name. For example, consider the
XML file entry:
<foo>
<bar>
<prop>some value</prop>
<prop>other value</prop>
<prop>last value</prop>
</bar>
</foo>
If you call getProperties("foo.bar.prop") will return a string array containing
{"some value", "other value", "last value"}.
Parameters: name - the name of the property to retrieve all child property values for the given node name. |
getProperty | public synchronized String getProperty(String name)(Code) | | Returns the value of the specified property.
Parameters: name - the name of the property to get. the value of the specified property. |
setProperties | public void setProperties(String name, List<String> values)(Code) | | Sets a property to an array of values. Multiple values matching the same property
is mapped to an XML file as multiple elements containing each value.
For example, using the name "foo.bar.prop", and the value string array containing
{"some value", "other value", "last value"} would produce the following XML:
<foo>
<bar>
<prop>some value</prop>
<prop>other value</prop>
<prop>last value</prop>
</bar>
</foo>
Parameters: name - the name of the property. Parameters: values - the values for the property (can be empty but not null). |
setProperty | public synchronized void setProperty(String name, String value)(Code) | | Sets the value of the specified property. If the property doesn't
currently exist, it will be automatically created.
Parameters: name - the name of the property to set. Parameters: value - the new value for the property. |
|
|