public class NettyDataBufferFactory extends Object implements DataBufferFactory
DataBufferFactory interface based on a
Netty ByteBufAllocator.PooledByteBufAllocator,
UnpooledByteBufAllocator| Constructor and Description |
|---|
NettyDataBufferFactory(io.netty.buffer.ByteBufAllocator byteBufAllocator)
Creates a new
NettyDataBufferFactory based on the given factory. |
| Modifier and Type | Method and Description |
|---|---|
NettyDataBuffer |
allocateBuffer()
Allocate a data buffer of a default initial capacity.
|
NettyDataBuffer |
allocateBuffer(int initialCapacity)
Allocate a data buffer of the given initial capacity.
|
static io.netty.buffer.ByteBuf |
toByteBuf(DataBuffer buffer)
Return the given Netty
DataBuffer as a ByteBuf. |
String |
toString() |
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. |
public NettyDataBufferFactory(io.netty.buffer.ByteBufAllocator byteBufAllocator)
NettyDataBufferFactory based on the given factory.byteBufAllocator - the factory to usePooledByteBufAllocator,
UnpooledByteBufAllocatorpublic NettyDataBuffer allocateBuffer()
DataBufferFactoryallocateBuffer in interface DataBufferFactorypublic NettyDataBuffer allocateBuffer(int initialCapacity)
DataBufferFactoryallocateBuffer in interface DataBufferFactoryinitialCapacity - the initial capacity of the buffer to allocatepublic NettyDataBuffer wrap(ByteBuffer byteBuffer)
DataBufferFactoryByteBuffer in a DataBuffer.wrap in interface DataBufferFactorybyteBuffer - the NIO byte buffer to wrappublic NettyDataBuffer wrap(io.netty.buffer.ByteBuf byteBuf)
ByteBuf in a NettyDataBuffer.byteBuf - the Netty byte buffer to wrappublic static io.netty.buffer.ByteBuf toByteBuf(DataBuffer buffer)
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.ByteBuf