Package io.micronaut.core.io.buffer
Class ByteArrayBufferFactory
java.lang.Object
io.micronaut.core.io.buffer.ByteArrayBufferFactory
- All Implemented Interfaces:
ByteBufferFactory<Void,
byte[]>
@Internal
public class ByteArrayBufferFactory
extends Object
implements ByteBufferFactory<Void,byte[]>
ByteBufferFactory
implementation based on simple byte arrays.- Since:
- 4.7
- Author:
- Jonas Konrad
-
Field Summary
-
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.
-
Field Details
-
INSTANCE
-
-
Method Details
-
getNativeAllocator
- Specified by:
getNativeAllocator
in interfaceByteBufferFactory<Void,
byte[]> - Returns:
- The native allocator
-
buffer
Description copied from interface:ByteBufferFactory
Allocate aByteBuffer
. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
buffer
in interfaceByteBufferFactory<Void,
byte[]> - Returns:
- The buffer
-
buffer
Description copied from interface:ByteBufferFactory
Allocate aByteBuffer
with the given initial capacity. If it is a direct or heap buffer depends on the actual implementation.- Specified by:
buffer
in interfaceByteBufferFactory<Void,
byte[]> - Parameters:
initialCapacity
- The initial capacity- Returns:
- the buffer
-
buffer
Description copied from interface:ByteBufferFactory
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.- Specified by:
buffer
in interfaceByteBufferFactory<Void,
byte[]> - Parameters:
initialCapacity
- The initial capacitymaxCapacity
- The maximum capacity- Returns:
- The buffer
-
copiedBuffer
Description copied from interface:ByteBufferFactory
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.- Specified by:
copiedBuffer
in interfaceByteBufferFactory<Void,
byte[]> - Parameters:
bytes
- The bytes- Returns:
- The buffer
-
copiedBuffer
Description copied from interface:ByteBufferFactory
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.- Specified by:
copiedBuffer
in interfaceByteBufferFactory<Void,
byte[]> - Parameters:
nioBuffer
- The nioBuffer- Returns:
- The buffer
-
wrap
Description copied from interface:ByteBufferFactory
Wrap an existing buffer.- Specified by:
wrap
in interfaceByteBufferFactory<Void,
byte[]> - Parameters:
existing
- The buffer to wrap- Returns:
- The wrapped
ByteBuffer
-