public class UnsafeHeapBuffer extends AbstractBuffer
| Modifier and Type | Method and Description |
|---|---|
static UnsafeHeapBuffer |
allocate()
Allocates a heap buffer with an initial capacity of
4096 and a maximum capacity of HeapMemory.MAX_SIZE. |
static UnsafeHeapBuffer |
allocate(int initialCapacity)
Allocates a heap buffer with the given initial capacity.
|
static UnsafeHeapBuffer |
allocate(int initialCapacity,
int maxCapacity)
Allocates a new heap buffer.
|
byte[] |
array()
Returns the underlying byte array.
|
UnsafeHeapBuffer |
duplicate()
Returns a duplicate of the buffer.
|
boolean |
hasArray()
Returns whether the buffer has an array.
|
UnsafeHeapBuffer |
reset(byte[] array)
Resets the internal heap array.
|
static UnsafeHeapBuffer |
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, 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 UnsafeHeapBuffer 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 UnsafeHeapBytes will be initialized
to the next power of 2.
allocate(int),
allocate(int, int)public static UnsafeHeapBuffer allocate(int 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 UnsafeHeapBytes 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(int, int)public static UnsafeHeapBuffer allocate(int initialCapacity, int 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 UnsafeHeapBytes 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(int)public static UnsafeHeapBuffer 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 byte[] array()
Bufferpublic UnsafeHeapBuffer reset(byte[] array)
array - The internal array.public UnsafeHeapBuffer duplicate()
BufferCopyright © 2013–2018. All rights reserved.