Class DataBufferEncoder

    • 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<DataBuffer>
        Overrides:
        canEncode in class AbstractEncoder<DataBuffer>
        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
      • encodeValue

        public DataBuffer encodeValue​(DataBuffer buffer,
                                      DataBufferFactory bufferFactory,
                                      ResolvableType valueType,
                                      @Nullable
                                      MimeType mimeType,
                                      @Nullable
                                      Map<String,​Object> hints)
        Description copied from interface: Encoder
        Encode an Object of type T to a data buffer. This is useful for scenarios, that distinct messages (or events) are encoded and handled individually, in fully aggregated form.

        By default this method raises UnsupportedOperationException and it is expected that some encoders cannot produce a single buffer or cannot do so synchronously (e.g. encoding a Resource).

        Parameters:
        buffer - the value to be encoded
        bufferFactory - for creating the output DataBuffer
        valueType - the type for the value being encoded
        mimeType - the MIME type for the output content (optional)
        hints - additional information about how to encode
        Returns:
        the encoded content