fipaos.util
Class Serialize


public class Serialize

This class provides some simple Serialization primitives


Method Summary
 static Objectduplicate(Object in)
          Duplicates the given object using serialization - completely decouples both copies.
 static voidmain(String[] args)
           
 static byte[]toByteArray(Object o)
          Serialises the given object into a byte[]
 static ObjecttoObject(byte[] in)
          Reconstructs a serialised object from a byte[] to an Object

Method Detail

duplicate

public static Object duplicate(Object in)

Duplicates the given object using serialization - completely decouples both copies.

WARNING: This is potentially an order of magnitude slower than manually cloning an object

Parameters:
in - Object to duplicate
Returns: Duplicate object, or null if an error occured

main

public static void main(String[] args)

toByteArray

public static byte[] toByteArray(Object o)
Serialises the given object into a byte[]
Parameters:
o - Object to serialise
Returns: Byte[] containing the serialised object, or null if the object couldn't be serialised

toObject

public static Object toObject(byte[] in)
Reconstructs a serialised object from a byte[] to an Object
Parameters:
in - The byte[] containing a serialised object
Returns: The Object contained in the byte array, or null if it couldn't be de-serialized