com.opensymphony.module.propertyset.xml
Class XMLPropertySet

java.lang.Object
  extended bycom.opensymphony.module.propertyset.AbstractPropertySet
      extended bycom.opensymphony.module.propertyset.memory.MemoryPropertySet
          extended bycom.opensymphony.module.propertyset.memory.SerializablePropertySet
              extended bycom.opensymphony.module.propertyset.xml.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.1.1.1 $
Author:
Joe Walnes
See Also:
PropertySet, SerializablePropertySet, Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.opensymphony.module.propertyset.memory.MemoryPropertySet
MemoryPropertySet.ValueEntry
 
Field Summary
 
Fields inherited from class com.opensymphony.module.propertyset.AbstractPropertySet
schema
 
Fields inherited from interface com.opensymphony.module.propertyset.PropertySet
BOOLEAN, DATA, DATE, DOUBLE, INT, LONG, OBJECT, PROPERTIES, STRING, TEXT, XML
 
Constructor Summary
XMLPropertySet()
           
 
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.memory.SerializablePropertySet
getMap, init, remove, setImpl
 
Methods inherited from class com.opensymphony.module.propertyset.memory.MemoryPropertySet
exists, get, getKeys, getType, remove
 
Methods inherited from class com.opensymphony.module.propertyset.AbstractPropertySet
getAsActualType, 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
 

Constructor Detail

XMLPropertySet

public XMLPropertySet()
Method Detail

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.

Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException

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.

Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException

loadFromDocument

public void loadFromDocument(org.w3c.dom.Document doc)
                      throws PropertyImplementationException
Load properties from XML document.

Throws:
PropertyImplementationException

save

public void save(java.io.Writer out)
          throws javax.xml.parsers.ParserConfigurationException,
                 java.io.IOException
Save properties to XML output.

Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException

save

public void save(java.io.OutputStream out)
          throws javax.xml.parsers.ParserConfigurationException,
                 java.io.IOException
Save properties to XML output.

Throws:
javax.xml.parsers.ParserConfigurationException
java.io.IOException

saveToDocument

public org.w3c.dom.Document saveToDocument()
                                    throws javax.xml.parsers.ParserConfigurationException
Save properties to XML Document.

Throws:
javax.xml.parsers.ParserConfigurationException

See www.opensymphony.com for more information.

Copyright 2000-2005 - OpenSymphony