org.springframework.core.codec

## Class DataBufferDecoder

- java.lang.Object
- - org.springframework.core.codec.AbstractDecoder<T>
  - - org.springframework.core.codec.AbstractDataBufferDecoder<DataBuffer>
    - - org.springframework.core.codec.DataBufferDecoder

- All Implemented Interfaces:
    Decoder<DataBuffer>

      public class DataBufferDecoder
      extends AbstractDataBufferDecoder<DataBuffer>

  Simple pass-through decoder for `DataBuffers`.

  Note: The data buffers should be released via `DataBufferUtils.release(DataBuffer)` after they have been consumed. In addition, if using `Flux` or `Mono` operators such as flatMap, reduce, and others that prefetch, cache, and skip or filter out data items internally, please add `doOnDiscard(PooledDataBuffer.class, DataBufferUtils::release)` to the composition chain to ensure cached data buffers are released prior to an error or cancellation signal.

  Since:
    5.0
  Author:
    Arjen Poutsma, Rossen Stoyanchev

- - ### Field Summary

    - ### Fields inherited from class org.springframework.core.codec.AbstractDecoder

      `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataBufferDecoder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canDecode(ResolvableType elementType, MimeType mimeType)` Whether the decoder supports the given target element type and the MIME type of the source stream.
    `DataBuffer` | `decode(DataBuffer buffer, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)` Decode a data buffer to an Object of type T.
    `reactor.core.publisher.Flux<DataBuffer>` | `decode(Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)` Decode a `DataBuffer` input stream into a Flux of `T`.

    - ### Methods inherited from class org.springframework.core.codec.AbstractDataBufferDecoder

      `decodeDataBuffer, decodeToMono, getMaxInMemorySize, setMaxInMemorySize`

    - ### Methods inherited from class org.springframework.core.codec.AbstractDecoder

      `getDecodableMimeTypes, getLogger, setLogger`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.core.codec.Decoder

      `getDecodableMimeTypes`

- - ### Constructor Detail

    - #### DataBufferDecoder

          public DataBufferDecoder()

  - ### Method Detail

    - #### 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<DataBuffer>`
      Overrides:
        `canDecode` in class `AbstractDecoder<DataBuffer>`
      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<DataBuffer> decode(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 Flux of `T`.
      Specified by:
        `decode` in interface `Decoder<DataBuffer>`
      Overrides:
        `decode` in class `AbstractDataBufferDecoder<DataBuffer>`
      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 decoded elements

    - #### decode

          public DataBuffer decode(DataBuffer buffer,
                                   ResolvableType elementType,
                                   @Nullable
                                   MimeType mimeType,
                                   @Nullable
                                   Map<String,Object> hints)

      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:
        `buffer` - the `DataBuffer` to decode
        `elementType` - 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`