Package io.micronaut.runtime.http.codec
Class TextPlainCodec
java.lang.Object
io.micronaut.runtime.http.codec.TextPlainCodec
- All Implemented Interfaces:
MediaTypeCodec
A codec that handles
MediaType.TEXT_PLAIN
.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
-
Constructor Summary
ConstructorDescriptionTextPlainCodec
(Charset defaultCharset, ConversionService conversionService) TextPlainCodec
(Optional<Charset> defaultCharset, @Nullable CodecConfiguration codecConfiguration, ConversionService conversionService) -
Method Summary
Modifier and TypeMethodDescription<T> T
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 givenInputStream
.<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 aByteBuffer
.<T> void
encode
(T object, OutputStream outputStream) Encode the given type to the givenOutputStream
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.http.codec.MediaTypeCodec
decode, decode, decode, decode, decode, encode, encode, encode, supportsType
-
Field Details
-
CONFIGURATION_QUALIFIER
- See Also:
-
-
Constructor Details
-
TextPlainCodec
@Inject public TextPlainCodec(@Value("${micronaut.application.default-charset}") Optional<Charset> defaultCharset, @Named("text") @Nullable @Nullable CodecConfiguration codecConfiguration, ConversionService conversionService) - Parameters:
defaultCharset
- The default charset used for serialization and deserializationcodecConfiguration
- The configuration for the codecconversionService
- The conversion service
-
TextPlainCodec
- Parameters:
defaultCharset
- The default charset used for serialization and deserializationconversionService
- The conversion service
-
-
Method Details
-
getMediaTypes
- Specified by:
getMediaTypes
in interfaceMediaTypeCodec
- Returns:
- The media type of the codec
-
decode
Description copied from interface:MediaTypeCodec
Decode the given type from the given buffer. Implementations optimized to handleByteBuffer
instances should override this method.- Specified by:
decode
in interfaceMediaTypeCodec
- Type Parameters:
T
- The decoded type- Parameters:
type
- The typebuffer
- the buffer- Returns:
- The decoded result
- Throws:
CodecException
- When the result cannot be decoded
-
decode
Description copied from interface:MediaTypeCodec
Decode the given type from the given bytes.- Specified by:
decode
in interfaceMediaTypeCodec
- Type Parameters:
T
- The decoded type- Parameters:
type
- The typebytes
- The bytes- Returns:
- The decoded result
- Throws:
CodecException
- When the result cannot be decoded
-
decode
Description copied from interface:MediaTypeCodec
Decode the given type from the givenInputStream
.- Specified by:
decode
in interfaceMediaTypeCodec
- Type Parameters:
T
- The generic type- Parameters:
type
- The typeinputStream
- The input stream- Returns:
- The decoded result
- Throws:
CodecException
- When the result cannot be decoded
-
encode
Description copied from interface:MediaTypeCodec
Encode the given type to the givenOutputStream
.- Specified by:
encode
in interfaceMediaTypeCodec
- Type Parameters:
T
- The generic type- Parameters:
object
- The object to encodeoutputStream
- The output stream- Throws:
CodecException
- When the result cannot be encoded
-
encode
Description copied from interface:MediaTypeCodec
Encode the given type returning the object as a byte[].- Specified by:
encode
in interfaceMediaTypeCodec
- Type Parameters:
T
- The generic type- Parameters:
object
- The object to encode- Returns:
- The decoded result
- Throws:
CodecException
- When the result cannot be encoded
-
encode
public <T,B> ByteBuffer<B> encode(T object, ByteBufferFactory<?, B> allocator) throws CodecExceptionDescription copied from interface:MediaTypeCodec
Encode the given type returning the object as aByteBuffer
.- Specified by:
encode
in interfaceMediaTypeCodec
- Type Parameters:
T
- The generic typeB
- The buffer type- Parameters:
object
- The object to encodeallocator
- The allocator- Returns:
- The decoded result
- Throws:
CodecException
- When the result cannot be encoded
-