类 AbstractJackson2Decoder
- java.lang.Object
- org.springframework.http.codec.json.Jackson2CodecSupport
- org.springframework.http.codec.json.AbstractJackson2Decoder
- 所有已实现的接口:
Decoder<Object>,HttpMessageDecoder<Object>
public abstract class AbstractJackson2Decoder extends Jackson2CodecSupport implements HttpMessageDecoder<Object>
Abstract base class for Jackson 2.9 decoding, leveraging non-blocking parsing.Compatible with Jackson 2.9.7 and higher.
- 从以下版本开始:
- 5.0
- 作者:
- Sebastien Deleuze, Rossen Stoyanchev, Arjen Poutsma
- 另请参阅:
- Add support for non-blocking ("async") JSON parsing
字段概要
从类继承的字段 org.springframework.http.codec.json.Jackson2CodecSupport
JSON_VIEW_HINT, logger
构造器概要
构造器 限定符 构造器 说明 protectedAbstractJackson2Decoder(ObjectMapper mapper, MimeType... mimeTypes)Constructor with a JacksonObjectMapperto use.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 booleancanDecode(ResolvableType elementType, MimeType mimeType)Whether the decoder supports the given target element type and the MIME type of the source stream.reactor.core.publisher.Flux<Object>decode(org.reactivestreams.Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)Decode aDataBufferinput stream into a Flux ofT.Objectdecode(DataBuffer dataBuffer, ResolvableType targetType, MimeType mimeType, Map<String,Object> hints)Decode a data buffer to an Object of type T.reactor.core.publisher.Mono<Object>decodeToMono(org.reactivestreams.Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)Decode aDataBufferinput stream into a Mono ofT.protected <A extends Annotation>
AgetAnnotation(MethodParameter parameter, Class<A> annotType)List<MimeType>getDecodableMimeTypes()Return the list of MIME types this decoder supports.Map<String,Object>getDecodeHints(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response)Get decoding hints based on the server request or annotations on the target controller method parameter.intgetMaxInMemorySize()Return theconfiguredbyte count limit.protected reactor.core.publisher.Flux<DataBuffer>processInput(org.reactivestreams.Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)Process the input publisher into a flux.voidsetMaxInMemorySize(int byteCount)Set the max number of bytes that can be buffered by this decoder.从类继承的方法 org.springframework.http.codec.json.Jackson2CodecSupport
getHints, getJavaType, getMimeTypes, getObjectMapper, getParameter, supportsMimeType
构造器详细资料
AbstractJackson2Decoder
protected AbstractJackson2Decoder(ObjectMapper mapper, MimeType... mimeTypes)
Constructor with a JacksonObjectMapperto use.
方法详细资料
setMaxInMemorySize
public void setMaxInMemorySize(int byteCount)
Set the max number of bytes that can be buffered by this decoder. This is either the size of the entire input when decoding as a whole, or the size of one top-level JSON object within a JSON stream. When the limit is exceeded,DataBufferLimitExceptionis raised.By default this is set to 256K.
- 参数:
byteCount- the max number of bytes to buffer, or -1 for unlimited- 从以下版本开始:
- 5.1.11
getMaxInMemorySize
public int getMaxInMemorySize()
Return theconfiguredbyte count limit.- 从以下版本开始:
- 5.1.11
canDecode
public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType)
从接口复制的说明:DecoderWhether the decoder supports the given target element type and the MIME type of the source stream.
decode
public reactor.core.publisher.Flux<Object> decode(org.reactivestreams.Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
从接口复制的说明:DecoderDecode aDataBufferinput stream into a Flux ofT.- 指定者:
decode在接口中Decoder<Object>- 参数:
input- theDataBufferinput stream to decodeelementType- the expected type of elements in the output stream; this type must have been previously passed to theDecoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)method and it must have returnedtrue.mimeType- the MIME type associated with the input stream (optional)hints- additional information about how to do encode- 返回:
- the output stream with decoded elements
processInput
protected reactor.core.publisher.Flux<DataBuffer> processInput(org.reactivestreams.Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
Process the input publisher into a flux. Default implementation returnsFlux.from(Publisher), but subclasses can choose to customize this behavior.- 参数:
input- theDataBufferinput stream to processelementType- the expected type of elements in the output streammimeType- the MIME type associated with the input stream (optional)hints- additional information about how to do encode- 返回:
- the processed flux
- 从以下版本开始:
- 5.1.14
decodeToMono
public reactor.core.publisher.Mono<Object> decodeToMono(org.reactivestreams.Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
从接口复制的说明:DecoderDecode aDataBufferinput stream into a Mono ofT.- 指定者:
decodeToMono在接口中Decoder<Object>- 参数:
input- theDataBufferinput stream to decodeelementType- the expected type of elements in the output stream; this type must have been previously passed to theDecoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)method and it must have returnedtrue.mimeType- the MIME type associated with the input stream (optional)hints- additional information about how to do encode- 返回:
- the output stream with the decoded element
decode
public Object decode(DataBuffer dataBuffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints) throws DecodingException
从接口复制的说明:DecoderDecode a data buffer to an Object of type T. This is useful for scenarios, that distinct messages (or events) are decoded and handled individually, in fully aggregated form.- 指定者:
decode在接口中Decoder<Object>- 参数:
dataBuffer- theDataBufferto decodetargetType- the expected output typemimeType- the MIME type associated with the datahints- additional information about how to do encode- 返回:
- the decoded value, possibly
null - 抛出:
DecodingException
getDecodeHints
public Map<String,Object> getDecodeHints(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response)
从接口复制的说明:HttpMessageDecoderGet decoding hints based on the server request or annotations on the target controller method parameter.- 指定者:
getDecodeHints在接口中HttpMessageDecoder<Object>- 参数:
actualType- the actual target type to decode to, possibly a reactive wrapper and sourced fromMethodParameter, i.e. providing access to method parameter annotationselementType- the element type withinFlux/Monothat we're trying to decode torequest- the current requestresponse- the current response- 返回:
- a Map with hints, possibly empty
getDecodableMimeTypes
public List<MimeType> getDecodableMimeTypes()
从接口复制的说明:DecoderReturn the list of MIME types this decoder supports.- 指定者:
getDecodableMimeTypes在接口中Decoder<Object>
getAnnotation
protected <A extends Annotation> A getAnnotation(MethodParameter parameter, Class<A> annotType)
- 指定者:
getAnnotation在类中Jackson2CodecSupport