Package org.springframework.core.codec
Class ResourceDecoder
- java.lang.Object
- org.springframework.core.codec.AbstractDecoder<T>
- org.springframework.core.codec.AbstractDataBufferDecoder<Resource>
- org.springframework.core.codec.ResourceDecoder
public class ResourceDecoder extends AbstractDataBufferDecoder<Resource>
Decoder forResources.- Since:
- 5.0
- Author:
- Arjen Poutsma, Rossen Stoyanchev
Field Summary
Fields Modifier and Type Field Description static StringFILENAME_HINTName of hint with a filename for the resource(e.g.Fields inherited from class org.springframework.core.codec.AbstractDecoder
logger
Constructor Summary
Constructors Constructor Description ResourceDecoder()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanDecode(ResolvableType elementType, MimeType mimeType)Whether the decoder supports the given target element type and the MIME type of the source stream.reactor.core.publisher.Flux<Resource>decode(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)Decode aDataBufferinput stream into a Flux ofT.Resourcedecode(DataBuffer dataBuffer, ResolvableType elementType, MimeType mimeType, 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, setMaxInMemorySize
Methods inherited from class org.springframework.core.codec.AbstractDecoder
getDecodableMimeTypes, getLogger, setLogger
Field Detail
FILENAME_HINT
public static String FILENAME_HINT
Name of hint with a filename for the resource(e.g. from "Content-Disposition" HTTP header).
Constructor Detail
ResourceDecoder
public ResourceDecoder()
Method Detail
canDecode
public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType)
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<Resource>- Overrides:
canDecodein classAbstractDecoder<Resource>- 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<Resource> decode(org.reactivestreams.Publisher<DataBuffer> inputStream, 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<Resource>- Overrides:
decodein classAbstractDataBufferDecoder<Resource>- Parameters:
inputStream- 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 encode- Returns:
- the output stream with decoded elements
decode
public Resource decode(DataBuffer dataBuffer, 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:
dataBuffer- theDataBufferto decodeelementType- the expected output typemimeType- the MIME type associated with the datahints- additional information about how to do encode- Returns:
- the decoded value, possibly
null