Package org.springframework.core.codec
Interface Decoder<T>
- Type Parameters:
- T- the type of elements in the output stream
- All Known Subinterfaces:
- HttpMessageDecoder<T>
- All Known Implementing Classes:
- AbstractCharSequenceDecoder,- AbstractDataBufferDecoder,- AbstractDecoder,- AbstractJackson2Decoder,- ByteArrayDecoder,- ByteBufferDecoder,- CharBufferDecoder,- DataBufferDecoder,- Jackson2CborDecoder,- Jackson2JsonDecoder,- Jackson2SmileDecoder,- Jaxb2XmlDecoder,- KotlinSerializationBinaryDecoder,- KotlinSerializationCborDecoder,- KotlinSerializationJsonDecoder,- KotlinSerializationProtobufDecoder,- KotlinSerializationStringDecoder,- Netty5BufferDecoder,- NettyByteBufDecoder,- ProtobufDecoder,- ResourceDecoder,- StringDecoder,- XmlEventDecoder
public interface Decoder<T>
Strategy for decoding a 
DataBuffer input stream into an output stream
 of elements of type <T>.- Since:
- 5.0
- Author:
- Sebastien Deleuze, Rossen Stoyanchev
- 
Method SummaryModifier and TypeMethodDescriptionbooleancanDecode(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<T>decode(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) Decode aDataBufferinput stream into a Flux ofT.default Tdecode(DataBuffer buffer, ResolvableType targetType, MimeType mimeType, Map<String, Object> hints) Decode a data buffer to an Object of type T.reactor.core.publisher.Mono<T>decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) Decode aDataBufferinput stream into a Mono ofT.Return the list of MIME types supported by this Decoder.getDecodableMimeTypes(ResolvableType targetType) Return the list of MIME types supported by this Decoder for the given type of element.
- 
Method Details- 
canDecodeWhether the decoder supports the given target element type and the MIME type of the source stream.- Parameters:
- elementType- the target element type for the output stream
- mimeType- the mime type associated with the stream to decode (can be- nullif not specified)
- Returns:
- trueif supported,- falseotherwise
 
- 
decodereactor.core.publisher.Flux<T> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Decode aDataBufferinput stream into a Flux ofT.- Parameters:
- inputStream- the- DataBufferinput stream to decode
- elementType- the expected type of elements in the output stream; this type must have been previously passed to the- 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 decode
- Returns:
- the output stream with decoded elements
 
- 
decodeToMonoreactor.core.publisher.Mono<T> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Decode aDataBufferinput stream into a Mono ofT.- Parameters:
- inputStream- the- DataBufferinput stream to decode
- elementType- the expected type of elements in the output stream; this type must have been previously passed to the- 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 decode
- Returns:
- the output stream with the decoded element
 
- 
decode@Nullable default T decode(DataBuffer buffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingExceptionDecode 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- the- DataBufferto decode
- targetType- the expected output type
- mimeType- the MIME type associated with the data
- hints- additional information about how to do decode
- Returns:
- the decoded value, possibly null
- Throws:
- DecodingException
- Since:
- 5.2
 
- 
getDecodableMimeTypesReturn 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 viacanDecode(elementType, null). The list may also exclude MIME types supported only for a specific element type. Alternatively, usegetDecodableMimeTypes(ResolvableType)for a more precise list.- Returns:
- the list of supported MIME types
 
- 
getDecodableMimeTypesReturn the list of MIME types supported by this Decoder for the given type of element. This list may differ fromgetDecodableMimeTypes()if the Decoder doesn't support the given element type or if it supports it only for a subset of MIME types.- Parameters:
- targetType- the type of element to check for decoding
- Returns:
- the list of MIME types supported for the given target type
- Since:
- 5.3.4
 
 
-