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

public Class ResourceDecoder

extends AbstractDataBufferDecoder<Resource>
Class Inheritance
Imports
java.io.ByteArrayInputStream, java.util.Map, org.reactivestreams.Publisher, reactor.core.publisher.Flux, org.springframework.core.ResolvableType, org.springframework.core.io.ByteArrayResource, .InputStreamResource, .Resource, org.springframework.core.io.buffer.DataBuffer, .DataBufferUtils, org.springframework.lang.Nullable, org.springframework.util.MimeType, .MimeTypeUtils

Decoder for Resources.
Authors
Arjen Poutsma, Rossen Stoyanchev
Since
5.0

Field Summary

Modifier and TypeField and Description
public static final String
FILENAME_HINT

Name of hint with a filename for the resource(e.g. from "Content-Disposition" HTTP header).

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
canDecode(ResolvableType
the target element type for the output stream
elementType
,
MimeType
the mime type associated with the stream to decode (can be null if not specified)
mimeType
)

Overrides org.springframework.core.codec.AbstractDecoder.canDecode.

Implements org.springframework.core.codec.Decoder.canDecode.

Whether the decoder supports the given target element type and the MIME type of the source stream.
public Flux<Resource>
decode(Publisher<DataBuffer>
the DataBuffer input stream to decode
inputStream
,
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.AbstractDataBufferDecoder.decode.

Implements org.springframework.core.codec.Decoder.decode.

Decode a DataBuffer input stream into a Flux of T.
public Resource
decode(DataBuffer
the DataBuffer to decode
dataBuffer
,
ResolvableType
the expected output type
elementType
,
MimeType
the MIME type associated with the data
mimeType
,
Map<String, Object>
additional information about how to do decode
hints
)

Overrides default org.springframework.core.codec.Decoder.decode.

Decode a data buffer to an Object of type T.
Inherited from org.springframework.core.codec.AbstractDataBufferDecoder:
decodeDataBufferdecodeToMonogetMaxInMemorySizesetMaxInMemorySize

Field Detail

FILENAME_HINTback to summary
public static final String FILENAME_HINT

Name of hint with a filename for the resource(e.g. from "Content-Disposition" HTTP header).

Constructor Detail

ResourceDecoderback to summary
public ResourceDecoder()

Method Detail

canDecodeback to summary
public boolean canDecode(ResolvableType elementType, MimeType mimeType)

Overrides org.springframework.core.codec.AbstractDecoder.canDecode.

Implements org.springframework.core.codec.Decoder.canDecode.

Doc from org.springframework.core.codec.Decoder.canDecode.

Whether the decoder supports the given target element type and the MIME type of the source stream.

Parameters
elementType:ResolvableType

the target element type for the output stream

mimeType:MimeType

the mime type associated with the stream to decode (can be null if not specified)

Returns:boolean

true if supported, false otherwise

Annotations
@Override
decodeback to summary
public Flux<Resource> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Overrides org.springframework.core.codec.AbstractDataBufferDecoder.decode.

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
inputStream: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<Resource>

the output stream with decoded elements

Annotations
@Override
decodeback to summary
public Resource decode(DataBuffer dataBuffer, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Overrides default org.springframework.core.codec.Decoder.decode.

Doc from org.springframework.core.codec.Decoder.decode.

Decode 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:DataBuffer

the DataBuffer to decode

elementType:ResolvableType

the expected output type

mimeType:MimeType

the MIME type associated with the data

hints:Map<String, Object>

additional information about how to do decode

Returns:Resource

the decoded value, possibly null

Annotations
@Override