de.grogra.persistence
Class XMLPersistenceWriter

java.lang.Object
  extended by de.grogra.persistence.XMLPersistenceWriter
All Implemented Interfaces:
PersistenceOutput
Direct Known Subclasses:
XMLGraphWriter

public class XMLPersistenceWriter
extends java.lang.Object
implements PersistenceOutput

An XMLPersistenceWriter serializes data into XML elements and attributes. The output can be deserialized by an instance of XMLPersistenceReader.

Author:
Ole Kniemeyer

Field Summary
protected  PersistenceOutputListener listener
           
static java.lang.String NAMESPACE
           
static org.xml.sax.Attributes NS_ATTRIBUTE
           
static java.lang.String NS_PREFIX
           
 
Constructor Summary
XMLPersistenceWriter(org.xml.sax.ContentHandler ch, PersistenceOutputListener listener)
           
 
Method Summary
 void beginArray(int length, Type ct)
           
 void beginExtent(PersistenceManager manager)
           
 void beginField(ManageableType.Field field)
           
 void beginFields()
           
 boolean beginManaged(ManageableType type, boolean writeType)
           
 void endArray()
           
protected  void endElement(java.lang.String name)
           
 void endExtent()
           
 void endField(ManageableType.Field field)
           
 void endFields()
           
 void endManaged(java.lang.Object object, boolean writeType)
           
 void getAttributes(PersistenceCapable o, org.xml.sax.helpers.AttributesImpl attr)
           
 org.xml.sax.ContentHandler getContentHandler()
           
 void setNested(boolean nested)
           
