org.springframework.core.io.buffer

## Interface DataBufferFactory

- All Known Implementing Classes:
    DefaultDataBufferFactory, NettyDataBufferFactory

      public interface DataBufferFactory

  A factory for `DataBuffers`, allowing for allocation and wrapping of data buffers.
  Since:
    5.0
  Author:
    Arjen Poutsma
  See Also:
    `DataBuffer`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `DataBuffer` | `allocateBuffer()` Allocate a data buffer of a default initial capacity.
    `DataBuffer` | `allocateBuffer(int initialCapacity)` Allocate a data buffer of the given initial capacity.
    `DataBuffer` | `join(List<? extends DataBuffer> dataBuffers)` Return a new `DataBuffer` composed of the `dataBuffers` elements joined together.
    `DataBuffer` | `wrap(byte[] bytes)` Wrap the given `byte` array in a `DataBuffer`.
    `DataBuffer` | `wrap(ByteBuffer byteBuffer)` Wrap the given `ByteBuffer` in a `DataBuffer`.

- - ### Method Detail

    - #### allocateBuffer

          DataBuffer allocateBuffer()

      Allocate a data buffer of a default initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.
      Returns:
        the allocated buffer

    - #### allocateBuffer

          DataBuffer allocateBuffer(int initialCapacity)

      Allocate a data buffer of the given initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.
      Parameters:
        `initialCapacity` - the initial capacity of the buffer to allocate
      Returns:
        the allocated buffer

    - #### wrap

          DataBuffer wrap(ByteBuffer byteBuffer)

      Wrap the given `ByteBuffer` in a `DataBuffer`. Unlike allocating, wrapping does not use new memory.
      Parameters:
        `byteBuffer` - the NIO byte buffer to wrap
      Returns:
        the wrapped buffer

    - #### wrap

          DataBuffer wrap(byte[] bytes)

      Wrap the given `byte` array in a `DataBuffer`. Unlike allocating, wrapping does not use new memory.
      Parameters:
        `bytes` - the byte array to wrap
      Returns:
        the wrapped buffer

    - #### join

          DataBuffer join(List<? extends DataBuffer> dataBuffers)

      Return a new `DataBuffer` composed of the `dataBuffers` elements joined together. Depending on the implementation, the returned buffer may be a single buffer containing all data of the provided buffers, or it may be a true composite that contains references to the buffers.

      Note that the given data buffers do not have to be released, as they are released as part of the returned composite.

      Parameters:
        `dataBuffers` - the data buffers to be composed
      Returns:
        a buffer that is composed of the `dataBuffers` argument
      Since:
        5.0.3