org.granite.messaging.jmf
Class JMFDeserializer

java.lang.Object
  extended by org.granite.messaging.jmf.JMFDeserializer
All Implemented Interfaces:
DataInput, ObjectInput, ExtendedObjectInput, InputContext, JMFConstants
Direct Known Subclasses:
JMFDumper

public class JMFDeserializer
extends Object
implements InputContext

Author:
Franck WOLFF

Field Summary
protected  CodecRegistry codecRegistry
           
protected  SharedContext context
           
protected  InputStream inputStream
           
protected  List<Object> storedObjects
           
protected  List<String> storedStrings
           
 
Fields inherited from interface org.granite.messaging.jmf.JMFConstants
CLIENT_PERSISTENCE_COLLECTION_PACKAGE, JMF_1111_1010, JMF_1111_1011, JMF_1111_1100, JMF_1111_1101, JMF_1111_1110, JMF_1111_1111, JMF_ARRAY, JMF_ARRAY_LIST, JMF_BIG_DECIMAL, JMF_BIG_INTEGER, JMF_BOOLEAN, JMF_BOOLEAN_OBJECT, JMF_BYTE, JMF_BYTE_OBJECT, JMF_CHARACTER, JMF_CHARACTER_OBJECT, JMF_CLASS, JMF_DATE, JMF_DOUBLE, JMF_DOUBLE_OBJECT, JMF_ENUM, JMF_FLOAT, JMF_FLOAT_OBJECT, JMF_HASH_MAP, JMF_HASH_SET, JMF_INTEGER, JMF_INTEGER_OBJECT, JMF_LONG, JMF_LONG_OBJECT, JMF_NULL, JMF_OBJECT, JMF_OBJECT_END, JMF_SHORT, JMF_SHORT_OBJECT, JMF_SQL_DATE, JMF_SQL_TIME, JMF_SQL_TIMESTAMP, JMF_STRING, JMF_X011_1100, JMF_X011_1101, JMF_X011_1110, JMF_X011_1111, JMF_XX01_1110, JMF_XX01_1111, JMF_XXX0_1110, JMF_XXX0_1111, JMF_XXXX_0110, JMF_XXXX_0111, UTF8
 
Constructor Summary
JMFDeserializer(InputStream is, SharedContext context)
           
 
Method Summary
 int addSharedObject(Object o)
           
 int addSharedString(String s)
           
 int addUnresolvedSharedObject(String className)
           
 int available()
           
 void close()
           
 String getAlias(String remoteAlias)
           
 InputStream getInputStream()
           
 Reflection getReflection()
          Return the Reflection registered in the global JMF SharedContext.
 SharedContext getSharedContext()
           
 Object getSharedObject(int index)
           
 String getSharedString(int index)
           
 int read()
          Deprecated. 
 int read(byte[] b)
          Deprecated. 
 int read(byte[] b, int off, int len)
          Deprecated. 
 void readAndSetProperty(Object obj, Property property)
          Read the next data in the current input stream and set the given field of the given Object obj with this data.
 boolean readBoolean()
           
 byte readByte()
           
 char readChar()
           
 double readDouble()
           
 float readFloat()
           
 void readFully(byte[] b)
          Deprecated. 
 void readFully(byte[] b, int off, int len)
          Deprecated. 
 int readInt()
           
 String readLine()
          Deprecated. 
 long readLong()
           
 Object readObject()
           
 short readShort()
           
 int readUnsignedByte()
           
 int readUnsignedShort()
           
 String readUTF()
           
 int safeRead()
           
 void safeReadFully(byte[] b)
           
 void safeReadFully(byte[] b, int off, int len)
           
 void safeSkip(long n)
           
 Object setUnresolvedSharedObject(int index, Object o)
           
 long skip(long n)
          Deprecated. 
 int skipBytes(int n)
          Deprecated. 
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

storedStrings

protected final List<String> storedStrings

storedObjects

protected final List<Object> storedObjects

