org.springframework.http.codec.xml

Class Jaxb2XmlEncoder

  • All Implemented Interfaces:
    Encoder<java.lang.Object>


    public class Jaxb2XmlEncoder
    extends AbstractSingleValueEncoder<java.lang.Object>
    Encode from single value to a byte stream containing XML elements.

    @XmlElements and @XmlElement can be used to specify how collections should be marshalled.

    Since:
    5.0
    Author:
    Sebastien Deleuze, Arjen Poutsma
    See Also:
    Jaxb2XmlDecoder
    • Constructor Detail

      • Jaxb2XmlEncoder

        public Jaxb2XmlEncoder()
    • Method Detail

      • canEncode

        public boolean canEncode(ResolvableType elementType,
                                 @Nullable
                                 MimeType mimeType)
        Description copied from interface: Encoder
        Whether the encoder supports the given source element type and the MIME type for the output stream.
        Specified by:
        canEncode in interface Encoder<java.lang.Object>
        Overrides:
        canEncode in class AbstractEncoder<java.lang.Object>
        Parameters:
        elementType - the type of elements in the source stream
        mimeType - the MIME type for the output stream (can be null if not specified)
        Returns:
        true if supported, false otherwise
      • encode

        protected reactor.core.publisher.Flux<DataBuffer> encode(java.lang.Object value,
                                                                 DataBufferFactory dataBufferFactory,
                                                                 ResolvableType type,
                                                                 @Nullable
                                                                 MimeType mimeType,
                                                                 @Nullable
                                                                 java.util.Map<java.lang.String,java.lang.Object> hints)
        Description copied from class: AbstractSingleValueEncoder
        Encode T to an output DataBuffer stream.
        Specified by:
        encode in class AbstractSingleValueEncoder<java.lang.Object>
        Parameters:
        value - the value to process
        dataBufferFactory - a buffer factory used to create the output
        type - the stream element type to process
        mimeType - the mime type to process
        hints - additional information about how to do decode, optional
        Returns:
        the output stream