Package io.micronaut.buffer.netty
Class NettyByteBufferFactory
java.lang.Object
io.micronaut.buffer.netty.NettyByteBufferFactory
- All Implemented Interfaces:
ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
@Internal
@Singleton
public final class NettyByteBufferFactory
extends Object
implements ByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf>
A
ByteBufferFactory implementation for Netty.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final NettyByteBufferFactoryDefault Netty ByteBuffer Factory. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.NettyByteBufferFactory(io.netty.buffer.ByteBufAllocator allocator) -
Method Summary
Modifier and TypeMethodDescriptionByteBuffer<io.netty.buffer.ByteBuf>buffer()Allocate aByteBuffer.ByteBuffer<io.netty.buffer.ByteBuf>buffer(int initialCapacity) Allocate aByteBufferwith the given initial capacity.ByteBuffer<io.netty.buffer.ByteBuf>buffer(int initialCapacity, int maxCapacity) Allocate aByteBufferwith 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 specifiedarray'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.ByteBufAllocatorByteBuffer<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.
-
Field Details
-
DEFAULT
Default Netty ByteBuffer Factory.
-
-
Constructor Details
-
NettyByteBufferFactory
public NettyByteBufferFactory()Default constructor. -
NettyByteBufferFactory
public NettyByteBufferFactory(io.netty.buffer.ByteBufAllocator allocator) - Parameters:
allocator- TheByteBufAllocator
-
-
Method Details
-
getNativeAllocator
public io.netty.buffer.ByteBufAllocator getNativeAllocator()- Specified by:
getNativeAllocatorin interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> - Returns:
- The native allocator
-
buffer
Description copied from interface:ByteBufferFactoryAllocate aByteBuffer. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
bufferin interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> - Returns:
- The buffer
-
buffer
Description copied from interface:ByteBufferFactoryAllocate aByteBufferwith the given initial capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
bufferin interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> - Parameters:
initialCapacity- The initial capacity- Returns:
- the buffer
-
buffer
Description copied from interface:ByteBufferFactoryAllocate aByteBufferwith the given initial capacity and the given maximal capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
bufferin interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> - Parameters:
initialCapacity- The initial capacitymaxCapacity- The maximum capacity- Returns:
- The buffer
-
copiedBuffer
Description copied from interface:ByteBufferFactoryCreates a new big-endian buffer whose content is a copy of the specifiedarray's sub-region. The new buffer'sreaderIndexandwriterIndexare0and the specifiedlengthrespectively.- Specified by:
copiedBufferin interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> - Parameters:
bytes- The bytes- Returns:
- The buffer
-
copiedBuffer
Description copied from interface:ByteBufferFactoryCreates a new big-endian buffer whose content is a copy of the specified NIO buffer. The new buffer'sreaderIndexandwriterIndexare0and the specifiedlengthrespectively.- Specified by:
copiedBufferin interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> - Parameters:
nioBuffer- The nioBuffer- Returns:
- The buffer
-
wrap
Description copied from interface:ByteBufferFactoryWrap an existing buffer.- Specified by:
wrapin interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> - Parameters:
existing- The buffer to wrap- Returns:
- The wrapped
ByteBuffer
-
wrap
Description copied from interface:ByteBufferFactoryWrap an existing buffer.- Specified by:
wrapin interfaceByteBufferFactory<io.netty.buffer.ByteBufAllocator,io.netty.buffer.ByteBuf> - Parameters:
existing- The bytes to wrap- Returns:
- The wrapped
ByteBuffer
-