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
Object
s (POJOs).- Since:
- 5.0
- Author:
- Sebastien Deleuze, Arjen Poutsma
- See Also:
-
Field Summary
Fields inherited from class org.springframework.core.codec.AbstractDecoder
logger
-
Constructor Summary
ConstructorDescriptionJaxb2XmlDecoder
(MimeType... supportedMimeTypes) Create aJaxb2XmlDecoder
with the specified MIME types. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecode
(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
(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) Decode aDataBuffer
input stream into a Flux ofT
.decode
(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
(Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) Decode aDataBuffer
input stream into a Mono ofT
.int
Return theconfigured
byte count limit.Return the configured processor for customizing Unmarshaller instances.void
setMaxInMemorySize
(int byteCount) Set the max number of bytes that can be buffered by this decoder.void
setUnmarshallerProcessor
(Function<Unmarshaller, Unmarshaller> processor) Configure a processor function to customize Unmarshaller instances.Methods inherited from class org.springframework.core.codec.AbstractDecoder
getDecodableMimeTypes, getLogger, setLogger
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.codec.Decoder
getDecodableMimeTypes
-
Constructor Details
-
Jaxb2XmlDecoder
public Jaxb2XmlDecoder() -
Jaxb2XmlDecoder
Create aJaxb2XmlDecoder
with the specified MIME types.- Parameters:
supportedMimeTypes
- supported MIME types- Since:
- 5.1.9
-
-
Method Details
-
setUnmarshallerProcessor
Configure a processor function to customize Unmarshaller instances.- Parameters:
processor
- the function to use- Since:
- 5.1.3
-
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,DataBufferLimitException
is 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
public int getMaxInMemorySize()Return theconfigured
byte count limit.- Since:
- 5.1.11
-
canDecode
Description copied from interface:Decoder
Whether the decoder supports the given target element type and the MIME type of the source stream.- Specified by:
canDecode
in interfaceDecoder<Object>
- Overrides:
canDecode
in classAbstractDecoder<Object>
- Parameters:
elementType
- the target element type for the output streammimeType
- the mime type associated with the stream to decode (can benull
if not specified)- Returns:
true
if supported,false
otherwise
-
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:Decoder
Decode aDataBuffer
input stream into a Flux ofT
.- Parameters:
inputStream
- theDataBuffer
input 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 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:Decoder
Decode aDataBuffer
input stream into a Mono ofT
.- Specified by:
decodeToMono
in interfaceDecoder<Object>
- Overrides:
decodeToMono
in classAbstractDecoder<Object>
- Parameters:
input
- theDataBuffer
input 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 decode- Returns:
- the output stream with the decoded element
-
decode
@NonNull public Object decode(DataBuffer dataBuffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) throws DecodingExceptionDescription copied from interface:Decoder
Decode 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
- theDataBuffer
to 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
-