Class Jaxb2XmlDecoder

java.lang.Object
org.springframework.core.codec.AbstractDecoder<Object>
org.springframework.http.codec.xml.Jaxb2XmlDecoder
All Implemented Interfaces:
Decoder<Object>

public class Jaxb2XmlDecoder extends AbstractDecoder<Object>
Decode from a bytes stream containing XML elements to a stream of Objects (POJOs).
since:
5.0
Author:
sebastien Deleuze, Arjen Poutsma
see Also:
  • Constructor Details

    • Jaxb2XmlDecoder

      public&nbsp;Jaxb2XmlDecoder()
    • Jaxb2XmlDecoder

      public&nbsp;Jaxb2XmlDecoder(MimeType...&nbsp;supportedMimeTypes)
      Create a Jaxb2XmlDecoder with the specified MIME types.
      Parameters:
      supportedMimeTypes - supported MIME types
      since:
      5.1.9
  • Method Details

    • setUnmarshallerProcessor

      public&nbsp;void&nbsp;setUnmarshallerProcessor(Function<jakarta.xml.bind.Unmarshaller, jakarta.xml.bind.Unmarshaller>&nbsp;processor)
      Configure a processor function to customize Unmarshaller instances.
      Parameters:
      processor - the function to use
      since:
      5.1.3
    • getUnmarshallerProcessor

      public&nbsp;Function<jakarta.xml.bind.Unmarshaller, jakarta.xml.bind.Unmarshaller>&nbsp;getUnmarshallerProcessor()
      Return the configured processor for customizing Unmarshaller instances.
      since:
      5.1.3
    • setMaxInMemorysize

      public&nbsp;void&nbsp;setMaxInMemorysize(int&nbsp;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&nbsp;int&nbsp;getMaxInMemorysize()
      Return the configured byte count limit.
      since:
      5.1.11
    • canDecode

      public&nbsp;boolean&nbsp;canDecode(ResolvableType&nbsp;elementType, @Nullable MimeType&nbsp;mimeType)
      Description copied from interface:&nbsp;Decoder
      Whether the decoder supports the given target element type and the MIME type of the source stream.
      specified by:
      canDecode&nbsp;in interface&nbsp;Decoder<Object>
      Overrides:
      canDecode&nbsp;in class&nbsp;AbstractDecoder<Object>
      Parameters:
      elementType - the target element type for the output stream
      mimeType - the mime type associated with the stream to decode (can be null if not specified)
      Returns:
      true if supported, false otherwise
    • decode

      public&nbsp;reactor.core.publisher.Flux<Object>&nbsp;decode(Publisher<DataBuffer>&nbsp;inputstream, ResolvableType&nbsp;elementType, @Nullable MimeType&nbsp;mimeType, @Nullable Map<string,Object>&nbsp;hints)
      Description copied from interface:&nbsp;Decoder
      Decode a DataBuffer input stream into a Flux of T.
      Parameters:
      inputstream - the DataBuffer input 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
    • decodeToMono

      public&nbsp;reactor.core.publisher.Mono<Object>&nbsp;decodeToMono(Publisher<DataBuffer>&nbsp;input, ResolvableType&nbsp;elementType, @Nullable MimeType&nbsp;mimeType, @Nullable Map<string,Object>&nbsp;hints)
      Description copied from interface:&nbsp;Decoder
      Decode a DataBuffer input stream into a Mono of T.
      specified by:
      decodeToMono&nbsp;in interface&nbsp;Decoder<Object>
      Overrides:
      decodeToMono&nbsp;in class&nbsp;AbstractDecoder<Object>
      Parameters:
      input - the DataBuffer input 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
    • decode

      public&nbsp;Object&nbsp;decode(DataBuffer&nbsp;dataBuffer, ResolvableType&nbsp;targetType, @Nullable MimeType&nbsp;mimeType, @Nullable Map<string,Object>&nbsp;hints) throws DecodingException
      Description copied from interface:&nbsp;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 - the DataBuffer to 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