类 EncoderHttpMessageWriter<T>
java.lang.Object
cn.taketoday.http.codec.EncoderHttpMessageWriter<T>
- 类型参数:
T- the type of objects in the input stream
- 所有已实现的接口:
HttpMessageWriter<T>
- 直接已知子类:
ProtobufHttpMessageWriter
HttpMessageWriter that wraps and delegates to an Encoder.
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.
- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma, Sebastien Deleuze, Rossen Stoyanchev, Brian Clozel, Sam Brannen
-
字段概要
字段 -
构造器概要
构造器构造器说明EncoderHttpMessageWriter(cn.taketoday.core.codec.Encoder<T> encoder) Create an instance wrapping the givenEncoder. -
方法概要
修饰符和类型方法说明private static MediaTypeaddDefaultCharset(MediaType main, MediaType defaultType) booleanWhether the given object type is supported by this writer.cn.taketoday.core.codec.Encoder<T>Return theEncoderof this writer.Return the list of media types supported by this Writer.getWritableMediaTypes(cn.taketoday.core.ResolvableType elementType) Return the list of media types supported by this Writer for the given type of element.getWriteHints(cn.taketoday.core.ResolvableType streamType, cn.taketoday.core.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.private static MediaTypeinitDefaultMediaType(List<MediaType> mediaTypes) private static voidinitLogger(cn.taketoday.core.codec.Encoder<?> encoder) private booleanisStreamingMediaType(MediaType mediaType) private booleanmatchParameters(MediaType streamingMediaType, MediaType mediaType) private MediaTypeupdateContentType(ReactiveHttpOutputMessage message, MediaType mediaType) private static booleanuseFallback(MediaType main, MediaType fallback) reactor.core.publisher.Mono<Void>write(org.reactivestreams.Publisher<? extends T> inputStream, cn.taketoday.core.ResolvableType actualType, cn.taketoday.core.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, cn.taketoday.core.ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints) Write an given stream of object to the output message.
-
字段详细资料
-
logger
private static final cn.taketoday.logging.Logger logger -
encoder
-
mediaTypes
-
defaultMediaType
-
-
构造器详细资料
-
EncoderHttpMessageWriter
Create an instance wrapping the givenEncoder.
-
-
方法详细资料
-
initLogger
private static void initLogger(cn.taketoday.core.codec.Encoder<?> encoder) -
initDefaultMediaType
-
getEncoder
Return theEncoderof this writer. -
getWritableMediaTypes
从接口复制的说明:HttpMessageWriterReturn the list of media types supported by this Writer. The list may not apply to every possible target element type and calls to this method should typically be guarded viacanWrite(elementType, null). The list may also exclude media types supported only for a specific element type. Alternatively, useHttpMessageWriter.getWritableMediaTypes(ResolvableType)for a more precise list.- 指定者:
getWritableMediaTypes在接口中HttpMessageWriter<T>- 返回:
- the general list of supported media types
-
getWritableMediaTypes
从接口复制的说明:HttpMessageWriterReturn the list of media types supported by this Writer for the given type of element. This list may differ fromHttpMessageWriter.getWritableMediaTypes()if the Writer doesn't support the element type, or if it supports it only for a subset of media types.- 指定者:
getWritableMediaTypes在接口中HttpMessageWriter<T>- 参数:
elementType- the type of element to encode- 返回:
- the list of media types supported for the given class
-
canWrite
public boolean canWrite(cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType) 从接口复制的说明:HttpMessageWriterWhether 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)- 返回:
trueif writable,falseotherwise
-
write
public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends T> inputStream, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints) 从接口复制的说明:HttpMessageWriterWrite 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 (possiblynullto 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
-
updateContentType
@Nullable private MediaType updateContentType(ReactiveHttpOutputMessage message, @Nullable MediaType mediaType) -
useFallback
-
addDefaultCharset
-
isStreamingMediaType
-
matchParameters
-
write
public reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends T> inputStream, cn.taketoday.core.ResolvableType actualType, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> hints) 从接口复制的说明:HttpMessageWriterServer-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, theParametercan be accessed viaResolvableType.getSource().elementType- the type of Objects in the input streammediaType- the content type to use (possiblynullindicating the default content type of the writer should be used)request- the current requestresponse- the current response- 返回:
- a
Monothat indicates completion of writing or error
-
getWriteHints
protected Map<String,Object> getWriteHints(cn.taketoday.core.ResolvableType streamType, cn.taketoday.core.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.
-