public class NettyDataBufferFactory extends java.lang.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.
|
io.netty.buffer.ByteBufAllocator |
getByteBufAllocator()
Return the
ByteBufAllocator used by this factory. |
static io.netty.buffer.ByteBuf |
toByteBuf(DataBuffer buffer)
Return the given Netty
DataBuffer as a ByteBuf . |
java.lang.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(java.nio.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
,
UnpooledByteBufAllocator
public io.netty.buffer.ByteBufAllocator getByteBufAllocator()
ByteBufAllocator
used by this factory.public NettyDataBuffer allocateBuffer()
DataBufferFactory
allocateBuffer
in interface DataBufferFactory
public NettyDataBuffer allocateBuffer(int initialCapacity)
DataBufferFactory
allocateBuffer
in interface DataBufferFactory
initialCapacity
- the initial capacity of the buffer to allocatepublic NettyDataBuffer wrap(java.nio.ByteBuffer byteBuffer)
DataBufferFactory
ByteBuffer
in a DataBuffer
.wrap
in interface DataBufferFactory
byteBuffer
- the NIO byte buffer to wrappublic DataBuffer wrap(byte[] bytes)
DataBufferFactory
byte
array in a DataBuffer
.wrap
in interface DataBufferFactory
bytes
- the byte array 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
public java.lang.String toString()
toString
in class java.lang.Object