T
- the element typepublic abstract class AbstractDataBufferDecoder<T> extends AbstractDecoder<T>
Decoder
implementations that can decode
a DataBuffer
directly to the target element type.
Sub-classes must implement decodeDataBuffer(org.springframework.core.io.buffer.DataBuffer, org.springframework.core.ResolvableType, org.springframework.util.MimeType, java.util.Map<java.lang.String, java.lang.Object>)
to provide a way to
transform a DataBuffer
to the target data type. The default
decode(org.reactivestreams.Publisher<org.springframework.core.io.buffer.DataBuffer>, org.springframework.core.ResolvableType, org.springframework.util.MimeType, java.util.Map<java.lang.String, java.lang.Object>)
implementation transforms each individual data buffer while
decodeToMono(org.reactivestreams.Publisher<org.springframework.core.io.buffer.DataBuffer>, org.springframework.core.ResolvableType, org.springframework.util.MimeType, java.util.Map<java.lang.String, java.lang.Object>)
applies "reduce" and transforms the aggregated buffer.
Sub-classes can override decode(org.reactivestreams.Publisher<org.springframework.core.io.buffer.DataBuffer>, org.springframework.core.ResolvableType, org.springframework.util.MimeType, java.util.Map<java.lang.String, java.lang.Object>)
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
).
logger
Modifier | Constructor and Description |
---|---|
protected |
AbstractDataBufferDecoder(MimeType... supportedMimeTypes) |
Modifier and Type | Method and Description |
---|---|
reactor.core.publisher.Flux<T> |
decode(Publisher<DataBuffer> input,
ResolvableType elementType,
MimeType mimeType,
Map<String,Object> hints)
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
Decoder.decode(DataBuffer, ResolvableType, MimeType, Map) instead |
reactor.core.publisher.Mono<T> |
decodeToMono(Publisher<DataBuffer> input,
ResolvableType elementType,
MimeType mimeType,
Map<String,Object> hints)
Decode a
DataBuffer input stream into a Mono of T . |
int |
getMaxInMemorySize()
Return the
configured byte count limit. |
void |
setMaxInMemorySize(int byteCount)
Configure a limit on the number of bytes that can be buffered whenever
the input stream needs to be aggregated.
|
canDecode, getDecodableMimeTypes, getLogger, setLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, getDecodableMimeTypes
protected AbstractDataBufferDecoder(MimeType... supportedMimeTypes)
public void setMaxInMemorySize(int byteCount)
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.
byteCount
- the max number of bytes to buffer, or -1 for unlimitedpublic int getMaxInMemorySize()
configured
byte count limit.public reactor.core.publisher.Flux<T> decode(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
Decoder
DataBuffer
input stream into a Flux of T
.input
- the DataBuffer
input stream to decodeelementType
- the expected type of elements in the output stream;
this type must have been previously passed to the Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)
method and it must have returned true
.mimeType
- the MIME type associated with the input stream (optional)hints
- additional information about how to do decodepublic reactor.core.publisher.Mono<T> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
Decoder
DataBuffer
input stream into a Mono of T
.decodeToMono
in interface Decoder<T>
decodeToMono
in class AbstractDecoder<T>
input
- the DataBuffer
input stream to decodeelementType
- the expected type of elements in the output stream;
this type must have been previously passed to the Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)
method and it must have returned true
.mimeType
- the MIME type associated with the input stream (optional)hints
- additional information about how to do decode@Deprecated @Nullable protected T decodeDataBuffer(DataBuffer buffer, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
Decoder.decode(DataBuffer, ResolvableType, MimeType, Map)
insteadDataBuffer
to the target element type.