Package com.github.cafapi.common.api
Interface Codec
- All Superinterfaces:
Decoder
- All Known Implementing Classes:
JsonCodec
,JsonLzfCodec
A Codec specifies methods to serialise data from a Java object to byte format, and deserialise data from byte format back into a
specified Java class.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> T
deserialise
(byte[] data, Class<T> clazz) <T> T
deserialise
(byte[] data, Class<T> clazz, DecodeMethod method) Deserialise the given data into the specified class.default <T> T
deserialise
(InputStream stream, Class<T> clazz) Deserialise the given data into the specified class using the default decode method.<T> T
deserialise
(InputStream stream, Class<T> clazz, DecodeMethod method) Deserialise the given data into the specified class using the default decode method.<T> byte[]
serialise
(T object) Serialise the given object into a byte data form.
-
Method Details
-
deserialise
- Throws:
CodecException
-
deserialise
Deserialise the given data into the specified class.- Type Parameters:
T
- the class the serialised data represents- Parameters:
data
- the serialised dataclazz
- the class the serialised data representsmethod
- specifies whether to use strict or lenient decoding during deserialisation- Returns:
- an instance of the class specified represented by the data
- Throws:
CodecException
- if the data could not be deserialised
-
deserialise
Deserialise the given data into the specified class using the default decode method.- Specified by:
deserialise
in interfaceDecoder
- Type Parameters:
T
- the class the serialised data represents- Parameters:
stream
- the serialised data as a streamclazz
- the class the serialised data represents- Returns:
- an instance of the class specified represented by the data
- Throws:
CodecException
- if the data could not be deserialised
-
deserialise
Deserialise the given data into the specified class using the default decode method.- Type Parameters:
T
- the class the serialised data represents- Parameters:
stream
- the serialised data as a streamclazz
- the class the serialised data representsmethod
- specifies whether to use strict or lenient decoding during deserialisation- Returns:
- an instance of the class specified represented by the data
- Throws:
CodecException
- if the data could not be deserialised
-
serialise
Serialise the given object into a byte data form.- Type Parameters:
T
- the class of the object to serialise- Parameters:
object
- the object to serialise- Returns:
- the serialised data of the given object
- Throws:
CodecException
- if the object could not be serialised
-