|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream java.io.ObjectInputStream rice.p2p.util.XMLObjectInputStream
public class XMLObjectInputStream
XMLObjectInputStreamm is an extension of ObjectInputStreamm which provides for deserialization for objects which have been converted to XML via a XMLObjectOutputStream. This class supports all of the features of the ObjectInputStreamm, including serialization support for any Java object graph implementing the Serializable interface, support for Externalizable classes, custom deserialization via the readObject() method, class evolution via the readObjectNoData() method, alternate field reading mechanisms via the readFields() method, support for the readUnshared method, and dynamic object replacement via the readResolve() method. The format of the XML data to be read in should conform to the JSX XML Schema, available online at http://www.jsx.org/jsx.xsd. This class is designed to be able to read objects serialized using JSX, however, this has not been fully tested and bugs may be encountered.
Nested Class Summary | |
---|---|
class |
XMLObjectInputStream.GetField
This class is an implementation of GetField which is compatible with the XMLObjectInputStreamm. |
Field Summary | |
---|---|
protected static SoftHashMap |
CONSTRUCTORS
A cache of constructors, mapping classes to serialization constructors |
protected java.util.Stack |
currentClasses
The stack of class types which are being read off of the stream |
protected java.util.Stack |
currentObjects
The stack of objects which are currently being read off of the stream |
protected int |
depth
The depth at which we are currently at in the object tree |
protected static SoftHashMap |
READ_OBJECTS
The hashmap of readObject methods, mapping Class->Method |
protected static SoftHashMap |
READ_RESOLVES
The hashmap of readResolve methods, mapping Class->Method |
protected XMLReader |
reader
The underlying reader, which parses the XML |
protected java.util.Hashtable |
references
The hashtable of references, which is updated each time a new object is read off of the stream. |
protected sun.reflect.ReflectionFactory |
reflFactory
The ReflectionFactory, which allows for prividged construction of objects |
protected rice.p2p.util.XMLObjectInputStream.ValidationList |
vlist
The list of validation objects waiting for the entire object graph to be read in |
Fields inherited from interface java.io.ObjectStreamConstants |
---|
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING |
Constructor Summary | |
---|---|
XMLObjectInputStream(java.io.InputStream in)
Constructor which reads data from the given input stream in order deserialize objects. |
Method Summary | |
---|---|
void |
close()
Method which closes the underlying input stream for reading. |
void |
defaultReadObject()
Method which can be called by objects if they have a readObject() method. |
protected java.lang.Class |
getClass(java.lang.String name)
Method which returns the class object for class names written to the stream. |
protected java.lang.Object |
getReference(java.lang.String reference)
Method which returns a previously stored reference. |
protected java.lang.reflect.Constructor |
getSerializableConstructor(java.lang.Class c)
Method which returns the Serializable constructor for the provided class. |
protected java.lang.Object |
newInstance(java.lang.Class c)
Method which returns a new instance of the provided class. |
protected void |
putReference(java.lang.String reference,
java.lang.Object o)
Method which adds a reference in the hashtable of references. |
int |
read()
Method which reads a byte from the underlying output stream. |
int |
read(byte[] b,
int offset,
int length)
Method which reads a array of bytes from the underlying output stream. |
protected java.lang.Object |
readArray(boolean shared)
Method which reads an array off of the stream. |
boolean |
readBoolean()
Method which reads a boolean from the stream and returns the result. |
protected boolean |
readBooleanHelper()
Method which reads an boolean from the stream. |
byte |
readByte()
Method which reads a byte from the stream and returns the result. |
protected byte |
readByteHelper()
Method which reads an byte from the stream. |
char |
readChar()
Method which reads a char from the stream and returns the result. |
protected char |
readCharHelper()
Method which reads an char from the stream. |
protected java.lang.Object |
readClass(java.lang.Object o)
Method which reads the information for one class for a given object from the stream. |
double |
readDouble()
Method which reads a double from the stream and returns the result. |
protected double |
readDoubleHelper()
Method which reads an double from the stream. |
protected void |
readField(java.lang.Object o,
java.lang.Class c)
Method which reads a single field from the stream, and assignes it to the provided object. |
java.io.ObjectInputStream.GetField |
readFields()
Method which can be called by objects if they have a readObject() method. |
protected void |
readFields(java.lang.Object o,
java.lang.Class c)
Method which initiates the default field reading mechanism for the given object's class. |
float |
readFloat()
Method which reads a float from the stream and returns the result. |
protected float |
readFloatHelper()
Method which reads an float from the stream. |
void |
readFully(byte[] b)
Method which reads a byte from the underlying output stream. |
void |
readFully(byte[] b,
int offset,
int length)
Method which reads a byte from the underlying output stream. |
protected void |
readGetField(XMLObjectInputStream.GetField g)
Method which read a single field from the stream and places it in the provided GetField object. |
protected XMLObjectInputStream.GetField |
readGetFields()
Method which reads all of the field data from the stream, as readFields() does, but instead of assigning the fields to the object, it returns them as a GetField object. |
int |
readInt()
Method which reads an int from the stream and returns the result. |
protected int |
readIntHelper()
Method which reads an int from the stream. |
long |
readLong()
Method which reads a long from the stream and returns the result. |
protected long |
readLongHelper()
Method which reads an long from the stream. |
protected java.lang.Object |
readNull()
Method which reads a null item off of the stream. |
protected java.lang.Object |
readObjectHelper()
Method which reads an object from the stream. |
protected java.lang.Object |
readObjectOverride()
Method which is called by ObjectInputStreamm.readObject(), and reads the next object from the stream, and returns the result. |
protected java.lang.Object |
readOrdinaryObject(boolean shared)
Method which reads an ordinary object from the stream (not a String or Array). |
protected java.lang.String |
readPrimitive(java.lang.String type)
Method which reads a primitive value from the stream and returns the String representation to the callee for processing. |
protected void |
readPrimitiveField(java.lang.Object o,
java.lang.reflect.Field f)
Method which reads a primitive field from the stream, and places it in the given object. |
protected void |
readPrimitiveGetField(XMLObjectInputStream.GetField g)
Method which reads a primitive field from the stream, and places it in the provided GetField object. |
protected java.lang.Object |
readReference()
Method which reads a reference off of the stream, and looks the reference up in the references table. |
short |
readShort()
Method which reads a short from the stream and returns the result. |
protected short |
readShortHelper()
Method which reads an short from the stream. |
protected void |
readStreamHeader()
Method which reads the XML header off of the stream. |
protected java.lang.Object |
readString(boolean shared)
Method which reads a string item off of the stream. |
protected void |
readUnreadOptionalData()
Method which reads any extra data from the stream which was not read by the object. |
java.lang.Object |
readUnshared()
Method which reads the next object from the stream and does not record a reference to the object. |
protected java.lang.Object |
readUnsharedHelper(boolean shared)
Method which reads an object from the stream. |
int |
readUnsignedByte()
Method which reads an unsigned byte from the underlying output stream. |
int |
readUnsignedShort()
Method which reads an unsigned short from the underlying output stream. |
java.lang.String |
readUTF()
Method which reads a UTF-encoded String from the stream and returns the result. |
void |
registerValidation(java.io.ObjectInputValidation obj,
int prio)
Register an object to be validated before the graph is returned. |
void |
reset()
Method which resets the input stream, which removes the binding of all previously stored references. |
Methods inherited from class java.io.ObjectInputStream |
---|
available, enableResolveObject, readClassDescriptor, readLine, readObject, resolveClass, resolveObject, resolveProxyClass, skipBytes |
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, read, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.io.ObjectInput |
---|
read, skip |
Field Detail |
---|
protected static SoftHashMap READ_RESOLVES
protected static SoftHashMap READ_OBJECTS
protected static SoftHashMap CONSTRUCTORS
protected XMLReader reader
protected java.util.Hashtable references
protected java.util.Stack currentObjects
protected java.util.Stack currentClasses
protected sun.reflect.ReflectionFactory reflFactory
protected rice.p2p.util.XMLObjectInputStream.ValidationList vlist
protected int depth
Constructor Detail |
---|
public XMLObjectInputStream(java.io.InputStream in) throws java.io.IOException
in
- The input stream to read data from
java.io.IOException
- If the stream header is corruptMethod Detail |
---|
protected void readStreamHeader() throws java.io.IOException
readStreamHeader
in class java.io.ObjectInputStream
java.io.IOException
- If the stream header is corruptpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.io.ObjectInput
close
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.io.IOException
- If an error occurspublic int read() throws java.io.IOException
read
in interface java.io.ObjectInput
read
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic int read(byte[] b, int offset, int length) throws java.io.IOException
read
in interface java.io.ObjectInput
read
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic void readFully(byte[] b) throws java.io.IOException
readFully
in interface java.io.DataInput
readFully
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic void readFully(byte[] b, int offset, int length) throws java.io.IOException
readFully
in interface java.io.DataInput
readFully
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic int readUnsignedByte() throws java.io.IOException
readUnsignedByte
in interface java.io.DataInput
readUnsignedByte
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic int readUnsignedShort() throws java.io.IOException
readUnsignedShort
in interface java.io.DataInput
readUnsignedShort
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic int readInt() throws java.io.IOException
readInt
in interface java.io.DataInput
readInt
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic boolean readBoolean() throws java.io.IOException
readBoolean
in interface java.io.DataInput
readBoolean
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic byte readByte() throws java.io.IOException
readByte
in interface java.io.DataInput
readByte
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic char readChar() throws java.io.IOException
readChar
in interface java.io.DataInput
readChar
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic double readDouble() throws java.io.IOException
readDouble
in interface java.io.DataInput
readDouble
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic float readFloat() throws java.io.IOException
readFloat
in interface java.io.DataInput
readFloat
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic long readLong() throws java.io.IOException
readLong
in interface java.io.DataInput
readLong
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic short readShort() throws java.io.IOException
readShort
in interface java.io.DataInput
readShort
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurspublic java.lang.String readUTF() throws java.io.IOException
readUTF
in interface java.io.DataInput
readUTF
in class java.io.ObjectInputStream
java.io.IOException
- If an error occursprotected java.lang.Object readObjectOverride() throws java.io.IOException, java.lang.ClassNotFoundException
readObjectOverride
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If a class in the stream cannot be foundpublic java.lang.Object readUnshared() throws java.io.IOException, java.lang.ClassNotFoundException
readUnshared
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If a class in the stream cannot be foundpublic void defaultReadObject() throws java.io.IOException, java.lang.ClassNotFoundException
defaultReadObject
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If a class in the stream cannot be found
java.io.NotActiveException
- If a object is not currently being readpublic java.io.ObjectInputStream.GetField readFields() throws java.io.IOException, java.lang.ClassNotFoundException
readFields
in class java.io.ObjectInputStream
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If a class in the stream cannot be found
java.io.NotActiveException
- If a object is not currently being readpublic void registerValidation(java.io.ObjectInputValidation obj, int prio) throws java.io.NotActiveException, java.io.InvalidObjectException
registerValidation
in class java.io.ObjectInputStream
obj
- the object to receive the validation callback.prio
- controls the order of callbacks
java.io.NotActiveException
- The stream is not currently reading objects
so it is invalid to register a callback.
java.io.InvalidObjectException
- The validation object is null.protected java.lang.reflect.Constructor getSerializableConstructor(java.lang.Class c) throws java.io.IOException, java.lang.NoSuchMethodException
c
- The class to fetch the constructor for
java.io.IOException
- If an error occurs
java.lang.NoSuchMethodException
- If the first non-Serializable class does not have a no-arg
Constructorprotected java.lang.Object newInstance(java.lang.Class c) throws java.io.IOException
c
- The class to create a new instance of
java.io.IOException
- If an error occursprotected java.lang.Class getClass(java.lang.String name) throws java.lang.ClassNotFoundException
name
- The name of the class to return
java.lang.ClassNotFoundException
- If the class cannot be foundprotected void putReference(java.lang.String reference, java.lang.Object o)
reference
- The reference name to useo
- The object to referenceprotected java.lang.Object getReference(java.lang.String reference)
reference
- The reference to use
protected java.lang.String readPrimitive(java.lang.String type) throws java.io.IOException
type
- The type of primitive which should be next
java.io.IOException
- If an error occursprotected int readIntHelper() throws java.io.IOException
type
- The type of primitive which should be next
java.io.IOException
- If an error occursprotected boolean readBooleanHelper() throws java.io.IOException
type
- The type of primitive which should be next
java.io.IOException
- If an error occursprotected byte readByteHelper() throws java.io.IOException
type
- The type of primitive which should be next
java.io.IOException
- If an error occursprotected char readCharHelper() throws java.io.IOException
type
- The type of primitive which should be next
java.io.IOException
- If an error occursprotected double readDoubleHelper() throws java.io.IOException
type
- The type of primitive which should be next
java.io.IOException
- If an error occursprotected float readFloatHelper() throws java.io.IOException
type
- The type of primitive which should be next
java.io.IOException
- If an error occursprotected long readLongHelper() throws java.io.IOException
type
- The type of primitive which should be next
java.io.IOException
- If an error occursprotected short readShortHelper() throws java.io.IOException
type
- The type of primitive which should be next
java.io.IOException
- If an error occursprotected java.lang.Object readObjectHelper() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be foundprotected java.lang.Object readUnsharedHelper(boolean shared) throws java.io.IOException, java.lang.ClassNotFoundException
shared
- Whether or not to record a reference to this object
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be foundprotected java.lang.Object readReference() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
- If an error occurs or if a reference is not found
java.lang.ClassNotFoundException
- If the class cannot be foundprotected java.lang.Object readNull() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be foundprotected java.lang.Object readString(boolean shared) throws java.io.IOException, java.lang.ClassNotFoundException
shared
- Whether or not to add this string to the references table
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be foundprotected java.lang.Object readOrdinaryObject(boolean shared) throws java.io.IOException, java.lang.ClassNotFoundException
shared
- Whether or not to record a reference to this object
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be found
java.io.NotSerializableException
- If the class to be deserialized is not Serializableprotected java.lang.Object readClass(java.lang.Object o) throws java.io.IOException, java.lang.ClassNotFoundException
o
- The object we are reading the the class for
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be foundprotected void readUnreadOptionalData() throws java.io.IOException, java.lang.ClassNotFoundException
o
- The object we are reading the the class for
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be foundprotected XMLObjectInputStream.GetField readGetFields() throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be foundprotected void readGetField(XMLObjectInputStream.GetField g) throws java.io.IOException, java.lang.ClassNotFoundException
g
- The GetField object into which the field should be put
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be foundprotected void readPrimitiveGetField(XMLObjectInputStream.GetField g) throws java.io.IOException, java.lang.ClassNotFoundException
g
- The GetField object to put the primitive in
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
protected void readFields(java.lang.Object o, java.lang.Class c) throws java.io.IOException, java.lang.ClassNotFoundException
o
- The object which is currently being read inc
- The class to read the fields for
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be foundprotected void readField(java.lang.Object o, java.lang.Class c) throws java.io.IOException, java.lang.ClassNotFoundException
o
- The object which is currently being read inc
- The class to read the fields for
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be foundprotected void readPrimitiveField(java.lang.Object o, java.lang.reflect.Field f) throws java.io.IOException, java.lang.IllegalAccessException
o
- The object to put the primitive inf
- The field representing the primitive about to be read
java.io.IOException
- If an error occurs
java.lang.IllegalAccessException
protected java.lang.Object readArray(boolean shared) throws java.io.IOException, java.lang.ClassNotFoundException
shared
- Whether or not to add this array to the references table
java.io.IOException
- If an error occurs
java.lang.ClassNotFoundException
- If the class cannot be found
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |