Interface Codec

All Known Implementing Classes:
AbstractKryoCodec, CompositeCodec, MessageCodec, PojoCodec

public interface Codec
Interface for classes that perform both encode (serialize) and decode (deserialize) on multiple classes.
Since:
4.2
Author:
David Turanski
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    decode(byte[] bytes, Class<T> type)
    Decode an object of a given type.
    <T> T
    decode(InputStream inputStream, Class<T> type)
    Decode an object of a given type.
    byte[]
    encode(Object object)
    Encode an object to a byte array.
    void
    encode(Object object, OutputStream outputStream)
    Encode (encode) an object to an OutputStream.
  • Method Details

    • encode

      void encode(Object object, OutputStream outputStream) throws IOException
      Encode (encode) an object to an OutputStream.
      Parameters:
      object - the object to encode
      outputStream - the OutputStream
      Throws:
      IOException - if the operation fails
    • encode

      byte[] encode(Object object) throws IOException
      Encode an object to a byte array.
      Parameters:
      object - the object to encode
      Returns:
      the bytes
      Throws:
      IOException - if the operation fails
    • decode

      <T> T decode(InputStream inputStream, Class<T> type) throws IOException
      Decode an object of a given type.
      Type Parameters:
      T - the object's type
      Parameters:
      inputStream - the input stream containing the encoded object
      type - the object's class
      Returns:
      the object
      Throws:
      IOException - if the operation fails
    • decode

      <T> T decode(byte[] bytes, Class<T> type) throws IOException
      Decode an object of a given type.
      Type Parameters:
      T - the object's type
      Parameters:
      bytes - the byte array containing the encoded object
      type - the object's class
      Returns:
      the object
      Throws:
      IOException - if the operation fails