inputStream

protected final InputStream inputStream

context

protected final SharedContext context

codecRegistry

protected final CodecRegistry codecRegistry
Constructor Detail

JMFDeserializer

public JMFDeserializer(InputStream is,
                       SharedContext context)
Method Detail

readBoolean

public boolean readBoolean()
                    throws IOException
Specified by:
readBoolean in interface DataInput
Throws:
IOException

readByte

public byte readByte()
              throws IOException
Specified by:
readByte in interface DataInput
Throws:
IOException

readUnsignedByte

public int readUnsignedByte()
                     throws IOException
Specified by:
readUnsignedByte in interface DataInput
Throws:
IOException

readShort

public short readShort()
                throws IOException
Specified by:
readShort in interface DataInput
Throws:
IOException

readUnsignedShort

public int readUnsignedShort()
                      throws IOException
Specified by:
readUnsignedShort in interface DataInput
Throws:
IOException

readChar

public char readChar()
              throws IOException
Specified by:
readChar in interface DataInput
Throws:
IOException

readInt

public int readInt()
            throws IOException
Specified by:
readInt in interface DataInput
Throws:
IOException

readLong

public long readLong()
              throws IOException
Specified by:
readLong in interface DataInput
Throws:
IOException

readFloat

public float readFloat()
                throws IOException
Specified by:
readFloat in interface DataInput
Throws:
IOException

readDouble

public double readDouble()
                  throws IOException
Specified by:
readDouble in interface DataInput
Throws:
IOException

readUTF

public String readUTF()
               throws IOException
Specified by:
readUTF in interface DataInput
Throws:
IOException

readObject

public Object readObject()
                  throws ClassNotFoundException,
                         IOException
Specified by:
readObject in interface ObjectInput
Throws:
ClassNotFoundException
IOException

available

public int available()
              throws IOException
Specified by:
available in interface ObjectInput
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface ObjectInput
Throws:
IOException

read

@Deprecated
public int read()
         throws IOException
Deprecated. 

Description copied from interface: ExtendedObjectInput
Should never be used with JMF ExtendedObjectCodec. Use DataInput.readByte() instead.

Specified by:
read in interface ObjectInput
Specified by:
read in interface ExtendedObjectInput
Throws:
IOException

read

@Deprecated
public int read(byte[] b)
         throws IOException
Deprecated. 

Description copied from interface: ExtendedObjectInput
Should never be used with JMF ExtendedObjectCodec. Use (byte[])ObjectInput.readObject() instead.

Specified by:
read in interface ObjectInput
Specified by:
read in interface ExtendedObjectInput
Throws:
IOException

read

@Deprecated
public int read(byte[] b,
                           int off,
                           int len)
         throws IOException
Deprecated. 

Description copied from interface: ExtendedObjectInput
Should never be used with JMF ExtendedObjectCodec. Use (byte[])ObjectInput.readObject() instead.

Specified by:
read in interface ObjectInput
Specified by:
read in interface ExtendedObjectInput
Throws:
IOException

readFully

@Deprecated
public void readFully(byte[] b)
               throws IOException
Deprecated. 

Description copied from interface: ExtendedObjectInput
Should never be used with JMF ExtendedObjectCodec. Use (byte[])ObjectInput.readObject() instead.

Specified by:
readFully in interface DataInput
Specified by:
readFully in interface ExtendedObjectInput
Throws:
IOException

readFully

@Deprecated
public void readFully(byte[] b,
                                 int off,
                                 int len)
               throws IOException
Deprecated. 

Description copied from interface: ExtendedObjectInput
Should never be used with JMF ExtendedObjectCodec. Use (byte[])ObjectInput.readObject() instead.

Specified by:
readFully in interface DataInput
Specified by:
readFully in interface ExtendedObjectInput
Throws:
IOException

readLine

@Deprecated
public String readLine()
                throws IOException
Deprecated. 

