com.atomikos.util
Class SerializationUtils

java.lang.Object
  extended by com.atomikos.util.SerializationUtils

public class SerializationUtils
extends Object

Mostly a copy/paste of Commons Lang SerializationUtils (v3.x).


Constructor Summary
SerializationUtils()
           
 
Method Summary
static
<T> T
deserialize(byte[] objectData)
           Deserializes a single Object from an array of bytes.
static byte[] serialize(Serializable obj)
          Serializes an Object to a byte array for storage/serialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializationUtils

public SerializationUtils()
Method Detail

serialize

public static byte[] serialize(Serializable obj)

Serializes an Object to a byte array for storage/serialization.

Parameters:
obj - the object to serialize to bytes
Returns:
a byte[] with the converted Serializable
Throws:
RuntimeException - (runtime) if the serialization fails

deserialize

public static <T> T deserialize(byte[] objectData)

Deserializes a single Object from an array of bytes.

If the call site incorrectly types the return value, a ClassCastException is thrown from the call site. Without Generics in this declaration, the call site must type cast and can cause the same ClassCastException. Note that in both cases, the ClassCastException is in the call site, not in this method.

Type Parameters:
T - the object type to be deserialized
Parameters:
objectData - the serialized object, must not be null
Returns:
the deserialized object
Throws:
IllegalArgumentException - if objectData is null


Copyright © 2014. All Rights Reserved.