Class SerializationHelper


  • public class SerializationHelper
    extends java.lang.Object

    Provide common functionalities for serialization of object.

    This class throws exceptions for invalid null inputs. Each method documents its behavior in more detail.

    Since:
    OracleAS 10.0.3
    Author:
    Steven Vo
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object clone​(java.io.Serializable object)
      Deep clone a Serializable object using serialization.
      static java.lang.Object deserialize​(byte[] objectBytes)
      Deserialize an object from a byte array
      static java.lang.Object deserialize​(java.io.InputStream inputStream)
      Deserialze an object from an InputStream
      static byte[] serialize​(java.io.Serializable obj)
      Serialize the object to a byte array
      static void serialize​(java.io.Serializable obj, java.io.OutputStream outputStream)
      Serialize the object to an OutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SerializationHelper

        public SerializationHelper()
    • Method Detail

      • clone

        public static java.lang.Object clone​(java.io.Serializable object)
                                      throws java.io.IOException,
                                             java.lang.ClassNotFoundException

        Deep clone a Serializable object using serialization.

        Parameters:
        the - serializable object
        Returns:
        the deep cloned object
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • serialize

        public static void serialize​(java.io.Serializable obj,
                                     java.io.OutputStream outputStream)
                              throws java.io.IOException
        Serialize the object to an OutputStream
        Parameters:
        obj - the object to serialize to bytes
        outputStream - the stream to write to, can not be null
        Throws:
        java.io.IOException
      • serialize

        public static byte[] serialize​(java.io.Serializable obj)
                                throws java.io.IOException
        Serialize the object to a byte array
        Parameters:
        obj - the object to serialize to bytes
        Returns:
        a byte[] of the obj
        Throws:
        java.io.IOException
      • deserialize

        public static java.lang.Object deserialize​(java.io.InputStream inputStream)
                                            throws java.io.IOException,
                                                   java.lang.ClassNotFoundException
        Deserialze an object from an InputStream
        Parameters:
        inputStream - the serialized object input stream, must not be null
        Returns:
        the deserialized object
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • deserialize

        public static java.lang.Object deserialize​(byte[] objectBytes)
                                            throws java.io.IOException,
                                                   java.lang.ClassNotFoundException
        Deserialize an object from a byte array
        Parameters:
        objectBytes - the serialized object, can not be null
        Returns:
        the deserialized object
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException