@Singleton public class TextPlainCodec extends Object implements MediaTypeCodec
MediaType.TEXT_PLAIN.| Modifier and Type | Field and Description |
|---|---|
static String |
CONFIGURATION_QUALIFIER |
| Constructor and Description |
|---|
TextPlainCodec(Charset defaultCharset) |
TextPlainCodec(Optional<Charset> defaultCharset,
CodecConfiguration codecConfiguration) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
decode(Argument<T> type,
byte[] bytes)
Decode the given type from the given bytes.
|
<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. |
<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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdecode, decode, decode, decode, decode, encode, encode, encode, supportsTypepublic static final String CONFIGURATION_QUALIFIER
@Inject public TextPlainCodec(@Value(value="${micronaut.application.default-charset}") Optional<Charset> defaultCharset, @Named(value="text") @Nullable CodecConfiguration codecConfiguration)
defaultCharset - The default charset used for serialization and deserializationcodecConfiguration - The configuration for the codecpublic TextPlainCodec(Charset defaultCharset)
defaultCharset - The default charset used for serialization and deserializationpublic Collection<MediaType> getMediaTypes()
getMediaTypes in interface MediaTypeCodecpublic <T> T decode(Argument<T> type, ByteBuffer<?> buffer) throws CodecException
MediaTypeCodecByteBuffer instances
should override this method.decode in interface MediaTypeCodecT - The decoded typetype - The typebuffer - the bufferCodecException - When the result cannot be decodedpublic <T> T decode(Argument<T> type, byte[] bytes) throws CodecException
MediaTypeCodecdecode in interface MediaTypeCodecT - The decoded typetype - The typebytes - The bytesCodecException - When the result cannot be decodedpublic <T> T decode(Argument<T> type, InputStream inputStream) throws CodecException
MediaTypeCodecInputStream.decode in interface MediaTypeCodecT - The generic typetype - The typeinputStream - The input streamCodecException - When the result cannot be decodedpublic <T> void encode(T object,
OutputStream outputStream)
throws CodecException
MediaTypeCodecOutputStream.encode in interface MediaTypeCodecT - The generic typeobject - The object to encodeoutputStream - The output streamCodecException - When the result cannot be encodedpublic <T> byte[] encode(T object)
throws CodecException
MediaTypeCodecencode in interface MediaTypeCodecT - The generic typeobject - The object to encodeCodecException - When the result cannot be encodedpublic <T,B> ByteBuffer<B> encode(T object, ByteBufferFactory<?,B> allocator) throws CodecException
MediaTypeCodecByteBuffer.encode in interface MediaTypeCodecT - The generic typeB - The buffer typeobject - The object to encodeallocator - The allocatorCodecException - When the result cannot be encoded