java.lang.Object
org.jboss.arquillian.drone.webdriver.factory.remote.reusable.SerializationUtils

public class SerializationUtils extends Object
The utility methods for serializing / deserializing objects
Author:
Lukas Fryc
  • Constructor Details

    • SerializationUtils

      public SerializationUtils()
  • Method Details

    • serializeToBytes

      public static byte[] serializeToBytes(Serializable object) throws IOException
      Takes serializable object and serializes it to the byte array
      Parameters:
      object - object to serialize
      Returns:
      the byte array representing serializable object
      Throws:
      InvalidClassException - Something is wrong with a class used by serialization.
      NotSerializableException - Some object to be serialized does not implement the java.io.Serializable interface.
      IOException - Any exception thrown by the underlying OutputStream.
    • deserializeFromBytes

      public static <T extends Serializable> T deserializeFromBytes(Class<T> classType, byte[] serializedObject) throws IOException, ClassNotFoundException
      Takes byte array representing serialized object and constructs its object form
      Parameters:
      classType - Type of the returned object
      serializedObject - byte array representing serialized object
      Returns:
      deserialized object
      Throws:
      ClassNotFoundException - Class of a serialized object cannot be found.
      InvalidClassException - Something is wrong with a class used by serialization.
      StreamCorruptedException - Control information in the stream is inconsistent.
      OptionalDataException - Primitive data was found in the stream instead of objects.
      IOException - Any of the usual Input/Output related exceptions.