public class BufferUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static long |
ARRAY_BASE_OFFSET |
static long |
BYTE_BUFFER_HB_FIELD_OFFSET |
static long |
BYTE_BUFFER_OFFSET_FIELD_OFFSET |
static java.nio.ByteOrder |
NATIVE_BYTE_ORDER |
static byte[] |
NULL_BYTES |
Constructor and Description |
---|
BufferUtil() |
Modifier and Type | Method and Description |
---|---|
static long |
address(java.nio.ByteBuffer buffer)
Get the address at which the underlying buffer storage begins.
|
static java.nio.ByteBuffer |
allocateDirectAligned(int capacity,
int alignment)
Allocate a new direct
ByteBuffer that is aligned on a given alignment boundary. |
static byte[] |
array(java.nio.ByteBuffer buffer)
Get the array from a read-only
ByteBuffer similar to ByteBuffer.array() . |
static int |
arrayOffset(java.nio.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(java.nio.ByteBuffer buffer,
long index,
int length)
Bounds check the access range and throw a
IndexOutOfBoundsException if exceeded. |
public static final byte[] NULL_BYTES
public static final java.nio.ByteOrder NATIVE_BYTE_ORDER
public static final long ARRAY_BASE_OFFSET
public static final long BYTE_BUFFER_HB_FIELD_OFFSET
public static final long BYTE_BUFFER_OFFSET_FIELD_OFFSET
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(java.nio.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(java.nio.ByteBuffer buffer)
buffer
- that wraps the underlying storage.public static byte[] array(java.nio.ByteBuffer buffer)
ByteBuffer
similar to ByteBuffer.array()
.buffer
- that wraps the underlying array.public static int arrayOffset(java.nio.ByteBuffer buffer)
ByteBuffer
similar to ByteBuffer.arrayOffset()
.buffer
- that wraps the underlying array.public static java.nio.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.java.lang.IllegalArgumentException
- if the alignment is not a power of 2.Copyright © 2014-2017 Real Logic Ltd. All Rights Reserved.