Package io.micronaut.core.io.buffer
Interface ByteBufferFactory<T,B>
-
- Type Parameters:
T- The typeB- The body
public interface ByteBufferFactory<T,B>An allocator forByteBufferinstances.- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ByteBuffer<B>buffer()Allocate aByteBuffer.ByteBuffer<B>buffer(int initialCapacity)Allocate aByteBufferwith the given initial capacity.ByteBuffer<B>buffer(int initialCapacity, int maxCapacity)Allocate aByteBufferwith the given initial capacity and the given maximal capacity.ByteBuffer<B>copiedBuffer(byte[] bytes)Creates a new big-endian buffer whose content is a copy of the specifiedarray's sub-region.ByteBuffer<B>copiedBuffer(java.nio.ByteBuffer nioBuffer)Creates a new big-endian buffer whose content is a copy of the specified NIO buffer.TgetNativeAllocator()ByteBuffer<B>wrap(byte[] existing)Wrap an existing buffer.ByteBuffer<B>wrap(B existing)Wrap an existing buffer.
-
-
-
Method Detail
-
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
ByteBuffer<B> buffer(int initialCapacity)
Allocate aByteBufferwith 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
ByteBuffer<B> buffer(int initialCapacity, int maxCapacity)
Allocate aByteBufferwith 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
ByteBuffer<B> copiedBuffer(byte[] bytes)
Creates a new big-endian buffer whose content is a copy of the specifiedarray's sub-region. The new buffer'sreaderIndexandwriterIndexare0and the specifiedlengthrespectively.- Parameters:
bytes- The bytes- Returns:
- The buffer
-
copiedBuffer
ByteBuffer<B> copiedBuffer(java.nio.ByteBuffer nioBuffer)
Creates a new big-endian buffer whose content is a copy of the specified NIO buffer. The new buffer'sreaderIndexandwriterIndexare0and the specifiedlengthrespectively.- Parameters:
nioBuffer- The nioBuffer- Returns:
- The buffer
-
wrap
ByteBuffer<B> wrap(B existing)
Wrap an existing buffer.- Parameters:
existing- The buffer to wrap- Returns:
- The wrapped
ByteBuffer
-
wrap
ByteBuffer<B> wrap(byte[] existing)
Wrap an existing buffer.- Parameters:
existing- The bytes to wrap- Returns:
- The wrapped
ByteBuffer
-
-