Class DataBufferDecoder
java.lang.Object
org.springframework.core.codec.AbstractDecoder<DataBuffer>
org.springframework.core.codec.AbstractDataBufferDecoder<DataBuffer>
org.springframework.core.codec.DataBufferDecoder
- All Implemented Interfaces:
Decoder<DataBuffer>
Simple pass-through decoder for
DataBuffers.
Note: The data buffers should be released via
DataBufferUtils.release(DataBuffer)
after they have been consumed. In addition, if using Flux or
Mono operators such as flatMap, reduce, and others that prefetch,
cache, and skip or filter out data items internally, please add
doOnDiscard(DataBuffer.class, DataBufferUtils::release) to the
composition chain to ensure cached data buffers are released prior to an
error or cancellation signal.
- Since:
- 5.0
- Author:
- Arjen Poutsma, Rossen Stoyanchev
-
Field Summary
Fields inherited from class org.springframework.core.codec.AbstractDecoder
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDecode(ResolvableType elementType, @Nullable MimeType mimeType) Whether the decoder supports the given target element type and the MIME type of the source stream.reactor.core.publisher.Flux<DataBuffer> decode(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Decode aDataBufferinput stream into a Flux ofT.decode(DataBuffer buffer, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Decode a data buffer to an Object of type T.Methods inherited from class org.springframework.core.codec.AbstractDataBufferDecoder
decodeDataBuffer, decodeToMono, getMaxInMemorySize, setMaxInMemorySizeMethods inherited from class org.springframework.core.codec.AbstractDecoder
getDecodableMimeTypes, getLogger, setLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.codec.Decoder
getDecodableMimeTypes
-
Constructor Details
-
DataBufferDecoder
public DataBufferDecoder()
-
-
Method Details
-
canDecode
Description copied from interface:DecoderWhether the decoder supports the given target element type and the MIME type of the source stream.- Specified by:
canDecodein interfaceDecoder<DataBuffer>- Overrides:
canDecodein classAbstractDecoder<DataBuffer>- Parameters:
elementType- the target element type for the output streammimeType- the mime type associated with the stream to decode (can benullif not specified)- Returns:
trueif supported,falseotherwise
-
decode
public reactor.core.publisher.Flux<DataBuffer> decode(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Description copied from interface:DecoderDecode aDataBufferinput stream into a Flux ofT.- Specified by:
decodein interfaceDecoder<DataBuffer>- Overrides:
decodein classAbstractDataBufferDecoder<DataBuffer>- Parameters:
input- theDataBufferinput stream to decodeelementType- the expected type of elements in the output stream; this type must have been previously passed to theDecoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)method and it must have returnedtrue.mimeType- the MIME type associated with the input stream (optional)hints- additional information about how to do decode- Returns:
- the output stream with decoded elements
-
decode
public DataBuffer decode(DataBuffer buffer, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Description copied from interface:DecoderDecode a data buffer to an Object of type T. This is useful for scenarios, that distinct messages (or events) are decoded and handled individually, in fully aggregated form.- Parameters:
buffer- theDataBufferto decodeelementType- the expected output typemimeType- the MIME type associated with the datahints- additional information about how to do decode- Returns:
- the decoded value, possibly
null
-