类 AbstractJackson2Encoder
java.lang.Object
cn.taketoday.http.codec.json.Jackson2CodecSupport
cn.taketoday.http.codec.json.AbstractJackson2Encoder
- 所有已实现的接口:
cn.taketoday.core.codec.Encoder<Object>,HttpMessageEncoder<Object>
public abstract class AbstractJackson2Encoder
extends Jackson2CodecSupport
implements HttpMessageEncoder<Object>
Base class providing support methods for Jackson 2.9 encoding. For non-streaming use
cases,
Flux elements are collected into a List before serialization for
performance reason.- 从以下版本开始:
- 4.0
- 作者:
- Sebastien Deleuze, Arjen Poutsma
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明private static final byte[]private static final Map<String,JsonEncoding> private static final byte[]从类继承的字段 cn.taketoday.http.codec.json.Jackson2CodecSupport
ACTUAL_TYPE_HINT, JSON_VIEW_HINT, logger -
构造器概要
构造器限定符构造器说明protectedAbstractJackson2Encoder(ObjectMapper mapper, cn.taketoday.util.MimeType... mimeTypes) Constructor with a JacksonObjectMapperto use. -
方法概要
修饰符和类型方法说明booleancanEncode(cn.taketoday.core.ResolvableType elementType, cn.taketoday.util.MimeType mimeType) private ObjectWritercreateObjectWriter(ObjectMapper mapper, cn.taketoday.core.ResolvableType valueType, cn.taketoday.util.MimeType mimeType, Class<?> jsonView, Map<String, Object> hints) protected ObjectWritercustomizeWriter(ObjectWriter writer, cn.taketoday.util.MimeType mimeType, cn.taketoday.core.ResolvableType elementType, Map<String, Object> hints) Subclasses can use this method to customizeObjectWriterused for writing values.reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>encode(org.reactivestreams.Publisher<?> inputStream, cn.taketoday.core.io.buffer.DataBufferFactory bufferFactory, cn.taketoday.core.ResolvableType elementType, cn.taketoday.util.MimeType mimeType, Map<String, Object> hints) private cn.taketoday.core.io.buffer.DataBufferencodeStreamingValue(Object value, cn.taketoday.core.io.buffer.DataBufferFactory bufferFactory, Map<String, Object> hints, SequenceWriter sequenceWriter, ByteArrayBuilder byteArrayBuilder, byte[] prefix, byte[] suffix) cn.taketoday.core.io.buffer.DataBufferencodeValue(Object value, cn.taketoday.core.io.buffer.DataBufferFactory bufferFactory, cn.taketoday.core.ResolvableType valueType, cn.taketoday.util.MimeType mimeType, Map<String, Object> hints) protected <A extends Annotation>
AgetAnnotation(cn.taketoday.core.MethodParameter parameter, Class<A> annotType) List<cn.taketoday.util.MimeType>List<cn.taketoday.util.MimeType>getEncodableMimeTypes(cn.taketoday.core.ResolvableType elementType) getEncodeHints(cn.taketoday.core.ResolvableType actualType, cn.taketoday.core.ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) Get decoding hints based on the server request or annotations on the target controller method parameter.protected JsonEncodinggetJsonEncoding(cn.taketoday.util.MimeType mimeType) Determine the JSON encoding to use for the given mime type.Return "streaming" media types for which flushing should be performed automatically vs at the end of the input stream.protected byte[]getStreamingMediaTypeSeparator(cn.taketoday.util.MimeType mimeType) Return the separator to use for the given mime type.private voidvoidsetStreamingMediaTypes(List<MediaType> mediaTypes) Configure "streaming" media types for which flushing should be performed automatically vs at the end of the stream.从类继承的方法 cn.taketoday.http.codec.json.Jackson2CodecSupport
getHints, getJavaType, getMediaTypesForProblemDetail, getMimeTypes, getMimeTypes, getObjectMapper, getObjectMapperRegistrations, getObjectMappersForType, getParameter, logWarningIfNecessary, notSupportsMimeType, registerObjectMappersForType, selectObjectMapper, setObjectMapper
-
字段详细资料
-
NEWLINE_SEPARATOR
private static final byte[] NEWLINE_SEPARATOR -
EMPTY_BYTES
private static final byte[] EMPTY_BYTES -
ENCODINGS
-
streamingMediaTypes
-
-
构造器详细资料
-
AbstractJackson2Encoder
Constructor with a JacksonObjectMapperto use.
-
-
方法详细资料
-
setStreamingMediaTypes
Configure "streaming" media types for which flushing should be performed automatically vs at the end of the stream. -
canEncode
public boolean canEncode(cn.taketoday.core.ResolvableType elementType, @Nullable cn.taketoday.util.MimeType mimeType) - 指定者:
canEncode在接口中cn.taketoday.core.codec.Encoder<Object>
-
encode
public reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer> encode(org.reactivestreams.Publisher<?> inputStream, cn.taketoday.core.io.buffer.DataBufferFactory bufferFactory, cn.taketoday.core.ResolvableType elementType, @Nullable cn.taketoday.util.MimeType mimeType, @Nullable Map<String, Object> hints) - 指定者:
encode在接口中cn.taketoday.core.codec.Encoder<Object>
-
encodeValue
public cn.taketoday.core.io.buffer.DataBuffer encodeValue(Object value, cn.taketoday.core.io.buffer.DataBufferFactory bufferFactory, cn.taketoday.core.ResolvableType valueType, @Nullable cn.taketoday.util.MimeType mimeType, @Nullable Map<String, Object> hints) - 指定者:
encodeValue在接口中cn.taketoday.core.codec.Encoder<Object>
-
encodeStreamingValue
private cn.taketoday.core.io.buffer.DataBuffer encodeStreamingValue(Object value, cn.taketoday.core.io.buffer.DataBufferFactory bufferFactory, @Nullable Map<String, Object> hints, SequenceWriter sequenceWriter, ByteArrayBuilder byteArrayBuilder, byte[] prefix, byte[] suffix) -
logValue
-
createObjectWriter
private ObjectWriter createObjectWriter(ObjectMapper mapper, cn.taketoday.core.ResolvableType valueType, @Nullable cn.taketoday.util.MimeType mimeType, @Nullable Class<?> jsonView, @Nullable Map<String, Object> hints) -
customizeWriter
protected ObjectWriter customizeWriter(ObjectWriter writer, @Nullable cn.taketoday.util.MimeType mimeType, cn.taketoday.core.ResolvableType elementType, @Nullable Map<String, Object> hints) Subclasses can use this method to customizeObjectWriterused for writing values.- 参数:
writer- the writer instance to customizemimeType- the selected MIME typeelementType- the type of element values to writehints- a map with serialization hints; the Reactor Context, when available, may be accessed under the keyContextView.class.getName()- 返回:
- the customized
ObjectWriterto use
-
getStreamingMediaTypeSeparator
@Nullable protected byte[] getStreamingMediaTypeSeparator(@Nullable cn.taketoday.util.MimeType mimeType) Return the separator to use for the given mime type.By default, this method returns new line
"\n"if the given mime type is one of the configuredstreamingmime types. -
getJsonEncoding
Determine the JSON encoding to use for the given mime type.- 参数:
mimeType- the mime type as requested by the caller- 返回:
- the JSON encoding to use (never
null)
-
getEncodableMimeTypes
- 指定者:
getEncodableMimeTypes在接口中cn.taketoday.core.codec.Encoder<Object>
-
getEncodableMimeTypes
public List<cn.taketoday.util.MimeType> getEncodableMimeTypes(cn.taketoday.core.ResolvableType elementType) - 指定者:
getEncodableMimeTypes在接口中cn.taketoday.core.codec.Encoder<Object>
-
getStreamingMediaTypes
从接口复制的说明:HttpMessageEncoderReturn "streaming" media types for which flushing should be performed automatically vs at the end of the input stream.- 指定者:
getStreamingMediaTypes在接口中HttpMessageEncoder<Object>
-
getEncodeHints
public Map<String,Object> getEncodeHints(@Nullable cn.taketoday.core.ResolvableType actualType, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response) 从接口复制的说明:HttpMessageEncoderGet decoding hints based on the server request or annotations on the target controller method parameter.- 指定者:
getEncodeHints在接口中HttpMessageEncoder<Object>- 参数:
actualType- the actual source type to encode, possibly a reactive wrapper and sourced fromParameter, i.e. providing access to method annotations.elementType- the element type withinFlux/Monothat we're trying to encode.request- the current requestresponse- the current response- 返回:
- a Map with hints, possibly empty
-
getAnnotation
protected <A extends Annotation> A getAnnotation(cn.taketoday.core.MethodParameter parameter, Class<A> annotType) - 指定者:
getAnnotation在类中Jackson2CodecSupport
-