public class HeapBuffer extends AbstractBuffer
| Modifier and Type | Method and Description |
|---|---|
static HeapBuffer |
allocate()
Allocates a heap buffer with an initial capacity of
4096 and a maximum capacity of HeapMemory.MAX_SIZE. |
static HeapBuffer |
allocate(long initialCapacity)
Allocates a heap buffer with the given initial capacity.
|
static HeapBuffer |
allocate(long initialCapacity,
long maxCapacity)
Allocates a new heap buffer.
|
byte[] |
array()
Returns the underlying byte array.
|
HeapBuffer |
reset(byte[] array)
Resets the internal heap array.
|
static HeapBuffer |
wrap(byte[] bytes)
Wraps the given bytes in a heap buffer.
|
acquire, 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, 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, writeUnsignedByte, writeUnsignedByte, writeUnsignedInt, writeUnsignedInt, writeUnsignedMedium, writeUnsignedMedium, writeUnsignedShort, writeUnsignedShort, writeUTF8, writeUTF8, zero, zero, zeropublic static HeapBuffer allocate()
4096 and a maximum capacity of HeapMemory.MAX_SIZE.
When the buffer is constructed, HeapMemoryAllocator will be used to allocate
capacity bytes of memory on the Java heap. The resulting buffer will be initialized with a capacity of
4096 and have a maximum capacity of HeapMemory.MAX_SIZE. The buffer's capacity will dynamically
expand as bytes are written to the buffer. The underlying HeapBytes will be initialized
to the next power of 2.
allocate(long),
allocate(long, long)public static HeapBuffer allocate(long initialCapacity)
When the buffer is constructed, HeapMemoryAllocator will be used to allocate
capacity bytes of memory on the Java heap. The resulting buffer will have an initial capacity of capacity.
The underlying HeapBytes 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 capacity for
an array on the Java heap - Integer.MAX_VALUE - 5allocate(),
allocate(long, long)public static HeapBuffer allocate(long initialCapacity, long maxCapacity)
When the buffer is constructed, HeapMemoryAllocator will be used to allocate
capacity bytes of memory on the Java heap. 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 HeapBytes 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 initialCapacity or maxCapacity is greater than the
maximum allowed count for an array on the Java heap - Integer.MAX_VALUE - 5allocate(),
allocate(long)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 byte[] array()
public HeapBuffer reset(byte[] array)
array - The internal array.Copyright © 2013–2015. All rights reserved.