public interface MediaTypeCodec
Modifier and Type | Method and Description |
---|---|
default <T> T |
decode(Argument<T> type,
byte[] bytes)
Decode the given type from the given bytes.
|
default <T> T |
decode(Argument<T> type,
ByteBuffer<?> buffer)
Decode the given type from the given buffer.
|
<T> T |
decode(Argument<T> type,
InputStream inputStream)
Decode the given type from the given
InputStream . |
default <T> T |
decode(Argument<T> type,
String data)
Decode the given type from the given bytes.
|
default <T> T |
decode(Class<T> type,
byte[] bytes)
Decode the given type from the given bytes.
|
default <T> T |
decode(Class<T> type,
ByteBuffer<?> buffer)
Decode the given type from the given buffer.
|
default <T> T |
decode(Class<T> type,
InputStream inputStream)
Decode the given type from the given
InputStream . |
default <T> T |
decode(Class<T> type,
String data)
Decode the given type from the given bytes.
|
<T> byte[] |
encode(T object)
Encode the given type returning the object as a byte[].
|
<T> ByteBuffer |
encode(T object,
ByteBufferFactory allocator)
Encode the given type returning the object as a
ByteBuffer . |
<T> void |
encode(T object,
OutputStream outputStream)
Encode the given type to the given
OutputStream . |
Collection<MediaType> |
getMediaTypes() |
default boolean |
supportsType(Class<?> type)
Whether the codec can decode the given type.
|
Collection<MediaType> getMediaTypes()
<T> T decode(Argument<T> type, InputStream inputStream) throws CodecException
InputStream
.T
- The generic typetype
- The typeinputStream
- The input streamCodecException
- When the result cannot be decoded<T> void encode(T object, OutputStream outputStream) throws CodecException
OutputStream
.T
- The generic typeobject
- The object to encodeoutputStream
- The output streamCodecException
- When the result cannot be encoded<T> byte[] encode(T object) throws CodecException
T
- The generic typeobject
- The object to encodeCodecException
- When the result cannot be encoded<T> ByteBuffer encode(T object, ByteBufferFactory allocator) throws CodecException
ByteBuffer
.T
- The generic typeobject
- The object to encodeallocator
- The allocatorCodecException
- When the result cannot be encodeddefault <T> T decode(Class<T> type, InputStream inputStream) throws CodecException
InputStream
.T
- The generic typetype
- The typeinputStream
- The input streamCodecException
- When the result cannot be decodeddefault <T> T decode(Class<T> type, byte[] bytes) throws CodecException
T
- The decoded typetype
- The typebytes
- The bytesCodecException
- When the result cannot be decodeddefault <T> T decode(Argument<T> type, byte[] bytes) throws CodecException
T
- The decoded typetype
- The typebytes
- The bytesCodecException
- When the result cannot be decodeddefault <T> T decode(Class<T> type, ByteBuffer<?> buffer) throws CodecException
ByteBuffer
instances
should override this method.T
- The decoded typetype
- The typebuffer
- the bufferCodecException
- When the result cannot be decodeddefault <T> T decode(Argument<T> type, ByteBuffer<?> buffer) throws CodecException
ByteBuffer
instances
should override this method.T
- The decoded typetype
- The typebuffer
- the bufferCodecException
- When the result cannot be decodeddefault <T> T decode(Class<T> type, String data) throws CodecException
T
- The decoded typetype
- The typedata
- The data as a stringCodecException
- When the result cannot be decodeddefault <T> T decode(Argument<T> type, String data) throws CodecException
T
- The decoded typetype
- The typedata
- The data as a stringCodecException
- When the result cannot be decodeddefault boolean supportsType(Class<?> type)
type
- The type