org.springframework.core.codec

Class AbstractSingleValueEncoder<T>

  • Type Parameters:
    T - the element type
    All Implemented Interfaces:
    Encoder<T>
    Direct Known Subclasses:
    Jaxb2XmlEncoder, ResourceEncoder


    public abstract class AbstractSingleValueEncoder<T>
    extends AbstractEncoder<T>
    Abstract base class for Encoder classes that can only deal with a single value.
    Since:
    5.0
    Author:
    Arjen Poutsma
    • Constructor Detail

      • AbstractSingleValueEncoder

        public AbstractSingleValueEncoder(MimeType... supportedMimeTypes)
    • Method Detail

      • encode

        public final reactor.core.publisher.Flux<DataBuffer> encode(org.reactivestreams.Publisher<? extends T> inputStream,
                                                                    DataBufferFactory bufferFactory,
                                                                    ResolvableType elementType,
                                                                    @Nullable
                                                                    MimeType mimeType,
                                                                    @Nullable
                                                                    java.util.Map<java.lang.String,java.lang.Object> hints)
        Description copied from interface: Encoder
        Encode a stream of Objects of type T into a DataBuffer output stream.
        Parameters:
        inputStream - the input stream of Objects to encode. If the input should be encoded as a single value rather than as a stream of elements, an instance of Mono should be used.
        bufferFactory - for creating output stream DataBuffer's
        elementType - the expected type of elements in the input stream; this type must have been previously passed to the Encoder.canEncode(org.springframework.core.ResolvableType, org.springframework.util.MimeType) method and it must have returned true.
        mimeType - the MIME type for the output stream (optional)
        hints - additional information about how to do encode
        Returns:
        the output stream
      • encode

        protected abstract reactor.core.publisher.Flux<DataBuffer> encode(T t,
                                                                          DataBufferFactory dataBufferFactory,
                                                                          ResolvableType type,
                                                                          @Nullable
                                                                          MimeType mimeType,
                                                                          @Nullable
                                                                          java.util.Map<java.lang.String,java.lang.Object> hints)
        Encode T to an output DataBuffer stream.
        Parameters:
        t - 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