Class CompositeCodec
java.lang.Object
org.springframework.integration.codec.CompositeCodec
- All Implemented Interfaces:
Codec
public class CompositeCodec extends Object implements Codec
A Codec that can delegate to one out of many Codecs, each mapped to a class.
- Since:
- 4.2
- Author:
- David Turanski
-
Constructor Summary
Constructors Constructor Description CompositeCodec(Map<Class<?>,Codec> delegates, Codec defaultCodec)
CompositeCodec(Codec defaultCodec)
-
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 typebyte[]
encode(Object object)
Encode an object to a byte arrayvoid
encode(Object object, OutputStream outputStream)
Encode (encode) an object to an OutputStream
-
Constructor Details
-
Method Details
-
encode
Description copied from interface:Codec
Encode (encode) an object to an OutputStream- Specified by:
encode
in interfaceCodec
- Parameters:
object
- the object to encodeoutputStream
- the OutputStream- Throws:
IOException
- if the operation fails
-
encode
Description copied from interface:Codec
Encode an object to a byte array- Specified by:
encode
in interfaceCodec
- Parameters:
object
- the object to encode- Returns:
- the bytes
- Throws:
IOException
- if the operation fails
-
decode
Description copied from interface:Codec
Decode an object of a given type- Specified by:
decode
in interfaceCodec
- Type Parameters:
T
- the object's type- Parameters:
inputStream
- the input stream containing the encoded objecttype
- the object's class- Returns:
- the object
- Throws:
IOException
- if the operation fails
-
decode
Description copied from interface:Codec
Decode an object of a given type- Specified by:
decode
in interfaceCodec
- Type Parameters:
T
- the object's type- Parameters:
bytes
- the byte array containing the encoded objecttype
- the object's class- Returns:
- the object
- Throws:
IOException
- if the operation fails
-