|
Openfire 3.6.0 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jivesoftware.util.XMLProperties
public class XMLProperties
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.
Constructor Summary | |
---|---|
XMLProperties(File file)
Creates a new XMLPropertiesTest object. |
|
XMLProperties(InputStream in)
Loads XML properties from a stream. |
|
XMLProperties(String fileName)
Creates a new XMLPropertiesTest object. |
Method Summary | |
---|---|
void |
deleteProperty(String name)
Deletes the specified property. |
String |
getAttribute(String name,
String attribute)
Returns the value of the attribute of the given property name or null if it doesn't exist. |
Iterator |
getChildProperties(String name)
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. |
String[] |
getChildrenProperties(String parent)
Return all children property names of a parent property as a String array, or an empty array if the if there are no children. |
String[] |
getProperties(String name)
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. |
String |
getProperty(String name)
Returns the value of the specified property. |
void |
setProperties(Map<String,String> propertyMap)
|
void |
setProperties(String name,
List<String> values)
Sets a property to an array of values. |
void |
setProperty(String name,
String value)
Sets the value of the specified property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLProperties(String fileName) throws IOException
fileName
- the full path the file that properties should be read from
and written to.
IOException
- if an error occurs loading the properties.public XMLProperties(InputStream in) throws IOException
in
- the input stream of XML.
IOException
- if an exception occurs when reading the stream.public XMLProperties(File file) throws IOException
file
- the file that properties should be read from and written to.
IOException
- if an error occurs loading the properties.Method Detail |
---|
public String getProperty(String name)
name
- the name of the property to get.
public String[] getProperties(String name)
<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"}.
name
- the name of the property to retrieve
public Iterator getChildProperties(String name)
<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"}.
name
- the name of the property to retrieve
public String getAttribute(String name, String attribute)
name
- the property name to lookup - ie, "foo.bar"attribute
- the name of the attribute, ie "id"
public void setProperties(String name, List<String> values)
<foo> <bar> <prop>some value</prop> <prop>other value</prop> <prop>last value</prop> </bar> </foo>
name
- the name of the property.values
- the values for the property (can be empty but not null).public String[] getChildrenProperties(String parent)
parent
- the name of the parent property.
public void setProperty(String name, String value)
name
- the name of the property to set.value
- the new value for the property.public void deleteProperty(String name)
name
- the property to delete.public void setProperties(Map<String,String> propertyMap)
|
Openfire 3.6.0 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |