uk.ac.ebi.intact.util
Class Serializer

java.lang.Object
  |
  +--uk.ac.ebi.intact.util.Serializer

public class Serializer
extends java.lang.Object

Simple utility class for checking serialization for objects. Typically used in test cases to check particular objects whose serialization behaviour may be unknown.

Author:
Chris Lewington

Constructor Summary
Serializer()
           
 
Method Summary
protected static java.lang.Object deserialize(byte[] bytes)
          simple method to deserialize an array of bytes.
protected static byte[] serialize(java.io.Serializable obj)
          simple method to serialize an object.
static java.lang.Object serializeDeserialize(java.io.Serializable obj)
          performs serialization and then deserialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Serializer

public Serializer()
Method Detail

serializeDeserialize

public static java.lang.Object serializeDeserialize(java.io.Serializable obj)
performs serialization and then deserialization. If it fails, a runtime exception is thrown - otherwise the original object is returned.

Parameters:
obj - - the object to serialize
Returns:
Object the oroginal object, if serialization was successful

serialize

protected static byte[] serialize(java.io.Serializable obj)
                           throws java.io.IOException
simple method to serialize an object.

Parameters:
obj - - an object to serialize
Returns:
byte[] a byte array of the serialized object
Throws:
java.io.IOException - thrown if the serialization failed

deserialize

protected static java.lang.Object deserialize(byte[] bytes)
                                       throws java.io.IOException,
                                              java.lang.ClassNotFoundException
simple method to deserialize an array of bytes.

Parameters:
bytes - - the array which should hopefully be an object (!)
Returns:
Object the deserialized object
Throws:
java.io.IOException - if there were byte stream problems
java.lang.ClassNotFoundException - thrown if the object to construct cannot be found


IntAct Project - EMBL-EBI 2004 - intact-help@ebi.ac.uk