类 DecoderHttpMessageReader<T>
- java.lang.Object
- org.springframework.http.codec.DecoderHttpMessageReader<T>
- 类型参数:
T- the type of objects in the decoded output stream
- 所有已实现的接口:
HttpMessageReader<T>
- 直接已知子类:
ResourceHttpMessageReader
public class DecoderHttpMessageReader<T> extends Object implements HttpMessageReader<T>
HttpMessageReaderthat wraps and delegates to aDecoder.Also a
HttpMessageReaderthat pre-resolves decoding hints from the extra information available on the server side such as the request or controller method parameter annotations.- 从以下版本开始:
- 5.0
- 作者:
- Arjen Poutsma, Sebastien Deleuze, Rossen Stoyanchev
构造器概要
构造器 构造器 说明 DecoderHttpMessageReader(Decoder<T> decoder)Create an instance wrapping the givenDecoder.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 booleancanRead(ResolvableType elementType, MediaType mediaType)Whether the given object type is supported by this reader.protected MediaTypegetContentType(HttpMessage inputMessage)Determine the Content-Type of the HTTP message based on the "Content-Type" header or otherwise default toMediaType.APPLICATION_OCTET_STREAM.Decoder<T>getDecoder()Return theDecoderof this reader.List<MediaType>getReadableMediaTypes()Return theMediaType's that this reader supports.protected Map<String,Object>getReadHints(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response)Get additional hints for decoding for example based on the server request or annotations from controller method parameters.reactor.core.publisher.Flux<T>read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)Server-side only alternative toHttpMessageReader.read(ResolvableType, ReactiveHttpInputMessage, Map)with additional context available.reactor.core.publisher.Flux<T>read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)Read from the input message and encode to a stream of objects.reactor.core.publisher.Mono<T>readMono(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)Server-side only alternative toHttpMessageReader.readMono(ResolvableType, ReactiveHttpInputMessage, Map)with additional, context available.reactor.core.publisher.Mono<T>readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)Read from the input message and encode to a single object.
构造器详细资料
DecoderHttpMessageReader
public DecoderHttpMessageReader(Decoder<T> decoder)
Create an instance wrapping the givenDecoder.
方法详细资料
getDecoder
public Decoder<T> getDecoder()
Return theDecoderof this reader.
getReadableMediaTypes
public List<MediaType> getReadableMediaTypes()
从接口复制的说明:HttpMessageReaderReturn theMediaType's that this reader supports.- 指定者:
getReadableMediaTypes在接口中HttpMessageReader<T>
canRead
public boolean canRead(ResolvableType elementType, @Nullable MediaType mediaType)
从接口复制的说明:HttpMessageReaderWhether the given object type is supported by this reader.- 指定者:
canRead在接口中HttpMessageReader<T>- 参数:
elementType- the type of object to checkmediaType- the media type for the read (possiblynull)- 返回:
trueif readable,falseotherwise
read
public reactor.core.publisher.Flux<T> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)
从接口复制的说明:HttpMessageReaderRead from the input message and encode to a stream of objects.- 指定者:
read在接口中HttpMessageReader<T>- 参数:
elementType- the type of objects in the stream which must have been previously checked viaHttpMessageReader.canRead(ResolvableType, MediaType)message- the message to read fromhints- additional information about how to read and decode the input- 返回:
- the decoded stream of elements
readMono
public reactor.core.publisher.Mono<T> readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)
从接口复制的说明:HttpMessageReaderRead from the input message and encode to a single object.- 指定者:
readMono在接口中HttpMessageReader<T>- 参数:
elementType- the type of objects in the stream which must have been previously checked viaHttpMessageReader.canRead(ResolvableType, MediaType)message- the message to read fromhints- additional information about how to read and decode the input- 返回:
- the decoded object
getContentType
@Nullable protected MediaType getContentType(HttpMessage inputMessage)
Determine the Content-Type of the HTTP message based on the "Content-Type" header or otherwise default toMediaType.APPLICATION_OCTET_STREAM.- 参数:
inputMessage- the HTTP message- 返回:
- the MediaType, possibly
null.
read
public reactor.core.publisher.Flux<T> read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
从接口复制的说明:HttpMessageReaderServer-side only alternative toHttpMessageReader.read(ResolvableType, ReactiveHttpInputMessage, Map)with additional context available.- 指定者:
read在接口中HttpMessageReader<T>- 参数:
actualType- the actual type of the target method parameter; for annotated controllers, theMethodParametercan be accessed viaResolvableType.getSource().elementType- the type of Objects in the output streamrequest- the current requestresponse- the current responsehints- additional information about how to read the body- 返回:
- the decoded stream of elements
readMono
public reactor.core.publisher.Mono<T> readMono(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
从接口复制的说明:HttpMessageReaderServer-side only alternative toHttpMessageReader.readMono(ResolvableType, ReactiveHttpInputMessage, Map)with additional, context available.- 指定者:
readMono在接口中HttpMessageReader<T>- 参数:
actualType- the actual type of the target method parameter; for annotated controllers, theMethodParametercan be accessed viaResolvableType.getSource().elementType- the type of Objects in the output streamrequest- the current requestresponse- the current responsehints- additional information about how to read the body- 返回:
- the decoded stream of elements
getReadHints
protected Map<String,Object> getReadHints(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response)
Get additional hints for decoding for example based on the server request or annotations from controller method parameters. By default, delegate to the decoder if it is an instance ofHttpMessageDecoder.