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 Jaxb2XmlDecoder()
    • Jaxb2XmlDecoder

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

    • setUnmarshallerProcessor

      public void setUnmarshallerProcessor(Function<Unmarshaller,Unmarshaller> processor)
      Configure a processor function to customize Unmarshaller instances.
      Parameters:
      processor - the function to use
      Since:
      5.1.3
    • getUnmarshallerProcessor

      public Function<Unmarshaller,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, 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 the configured byte count limit.
      Since:
      5.1.11
    • canDecode

      public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType)
      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 interface Decoder<Object>
      Overrides:
      canDecode in 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 null 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 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(org.springframework.core.ResolvableType, org.springframework.util.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 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 a DataBuffer input stream into a Mono of T.
      Specified by:
      decodeToMono in interface Decoder<Object>
      Overrides:
      decodeToMono in class 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(org.springframework.core.ResolvableType, org.springframework.util.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 Object decode(DataBuffer dataBuffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints) throws DecodingException
      Description 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 - 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