类 AbstractJackson2Encoder

java.lang.Object
cn.taketoday.http.codec.json.Jackson2CodecSupport
cn.taketoday.http.codec.json.AbstractJackson2Encoder
所有已实现的接口:
cn.taketoday.core.codec.Encoder<Object>, HttpMessageEncoder<Object>
直接已知子类:
Jackson2CborEncoder, Jackson2JsonEncoder, Jackson2SmileEncoder

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
  • 字段详细资料

    • NEWLINE_SEPARATOR

      private static final byte[] NEWLINE_SEPARATOR
    • EMPTY_BYTES

      private static final byte[] EMPTY_BYTES
    • ENCODINGS

      private static final Map<String,JsonEncoding> ENCODINGS
    • streamingMediaTypes

      private final List<MediaType> streamingMediaTypes
  • 构造器详细资料

    • AbstractJackson2Encoder

      protected AbstractJackson2Encoder(ObjectMapper mapper, cn.taketoday.util.MimeType... mimeTypes)
      Constructor with a Jackson ObjectMapper to use.
  • 方法详细资料

    • setStreamingMediaTypes

      public void setStreamingMediaTypes(List<MediaType> mediaTypes)
      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

      private void logValue(@Nullable Map<String,Object> hints, Object value)
    • 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 customize ObjectWriter used for writing values.
      参数:
      writer - the writer instance to customize
      mimeType - the selected MIME type
      elementType - the type of element values to write
      hints - a map with serialization hints; the Reactor Context, when available, may be accessed under the key ContextView.class.getName()
      返回:
      the customized ObjectWriter to 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 configured streaming mime types.

    • getJsonEncoding

      protected JsonEncoding getJsonEncoding(@Nullable cn.taketoday.util.MimeType mimeType)
      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

      public List<cn.taketoday.util.MimeType> 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

      public List<MediaType> getStreamingMediaTypes()
      从接口复制的说明: HttpMessageEncoder
      Return "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)
      从接口复制的说明: HttpMessageEncoder
      Get 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 from Parameter, i.e. providing access to method annotations.
      elementType - the element type within Flux/Mono that we're trying to encode.
      request - the current request
      response - 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