Package io.micronaut.core.io.buffer
Interface ByteBufferFactory<T,B>
- Type Parameters:
T
- The typeB
- The body
- All Known Implementing Classes:
NettyByteBufferFactory
public interface ByteBufferFactory<T,B>
An allocator for
ByteBuffer
instances.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Method Summary
Modifier and TypeMethodDescriptionbuffer()
Allocate aByteBuffer
.buffer
(int initialCapacity) Allocate aByteBuffer
with the given initial capacity.buffer
(int initialCapacity, int maxCapacity) Allocate aByteBuffer
with the given initial capacity and the given maximal capacity.copiedBuffer
(byte[] bytes) Creates a new big-endian buffer whose content is a copy of the specifiedarray
's sub-region.copiedBuffer
(ByteBuffer nioBuffer) Creates a new big-endian buffer whose content is a copy of the specified NIO buffer.wrap
(byte[] existing) Wrap an existing buffer.Wrap an existing buffer.
-
Method Details
-
getNativeAllocator
T getNativeAllocator()- Returns:
- The native allocator
-
buffer
ByteBuffer<B> buffer()Allocate aByteBuffer
. If it is a direct or heap buffer depends on the actual implementation.- Returns:
- The buffer
-
buffer
Allocate aByteBuffer
with the given initial capacity. If it is a direct or heap buffer depends on the actual implementation.- Parameters:
initialCapacity
- The initial capacity- Returns:
- the buffer
-
buffer
Allocate aByteBuffer
with the given initial capacity and the given maximal capacity. If it is a direct or heap buffer depends on the actual implementation.- Parameters:
initialCapacity
- The initial capacitymaxCapacity
- The maximum capacity- Returns:
- The buffer
-
copiedBuffer
Creates a new big-endian buffer whose content is a copy of the specifiedarray
's sub-region. The new buffer'sreaderIndex
andwriterIndex
are0
and the specifiedlength
respectively.- Parameters:
bytes
- The bytes- Returns:
- The buffer
-
copiedBuffer
Creates a new big-endian buffer whose content is a copy of the specified NIO buffer. The new buffer'sreaderIndex
andwriterIndex
are0
and the specifiedlength
respectively.- Parameters:
nioBuffer
- The nioBuffer- Returns:
- The buffer
-
wrap
Wrap an existing buffer.- Parameters:
existing
- The buffer to wrap- Returns:
- The wrapped
ByteBuffer
-
wrap
Wrap an existing buffer.- Parameters:
existing
- The bytes to wrap- Returns:
- The wrapped
ByteBuffer
-