de.grogra.persistence
Class XMLPersistenceReader

java.lang.Object
  extended by de.grogra.persistence.XMLPersistenceReader
All Implemented Interfaces:
PersistenceInput
Direct Known Subclasses:
XMLGraphReader

public class XMLPersistenceReader
extends java.lang.Object
implements PersistenceInput

An XMLPersistenceReader is used to read the serialization output of an XMLPersistenceWriter.

Author:
Ole Kniemeyer

Field Summary
 
Fields inherited from interface de.grogra.persistence.PersistenceInput
ARRAY_OBJECT, MANAGEABLE_OBJECT, MIN_UNUSED_KIND, NULL_OBJECT, PERSISTENT_OBJECT_ID, PLAIN_OBJECT, SERIALIZED_OBJECT, SHARED_OBJECT_REFERENCE, STRING_OBJECT
 
Constructor Summary
XMLPersistenceReader(PersistenceBindings bindings)
           
 
Method Summary
 boolean areFieldsProvided()
           
 int beginArray()
           
 boolean beginComponent(ManageableType.ArrayComponent c, int index)
           
 ManageableType.Field beginField(ManageableType type, ManageableType.Field field)
           
 ManageableType beginManaged()
           
 void endArray()
           
 void endComponent()
           
 void endField()
           
 void endManaged()
           
 PersistenceBindings getBindings()
           
protected  ManageableType.Field getManagedField(ManageableType t, java.lang.String name)
           
 int getNextObjectKind()
           
 PersistenceCapable getObject(long id)
           
 java.lang.String peekName()
           
 void readAttribute(PersistenceCapable object, java.lang.String uri, java.lang.String name, java.lang.String value)
           
 boolean readBoolean()
           
 byte readByte()
           
 char readChar()
           
 double readDouble()
           
 void readElements(PersistenceCapable object, SAXElement parent)
           
 float readFloat()
           
 int readInt()
           
 long readLong()
           
 java.lang.String readName()
           
 java.lang.Object readObject(int kind, Type type)
           
 PersistenceCapable readPersistentObject()
           
 long readPersistentObjectId()
           
 Shareable readSharedObject()
           
 short readShort()
           
 java.lang.String readString()
           
 int readUnsignedByte()
           
 int readUnsignedShort()
           
 void registerObject(long id, PersistenceCapable o)
           
protected  java.lang.String replaceType(java.lang.String type)
           
 void resolve()
           
 PersistenceCapable resolveId(long inputId)
           
 void setNested(boolean nested)
           
 void valueOf(Manageable object, java.lang.String value)
          Deserializes a string into an existing object.
 java.lang.Object valueOf(Type type, java.lang.String s)
          Deserializes a string into an object of the given type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLPersistenceReader

public XMLPersistenceReader(PersistenceBindings bindings)
Method Detail

areFieldsProvided

public boolean areFieldsProvided()
Specified by:
areFieldsProvided in interface PersistenceInput

beginArray

public int beginArray()
               throws java.io.IOException
Specified by:
beginArray in interface PersistenceInput
Throws:
java.io.IOException

beginComponent

public boolean beginComponent(ManageableType.ArrayComponent c,
                              int index)
                       throws java.io.IOException
Specified by:
beginComponent in interface PersistenceInput
Throws:
java.io.IOException

beginField

public ManageableType.Field beginField(ManageableType type,
                                       ManageableType.Field field)
                                throws java.io.IOException
Specified by:
beginField in interface PersistenceInput
Throws:
java.io.IOException

beginManaged

public ManageableType beginManaged()
                            throws java.io.IOException
Specified by:
beginManaged in interface PersistenceInput
Throws:
java.io.IOException

endArray

public void endArray()
Specified by:
endArray in interface PersistenceInput

endComponent

public void endComponent()
Specified by:
endComponent in interface PersistenceInput

endField

public void endField()
Specified by:
endField in interface PersistenceInput

endManaged

public void endManaged()
                throws java.io.IOException
Specified by:
endManaged in interface PersistenceInput
Throws:
java.io.IOException

getBindings

public PersistenceBindings getBindings()
Specified by:
getBindings in interface PersistenceInput

getManagedField

protected ManageableType.Field getManagedField(ManageableType t,
                                               java.lang.String name)

