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

public abstract Class AbstractDataBufferDecoder<T>

extends AbstractDecoder<T>
Class Inheritance
Known Direct Subclasses
org.springframework.core.codec.ByteArrayDecoder, org.springframework.core.codec.ByteBufferDecoder, org.springframework.core.codec.DataBufferDecoder, org.springframework.core.codec.Netty5BufferDecoder, org.springframework.core.codec.NettyByteBufDecoder, org.springframework.core.codec.ResourceDecoder, org.springframework.core.codec.AbstractCharSequenceDecoder
Type Parameters
<T>
the element type
Imports
java.util.Map, org.reactivestreams.Publisher, reactor.core.publisher.Flux, .Mono, org.springframework.core.ResolvableType, org.springframework.core.io.buffer.DataBuffer, .DataBufferUtils, org.springframework.lang.Nullable, org.springframework.util.MimeType

Abstract base class for Decoder implementations that can decode a DataBuffer directly to the target element type.

Sub-classes must implement decodeDataBuffer to provide a way to transform a DataBuffer to the target data type. The default decode implementation transforms each individual data buffer while decodeToMono applies "reduce" and transforms the aggregated buffer.

Sub-classes can override decode in order to split the input stream along different boundaries (e.g. on new line characters for String) or always reduce to a single data buffer (e.g. Resource).

Author
Rossen Stoyanchev
Since
5.0

Field Summary

Modifier and TypeField and Description
private int
Inherited from org.springframework.core.codec.AbstractDecoder:
logger

Constructor Summary

AccessConstructor and Description
protected
AbstractDataBufferDecoder(MimeType... supportedMimeTypes)

Method Summary

Modifier and TypeMethod and Description
public Flux<T>
decode(Publisher<DataBuffer>
the DataBuffer input stream to decode
input
,
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.
protected T
decodeDataBuffer(DataBuffer buffer, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Deprecated as of 5.2, please implement decode(DataBuffer, ResolvableType, MimeType, Map) instead
How to decode a DataBuffer to the target element type.
public Mono<T>
decodeToMono(Publisher<DataBuffer>
the DataBuffer input stream to decode
input
,
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
)

Overrides org.springframework.core.codec.AbstractDecoder.decodeToMono.

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

Decode a DataBuffer input stream into a Mono of T.
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.core.codec.AbstractDecoder:
canDecodegetDecodableMimeTypesgetLoggersetLogger

Field Detail

maxInMemorySizeback to summary
private int maxInMemorySize

Constructor Detail

AbstractDataBufferDecoderback to summary
protected AbstractDataBufferDecoder(MimeType... supportedMimeTypes)

Method Detail

decodeback to summary
public Flux<T> decode(Publisher<DataBuffer> input, 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
input: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<T>

the output stream with decoded elements

Annotations
@Override
decodeDataBufferback to summary
protected T decodeDataBuffer(DataBuffer buffer, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Deprecated

as of 5.2, please implement decode(DataBuffer, ResolvableType, MimeType, Map) instead

How to decode a DataBuffer to the target element type.

Annotations
@Deprecated
@Nullable
decodeToMonoback to summary
public Mono<T> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Overrides org.springframework.core.codec.AbstractDecoder.decodeToMono.

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
input: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<T>

the output stream with the decoded element

Annotations
@Override
getMaxInMemorySizeback to summary
public int getMaxInMemorySize()

Return the configured byte count limit.

Since
5.1.11
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

Since
5.1.11