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 Summary
Fields inherited from class AbstractDecoder
logger -
Constructor Summary
ConstructorsConstructorDescriptionJaxb2XmlDecoder(MimeType... supportedMimeTypes) Create aJaxb2XmlDecoderwith the specified MIME types. -
Method Summary
Modifier 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 AbstractDecoder
getDecodableMimeTypes, getLogger, setLoggerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Decoder
getDecodableMimeTypes
-
Constructor Details
-
Jaxb2XmlDecoder
public Jaxb2XmlDecoder() -
Jaxb2XmlDecoder
Create aJaxb2XmlDecoderwith the specified MIME types.- Parameters:
supportedMimeTypes- supported MIME types- Since:
- 5.1.9
-
-
Method Details
-
setUnmarshallerProcessor
public 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
-
getUnmarshallerProcessor
public Function<jakarta.xml.bind.Unmarshaller, jakarta.xml.bind.Unmarshaller> getUnmarshallerProcessor()Return the configured processor for customizing Unmarshaller instances.- Since:
- 5.1.3
-
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 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
-
canDecode
Description copied from interface:DecoderWhether the decoder supports the given target element type and the MIME type of the source stream.- Specified by:
canDecodein interfaceDecoder<Object>- Overrides:
canDecodein classAbstractDecoder<Object>- Parameters:
elementType- the target element type for the output streammimeType- the mime type associated with the stream to decode (can benullif not specified)- Returns:
trueif supported,falseotherwise
-
decode
public 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- theDataBufferinput stream to decodeelementType- the expected type of elements in the output stream; this type must have been previously passed to theDecoder.canDecode(ResolvableType, MimeType)method and it must have returnedtrue.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
-
decodeToMono
public 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 interfaceDecoder<Object>- Overrides:
decodeToMonoin classAbstractDecoder<Object>- Parameters:
input- theDataBufferinput stream to decodeelementType- the expected type of elements in the output stream; this type must have been previously passed to theDecoder.canDecode(ResolvableType, MimeType)method and it must have returnedtrue.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
-
decode
public 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- theDataBufferto decodetargetType- the expected output typemimeType- the MIME type associated with the datahints- additional information about how to do decode- Returns:
- the decoded value, possibly
null - Throws:
DecodingException
-