类 EncoderHttpMessageWriter<T>
- java.lang.Object
- org.springframework.http.codec.EncoderHttpMessageWriter<T>
- 类型参数:
T
- the type of objects in the input stream
- 所有已实现的接口:
HttpMessageWriter<T>
- 直接已知子类:
ProtobufHttpMessageWriter
public class EncoderHttpMessageWriter<T> extends Object implements HttpMessageWriter<T>
HttpMessageWriter
that wraps and delegates to anEncoder
.Also a
HttpMessageWriter
that pre-resolves encoding hints from the extra information available on the server side such as the request or controller method annotations.- 从以下版本开始:
- 5.0
- 作者:
- Arjen Poutsma, Sebastien Deleuze, Rossen Stoyanchev, Brian Clozel, Sam Brannen
构造器概要
构造器 构造器 说明 EncoderHttpMessageWriter(Encoder<T> encoder)
Create an instance wrapping the givenEncoder
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 boolean
canWrite(ResolvableType elementType, MediaType mediaType)
Whether the given object type is supported by this writer.Encoder<T>
getEncoder()
Return theEncoder
of this writer.List<MediaType>
getWritableMediaTypes()
Return theMediaType
's that this writer supports.protected Map<String,Object>
getWriteHints(ResolvableType streamType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response)
Get additional hints for encoding for example based on the server request or annotations from controller method parameters.reactor.core.publisher.Mono<Void>
write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
Server-side only alternative toHttpMessageWriter.write(Publisher, ResolvableType, MediaType, ReactiveHttpOutputMessage, Map)
with additional context available.reactor.core.publisher.Mono<Void>
write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
Write an given stream of object to the output message.
构造器详细资料
EncoderHttpMessageWriter
public EncoderHttpMessageWriter(Encoder<T> encoder)
Create an instance wrapping the givenEncoder
.
方法详细资料
getEncoder
public Encoder<T> getEncoder()
Return theEncoder
of this writer.
getWritableMediaTypes
public List<MediaType> getWritableMediaTypes()
从接口复制的说明:HttpMessageWriter
Return theMediaType
's that this writer supports.- 指定者:
getWritableMediaTypes
在接口中HttpMessageWriter<T>
canWrite
public boolean canWrite(ResolvableType elementType, @Nullable MediaType mediaType)
从接口复制的说明:HttpMessageWriter
Whether the given object type is supported by this writer.- 指定者:
canWrite
在接口中HttpMessageWriter<T>
- 参数:
elementType
- the type of object to checkmediaType
- the media type for the write (possiblynull
)- 返回:
true
if writable,false
otherwise
write
public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType elementType, @Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
从接口复制的说明:HttpMessageWriter
Write an given stream of object to the output message.- 指定者:
write
在接口中HttpMessageWriter<T>
- 参数:
inputStream
- the objects to writeelementType
- the type of objects in the stream which must have been previously checked viaHttpMessageWriter.canWrite(ResolvableType, MediaType)
mediaType
- the content type for the write (possiblynull
to indicate that the default content type of the writer must be used)message
- the message to write tohints
- additional information about how to encode and write- 返回:
- indicates completion or error
write
public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType actualType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
从接口复制的说明:HttpMessageWriter
Server-side only alternative toHttpMessageWriter.write(Publisher, ResolvableType, MediaType, ReactiveHttpOutputMessage, Map)
with additional context available.- 指定者:
write
在接口中HttpMessageWriter<T>
actualType
- the actual return type of the method that returned the value; for annotated controllers, theMethodParameter
can be accessed viaResolvableType.getSource()
.elementType
- the type of Objects in the input streammediaType
- the content type to use (possiblynull
indicating the default content type of the writer should be used)request
- the current requestresponse
- the current response- 返回:
- a
Mono
that indicates completion of writing or error
getWriteHints
protected Map<String,Object> getWriteHints(ResolvableType streamType, ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response)
Get additional hints for encoding for example based on the server request or annotations from controller method parameters. By default, delegate to the encoder if it is an instance ofHttpMessageEncoder
.