public class HeapBuffer extends ByteBufferBuffer
ByteBuffer based buffer.| Modifier and Type | Method and Description |
|---|---|
static HeapBuffer |
allocate()
Allocates a direct buffer with an initial capacity of
4096 and a maximum capacity of Long.MAX_VALUE. |
static HeapBuffer |
allocate(int initialCapacity)
Allocates a direct buffer with the given initial capacity.
|
static HeapBuffer |
allocate(int initialCapacity,
int maxCapacity)
Allocates a new direct buffer.
|
HeapBuffer |
duplicate()
Returns a duplicate of the buffer.
|
boolean |
hasArray()
Returns whether the buffer has an array.
|
static HeapBuffer |
wrap(byte[] bytes)
Wraps the given bytes in a heap buffer.
|
arrayacquire, asReadOnlyBuffer, bytes, capacity, capacity, clear, close, compact, flip, flush, hasRemaining, isDirect, isFile, isReadOnly, limit, limit, mark, maxCapacity, offset, order, order, position, position, read, read, read, read, read, read, read, readBoolean, readBoolean, readByte, readByte, readChar, readChar, readDouble, readDouble, readFloat, readFloat, readInt, readInt, readLong, readLong, readMedium, readMedium, readShort, readShort, readString, readString, readString, readString, readUnsignedByte, readUnsignedByte, readUnsignedInt, readUnsignedInt, readUnsignedMedium, readUnsignedMedium, readUnsignedShort, readUnsignedShort, readUTF8, readUTF8, references, release, remaining, reset, rewind, skip, slice, slice, slice, write, write, write, write, write, write, write, writeBoolean, writeBoolean, writeByte, writeByte, writeChar, writeChar, writeDouble, writeDouble, writeFloat, writeFloat, writeInt, writeInt, writeLong, writeLong, writeMedium, writeMedium, writeShort, writeShort, writeString, writeString, writeString, writeString, writeUnsignedByte, writeUnsignedByte, writeUnsignedInt, writeUnsignedInt, writeUnsignedMedium, writeUnsignedMedium, writeUnsignedShort, writeUnsignedShort, writeUTF8, writeUTF8, zero, zero, zeroequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitreadByteswriteBytespublic static HeapBuffer allocate()
4096 and a maximum capacity of Long.MAX_VALUE.
When the buffer is constructed, DirectMemoryAllocator will be used to allocate
capacity bytes of off-heap memory. The resulting buffer will be initialized with a capacity of 4096
and have a maximum capacity of Long.MAX_VALUE. The buffer's capacity will dynamically expand as
bytes are written to the buffer. The underlying UnsafeDirectBytes will be initialized to the next power of 2.
allocate(int),
allocate(int, int)public static HeapBuffer allocate(int initialCapacity)
When the buffer is constructed, DirectMemoryAllocator will be used to allocate
capacity bytes of off-heap memory. The resulting buffer will have an initial capacity of capacity.
The underlying UnsafeDirectBytes will be initialized to the next power of 2.
initialCapacity - The initial capacity of the buffer to allocate (in bytes).IllegalArgumentException - If capacity is greater than the maximum allowed count for
a ByteBuffer - Integer.MAX_VALUE - 5allocate(),
allocate(int, int)public static HeapBuffer allocate(int initialCapacity, int maxCapacity)
When the buffer is constructed, DirectMemoryAllocator will be used to allocate
capacity bytes of off-heap memory. The resulting buffer will have an initial capacity of initialCapacity
and will be doubled up to maxCapacity as bytes are written to the buffer. The underlying UnsafeDirectBytes
will be initialized to the next power of 2.
initialCapacity - The initial capacity of the buffer to allocate (in bytes).maxCapacity - The maximum capacity of the buffer.IllegalArgumentException - If capacity or maxCapacity is greater than the maximum
allowed count for a ByteBuffer - Integer.MAX_VALUE - 5allocate(),
allocate(int)public static HeapBuffer wrap(byte[] bytes)
The buffer will be created with an initial capacity and maximum capacity equal to the byte array count.
bytes - The bytes to wrap.public boolean hasArray()
Bufferpublic HeapBuffer duplicate()
BufferCopyright © 2013–2018. All rights reserved.