Class JPPFSerializationHelper

java.lang.Object
org.jppf.serialization.JPPFSerializationHelper

public class JPPFSerializationHelper extends Object
A collection of static utility methods to help with serialization in JPPF.
Author:
Laurent Cohen
  • Constructor Details

    • JPPFSerializationHelper

      public JPPFSerializationHelper()
  • Method Details

    • serialize

      public static void serialize(Object object, OutputStream os) throws Exception
      Serialize the specified object to the specified stream, according to the configured serialization scheme.
      Parameters:
      object - the object to serialize.
      os - the outout stream to serialize to.
      Throws:
      Exception - if any error occurs during the serialization.
    • serializeToBytes

      public static byte[] serializeToBytes(Object object) throws Exception
      Serialize an object to an array of bytes.
      Parameters:
      object - the object to serialize.
      Returns:
      an array of byte containing the serialized object, starting at position 0 and with no unused position.
      Throws:
      Exception - if any error occurs during the serialization.
    • deserialize

      public static Object deserialize(InputStream is) throws Exception
      Serialize the an object from the specified stream, according to the configured serialization scheme.
      Parameters:
      is - the input stream to deserialize from.
      Returns:
      a deserialized object.
      Throws:
      Exception - if any error occurs during the deserialization.
    • deserializeFromBytes

      public static Object deserializeFromBytes(byte[] bytes, int offset, int len) throws Exception
      Desrialize an object from an array of bytes.
      Parameters:
      bytes - the bytes to deserialize from.
      offset - the position at which to start reading in the array.
      len - the number of bytes to read.
      Returns:
      a deserialized object.
      Throws:
      Exception - if any error occurs during the deserialization.