public final class BufferUtil extends Object
Modifier and Type | Field and Description |
---|---|
static long |
ARRAY_BASE_OFFSET
Byte array base offset.
|
static long |
BYTE_BUFFER_ADDRESS_FIELD_OFFSET
Offset of the
java.nio.Buffer#address field. |
static long |
BYTE_BUFFER_HB_FIELD_OFFSET
Offset of the
java.nio.ByteBuffer#hb field. |
static long |
BYTE_BUFFER_OFFSET_FIELD_OFFSET
Offset of the
java.nio.ByteBuffer#offset field. |
static ByteOrder |
NATIVE_BYTE_ORDER
Native byte order.
|
static byte[] |
NULL_BYTES
UTF-8-encoded byte representation of the
"null" string. |
Modifier and Type | Method and Description |
---|---|
static long |
address(ByteBuffer buffer)
Get the address at which the underlying buffer storage begins.
|
static ByteBuffer |
allocateDirectAligned(int capacity,
int alignment)
Allocate a new direct
ByteBuffer that is aligned on a given alignment boundary. |
static byte[] |
array(ByteBuffer buffer)
Get the array from a read-only
ByteBuffer similar to ByteBuffer.array() . |
static int |
arrayOffset(ByteBuffer buffer)
Get the array offset from a read-only
ByteBuffer similar to ByteBuffer.arrayOffset() . |
static void |
boundsCheck(byte[] buffer,
long index,
int length)
Bounds check the access range and throw a
IndexOutOfBoundsException if exceeded. |
static void |
boundsCheck(ByteBuffer buffer,
long index,
int length)
Bounds check the access range and throw a
IndexOutOfBoundsException if exceeded. |
static void |
free(ByteBuffer buffer)
Free direct
ByteBuffer by invoking Cleaner on it. |
static void |
free(DirectBuffer buffer)
Free the underlying direct
ByteBuffer by invoking Cleaner on it. |
public static final byte[] NULL_BYTES
"null"
string.public static final ByteOrder NATIVE_BYTE_ORDER
public static final long ARRAY_BASE_OFFSET
public static final long BYTE_BUFFER_HB_FIELD_OFFSET
java.nio.ByteBuffer#hb
field.public static final long BYTE_BUFFER_OFFSET_FIELD_OFFSET
java.nio.ByteBuffer#offset
field.public static final long BYTE_BUFFER_ADDRESS_FIELD_OFFSET
java.nio.Buffer#address
field.public static void boundsCheck(byte[] buffer, long index, int length)
IndexOutOfBoundsException
if exceeded.buffer
- to be checked.index
- at which the access will begin.length
- of the range accessed.public static void boundsCheck(ByteBuffer buffer, long index, int length)
IndexOutOfBoundsException
if exceeded.buffer
- to be checked.index
- at which the access will begin.length
- of the range accessed.public static long address(ByteBuffer buffer)
buffer
- that wraps the underlying storage.public static byte[] array(ByteBuffer buffer)
ByteBuffer
similar to ByteBuffer.array()
.buffer
- that wraps the underlying array.public static int arrayOffset(ByteBuffer buffer)
ByteBuffer
similar to ByteBuffer.arrayOffset()
.buffer
- that wraps the underlying array.public static ByteBuffer allocateDirectAligned(int capacity, int alignment)
ByteBuffer
that is aligned on a given alignment boundary.capacity
- required for the buffer.alignment
- boundary at which the buffer should begin.ByteBuffer
with the required alignment.IllegalArgumentException
- if the alignment is not a power of 2.public static void free(DirectBuffer buffer)
ByteBuffer
by invoking Cleaner
on it. No op if null
or if the
underlying ByteBuffer
non-direct.buffer
- to be freedByteBuffer.isDirect()
public static void free(ByteBuffer buffer)
buffer
- to be freedByteBuffer.isDirect()
Copyright © 2014-2021 Real Logic Limited. All Rights Reserved.