Top Description Methods
org.springframework.core.codec

public Interface Decoder<T>

Known Direct Implementers
org.springframework.core.codec.AbstractDecoder
Type Parameters
<T>
the type of elements in the output stream
Imports
java.util.Collections, .List, .Map, java.util.concurrent.CompletableFuture, .ExecutionException, org.reactivestreams.Publisher, reactor.core.publisher.Flux, .Mono, org.springframework.core.ResolvableType, org.springframework.core.io.buffer.DataBuffer, org.springframework.lang.Nullable, org.springframework.util.Assert, .MimeType

Strategy for decoding a DataBuffer input stream into an output stream of elements of type <T>.
Authors
Sebastien Deleuze, Rossen Stoyanchev
Since
5.0

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if supported, false otherwise
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
)

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

public Flux<T>

Returns:

the output stream with decoded elements
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
)

Decode a DataBuffer input stream into a Flux of T.

public default T

Returns:

the decoded value, possibly null
decode
(DataBuffer
the DataBuffer to decode
buffer
,
ResolvableType
the expected output type
targetType
,
MimeType
the MIME type associated with the data
mimeType
,
Map<String, Object>
additional information about how to do decode
hints
)

Decode a data buffer to an Object of type T.

public Mono<T>

Returns:

the output stream with the decoded element
decodeToMono
(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
)

Decode a DataBuffer input stream into a Mono of T.

public List<MimeType>

Returns:

the list of supported MIME types
getDecodableMimeTypes
()

Return the list of MIME types supported by this Decoder.

public default List<MimeType>

Returns:

the list of MIME types supported for the given target type
getDecodableMimeTypes
(ResolvableType
the type of element to check for decoding
targetType
)

Return the list of MIME types supported by this Decoder for the given type of element.

Method Detail

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

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

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

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<T>

the output stream with decoded elements

decodeback to summary
public default T decode(DataBuffer buffer, ResolvableType targetType, MimeType mimeType, Map<String, Object> hints) throws DecodingException

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

the DataBuffer to decode

targetType: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:T

the decoded value, possibly null

Annotations
@Nullable
Since
5.2
decodeToMonoback to summary
public Mono<T> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Decode a DataBuffer input stream into a Mono 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:Mono<T>

the output stream with the decoded element

getDecodableMimeTypesback to summary
public List<MimeType> getDecodableMimeTypes()

Return the list of MIME types supported by this Decoder. The list may not apply to every possible target element type and calls to this method should typically be guarded via canDecode(elementType, null). The list may also exclude MIME types supported only for a specific element type. Alternatively, use getDecodableMimeTypes(ResolvableType) for a more precise list.

Returns:List<MimeType>

the list of supported MIME types

getDecodableMimeTypesback to summary
public default List<MimeType> getDecodableMimeTypes(ResolvableType targetType)

Return the list of MIME types supported by this Decoder for the given type of element. This list may differ from getDecodableMimeTypes() if the Decoder doesn't support the given element type or if it supports it only for a subset of MIME types.

Parameters
targetType:ResolvableType

the type of element to check for decoding

Returns:List<MimeType>

the list of MIME types supported for the given target type

Since
5.3.4