org.springframework.core.io.buffer

## 类 DefaultDataBufferFactory

- java.lang.Object
- - org.springframework.core.io.buffer.DefaultDataBufferFactory

- 所有已实现的接口:
    DataBufferFactory

      public class DefaultDataBufferFactory
      extends Object
      implements DataBufferFactory

  Default implementation of the `DataBufferFactory` interface. Allows for specification of the default initial capacity at construction time, as well as whether heap-based or direct buffers are to be preferred.
  从以下版本开始:
    5.0
  作者:
    Arjen Poutsma

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static int` | `DEFAULT_INITIAL_CAPACITY` The default capacity when none is specified.

  - ### 构造器概要

    构造器
    构造器和说明
    `DefaultDataBufferFactory()` Creates a new `DefaultDataBufferFactory` with default settings.
    `DefaultDataBufferFactory(boolean preferDirect)` Creates a new `DefaultDataBufferFactory`, indicating whether direct buffers should be created by `allocateBuffer()` and `allocateBuffer(int)`.
    `DefaultDataBufferFactory(boolean preferDirect, int defaultInitialCapacity)` Creates a new `DefaultDataBufferFactory`, indicating whether direct buffers should be created by `allocateBuffer()` and `allocateBuffer(int)`, and what the capacity is to be used for `allocateBuffer()`.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `DefaultDataBuffer` | `allocateBuffer()` Allocate a data buffer of a default initial capacity.
    `DefaultDataBuffer` | `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.
    `String` | `toString()`
    `DataBuffer` | `wrap(byte[] bytes)` Wrap the given `byte` array in a `DataBuffer`.
    `DefaultDataBuffer` | `wrap(ByteBuffer byteBuffer)` Wrap the given `ByteBuffer` in a `DataBuffer`.

    - ### 从类继承的方法 java.lang.Object

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

- - ### 字段详细资料

    - #### DEFAULT_INITIAL_CAPACITY

          public static final int DEFAULT_INITIAL_CAPACITY

      The default capacity when none is specified.
      另请参阅:
        `DefaultDataBufferFactory()`, `DefaultDataBufferFactory(boolean)`, 常量字段值

  - ### 构造器详细资料

    - #### DefaultDataBufferFactory

          public DefaultDataBufferFactory()

      Creates a new `DefaultDataBufferFactory` with default settings.

    - #### DefaultDataBufferFactory

          public DefaultDataBufferFactory(boolean preferDirect)

      Creates a new `DefaultDataBufferFactory`, indicating whether direct buffers should be created by `allocateBuffer()` and `allocateBuffer(int)`.
      参数:
        `preferDirect` - `true` if direct buffers are to be preferred; `false` otherwise

    - #### DefaultDataBufferFactory

          public DefaultDataBufferFactory(boolean preferDirect,
                                          int defaultInitialCapacity)

      Creates a new `DefaultDataBufferFactory`, indicating whether direct buffers should be created by `allocateBuffer()` and `allocateBuffer(int)`, and what the capacity is to be used for `allocateBuffer()`.
      参数:
        `preferDirect` - `true` if direct buffers are to be preferred; `false` otherwise

  - ### 方法详细资料

    - #### allocateBuffer

          public DefaultDataBuffer allocateBuffer()

      从接口复制的说明: `DataBufferFactory`
      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.
      指定者:
        `allocateBuffer` 在接口中 `DataBufferFactory`
      返回:
        the allocated buffer

    - #### allocateBuffer

          public DefaultDataBuffer allocateBuffer(int initialCapacity)

      从接口复制的说明: `DataBufferFactory`
      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.
      指定者:
        `allocateBuffer` 在接口中 `DataBufferFactory`
      参数:
        `initialCapacity` - the initial capacity of the buffer to allocate
      返回:
        the allocated buffer

    - #### wrap

          public DefaultDataBuffer wrap(ByteBuffer byteBuffer)

      从接口复制的说明: `DataBufferFactory`
      Wrap the given `ByteBuffer` in a `DataBuffer`. Unlike allocating, wrapping does not use new memory.
      指定者:
        `wrap` 在接口中 `DataBufferFactory`
      参数:
        `byteBuffer` - the NIO byte buffer to wrap
      返回:
        the wrapped buffer

    - #### wrap

          public DataBuffer wrap(byte[] bytes)

      从接口复制的说明: `DataBufferFactory`
      Wrap the given `byte` array in a `DataBuffer`. Unlike allocating, wrapping does not use new memory.
      指定者:
        `wrap` 在接口中 `DataBufferFactory`
      参数:
        `bytes` - the byte array to wrap
      返回:
        the wrapped buffer

    - #### join

          public 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.

      This implementation creates a single `DefaultDataBuffer` to contain the data in `dataBuffers`.

      指定者:
        `join` 在接口中 `DataBufferFactory`
      参数:
        `dataBuffers` - the data buffers to be composed
      返回:
        a buffer that is composed from the `dataBuffers` argument

    - #### toString

          public String toString()

      覆盖:
        `toString` 在类中 `Object`