messif.objects.nio
Class JavaToBinarySerializable

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.ByteArrayOutputStream
          extended by messif.objects.nio.JavaToBinarySerializable
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, BinarySerializable

public class JavaToBinarySerializable
extends java.io.ByteArrayOutputStream
implements BinarySerializable

This is a helper class to provide the BinarySerializable wrapping of the native serialization of Java.


Field Summary
 
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
JavaToBinarySerializable(java.lang.Object object)
          Creates an instance of a serialized version of the object.
 
Method Summary
static java.lang.Object binaryDeserialize(BinaryInput input, BinarySerializator serializator)
          Deserialize a previously stored object from input buffer.
 int binarySerialize(BinaryOutput output, BinarySerializator serializator)
          Binary-serialize this object into the output.
 int getBinarySize(BinarySerializator serializator)
          Returns the exact size of the binary-serialized version of this object in bytes.
 
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, write, write, writeTo
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaToBinarySerializable

public JavaToBinarySerializable(java.lang.Object object)
                         throws java.io.IOException
Creates an instance of a serialized version of the object.

Parameters:
object - the object from which to create a serialized version
Throws:
java.io.IOException - if there was an I/O error during serialization
Method Detail

binarySerialize

public int binarySerialize(BinaryOutput output,
                           BinarySerializator serializator)
                    throws java.io.IOException
Description copied from interface: BinarySerializable
Binary-serialize this object into the output.

Specified by:
binarySerialize in interface BinarySerializable
Parameters:
output - the binary output that this object is serialized into
serializator - the serializator used to write objects
Returns:
the number of bytes written
Throws:
java.io.IOException - if there was an I/O error during serialization

getBinarySize

public int getBinarySize(BinarySerializator serializator)
Description copied from interface: BinarySerializable
Returns the exact size of the binary-serialized version of this object in bytes.

Specified by:
getBinarySize in interface BinarySerializable
Parameters:
serializator - the serializator used to write objects
Returns:
size of the binary-serialized version of this object

binaryDeserialize

public static java.lang.Object binaryDeserialize(BinaryInput input,
                                                 BinarySerializator serializator)
                                          throws java.io.IOException
Deserialize a previously stored object from input buffer.

Parameters:
input - the buffer from which to read the object
serializator - the serializator used to read the data
Returns:
the previously stored object
Throws:
java.io.IOException - if there was an I/O error during deserialization