messif.objects.nio
Interface BinarySerializable

All Known Implementing Classes:
AbstractObjectKey, DoubleKey, DoubleKeyInterval, IntegerKey, JavaToBinarySerializable, LongKey, MetaObjectMap, ObjectByteVector, ObjectByteVectorL1, ObjectFloatUnitVector, ObjectFloatUnitVectorL2, ObjectFloatVector, ObjectFloatVectorL1, ObjectFloatVectorL2, ObjectIntVector, ObjectIntVectorL1, ObjectIntVectorL2, ObjectShortVector, ObjectShortVectorL1, ObjectShortVectorL2, ObjectString, ObjectStringEditDist, PrecompDistPerforatedArrayFilter, PrecomputedDistancesFilter, PrecomputedDistancesFixedArrayFilter, PrecomputedDistancesPivotMapFilter

public interface BinarySerializable

The BinarySerializable interface marks the implementing class to be able to serialize itself into a stream of bytes provided by the BinarySerializator.

The class should be able to reconstruct itself from these data by providing either a constructor or a factory method. The factory method should have the following prototype:

      ObjectClass binaryDeserialize(BinaryInput input, BinarySerializator serializator) throws IOException
 
The constructor should have the following prototype:
      ClassConstructor(BinaryInput input, BinarySerializator serializator) throws IOException
 
The access specificator of the construtor or the factory method is not important and can be even private.

See Also:
JavaToBinarySerializable, BinarySerializator

Method Summary
 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.
 

Method Detail

getBinarySize

int getBinarySize(BinarySerializator serializator)
Returns the exact size of the binary-serialized version of this object in bytes.

Parameters:
serializator - the serializator used to write objects
Returns:
size of the binary-serialized version of this object

binarySerialize

int binarySerialize(BinaryOutput output,
                    BinarySerializator serializator)
                    throws java.io.IOException
Binary-serialize this object into the output.

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