Description copied from interface: ExtendedObjectInput
Should never be used with JMF ExtendedObjectCodec. Use DataInput.readUTF() instead and parse the String.

Specified by:
readLine in interface DataInput
Specified by:
readLine in interface ExtendedObjectInput
Throws:
IOException

skipBytes

@Deprecated
public int skipBytes(int n)
              throws IOException
Deprecated. 

Description copied from interface: ExtendedObjectInput
Should never be used with JMF ExtendedObjectCodec.

Specified by:
skipBytes in interface DataInput
Specified by:
skipBytes in interface ExtendedObjectInput
Throws:
IOException

skip

@Deprecated
public long skip(long n)
          throws IOException
Deprecated. 

Description copied from interface: ExtendedObjectInput
Should never be used with JMF ExtendedObjectCodec.

Specified by:
skip in interface ObjectInput
Specified by:
skip in interface ExtendedObjectInput
Throws:
IOException

getSharedContext

public SharedContext getSharedContext()
Specified by:
getSharedContext in interface InputContext

getInputStream

public InputStream getInputStream()
Specified by:
getInputStream in interface InputContext

safeRead

public int safeRead()
             throws IOException
Specified by:
safeRead in interface InputContext
Throws:
IOException

safeReadFully

public void safeReadFully(byte[] b)
                   throws IOException
Specified by:
safeReadFully in interface InputContext
Throws:
IOException

safeReadFully

public void safeReadFully(byte[] b,
                          int off,
                          int len)
                   throws IOException
Specified by:
safeReadFully in interface InputContext
Throws:
IOException

safeSkip

public void safeSkip(long n)
              throws IOException
Specified by:
safeSkip in interface InputContext
Throws:
IOException

addSharedString

public int addSharedString(String s)
Specified by:
addSharedString in interface InputContext

getSharedString

public String getSharedString(int index)
Specified by:
getSharedString in interface InputContext

addSharedObject

public int addSharedObject(Object o)
Specified by:
addSharedObject in interface InputContext

getSharedObject

public Object getSharedObject(int index)
Specified by:
getSharedObject in interface InputContext

addUnresolvedSharedObject

public int addUnresolvedSharedObject(String className)
Specified by:
addUnresolvedSharedObject in interface InputContext

setUnresolvedSharedObject

public Object setUnresolvedSharedObject(int index,
                                        Object o)
Specified by:
setUnresolvedSharedObject in interface InputContext

getReflection

public Reflection getReflection()
Description copied from interface: ExtendedObjectInput
Return the Reflection registered in the global JMF SharedContext.

Specified by:
getReflection in interface ExtendedObjectInput
Returns:
A Reflection utility that can be used to load classes during the deserialization process.

getAlias

public String getAlias(String remoteAlias)
Specified by:
getAlias in interface ExtendedObjectInput

readAndSetProperty

public void readAndSetProperty(Object obj,
                               Property property)
                        throws IOException,
                               ClassNotFoundException,
                               IllegalAccessException,
                               InvocationTargetException
Description copied from interface: ExtendedObjectInput
Read the next data in the current input stream and set the given field of the given Object obj with this data. This method is only a convenient shortcut for reading data from the input stream and setting the value of a Field to this data without knowing its type. For example, given a field f1 of type boolean (the primitive type) and a field f2 of type int (the primitive type):
 in.readAndSetProperty(obj, f1);
 in.readAndSetProperty(obj, f2);
 
is equivalent to:
 f1.setBoolean(obj, in.readBoolean());
 f2.setInt(obj, in.readInt());
 

Specified by:
readAndSetProperty in interface ExtendedObjectInput
Parameters:
obj - The instance of the class declaring the property.
property - The property to set with the read value.
Throws:
IOException - If any I/O error occur.
JMFEncodingException - If read data isn't of expected type (ie. the type of the given property).
ClassNotFoundException - If the class of a serialized object cannot be found.
IllegalAccessException - If the property cannot be accessed.
InvocationTargetException