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