goodsjpi
Class SerializableObjectFactory

java.lang.Object
  extended bygoodsjpi.SerializableObjectFactory
All Implemented Interfaces:
RawBinaryFactory

public class SerializableObjectFactory
extends java.lang.Object
implements RawBinaryFactory

Factory for raw binary objects using Java serialization mechanism


Constructor Summary
SerializableObjectFactory()
           
 
Method Summary
 int pack(java.lang.Object obj, byte[] arr, int offs)
          Pack raw binary object to byte array
 int size(java.lang.Object obj)
          Get size of raw binary object in bytes
 boolean supports(java.lang.Class cls)
          Check if specified las supported by thisd factory
 java.lang.Object unpack(java.lang.Class cls, byte[] arr, int off, int size)
          Unpack raw binary object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializableObjectFactory

public SerializableObjectFactory()
Method Detail

size

public int size(java.lang.Object obj)
Description copied from interface: RawBinaryFactory
Get size of raw binary object in bytes

Specified by:
size in interface RawBinaryFactory
Parameters:
obj - raw binary object
Returns:
size of packed raw binary object

pack

public int pack(java.lang.Object obj,
                byte[] arr,
                int offs)
Description copied from interface: RawBinaryFactory
Pack raw binary object to byte array

Specified by:
pack in interface RawBinaryFactory
Parameters:
obj - raw binary object
arr - array to store packed image of raw binary object
offs - offset in the array where object should be packed
Returns:
bumer of bytes in packed object image. It should be the same as returned by RawBinary.size method.

unpack

public java.lang.Object unpack(java.lang.Class cls,
                               byte[] arr,
                               int off,
                               int size)
Description copied from interface: RawBinaryFactory
Unpack raw binary object

Specified by:
unpack in interface RawBinaryFactory
Parameters:
cls - class of raw binary object
arr - array containing packed raw binary object
off - offset of packed binary object in the array
size - size of packed binary object
Returns:
created raw binary object with unpacked content

supports

public boolean supports(java.lang.Class cls)
Description copied from interface: RawBinaryFactory
Check if specified las supported by thisd factory

Specified by:
supports in interface RawBinaryFactory
Parameters:
cls - raw binary object class
Returns:
true if factory is able to pack/unpack instances of these class