org.springframework.core.io.buffer

## 类 NettyDataBufferFactory

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

- 所有已实现的接口:
    DataBufferFactory

      public class NettyDataBufferFactory
      extends Object
      implements DataBufferFactory

  Implementation of the `DataBufferFactory` interface based on a Netty `ByteBufAllocator`.
  从以下版本开始:
    5.0
  作者:
    Arjen Poutsma, Juergen Hoeller
  另请参阅:
    `PooledByteBufAllocator`, `UnpooledByteBufAllocator`

- - ### 构造器概要

    构造器
    构造器和说明
    `NettyDataBufferFactory(io.netty.buffer.ByteBufAllocator byteBufAllocator)` Create a new `NettyDataBufferFactory` based on the given factory.

  - ### 方法概要

    所有方法 静态方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `NettyDataBuffer` | `allocateBuffer()` Allocate a data buffer of a default initial capacity.
    `NettyDataBuffer` | `allocateBuffer(int initialCapacity)` Allocate a data buffer of the given initial capacity.
    `io.netty.buffer.ByteBufAllocator` | `getByteBufAllocator()` Return the `ByteBufAllocator` used by this factory.
    `DataBuffer` | `join(List<? extends DataBuffer> dataBuffers)` Return a new `DataBuffer` composed of the `dataBuffers` elements joined together.
    `static io.netty.buffer.ByteBuf` | `toByteBuf(DataBuffer buffer)` Return the given Netty `DataBuffer` as a `ByteBuf`.
    `String` | `toString()`
    `DataBuffer` | `wrap(byte[] bytes)` Wrap the given `byte` array in a `DataBuffer`.
    `NettyDataBuffer` | `wrap(io.netty.buffer.ByteBuf byteBuf)` Wrap the given Netty `ByteBuf` in a `NettyDataBuffer`.
    `NettyDataBuffer` | `wrap(ByteBuffer byteBuffer)` Wrap the given `ByteBuffer` in a `DataBuffer`.

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

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

- - ### 构造器详细资料

    - #### NettyDataBufferFactory

          public NettyDataBufferFactory(io.netty.buffer.ByteBufAllocator byteBufAllocator)

      Create a new `NettyDataBufferFactory` based on the given factory.
      参数:
        `byteBufAllocator` - the factory to use
      另请参阅:
        `PooledByteBufAllocator`, `UnpooledByteBufAllocator`

  - ### 方法详细资料

    - #### getByteBufAllocator

          public io.netty.buffer.ByteBufAllocator getByteBufAllocator()

      Return the `ByteBufAllocator` used by this factory.

    - #### allocateBuffer

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

    - #### wrap

          public NettyDataBuffer wrap(io.netty.buffer.ByteBuf byteBuf)

      Wrap the given Netty `ByteBuf` in a `NettyDataBuffer`.
      参数:
        `byteBuf` - the Netty byte buffer 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 uses Netty's `CompositeByteBuf`.

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

    - #### toByteBuf

          public static io.netty.buffer.ByteBuf toByteBuf(DataBuffer buffer)

      Return the given Netty `DataBuffer` as a `ByteBuf`.

      Returns the native buffer if `buffer` is a `NettyDataBuffer`; returns `Unpooled.wrappedBuffer(ByteBuffer)` otherwise.

      参数:
        `buffer` - the `DataBuffer` to return a `ByteBuf` for
      返回:
        the netty `ByteBuf`

    - #### toString

          public String toString()

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