com.opensymphony.module.propertyset
Class XMLPropertySet
java.lang.Object
|
+--com.opensymphony.module.propertyset.AbstractPropertySet
|
+--com.opensymphony.module.propertyset.MemoryPropertySet
|
+--com.opensymphony.module.propertyset.SerializablePropertySet
|
+--com.opensymphony.module.propertyset.XMLPropertySet
- All Implemented Interfaces:
- PropertySet, java.io.Serializable
- public class XMLPropertySet
- extends SerializablePropertySet
The XMLPropertySet behaves as an in-memory typed PropertySet, with the ability to
load and save all the properties to/from an XML document.
- boolean, int, long, double and String properties are saved as simple Text nodes.
- text and XML properties are stored as CDATA blocks.
- java.util.Date properties are stored in
yyyy-mm-dd HH:mm:ss
format.
- java.util.Properties properties are stored in child elements.
- java.lang.Object and byte[] data properties are encoded using base64 into text and stored as CDATA blocks.
Example:
XMLPropertySet p = new XMLPropertySet(); // create blank property-set
p.load( new FileReader("my-properties.xml") ); // load properties from XML.
System.out.println( p.getString("name") );
p.setString("name","blah blah");
p.save( new FileWriter("my-properties.xml") ); // save properties back to XML.
- Version:
- $Revision: 1.5 $
- Author:
- Joe Walnes
- See Also:
PropertySet
,
SerializablePropertySet
, Serialized Form
Fields inherited from interface com.opensymphony.module.propertyset.PropertySet |
BOOLEAN, DATA, DATE, DOUBLE, INT, LONG, OBJECT, PROPERTIES, STRING, TEXT, XML |
Method Summary |
void |
load(java.io.InputStream in)
Load properties from XML input. |
void |
load(java.io.Reader in)
Load properties from XML input. |
void |
loadFromDocument(org.w3c.dom.Document doc)
Load properties from XML document. |
void |
save(java.io.OutputStream out)
Save properties to XML output. |
void |
save(java.io.Writer out)
Save properties to XML output. |
org.w3c.dom.Document |
saveToDocument()
Save properties to XML Document. |
Methods inherited from class com.opensymphony.module.propertyset.AbstractPropertySet |
getBoolean, getData, getDate, getDouble, getInt, getKeys, getKeys, getKeys, getLong, getObject, getProperties, getSchema, getString, getText, getXML, isSettable, setAsActualType, setBoolean, setData, setDate, setDouble, setInt, setLong, setObject, setProperties, setSchema, setString, setText, setXML, supportsType, supportsTypes, toString, type, type |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
XMLPropertySet
public XMLPropertySet()
saveToDocument
public org.w3c.dom.Document saveToDocument()
throws javax.xml.parsers.ParserConfigurationException
- Save properties to XML Document.
save
public void save(java.io.Writer out)
throws javax.xml.parsers.ParserConfigurationException,
java.io.IOException
- Save properties to XML output.
save
public void save(java.io.OutputStream out)
throws javax.xml.parsers.ParserConfigurationException,
java.io.IOException
- Save properties to XML output.
loadFromDocument
public void loadFromDocument(org.w3c.dom.Document doc)
throws PropertyImplementationException
- Load properties from XML document.
load
public void load(java.io.Reader in)
throws javax.xml.parsers.ParserConfigurationException,
java.io.IOException,
org.xml.sax.SAXException
- Load properties from XML input.
load
public void load(java.io.InputStream in)
throws javax.xml.parsers.ParserConfigurationException,
java.io.IOException,
org.xml.sax.SAXException
- Load properties from XML input.