getNextObjectKind

public int getNextObjectKind()
                      throws java.io.IOException
Specified by:
getNextObjectKind in interface PersistenceInput
Throws:
java.io.IOException

getObject

public PersistenceCapable getObject(long id)

peekName

public java.lang.String peekName()
                          throws java.io.IOException
Throws:
java.io.IOException

readAttribute

public final void readAttribute(PersistenceCapable object,
                                java.lang.String uri,
                                java.lang.String name,
                                java.lang.String value)
                         throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

readBoolean

public boolean readBoolean()
                    throws java.io.IOException
Specified by:
readBoolean in interface PersistenceInput
Throws:
java.io.IOException

readByte

public byte readByte()
              throws java.io.IOException
Specified by:
readByte in interface PersistenceInput
Throws:
java.io.IOException

readChar

public char readChar()
              throws java.io.IOException
Specified by:
readChar in interface PersistenceInput
Throws:
java.io.IOException

readDouble

public double readDouble()
                  throws java.io.IOException
Specified by:
readDouble in interface PersistenceInput
Throws:
java.io.IOException

readElements

public final void readElements(PersistenceCapable object,
                               SAXElement parent)
                        throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

readFloat

public float readFloat()
                throws java.io.IOException
Specified by:
readFloat in interface PersistenceInput
Throws:
java.io.IOException

readInt

public int readInt()
            throws java.io.IOException
Specified by:
readInt in interface PersistenceInput
Throws:
java.io.IOException

readLong

public long readLong()
              throws java.io.IOException
Specified by:
readLong in interface PersistenceInput
Throws:
java.io.IOException

readName

public java.lang.String readName()
                          throws java.io.IOException
Specified by:
readName in interface PersistenceInput
Throws:
java.io.IOException

readObject

public java.lang.Object readObject(int kind,
                                   Type type)
                            throws java.io.IOException
Specified by:
readObject in interface PersistenceInput
Throws:
java.io.IOException

readPersistentObject

public PersistenceCapable readPersistentObject()
                                        throws java.io.IOException
Specified by:
readPersistentObject in interface PersistenceInput
Throws:
java.io.IOException

readPersistentObjectId

public long readPersistentObjectId()
                            throws java.io.IOException
Specified by:
readPersistentObjectId in interface PersistenceInput
Throws:
java.io.IOException

readSharedObject

public Shareable readSharedObject()
                           throws java.io.IOException
Specified by:
readSharedObject in interface PersistenceInput
Throws:
java.io.IOException

readShort

public short readShort()
                throws java.io.IOException
Specified by:
readShort in interface PersistenceInput
Throws:
java.io.IOException

readString

public java.lang.String readString()
                            throws java.io.IOException
Specified by:
readString in interface PersistenceInput
Throws:
java.io.IOException

readUnsignedByte

public int readUnsignedByte()
                     throws java.io.IOException
Specified by:
readUnsignedByte in interface PersistenceInput
Throws:
java.io.IOException

readUnsignedShort

public int readUnsignedShort()
                      throws java.io.IOException
Specified by:
readUnsignedShort in interface PersistenceInput
Throws:
java.io.IOException

registerObject

public void registerObject(long id,
                           PersistenceCapable o)

replaceType

protected java.lang.String replaceType(java.lang.String type)

resolve

public void resolve()

resolveId

public PersistenceCapable resolveId(long inputId)
Specified by:
resolveId in interface PersistenceInput

setNested

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

valueOf

public void valueOf(Manageable object,
                    java.lang.String value)
Deserializes a string into an existing object. The string must have been generated by XMLPersistenceWriter.toString(Manageable) with an object argument of the same class.

Parameters:
object - the object's content will be set using the serialized description in value
value - the serialized description of the object

valueOf

public java.lang.Object valueOf(Type type,
                                java.lang.String s)
                         throws java.lang.InstantiationException,
                                java.lang.IllegalAccessException,
                                java.lang.reflect.InvocationTargetException,
                                java.lang.ClassNotFoundException
Deserializes a string into an object of the given type. The string must have been generated by XMLPersistenceWriter.toString(Type, Object) with the same type as argument.

Parameters:
type - the type of the object to deserialize
s - the serialized description of the object
Returns:
deserialized object
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.ClassNotFoundException