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.
|
default <T> byte[] |
encode(Argument<T> type,
T object)
Encode the given type returning the object as a byte[].
|
default <T,B> ByteBuffer<B> |
encode(Argument<T> type,
T object,
ByteBufferFactory<?,B> allocator)
Encode the given type returning the object as a
ByteBuffer . |
default <T> void |
encode(Argument<T> type,
T object,
OutputStream outputStream)
Encode the given type to the given
OutputStream . |
<T> byte[] |
encode(T object)
Encode the given type returning the object as a byte[].
|
<T,B> ByteBuffer<B> |
encode(T object,
ByteBufferFactory<?,B> 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,B> ByteBuffer<B> encode(T object, ByteBufferFactory<?,B> allocator) throws CodecException
ByteBuffer
.T
- The generic typeB
- The buffer typeobject
- The object to encodeallocator
- The allocatorCodecException
- When the result cannot be encodeddefault <T> void encode(@NonNull Argument<T> type, @NonNull T object, @NonNull OutputStream outputStream) throws CodecException
OutputStream
.T
- The generic typetype
- The type including any generics and/or metadata.object
- The object to encodeoutputStream
- The output streamCodecException
- When the result cannot be encoded@NonNull default <T> byte[] encode(@NonNull Argument<T> type, T object) throws CodecException
T
- The generic typetype
- The type including any generics and/or metadataobject
- The object to encodeCodecException
- When the result cannot be encoded@NonNull default <T,B> ByteBuffer<B> encode(@NonNull Argument<T> type, T object, @NonNull ByteBufferFactory<?,B> allocator) throws CodecException
ByteBuffer
.T
- The generic typeB
- The buffer typetype
- The type including any generics and/or metadataobject
- 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