Class Jaxb2XmlDecoder
java.lang.Object
org.springframework.core.codec.AbstractDecoder<Object>
org.springframework.http.codec.xml.Jaxb2XmlDecoder
Decode from a bytes stream containing XML elements to a stream of
Objects (POJOs).- Since:
- 5.0
- Author:
- Sebastien Deleuze, Arjen Poutsma
- See Also:
- 
Field SummaryFields inherited from class AbstractDecoderlogger
- 
Constructor SummaryConstructorsConstructorDescriptionJaxb2XmlDecoder(MimeType... supportedMimeTypes) Create aJaxb2XmlDecoderwith the specified MIME types.
- 
Method SummaryModifier and TypeMethodDescriptionbooleancanDecode(ResolvableType elementType, @Nullable 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(Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Decode aDataBufferinput stream into a Flux ofT.decode(DataBuffer dataBuffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Decode a data buffer to an Object of type T.reactor.core.publisher.Mono<Object> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Decode aDataBufferinput stream into a Mono ofT.intReturn theconfiguredbyte count limit.Function<jakarta.xml.bind.Unmarshaller, jakarta.xml.bind.Unmarshaller> Return the configured processor for customizing Unmarshaller instances.voidsetMaxInMemorySize(int byteCount) Set the max number of bytes that can be buffered by this decoder.voidsetUnmarshallerProcessor(Function<jakarta.xml.bind.Unmarshaller, jakarta.xml.bind.Unmarshaller> processor) Configure a processor function to customize Unmarshaller instances.Methods inherited from class AbstractDecodergetDecodableMimeTypes, getLogger, setLoggerMethods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DecodergetDecodableMimeTypes
- 
Constructor Details- 
Jaxb2XmlDecoderpublic Jaxb2XmlDecoder()
- 
Jaxb2XmlDecoderCreate aJaxb2XmlDecoderwith the specified MIME types.- Parameters:
- supportedMimeTypes- supported MIME types
- Since:
- 5.1.9
 
 
- 
- 
Method Details- 
setUnmarshallerProcessorpublic void setUnmarshallerProcessor(Function<jakarta.xml.bind.Unmarshaller, jakarta.xml.bind.Unmarshaller> processor) Configure a processor function to customize Unmarshaller instances.- Parameters:
- processor- the function to use
- Since:
- 5.1.3
 
- 
getUnmarshallerProcessorpublic Function<jakarta.xml.bind.Unmarshaller, jakarta.xml.bind.Unmarshaller> getUnmarshallerProcessor()Return the configured processor for customizing Unmarshaller instances.- Since:
- 5.1.3
 
- 
setMaxInMemorySizepublic 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 when using async parsing with Aalto XML, it is the size of one top-level XML tree. When the limit is exceeded,DataBufferLimitExceptionis raised.By default this is set to 256K. - Parameters:
- byteCount- the max number of bytes to buffer, or -1 for unlimited
- Since:
- 5.1.11
 
- 
getMaxInMemorySize
- 
canDecodeDescription copied from interface:DecoderWhether the decoder supports the given target element type and the MIME type of the source stream.- Specified by:
- canDecodein interface- Decoder<Object>
- Overrides:
- canDecodein class- AbstractDecoder<Object>
- Parameters:
- elementType- the target element type for the output stream
- mimeType- the mime type associated with the stream to decode (can be- nullif not specified)
- Returns:
- trueif supported,- falseotherwise
 
- 
decodepublic reactor.core.publisher.Flux<Object> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Description copied from interface:DecoderDecode aDataBufferinput stream into a Flux ofT.- Parameters:
- inputStream- the- DataBufferinput stream to decode
- elementType- the expected type of elements in the output stream; this type must have been previously passed to the- Decoder.canDecode(ResolvableType, MimeType)method and it must have returned- true.
- mimeType- the MIME type associated with the input stream (optional)
- hints- additional information about how to do decode
- Returns:
- the output stream with decoded elements
 
- 
decodeToMonopublic reactor.core.publisher.Mono<Object> decodeToMono(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Description copied from interface:DecoderDecode aDataBufferinput stream into a Mono ofT.- Specified by:
- decodeToMonoin interface- Decoder<Object>
- Overrides:
- decodeToMonoin class- AbstractDecoder<Object>
- Parameters:
- input- the- DataBufferinput stream to decode
- elementType- the expected type of elements in the output stream; this type must have been previously passed to the- Decoder.canDecode(ResolvableType, MimeType)method and it must have returned- true.
- mimeType- the MIME type associated with the input stream (optional)
- hints- additional information about how to do decode
- Returns:
- the output stream with the decoded element
 
- 
decodepublic Object decode(DataBuffer dataBuffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingExceptionDescription copied from interface: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.- Parameters:
- dataBuffer- the- DataBufferto decode
- targetType- the expected output type
- mimeType- the MIME type associated with the data
- hints- additional information about how to do decode
- Returns:
- the decoded value, possibly null
- Throws:
- DecodingException
 
 
-