接口 Decoder<T>
- 类型参数:
T
- the type of elements in the output stream
- 所有已知子接口:
HttpMessageDecoder<T>
- 所有已知实现类:
AbstractDataBufferDecoder
,AbstractDecoder
,AbstractJackson2Decoder
,ByteArrayDecoder
,ByteBufferDecoder
,DataBufferDecoder
,Jackson2CborDecoder
,Jackson2JsonDecoder
,Jackson2SmileDecoder
,Jaxb2XmlDecoder
,ProtobufDecoder
,ResourceDecoder
,StringDecoder
,XmlEventDecoder
public interface Decoder<T>
Strategy for decoding aDataBuffer
input stream into an output stream of elements of type<T>
.- 从以下版本开始:
- 5.0
- 作者:
- Sebastien Deleuze, Rossen Stoyanchev
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 boolean
canDecode(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(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)
Decode aDataBuffer
input stream into a Flux ofT
.default T
decode(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(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)
Decode aDataBuffer
input stream into a Mono ofT
.List<MimeType>
getDecodableMimeTypes()
Return the list of MIME types this decoder supports.
方法详细资料
canDecode
boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType)
Whether the decoder supports the given target element type and the MIME type of the source stream.- 参数:
elementType
- the target element type for the output streammimeType
- the mime type associated with the stream to decode (can benull
if not specified)- 返回:
true
if supported,false
otherwise
decode
reactor.core.publisher.Flux<T> decode(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
Decode aDataBuffer
input stream into a Flux ofT
.- 参数:
inputStream
- theDataBuffer
input stream to decodeelementType
- the expected type of elements in the output stream; this type must have been previously passed to thecanDecode(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- 返回:
- the output stream with decoded elements
decodeToMono
reactor.core.publisher.Mono<T> decodeToMono(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
Decode aDataBuffer
input stream into a Mono ofT
.- 参数:
inputStream
- theDataBuffer
input stream to decodeelementType
- the expected type of elements in the output stream; this type must have been previously passed to thecanDecode(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- 返回:
- 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 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.- 参数:
buffer
- theDataBuffer
to decodetargetType
- the expected output typemimeType
- the MIME type associated with the datahints
- additional information about how to do encode- 返回:
- the decoded value, possibly
null
- 抛出:
DecodingException
- 从以下版本开始:
- 5.2
getDecodableMimeTypes
List<MimeType> getDecodableMimeTypes()
Return the list of MIME types this decoder supports.