@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, wait
decode, decode, decode, decode, decode, encode, encode, encode, supportsType
public 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 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, byte[] bytes) throws CodecException
MediaTypeCodec
decode
in interface MediaTypeCodec
T
- The decoded typetype
- The typebytes
- The bytesCodecException
- When the result cannot be decodedpublic <T> T decode(Argument<T> type, 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, 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