public 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(<any>, 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(<any>, 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(<any>, 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
).
Modifier | Constructor and Description |
---|---|
protected |
AbstractDataBufferDecoder(MimeType... supportedMimeTypes) |
Modifier and Type | Method and Description |
---|---|
<any> |
decode(<any> inputStream,
ResolvableType elementType,
MimeType mimeType,
java.util.Map<java.lang.String,java.lang.Object> hints)
Decode a
DataBuffer input stream into a Flux of T . |
protected abstract T |
decodeDataBuffer(DataBuffer buffer,
ResolvableType elementType,
MimeType mimeType,
java.util.Map<java.lang.String,java.lang.Object> hints)
How to decode a
DataBuffer to the target element type. |
<any> |
decodeToMono(<any> inputStream,
ResolvableType elementType,
MimeType mimeType,
java.util.Map<java.lang.String,java.lang.Object> hints)
Decode a
DataBuffer input stream into a Mono of T . |
canDecode, getDecodableMimeTypes
protected AbstractDataBufferDecoder(MimeType... supportedMimeTypes)
public <any> decode(<any> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable java.util.Map<java.lang.String,java.lang.Object> hints)
Decoder
DataBuffer
input stream into a Flux of T
.inputStream
- 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 encodepublic <any> decodeToMono(<any> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable java.util.Map<java.lang.String,java.lang.Object> hints)
Decoder
DataBuffer
input stream into a Mono of T
.decodeToMono
in interface Decoder<T>
decodeToMono
in class AbstractDecoder<T>
inputStream
- 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 encodeprotected abstract T decodeDataBuffer(DataBuffer buffer, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable java.util.Map<java.lang.String,java.lang.Object> hints)
DataBuffer
to the target element type.