com.jstatcom.util
Class SerializationHelper

java.lang.Object
  extended by com.jstatcom.util.SerializationHelper

public final class SerializationHelper
extends java.lang.Object

Helper methods for (de)serialization and de/encoding to strings.

Author:
Markus Kraetzig

Constructor Summary
SerializationHelper()
           
 
Method Summary
static
<T> T
decode(java.lang.String encodedString)
          Decode Base64 encoded string (with encode).
static java.lang.String encode(java.lang.Object o)
          Base64 encoding of serializable objects.
static byte[] getByteFromObject(java.lang.Object o)
          Serializes o to a byte array representation.
static
<T> T
getObjectFromByteArray(byte[] byteArray)
          Deserializes an object from the byte array representation of the serialized version.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerializationHelper

public SerializationHelper()
Method Detail

getByteFromObject

public static byte[] getByteFromObject(java.lang.Object o)
Serializes o to a byte array representation.

Parameters:
o - object to serialize
Returns:
byte array with serialized o
Throws:
java.lang.IllegalArgumentException - if (!(o instanceof Serializable))

getObjectFromByteArray

public static <T> T getObjectFromByteArray(byte[] byteArray)
Deserializes an object from the byte array representation of the serialized version.

Parameters:
byteArray - byte array representation of serialized object
Returns:
deserialized object

encode

public static java.lang.String encode(java.lang.Object o)
Base64 encoding of serializable objects.

Parameters:
o - serializable object, may be null
Returns:
Base64 eoncoded string
Throws:
java.lang.IllegalArgumentException - if (o != null && !(o instanceof Serializable))

decode

public static <T> T decode(java.lang.String encodedString)
Decode Base64 encoded string (with encode).

Parameters:
encodedString - may be null
Returns:
instance of T or null if argument was null