@Internal @Singleton public class NettyByteBufferFactory extends Object implements ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
ByteBufferFactory
implementation for Netty.Modifier and Type | Field and Description |
---|---|
static NettyByteBufferFactory |
DEFAULT
Default Netty ByteBuffer Factory.
|
Constructor and Description |
---|
NettyByteBufferFactory()
Default constructor.
|
NettyByteBufferFactory(io.netty.buffer.ByteBufAllocator allocator) |
Modifier and Type | Method and Description |
---|---|
ByteBuffer<io.netty.buffer.ByteBuf> |
buffer()
Allocate a
ByteBuffer . |
ByteBuffer<io.netty.buffer.ByteBuf> |
buffer(int initialCapacity)
Allocate a
ByteBuffer with the given initial capacity. |
ByteBuffer<io.netty.buffer.ByteBuf> |
buffer(int initialCapacity,
int maxCapacity)
Allocate a
ByteBuffer with the given initial capacity and the given maximal capacity. |
ByteBuffer<io.netty.buffer.ByteBuf> |
copiedBuffer(byte[] bytes)
Creates a new big-endian buffer whose content is a copy of the specified
array 's sub-region. |
ByteBuffer<io.netty.buffer.ByteBuf> |
copiedBuffer(ByteBuffer nioBuffer)
Creates a new big-endian buffer whose content is a copy of the specified NIO buffer.
|
io.netty.buffer.ByteBufAllocator |
getNativeAllocator() |
ByteBuffer<io.netty.buffer.ByteBuf> |
wrap(byte[] existing)
Wrap an existing buffer.
|
ByteBuffer<io.netty.buffer.ByteBuf> |
wrap(io.netty.buffer.ByteBuf existing)
Wrap an existing buffer.
|
public static final NettyByteBufferFactory DEFAULT
public NettyByteBufferFactory()
public NettyByteBufferFactory(io.netty.buffer.ByteBufAllocator allocator)
allocator
- The ByteBufAllocator
public io.netty.buffer.ByteBufAllocator getNativeAllocator()
getNativeAllocator
in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
public ByteBuffer<io.netty.buffer.ByteBuf> buffer()
ByteBufferFactory
ByteBuffer
. If it is a direct or heap buffer depends on the actual implementation.buffer
in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
public ByteBuffer<io.netty.buffer.ByteBuf> buffer(int initialCapacity)
ByteBufferFactory
ByteBuffer
with the given initial capacity. If it is a direct or heap buffer depends on the
actual implementation.buffer
in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
initialCapacity
- The initial capacitypublic ByteBuffer<io.netty.buffer.ByteBuf> buffer(int initialCapacity, int maxCapacity)
ByteBufferFactory
ByteBuffer
with the given initial capacity and the given maximal capacity. If it is a direct
or heap buffer depends on the actual implementation.buffer
in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
initialCapacity
- The initial capacitymaxCapacity
- The maximum capacitypublic ByteBuffer<io.netty.buffer.ByteBuf> copiedBuffer(byte[] bytes)
ByteBufferFactory
array
's sub-region. The new
buffer's readerIndex
and writerIndex
are 0
and the specified length
respectively.copiedBuffer
in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
bytes
- The bytespublic ByteBuffer<io.netty.buffer.ByteBuf> copiedBuffer(ByteBuffer nioBuffer)
ByteBufferFactory
readerIndex
and writerIndex
are 0
and the specified length
respectively.copiedBuffer
in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
nioBuffer
- The nioBufferpublic ByteBuffer<io.netty.buffer.ByteBuf> wrap(io.netty.buffer.ByteBuf existing)
ByteBufferFactory
wrap
in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
existing
- The buffer to wrapByteBuffer
public ByteBuffer<io.netty.buffer.ByteBuf> wrap(byte[] existing)
ByteBufferFactory
wrap
in interface ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
existing
- The bytes to wrapByteBuffer