Top Description Fields Constructors Methods
org.springframework.http.codec

public abstract Class KotlinSerializationBinaryDecoder<T extends kotlinx.serialization.BinaryFormat>

extends KotlinSerializationSupport<T extends kotlinx.serialization.BinaryFormat>
implements Decoder<Object>
Class Inheritance
All Implemented Interfaces
org.springframework.core.codec.Decoder
Known Direct Subclasses
org.springframework.http.codec.cbor.KotlinSerializationCborDecoder, org.springframework.http.codec.protobuf.KotlinSerializationProtobufDecoder
Type Parameters
<T>
the type of BinaryFormat
Imports
java.util.List, .Map, kotlinx.serialization.BinaryFormat, kotlinx.serialization.KSerializer, org.reactivestreams.Publisher, reactor.core.publisher.Flux, .Mono, org.springframework.core.ResolvableType, org.springframework.core.codec.ByteArrayDecoder, .Decoder, .DecodingException, org.springframework.core.io.buffer.DataBuffer, org.springframework.lang.Nullable, org.springframework.util.MimeType

Abstract base class for Decoder implementations that defer to Kotlin binary serializers.
Authors
Sebastien Deleuze, Iain Henderson, Arjen Poutsma
Since
6.0

Field Summary

Modifier and TypeField and Description
private final ByteArrayDecoder

Constructor Summary

AccessConstructor and Description
public
KotlinSerializationBinaryDecoder(T format, MimeType... supportedMimeTypes)

Method Summary

Modifier and TypeMethod and Description
public boolean
canDecode(ResolvableType
the target element type for the output stream
elementType
,
MimeType
the mime type associated with the stream to decode (can be null if not specified)
mimeType
)

Implements org.springframework.core.codec.Decoder.canDecode.

Whether the decoder supports the given target element type and the MIME type of the source stream.

public Flux<Object>
decode(Publisher<DataBuffer>
the DataBuffer input stream to decode
inputStream
,
ResolvableType
the expected type of elements in the output stream; this type must have been previously passed to the canDecode method and it must have returned true.
elementType
,
MimeType
the MIME type associated with the input stream (optional)
mimeType
,
Map<String, Object>
additional information about how to do decode
hints
)

Implements org.springframework.core.codec.Decoder.decode.

Decode a DataBuffer input stream into a Flux of T.

public Mono<Object>
decodeToMono(Publisher<DataBuffer>
the DataBuffer input stream to decode
inputStream
,
ResolvableType
the expected type of elements in the output stream; this type must have been previously passed to the canDecode method and it must have returned true.
elementType
,
MimeType
the MIME type associated with the input stream (optional)
mimeType
,
Map<String, Object>
additional information about how to do decode
hints
)

Implements org.springframework.core.codec.Decoder.decodeToMono.

Decode a DataBuffer input stream into a Mono of T.

public List<MimeType>
getDecodableMimeTypes()

Implements org.springframework.core.codec.Decoder.getDecodableMimeTypes.

Return the list of MIME types supported by this Decoder.

public List<MimeType>
getDecodableMimeTypes(ResolvableType
the type of element to check for decoding
targetType
)

Overrides default org.springframework.core.codec.Decoder.getDecodableMimeTypes.

Return the list of MIME types supported by this Decoder for the given type of element.

public int
getMaxInMemorySize()

Return the configured byte count limit.

public void
setMaxInMemorySize(int
the max number of bytes to buffer, or -1 for unlimited
byteCount
)

Configure a limit on the number of bytes that can be buffered whenever the input stream needs to be aggregated.

Inherited from org.springframework.http.codec.KotlinSerializationSupport:
canSerializeformatserializersupportedMimeTypes

Field Detail

byteArrayDecoderback to summary
private final ByteArrayDecoder byteArrayDecoder

Constructor Detail

KotlinSerializationBinaryDecoderback to summary
public KotlinSerializationBinaryDecoder(T format, MimeType... supportedMimeTypes)

Method Detail

canDecodeback to summary
public boolean canDecode(ResolvableType elementType, MimeType mimeType)

Implements org.springframework.core.codec.Decoder.canDecode.

Doc from org.springframework.core.codec.Decoder.canDecode.

Whether the decoder supports the given target element type and the MIME type of the source stream.

Parameters
elementType:ResolvableType

the target element type for the output stream

mimeType:MimeType

the mime type associated with the stream to decode (can be null if not specified)

Returns:boolean

true if supported, false otherwise

Annotations
@Override
decodeback to summary
public Flux<Object> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Implements org.springframework.core.codec.Decoder.decode.

Doc from org.springframework.core.codec.Decoder.decode.

Decode a DataBuffer input stream into a Flux of T.

Parameters
inputStream:Publisher<DataBuffer>

the DataBuffer input stream to decode

elementType:ResolvableType

the expected type of elements in the output stream; this type must have been previously passed to the canDecode method and it must have returned true.

mimeType:MimeType

the MIME type associated with the input stream (optional)

hints:Map<String, Object>

additional information about how to do decode

Returns:Flux<Object>

the output stream with decoded elements

Annotations
@Override
decodeToMonoback to summary
public Mono<Object> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Implements org.springframework.core.codec.Decoder.decodeToMono.

Doc from org.springframework.core.codec.Decoder.decodeToMono.

Decode a DataBuffer input stream into a Mono of T.

Parameters
inputStream:Publisher<DataBuffer>

the DataBuffer input stream to decode

elementType:ResolvableType

the expected type of elements in the output stream; this type must have been previously passed to the canDecode method and it must have returned true.

mimeType:MimeType

the MIME type associated with the input stream (optional)

hints:Map<String, Object>

additional information about how to do decode

Returns:Mono<Object>

the output stream with the decoded element

Annotations
@Override
getDecodableMimeTypesback to summary
public List<MimeType> getDecodableMimeTypes()

Implements org.springframework.core.codec.Decoder.getDecodableMimeTypes.

Doc from org.springframework.core.codec.Decoder.getDecodableMimeTypes.

Return the list of MIME types supported by this Decoder. The list may not apply to every possible target element type and calls to this method should typically be guarded via canDecode(elementType, null). The list may also exclude MIME types supported only for a specific element type. Alternatively, use getDecodableMimeTypes(ResolvableType) for a more precise list.

Returns:List<MimeType>

the list of supported MIME types

Annotations
@Override
getDecodableMimeTypesback to summary
public List<MimeType> getDecodableMimeTypes(ResolvableType targetType)

Overrides default org.springframework.core.codec.Decoder.getDecodableMimeTypes.

Doc from org.springframework.core.codec.Decoder.getDecodableMimeTypes.

Return the list of MIME types supported by this Decoder for the given type of element. This list may differ from getDecodableMimeTypes() if the Decoder doesn't support the given element type or if it supports it only for a subset of MIME types.

Parameters
targetType:ResolvableType

the type of element to check for decoding

Returns:List<MimeType>

the list of MIME types supported for the given target type

Annotations
@Override
getMaxInMemorySizeback to summary
public int getMaxInMemorySize()

Return the configured byte count limit.

setMaxInMemorySizeback to summary
public void setMaxInMemorySize(int byteCount)

Configure a limit on the number of bytes that can be buffered whenever the input stream needs to be aggregated. This can be a result of decoding to a single DataBuffer, ByteBuffer, byte[], Resource, String, etc. It can also occur when splitting the input stream, e.g. delimited text, in which case the limit applies to data buffered between delimiters.

By default this is set to 256K.

Parameters
byteCount:int

the max number of bytes to buffer, or -1 for unlimited