net.sf.plist.io.domxml
Class DOMXMLWriter

java.lang.Object
  extended by net.sf.plist.io.PropertyListWriter
      extended by net.sf.plist.io.domxml.DOMXMLWriter

public class DOMXMLWriter
extends PropertyListWriter

Serializes a tree consisting of NSObjects to an XML property list


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.plist.io.PropertyListWriter
PropertyListWriter.Format
 
Field Summary
protected  DocumentBuilder db
          The DocumentBuilder
protected static DocumentBuilderFactory dbf
          The DocumentBuilderFactory
protected  Document doc
          The XML document
static String DOCTYPE_PUBLIC
          The public declaration of the document type
static String DOCTYPE_SYSTEM
          The URL of the document type
static String VERSION
          Version of this XML format
 
Fields inherited from class net.sf.plist.io.PropertyListWriter
defaultFormat, root
 
Constructor Summary
DOMXMLWriter(NSObject root)
           
 
Method Summary
protected  Element generateArray(NSArray array)
          Convert an NSArray to an XML element
protected  Element generateBoolean(NSBoolean bool)
          Convert an NSBoolean to an XML element
protected  Element generateData(NSData data)
          Convert an NSData to an XML element
protected  Element generateDate(NSDate date)
          Convert an NSDate to an XML element
protected  Element generateDictionary(NSDictionary dictionary)
          Convert an NSDictionary to an XML element
protected  Element generateInteger(NSInteger integer)
          Convert an NSInteger to an XML element
protected  Element generateKey(String name)
          Creates a key XML element
protected  Element generateNode(NSObject obj)
          Convert an NSObject to an XML element
protected  Element generateReal(NSReal real)
          Convert an NSReal to an XML element
protected  Element generateString(NSString string)
          Convert an NSString to an XML element
 void write(OutputStream stream)
          Write the property list to a stream
 void write(OutputStream stream, boolean indent)
          Convert a tree to a XML property list and write it to a stream
 
Methods inherited from class net.sf.plist.io.PropertyListWriter
write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

doc

protected final Document doc
The XML document


dbf

protected static final DocumentBuilderFactory dbf
The DocumentBuilderFactory


db

protected final DocumentBuilder db
The DocumentBuilder


DOCTYPE_PUBLIC

public static final String DOCTYPE_PUBLIC
The public declaration of the document type

See Also:
Constant Field Values

DOCTYPE_SYSTEM

public static final String DOCTYPE_SYSTEM
The URL of the document type

See Also:
Constant Field Values

VERSION

public static final String VERSION
Version of this XML format

See Also:
Constant Field Values
Constructor Detail

DOMXMLWriter

public DOMXMLWriter(NSObject root)
             throws ParserConfigurationException
Throws:
ParserConfigurationException
See Also:
PropertyListWriter.PropertyListWriter(NSObject)
Method Detail

write

public void write(OutputStream stream)
           throws DOMException,
                  PropertyListException,
                  IOException
Write the property list to a stream

Specified by:
write in class PropertyListWriter
Parameters:
stream - the stream to write the property list to
Throws:
PropertyListException - when generating the property list fails
IOException - when writing to the stream fails
DOMException

write

public void write(OutputStream stream,
                  boolean indent)
           throws DOMException,
                  PropertyListException,
                  IOException
Convert a tree to a XML property list and write it to a stream

Parameters:
stream - the stream to write the property list to
indent - whether the resulting XML file should be indented
Throws:
DOMException - when an error occurred generating the XML document
PropertyListException - when generating the property list fails
IOException - if an I/O error occurs

generateNode

protected Element generateNode(NSObject obj)
                        throws PropertyListException
Convert an NSObject to an XML element

Parameters:
obj - the NSObject to convert
Returns:
the XML element
Throws:
PropertyListException - when generating the property list fails

generateArray

protected Element generateArray(NSArray array)
                         throws DOMException,
                                PropertyListException
Convert an NSArray to an XML element

Parameters:
array - the NSArray to convert
Returns:
the XML element
Throws:
PropertyListException - when generating the property list fails
DOMException

generateBoolean

protected Element generateBoolean(NSBoolean bool)
Convert an NSBoolean to an XML element

Parameters:
bool - the NSBoolean to convert
Returns:
the XML element
Throws:
PropertyListException - when generating the property list fails

generateData

protected Element generateData(NSData data)
Convert an NSData to an XML element

Parameters:
data - the NSData to convert
Returns:
the XML element
Throws:
PropertyListException - when generating the property list fails

generateDate

protected Element generateDate(NSDate date)
Convert an NSDate to an XML element

Parameters:
date - the NSDate to convert
Returns:
the XML element
Throws:
PropertyListException - when generating the property list fails

generateDictionary

protected Element generateDictionary(NSDictionary dictionary)
                              throws DOMException,
                                     PropertyListException
Convert an NSDictionary to an XML element

Parameters:
dictionary - the NSDictionary to convert
Returns:
the XML element
Throws:
PropertyListException - when generating the property list fails
DOMException

generateReal

protected Element generateReal(NSReal real)
Convert an NSReal to an XML element

Parameters:
real - the NSReal to convert
Returns:
the XML element
Throws:
PropertyListException - when generating the property list fails

generateInteger

protected Element generateInteger(NSInteger integer)
Convert an NSInteger to an XML element

Parameters:
integer - the NSInteger to convert
Returns:
the XML element
Throws:
PropertyListException - when generating the property list fails

generateString

protected Element generateString(NSString string)
Convert an NSString to an XML element

Parameters:
string - the NSString to convert
Returns:
the XML element
Throws:
PropertyListException - when generating the property list fails

generateKey

protected Element generateKey(String name)
Creates a key XML element

Parameters:
name - the name of the key
Returns:
the XML element
Throws:
PropertyListException - when generating the property list fails