public interface DirectBuffer extends java.lang.Comparable<DirectBuffer>
| Modifier and Type | Method and Description |
|---|---|
long |
addressOffset()
Reads the underlying offset to to the memory address.
|
void |
boundsCheck(int index,
int length)
Check that a given length of bytes is within the bounds from a given index.
|
byte[] |
byteArray()
Get the underlying byte[] if one exists.
|
java.nio.ByteBuffer |
byteBuffer()
Get the underlying
ByteBuffer if one exists. |
int |
capacity()
Get the capacity of the underlying buffer.
|
void |
checkLimit(int limit)
Check that a given limit is not greater than the capacity of a buffer from a given offset.
|
byte |
getByte(int index)
Get the value at a given index.
|
void |
getBytes(int index,
byte[] dst)
Get from the underlying buffer into a supplied byte array.
|
void |
getBytes(int index,
byte[] dst,
int offset,
int length)
Get bytes from the underlying buffer into a supplied byte array.
|
void |
getBytes(int index,
java.nio.ByteBuffer dstBuffer,
int length)
Get from the underlying buffer into a supplied
ByteBuffer current Buffer.position(). |
void |
getBytes(int index,
java.nio.ByteBuffer dstBuffer,
int dstOffset,
int length)
Get from the underlying buffer into a supplied
ByteBuffer at a offset. |
void |
getBytes(int index,
MutableDirectBuffer dstBuffer,
int dstIndex,
int length)
Get bytes from this
DirectBuffer into the provided MutableDirectBuffer at given indices. |
char |
getChar(int index)
Get the value at a given index.
|
char |
getChar(int index,
java.nio.ByteOrder byteOrder)
Get the value at a given index.
|
double |
getDouble(int index)
Get the value at a given index.
|
double |
getDouble(int index,
java.nio.ByteOrder byteOrder)
Get the value at a given index.
|
float |
getFloat(int index)
Get the value at a given index.
|
float |
getFloat(int index,
java.nio.ByteOrder byteOrder)
Get the value at a given index.
|
int |
getInt(int index)
Get the value at a given index.
|
int |
getInt(int index,
java.nio.ByteOrder byteOrder)
Get the value at a given index.
|
long |
getLong(int index)
Get the value at a given index.
|
long |
getLong(int index,
java.nio.ByteOrder byteOrder)
Get the value at a given index.
|
short |
getShort(int index)
Get the value at a given index.
|
short |
getShort(int index,
java.nio.ByteOrder byteOrder)
Get the value at a given index.
|
java.lang.String |
getStringUtf8(int index)
Get a String from bytes encoded in UTF-8 format that is length prefixed.
|
java.lang.String |
getStringUtf8(int index,
java.nio.ByteOrder byteOrder)
Get a String from bytes encoded in UTF-8 format that is length prefixed.
|
java.lang.String |
getStringUtf8(int index,
int length)
Get part of String from bytes encoded in UTF-8 format that is length prefixed.
|
java.lang.String |
getStringWithoutLengthUtf8(int index,
int length)
Get an encoded UTF-8 String from the buffer that does not have a length prefix.
|
void |
wrap(byte[] buffer)
Attach a view to a byte[] for providing direct access.
|
void |
wrap(byte[] buffer,
int offset,
int length)
Attach a view to a byte[] for providing direct access.
|
void |
wrap(java.nio.ByteBuffer buffer)
Attach a view to a
ByteBuffer for providing direct access, the ByteBuffer can be
heap based or direct. |
void |
wrap(java.nio.ByteBuffer buffer,
int offset,
int length)
Attach a view to a
ByteBuffer for providing direct access. |
void |
wrap(DirectBuffer buffer)
Attach a view to an existing
DirectBuffer |
void |
wrap(DirectBuffer buffer,
int offset,
int length)
Attach a view to a
DirectBuffer for providing direct access. |
void |
wrap(long address,
int length)
Attach a view to an off-heap memory region by address.
|
int |
wrapAdjustment()
Get the adjustment in indices between an index in this buffer and the wrapped object.
|
void wrap(byte[] buffer)
buffer - to which the view is attached.void wrap(byte[] buffer,
int offset,
int length)
buffer - to which the view is attached.offset - at which the view begins.length - of the buffer included in the viewvoid wrap(java.nio.ByteBuffer buffer)
ByteBuffer for providing direct access, the ByteBuffer can be
heap based or direct.buffer - to which the view is attached.void wrap(java.nio.ByteBuffer buffer,
int offset,
int length)
ByteBuffer for providing direct access.buffer - to which the view is attached.offset - at which the view begins.length - of the buffer included in the viewvoid wrap(DirectBuffer buffer)
DirectBufferbuffer - to which the view is attached.void wrap(DirectBuffer buffer, int offset, int length)
DirectBuffer for providing direct access.buffer - to which the view is attached.offset - at which the view begins.length - of the buffer included in the viewvoid wrap(long address,
int length)
address - where the memory begins off-heaplength - of the buffer from the given addresslong addressOffset()
byte[] byteArray()
wrapAdjustment().java.nio.ByteBuffer byteBuffer()
ByteBuffer if one exists.
NB: there may not be a one-to-one mapping between indices on this buffer
and the underlying byte[], see wrapAdjustment().ByteBuffer if one exists.int capacity()
void checkLimit(int limit)
Can be overridden in a DirectBuffer subclass to enable an extensible buffer or handle retry after a flush.
limit - up to which access is required.java.lang.IndexOutOfBoundsException - if limit is beyond buffer capacity.long getLong(int index,
java.nio.ByteOrder byteOrder)
index - in bytes from which to get.byteOrder - of the value to be read.long getLong(int index)
index - in bytes from which to get.int getInt(int index,
java.nio.ByteOrder byteOrder)
index - in bytes from which to get.byteOrder - of the value to be read.int getInt(int index)
index - in bytes from which to get.double getDouble(int index,
java.nio.ByteOrder byteOrder)
index - in bytes from which to get.byteOrder - of the value to be read.double getDouble(int index)
index - in bytes from which to get.float getFloat(int index,
java.nio.ByteOrder byteOrder)
index - in bytes from which to get.byteOrder - of the value to be read.float getFloat(int index)
index - in bytes from which to get.short getShort(int index,
java.nio.ByteOrder byteOrder)
index - in bytes from which to get.byteOrder - of the value to be read.short getShort(int index)
index - in bytes from which to get.char getChar(int index,
java.nio.ByteOrder byteOrder)
index - in bytes from which to get.byteOrder - of the value to be read.char getChar(int index)
index - in bytes from which to get.byte getByte(int index)
index - in bytes from which to get.void getBytes(int index,
byte[] dst)
index - in the underlying buffer to start from.dst - into which the dst will be copied.void getBytes(int index,
byte[] dst,
int offset,
int length)
index - in the underlying buffer to start from.dst - into which the bytes will be copied.offset - in the supplied buffer to start the copylength - of the supplied buffer to use.void getBytes(int index,
MutableDirectBuffer dstBuffer,
int dstIndex,
int length)
DirectBuffer into the provided MutableDirectBuffer at given indices.index - in this buffer to begin getting the bytes.dstBuffer - to which the bytes will be copied.dstIndex - in the channel buffer to which the byte copy will begin.length - of the bytes to be copied.void getBytes(int index,
java.nio.ByteBuffer dstBuffer,
int length)
ByteBuffer current Buffer.position().
The destination buffer will have its Buffer.position() advanced as a result.index - in the underlying buffer to start from.dstBuffer - into which the bytes will be copied.length - of the supplied buffer to use.void getBytes(int index,
java.nio.ByteBuffer dstBuffer,
int dstOffset,
int length)
ByteBuffer at a offset.
The destination buffer will not have its Buffer.position() advanced as a result.index - in the underlying buffer to start from.dstBuffer - into which the bytes will be copied.dstOffset - in the target buffer.length - of the supplied buffer to use.java.lang.String getStringUtf8(int index)
index - at which the String begins.java.lang.String getStringUtf8(int index,
java.nio.ByteOrder byteOrder)
index - at which the String begins.byteOrder - for the length at the beginning of the String.java.lang.String getStringUtf8(int index,
int length)
index - at which the String begins.length - of the String in bytes to decode.java.lang.String getStringWithoutLengthUtf8(int index,
int length)
index - at which the String begins.length - of the String in bytes to decode.void boundsCheck(int index,
int length)
index - from which to check.length - in bytes of the range to check.java.lang.IndexOutOfBoundsException - if the length goes outside of the capacity range.int wrapAdjustment()
byteArray(),
byteBuffer()Copyright © 2014 - 2016 Real Logic Ltd. All Rights Reserved.