Class CompositeCodec

java.lang.Object
org.springframework.integration.codec.CompositeCodec
All Implemented Interfaces:
Codec

public class CompositeCodec
extends java.lang.Object
implements Codec
A Codec that can delegate to one out of many Codecs, each mapped to a class.
Since:
4.2
  • Constructor Summary

    Constructors 
    Constructor Description
    CompositeCodec​(java.util.Map<java.lang.Class<?>,​Codec> delegates, Codec defaultCodec)  
    CompositeCodec​(Codec defaultCodec)  
  • Method Summary

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

    Methods inherited from class java.lang.Object

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

  • Method Details

    • encode

      public void encode​(java.lang.Object object, java.io.OutputStream outputStream) throws java.io.IOException
      Description copied from interface: Codec
      Encode (encode) an object to an OutputStream.
      Specified by:
      encode in interface Codec
      Parameters:
      object - the object to encode
      outputStream - the OutputStream
      Throws:
      java.io.IOException - if the operation fails
    • encode

      public byte[] encode​(java.lang.Object object) throws java.io.IOException
      Description copied from interface: Codec
      Encode an object to a byte array.
      Specified by:
      encode in interface Codec
      Parameters:
      object - the object to encode
      Returns:
      the bytes
      Throws:
      java.io.IOException - if the operation fails
    • decode

      public <T> T decode​(java.io.InputStream inputStream, java.lang.Class<T> type) throws java.io.IOException
      Description copied from interface: Codec
      Decode an object of a given type.
      Specified by:
      decode in interface Codec
      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:
      java.io.IOException - if the operation fails
    • decode

      public <T> T decode​(byte[] bytes, java.lang.Class<T> type) throws java.io.IOException
      Description copied from interface: Codec
      Decode an object of a given type.
      Specified by:
      decode in interface Codec
      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:
      java.io.IOException - if the operation fails