protected  void startElement(java.lang.String name, org.xml.sax.Attributes attr)
           
 java.lang.String toString(Manageable o)
          This method serializes o into a single string which may be used, e.g., as an attribute value of an XML element.
 java.lang.String toString(Type type, java.lang.Object o)
          This method serializes o of type type into a single string which may be used, e.g., as an attribute value of an XML element.
 void writeBoolean(boolean v)
           
 void writeByte(int v)
           
 void writeChar(int v)
           
 void writeDouble(double v)
           
 void writeFields(Manageable o)
           
 void writeFloat(float v)
           
 void writeInt(int v)
           
 void writeLong(long v)
           
 void writeName(java.lang.String v)
           
 void writeNullObject()
           
 void writeObject(java.lang.Object v, Type type)
           
 void writePersistentObjectReference(PersistenceCapable o)
           
 void writeSharedObjectReference(Shareable o)
           
 void writeShort(int v)
           
 void writeString(java.lang.String v)
           
 void writeStringObject(java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listener

protected final PersistenceOutputListener listener

NAMESPACE

public static final java.lang.String NAMESPACE
See Also:
Constant Field Values

NS_ATTRIBUTE

public static final org.xml.sax.Attributes NS_ATTRIBUTE

NS_PREFIX

public static final java.lang.String NS_PREFIX
See Also:
Constant Field Values
Constructor Detail

XMLPersistenceWriter

public XMLPersistenceWriter(org.xml.sax.ContentHandler ch,
                            PersistenceOutputListener listener)
Method Detail

beginArray

public void beginArray(int length,
                       Type ct)
                throws java.io.IOException
Specified by:
beginArray in interface PersistenceOutput
Throws:
java.io.IOException

beginExtent

public void beginExtent(PersistenceManager manager)
                 throws java.io.IOException
Throws:
java.io.IOException

beginField

public void beginField(ManageableType.Field field)
                throws java.io.IOException
Specified by:
beginField in interface PersistenceOutput
Throws:
java.io.IOException

beginFields

public void beginFields()
Specified by:
beginFields in interface PersistenceOutput

beginManaged

public boolean beginManaged(ManageableType type,
                            boolean writeType)
                     throws java.io.IOException
Specified by:
beginManaged in interface PersistenceOutput
Throws:
java.io.IOException

endArray

public void endArray()
              throws java.io.IOException
Specified by:
endArray in interface PersistenceOutput
Throws:
java.io.IOException

endElement

protected void endElement(java.lang.String name)
                   throws java.io.IOException
Throws:
java.io.IOException

endExtent

public void endExtent()
               throws java.io.IOException
Throws:
java.io.IOException

endField

public void endField(ManageableType.Field field)
              throws java.io.IOException
Specified by:
endField in interface PersistenceOutput
Throws:
java.io.IOException

endFields

public void endFields()
Specified by:
endFields in interface PersistenceOutput

endManaged

public void endManaged(java.lang.Object object,
                       boolean writeType)
                throws java.io.IOException
Specified by:
endManaged in interface PersistenceOutput
Throws:
java.io.IOException

getAttributes

public void getAttributes(PersistenceCapable o,
                          org.xml.sax.helpers.AttributesImpl attr)
                   throws java.io.IOException
Throws:
java.io.IOException

getContentHandler

public org.xml.sax.ContentHandler getContentHandler()

setNested

public void setNested(boolean nested)
Specified by:
setNested in interface PersistenceOutput

startElement

protected void startElement(java.lang.String name,
                            org.xml.sax.Attributes attr)
                     throws java.io.IOException
Throws:
java.io.IOException

toString

public java.lang.String toString(Manageable o)
This method serializes o into a single string which may be used, e.g., as an attribute value of an XML element. The value can be deserialized using XMLPersistenceReader.valueOf(Manageable, String).

Parameters:
o - the value to be serialized
Returns:
a string describing o

toString

public java.lang.String toString(Type type,
                                 java.lang.Object o)
This method serializes o of type type into a single string which may be used, e.g., as an attribute value of an XML element. The value can be deserialized using XMLPersistenceReader.valueOf(Type, String).

Parameters:
type - the type of o
o - the value to be serialized
Returns:
a string describing o

writeBoolean

public void writeBoolean(boolean v)
                  throws java.io.IOException
Specified by:
writeBoolean in interface PersistenceOutput
Throws:
java.io.IOException

writeByte

public void writeByte(int v)
               throws java.io.IOException
Specified by:
writeByte in interface PersistenceOutput
Throws:
java.io.IOException

writeChar

public void writeChar(int v)
               throws java.io.IOException
Specified by:
writeChar in interface PersistenceOutput
Throws:
java.io.IOException

writeDouble

public void writeDouble(double v)
                 throws java.io.IOException
Specified by:
writeDouble in interface PersistenceOutput
Throws:
java.io.IOException

writeFields

public void writeFields(Manageable o)
                 throws java.io.IOException
Throws:
java.io.IOException

writeFloat

public void writeFloat(float v)
                throws java.io.IOException
Specified by:
writeFloat in interface PersistenceOutput
Throws:
java.io.IOException

writeInt

public void writeInt(int v)
              throws java.io.IOException
Specified by:
writeInt in interface PersistenceOutput
Throws:
java.io.IOException

writeLong

public void writeLong(long v)
               throws java.io.IOException
Specified by:
writeLong in interface PersistenceOutput
Throws:
java.io.IOException

writeName

public void writeName(java.lang.String v)
Specified by:
writeName in interface PersistenceOutput

writeNullObject

public void writeNullObject()
                     throws java.io.IOException
Specified by:
writeNullObject in interface PersistenceOutput
Throws:
java.io.IOException

writeObject

public void writeObject(java.lang.Object v,
                        Type type)
                 throws java.io.IOException
Specified by:
writeObject in interface PersistenceOutput
Throws:
java.io.IOException

writePersistentObjectReference

public void writePersistentObjectReference(PersistenceCapable o)
                                    throws java.io.IOException
Specified by:
writePersistentObjectReference in interface PersistenceOutput
Throws:
java.io.IOException

writeSharedObjectReference

public void writeSharedObjectReference(Shareable o)
                                throws java.io.IOException
Specified by:
writeSharedObjectReference in interface PersistenceOutput
Throws:
java.io.IOException

writeShort

public void writeShort(int v)
                throws java.io.IOException
Specified by:
writeShort in interface PersistenceOutput
Throws:
java.io.IOException

writeString

public void writeString(java.lang.String v)
Specified by:
writeString in interface PersistenceOutput

writeStringObject

public void writeStringObject(java.lang.String value)
                       throws java.io.IOException
Specified by:
writeStringObject in interface PersistenceOutput
Throws:
java.io.IOException