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 final class ByteArrayBufferFactory
extends Object
implements ByteBufferFactory<Void,byte[]>
ByteBufferFactory implementation based on simple byte arrays.- Since:
- 4.7
- Author:
- Jonas Konrad
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbuffer()Allocate aByteBuffer.buffer(int initialCapacity) Allocate aByteBufferwith the given initial capacity.buffer(int initialCapacity, int maxCapacity) Allocate aByteBufferwith 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:
getNativeAllocatorin interfaceByteBufferFactory<Void,byte[]> - 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<Void,byte[]> - 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<Void,byte[]> - 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<Void,byte[]> - 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<Void,byte[]> - 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<Void,byte[]> - Parameters:
nioBuffer- The nioBuffer- Returns:
- The buffer
-
wrap
Description copied from interface:ByteBufferFactoryWrap an existing buffer.- Specified by:
wrapin interfaceByteBufferFactory<Void,byte[]> - Parameters:
existing- The buffer to wrap- Returns:
- The wrapped
ByteBuffer
-