org.granite.messaging.jmf
Class JMFSerializer

java.lang.Object
  extended by org.granite.messaging.jmf.JMFSerializer
All Implemented Interfaces:
DataOutput, ObjectOutput, ExtendedObjectOutput, JMFConstants, OutputContext

public class JMFSerializer
extends Object
implements OutputContext

Author:
Franck WOLFF

Field Summary
protected  CodecRegistry codecRegistry
           
protected  SharedContext context
           
protected  OutputStream outputStream
           
protected  Map<Object,Integer> storedObjects
           
protected  Map<String,Integer> 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
JMFSerializer(OutputStream outputStream, SharedContext context)
           
 
Method Summary
 void addToStoredObjects(Object o)
           
 void addToStoredStrings(String s)
           
 void close()
           
 void flush()
           
 String getAlias(String className)
           
 void getAndWriteProperty(Object obj, Property property)
           
 OutputStream getOutputStream()
           
 Reflection getReflection()
          Return the Reflection registered in the global JMF SharedContext.
 SharedContext getSharedContext()
           
 int indexOfStoredObjects(Object o)
           
 int indexOfStoredStrings(String s)
           
 void write(byte[] b)
          Deprecated. 
 void write(byte[] b, int off, int len)
          Deprecated. 
 void write(int b)
          Deprecated. 
 void writeBoolean(boolean v)
           
 void writeByte(int v)
           
 void writeBytes(String s)
          Deprecated. 
 void writeChar(int v)
           
 void writeChars(String s)
          Deprecated. 
 void writeDouble(double v)
           
 void writeFloat(float v)
           
 void writeInt(int v)
           
 void writeLong(long v)
           
 void writeObject(Object obj)
           
 void writeShort(int v)
           
 void writeUTF(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

storedStrings

protected final Map<String,Integer> storedStrings

storedObjects

protected final Map<Object,Integer> storedObjects

outputStream

protected final OutputStream outputStream

context

protected final SharedContext context

codecRegistry

protected final CodecRegistry codecRegistry
Constructor Detail

JMFSerializer

public JMFSerializer(OutputStream outputStream,
                     SharedContext context)
Method Detail

writeBoolean

public void writeBoolean(boolean v)
                  throws IOException
Specified by:
writeBoolean in interface DataOutput
Throws:
IOException

writeByte

public void writeByte(int v)
               throws IOException
Specified by:
writeByte in interface DataOutput
Throws:
IOException

writeShort

public void writeShort(int v)
                throws IOException
Specified by:
writeShort in interface DataOutput
Throws:
IOException

writeChar

public void writeChar(int v)
               throws IOException
Specified by:
writeChar in interface DataOutput
Throws:
IOException

writeInt

public void writeInt(int v)
              throws IOException
Specified by:
writeInt in interface DataOutput
Throws:
IOException

writeLong

public void writeLong(long v)
               throws IOException
Specified by:
writeLong in interface DataOutput
Throws:
IOException

writeFloat

public void writeFloat(float v)
                throws IOException
Specified by:
writeFloat in interface DataOutput
Throws:
IOException

writeDouble

public void writeDouble(double v)
                 throws IOException
Specified by:
writeDouble in interface DataOutput
Throws:
IOException

writeUTF

public void writeUTF(String s)
              throws IOException
Specified by:
writeUTF in interface DataOutput
Throws:
IOException

writeObject

public void writeObject(Object obj)
                 throws IOException
Specified by:
writeObject in interface ObjectOutput
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface ObjectOutput
Throws:
IOException

close

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

write

@Deprecated
public void write(int b)
           throws IOException
Deprecated. 

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Specified by:
write in interface ExtendedObjectOutput
Throws:
IOException

write

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

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Specified by:
write in interface ExtendedObjectOutput
Throws:
IOException

write

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

Specified by:
write in interface DataOutput
Specified by:
write in interface ObjectOutput
Specified by:
write in interface ExtendedObjectOutput
Throws:
IOException

writeBytes

@Deprecated
public void writeBytes(String s)
                throws IOException
Deprecated. 

Specified by:
writeBytes in interface DataOutput
Specified by:
writeBytes in interface ExtendedObjectOutput
Throws:
IOException

writeChars

@Deprecated
public void writeChars(String s)
                throws IOException
Deprecated. 

Specified by:
writeChars in interface DataOutput
Specified by:
writeChars in interface ExtendedObjectOutput
Throws:
IOException

getSharedContext

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

getOutputStream

public OutputStream getOutputStream()
Specified by:
getOutputStream in interface OutputContext

addToStoredStrings

public void addToStoredStrings(String s)
Specified by:
addToStoredStrings in interface OutputContext

indexOfStoredStrings

public int indexOfStoredStrings(String s)
Specified by:
indexOfStoredStrings in interface OutputContext

addToStoredObjects

public void addToStoredObjects(Object o)
Specified by:
addToStoredObjects in interface OutputContext

indexOfStoredObjects

public int indexOfStoredObjects(Object o)
Specified by:
indexOfStoredObjects in interface OutputContext

getReflection

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

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

getAlias

public String getAlias(String className)
Specified by:
getAlias in interface ExtendedObjectOutput

getAndWriteProperty

public void getAndWriteProperty(Object obj,
                                Property property)
                         throws IOException,
                                IllegalAccessException,
                                InvocationTargetException
Specified by:
getAndWriteProperty in interface ExtendedObjectOutput
Throws:
IOException
IllegalAccessException
InvocationTargetException