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
-
Method Summary
Modifier and Type Method Description <T> Tdecode(byte[] bytes, java.lang.Class<T> type)Decode an object of a given type<T> Tdecode(java.io.InputStream inputStream, java.lang.Class<T> type)Decode an object of a given typebyte[]encode(java.lang.Object object)Encode an object to a byte arrayvoidencode(java.lang.Object object, java.io.OutputStream outputStream)Encode (encode) an object to an OutputStream
-
Method Details
-
encode
void encode(java.lang.Object object, java.io.OutputStream outputStream) throws java.io.IOExceptionEncode (encode) an object to an OutputStream- Parameters:
object- the object to encodeoutputStream- the OutputStream- Throws:
java.io.IOException- if the operation fails
-
encode
byte[] encode(java.lang.Object object) throws java.io.IOExceptionEncode an object to a byte array- Parameters:
object- the object to encode- Returns:
- the bytes
- Throws:
java.io.IOException- if the operation fails
-
decode
<T> T decode(java.io.InputStream inputStream, java.lang.Class<T> type) throws java.io.IOExceptionDecode an object of a given type- Type Parameters:
T- the object's type- Parameters:
inputStream- the input stream containing the encoded objecttype- the object's class- Returns:
- the object
- Throws:
java.io.IOException- if the operation fails
-
decode
<T> T decode(byte[] bytes, java.lang.Class<T> type) throws java.io.IOExceptionDecode an object of a given type- Type Parameters:
T- the object's type- Parameters:
bytes- the byte array containing the encoded objecttype- the object's class- Returns:
- the object
- Throws:
java.io.IOException- if the operation fails
-