public class ExpandableDirectByteBuffer extends java.lang.Object implements MutableDirectBuffer
MutableDirectBuffer
that is backed by a direct ByteBuffer
. When values are put into the
buffer beyond its current length, then it will be expanded to accommodate the resulting position for the value.
Put operations will expand the capacity as necessary up to MAX_BUFFER_LENGTH
. Get operations will throw
a IndexOutOfBoundsException
if past current capacity.
ByteOrder
of a wrapped buffer is not applied to the ExpandableDirectByteBuffer
;
To control ByteOrder
use the appropriate method with the ByteOrder
overload.
Note: this class has a natural ordering that is inconsistent with equals. Types may be different but equal on buffer contents.
Modifier and Type | Field and Description |
---|---|
static int |
INITIAL_CAPACITY
Initial capacity of the buffer from which it will expand.
|
static int |
MAX_BUFFER_LENGTH
Maximum length to which the underlying buffer can grow.
|
Constructor and Description |
---|
ExpandableDirectByteBuffer()
Create an
ExpandableDirectByteBuffer with an initial length of INITIAL_CAPACITY . |
ExpandableDirectByteBuffer(int initialCapacity)
Create an
ExpandableDirectByteBuffer with a provided initial capacity. |
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.
|
int |
compareTo(DirectBuffer that) |
boolean |
equals(java.lang.Object obj) |
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 |
getStringAscii(int index)
Get a String from bytes encoded in ASCII format that is length prefixed.
|
java.lang.String |
getStringAscii(int index,
java.nio.ByteOrder byteOrder)
Get a String from bytes encoded in ASCII format that is length prefixed.
|
java.lang.String |
getStringAscii(int index,
int length)
Get part of String from bytes encoded in ASCII format that is length prefixed.
|
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 |
getStringWithoutLengthAscii(int index,
int length)
Get an encoded ASCII String from the buffer that does not have a length prefix.
|
java.lang.String |
getStringWithoutLengthUtf8(int index,
int length)
Get an encoded UTF-8 String from the buffer that does not have a length prefix.
|
int |
hashCode() |
boolean |
isExpandable()
Is this buffer expandable to accommodate putting data into it beyond the current capacity?
|
int |
parseIntAscii(int index,
int length)
Get the ASCII encoded integer value at a given index.
|
long |
parseLongAscii(int index,
int length)
Get the ASCII encoded long integer value at a given index.
|
int |
parseNaturalIntAscii(int index,
int length)
Get the ASCII encoded int sized natural value at a given index.
|
long |
parseNaturalLongAscii(int index,
int length)
Get the ASCII encoded long sized natural value at a given index.
|
void |
putByte(int index,
byte value)
Put a value to a given index.
|
void |
putBytes(int index,
byte[] src)
Put an array of src into the underlying buffer.
|
void |
putBytes(int index,
byte[] src,
int offset,
int length)
Put an array into the underlying buffer.
|
void |
putBytes(int index,
java.nio.ByteBuffer srcBuffer,
int length)
Put bytes into the underlying buffer for the view.
|
void |
putBytes(int index,
java.nio.ByteBuffer srcBuffer,
int srcIndex,
int length)
Put bytes into the underlying buffer for the view.
|
void |
putBytes(int index,
DirectBuffer srcBuffer,
int srcIndex,
int length)
Put bytes from a source
DirectBuffer into this MutableDirectBuffer at given indices. |
void |
putChar(int index,
char value)
Put a value to a given index.
|
void |
putChar(int index,
char value,
java.nio.ByteOrder byteOrder)
Put a value to a given index.
|
void |
putDouble(int index,
double value)
Put a value to a given index.
|
void |
putDouble(int index,
double value,
java.nio.ByteOrder byteOrder)
Put a value to a given index.
|
void |
putFloat(int index,
float value)
Put a value to a given index.
|
void |
putFloat(int index,
float value,
java.nio.ByteOrder byteOrder)
Put a value to a given index.
|
void |
putInt(int index,
int value)
Put a value to a given index.
|
void |
putInt(int index,
int value,
java.nio.ByteOrder byteOrder)
Put a value to a given index.
|
int |
putIntAscii(int index,
int value)
Puts an ASCII encoded int into the buffer
|
void |
putLong(int index,
long value)
Put a value to a given index.
|
void |
putLong(int index,
long value,
java.nio.ByteOrder byteOrder)
Put a value to a given index.
|
int |
putLongAscii(int index,
long value)
Puts an ASCII encoded long integer into the buffer
|
int |
putNaturalIntAscii(int index,
int value)
Puts an ASCII encoded int sized natural number into the buffer
|
int |
putNaturalIntAsciiFromEnd(int value,
int endExclusive)
Encode a natural number starting at its end position.
|
int |
putNaturalLongAscii(int index,
long value)
Puts an ASCII encoded long sized natural number into the buffer
|
void |
putNaturalPaddedIntAscii(int offset,
int length,
int value)
Encode a natural number with a specified maximum length.
|
void |
putShort(int index,
short value)
Put a value to a given index.
|
void |
putShort(int index,
short value,
java.nio.ByteOrder byteOrder)
Put a value to a given index.
|
int |
putStringAscii(int index,
java.lang.String value)
Encode a String as ASCII bytes to the buffer with a length prefix.
|
int |
putStringAscii(int index,
java.lang.String value,
java.nio.ByteOrder byteOrder)
Encode a String as ASCII bytes to the buffer with a length prefix.
|
int |
putStringUtf8(int index,
java.lang.String value)
Encode a String as UTF-8 bytes to the buffer with a length prefix.
|
int |
putStringUtf8(int index,
java.lang.String value,
java.nio.ByteOrder byteOrder)
Encode a String as UTF-8 bytes to the buffer with a length prefix.
|
int |
putStringUtf8(int index,
java.lang.String value,
java.nio.ByteOrder byteOrder,
int maxEncodedLength)
Encode a String as UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.
|
int |
putStringUtf8(int index,
java.lang.String value,
int maxEncodedLength)
Encode a String as UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.
|
int |
putStringWithoutLengthAscii(int index,
java.lang.String value)
Encode a String as ASCII bytes in the buffer without a length prefix.
|
int |
putStringWithoutLengthAscii(int index,
java.lang.String value,
int valueOffset,
int length)
Encode a String as ASCII bytes in the buffer without a length prefix taking a range of the value.
|
int |
putStringWithoutLengthUtf8(int index,
java.lang.String value)
Encode a String as UTF-8 bytes in the buffer without a length prefix.
|
void |
setMemory(int index,
int length,
byte value)
Set a region of memory to a given byte value.
|
java.lang.String |
toString() |
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.
|
public static final int MAX_BUFFER_LENGTH
public static final int INITIAL_CAPACITY
public ExpandableDirectByteBuffer()
ExpandableDirectByteBuffer
with an initial length of INITIAL_CAPACITY
.public ExpandableDirectByteBuffer(int initialCapacity)
ExpandableDirectByteBuffer
with a provided initial capacity.initialCapacity
- of the backing array.public void wrap(byte[] buffer)
DirectBuffer
wrap
in interface DirectBuffer
buffer
- to which the view is attached.public void wrap(byte[] buffer, int offset, int length)
DirectBuffer
wrap
in interface DirectBuffer
buffer
- to which the view is attached.offset
- at which the view begins.length
- of the buffer included in the viewpublic void wrap(java.nio.ByteBuffer buffer)
DirectBuffer
ByteBuffer
for providing direct access, the ByteBuffer
can be
heap based or direct. The ByteBuffer.order()
is not relevant for accessing the wrapped buffer.
When using this method to wrap the view of the ByteBuffer the entire ByteBuffer gets wrapped
between index 0 and capacity. If you want to just wrap the ByteBuffer between the position
and the limit then you should use the DirectBuffer.wrap(ByteBuffer, int, int)
method, eg:
directBuffer.wrap(byteBuffer, byteBuffer.position(), byteBuffer.remaining());
wrap
in interface DirectBuffer
buffer
- to which the view is attached.public void wrap(java.nio.ByteBuffer buffer, int offset, int length)
DirectBuffer
ByteBuffer
for providing direct access.
The ByteBuffer.order()
is not relevant for accessing the wrapped buffer.
wrap
in interface DirectBuffer
buffer
- to which the view is attached.offset
- at which the view begins.length
- of the buffer included in the viewpublic void wrap(DirectBuffer buffer)
DirectBuffer
DirectBuffer
wrap
in interface DirectBuffer
buffer
- to which the view is attached.public void wrap(DirectBuffer buffer, int offset, int length)
DirectBuffer
DirectBuffer
for providing direct access.wrap
in interface DirectBuffer
buffer
- to which the view is attached.offset
- at which the view begins.length
- of the buffer included in the viewpublic void wrap(long address, int length)
DirectBuffer
wrap
in interface DirectBuffer
address
- where the memory begins off-heaplength
- of the buffer from the given addresspublic long addressOffset()
DirectBuffer
addressOffset
in interface DirectBuffer
public byte[] byteArray()
DirectBuffer
NB: there may not be a one-to-one mapping between indices on this buffer
and the underlying byte[], see DirectBuffer.wrapAdjustment()
.
byteArray
in interface DirectBuffer
public java.nio.ByteBuffer byteBuffer()
DirectBuffer
ByteBuffer
if one exists.
NB: there may not be a one-to-one mapping between indices on this buffer
and the underlying byte[], see DirectBuffer.wrapAdjustment()
.
byteBuffer
in interface DirectBuffer
ByteBuffer
if one exists.public void setMemory(int index, int length, byte value)
MutableDirectBuffer
setMemory
in interface MutableDirectBuffer
index
- at which to start.length
- of the run of bytes to set.value
- the memory will be set to.public int capacity()
DirectBuffer
capacity
in interface DirectBuffer
public boolean isExpandable()
MutableDirectBuffer
isExpandable
in interface MutableDirectBuffer
public void checkLimit(int limit)
DirectBuffer
Can be overridden in a DirectBuffer subclass to enable an extensible buffer or handle retry after a flush.
checkLimit
in interface DirectBuffer
limit
- up to which access is required.public long getLong(int index, java.nio.ByteOrder byteOrder)
DirectBuffer
getLong
in interface DirectBuffer
index
- in bytes from which to get.byteOrder
- of the value to be read.public void putLong(int index, long value, java.nio.ByteOrder byteOrder)
MutableDirectBuffer
putLong
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- for at a given indexbyteOrder
- of the value when writtenpublic long getLong(int index)
DirectBuffer
getLong
in interface DirectBuffer
index
- in bytes from which to get.public void putLong(int index, long value)
MutableDirectBuffer
putLong
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- for at a given indexpublic int getInt(int index, java.nio.ByteOrder byteOrder)
DirectBuffer
getInt
in interface DirectBuffer
index
- in bytes from which to get.byteOrder
- of the value to be read.public void putInt(int index, int value, java.nio.ByteOrder byteOrder)
MutableDirectBuffer
putInt
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- to be writtenbyteOrder
- of the value when writtenpublic int getInt(int index)
DirectBuffer
getInt
in interface DirectBuffer
index
- in bytes from which to get.public int parseNaturalIntAscii(int index, int length)
DirectBuffer
parseNaturalIntAscii
in interface DirectBuffer
index
- in bytes from which to get.length
- the length in bytes to parsepublic long parseNaturalLongAscii(int index, int length)
DirectBuffer
parseNaturalLongAscii
in interface DirectBuffer
index
- in bytes from which to get.length
- the length in bytes to parsepublic int parseIntAscii(int index, int length)
DirectBuffer
parseIntAscii
in interface DirectBuffer
index
- in bytes from which to get.length
- the length in bytes to parsepublic long parseLongAscii(int index, int length)
DirectBuffer
parseLongAscii
in interface DirectBuffer
index
- in bytes from which to get.length
- the length in bytes to parsepublic void putInt(int index, int value)
MutableDirectBuffer
putInt
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- for at a given indexpublic int putIntAscii(int index, int value)
MutableDirectBuffer
putIntAscii
in interface MutableDirectBuffer
index
- the offset at which to put the intvalue
- the int to writepublic int putNaturalIntAscii(int index, int value)
MutableDirectBuffer
putNaturalIntAscii
in interface MutableDirectBuffer
index
- the offset at which to put the intvalue
- the int to writepublic void putNaturalPaddedIntAscii(int offset, int length, int value)
MutableDirectBuffer
NumberFormatException
will be thrown.putNaturalPaddedIntAscii
in interface MutableDirectBuffer
offset
- the offset to start encoding atlength
- the maximum length to encode.value
- the value to encodepublic int putNaturalIntAsciiFromEnd(int value, int endExclusive)
MutableDirectBuffer
putNaturalIntAsciiFromEnd
in interface MutableDirectBuffer
value
- the natural number to encodeendExclusive
- index after the last character encodedpublic int putNaturalLongAscii(int index, long value)
MutableDirectBuffer
putNaturalLongAscii
in interface MutableDirectBuffer
index
- the offset at which to put the intvalue
- the int to writepublic int putLongAscii(int index, long value)
MutableDirectBuffer
putLongAscii
in interface MutableDirectBuffer
index
- the offset at which to put the intvalue
- the int to writepublic double getDouble(int index, java.nio.ByteOrder byteOrder)
DirectBuffer
getDouble
in interface DirectBuffer
index
- in bytes from which to get.byteOrder
- of the value to be read.public void putDouble(int index, double value, java.nio.ByteOrder byteOrder)
MutableDirectBuffer
putDouble
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- to be writtenbyteOrder
- of the value when written.public double getDouble(int index)
DirectBuffer
getDouble
in interface DirectBuffer
index
- in bytes from which to get.public void putDouble(int index, double value)
MutableDirectBuffer
putDouble
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- to be writtenpublic float getFloat(int index, java.nio.ByteOrder byteOrder)
DirectBuffer
getFloat
in interface DirectBuffer
index
- in bytes from which to get.byteOrder
- of the value to be read.public void putFloat(int index, float value, java.nio.ByteOrder byteOrder)
MutableDirectBuffer
putFloat
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- to be writtenbyteOrder
- of the value when written.public float getFloat(int index)
DirectBuffer
getFloat
in interface DirectBuffer
index
- in bytes from which to get.public void putFloat(int index, float value)
MutableDirectBuffer
putFloat
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- to be writtenpublic short getShort(int index, java.nio.ByteOrder byteOrder)
DirectBuffer
getShort
in interface DirectBuffer
index
- in bytes from which to get.byteOrder
- of the value to be read.public void putShort(int index, short value, java.nio.ByteOrder byteOrder)
MutableDirectBuffer
putShort
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- to be writtenbyteOrder
- of the value when written.public short getShort(int index)
DirectBuffer
getShort
in interface DirectBuffer
index
- in bytes from which to get.public void putShort(int index, short value)
MutableDirectBuffer
putShort
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- to be writtenpublic byte getByte(int index)
DirectBuffer
getByte
in interface DirectBuffer
index
- in bytes from which to get.public void putByte(int index, byte value)
MutableDirectBuffer
putByte
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- to be writtenpublic void getBytes(int index, byte[] dst)
DirectBuffer
getBytes
in interface DirectBuffer
index
- in the underlying buffer to start from.dst
- into which the dst will be copied.public void getBytes(int index, byte[] dst, int offset, int length)
DirectBuffer
getBytes
in interface DirectBuffer
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.public void getBytes(int index, MutableDirectBuffer dstBuffer, int dstIndex, int length)
DirectBuffer
DirectBuffer
into the provided MutableDirectBuffer
at given indices.getBytes
in interface DirectBuffer
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.public void getBytes(int index, java.nio.ByteBuffer dstBuffer, int length)
DirectBuffer
ByteBuffer
current Buffer.position()
.
The destination buffer will have its Buffer.position()
advanced as a result.
getBytes
in interface DirectBuffer
index
- in the underlying buffer to start from.dstBuffer
- into which the bytes will be copied.length
- of the supplied buffer to use.public void getBytes(int index, java.nio.ByteBuffer dstBuffer, int dstOffset, int length)
DirectBuffer
ByteBuffer
at a offset.
The destination buffer will not have its Buffer.position()
advanced as a result.
getBytes
in interface DirectBuffer
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.public void putBytes(int index, byte[] src)
MutableDirectBuffer
putBytes
in interface MutableDirectBuffer
index
- in the underlying buffer to start from.src
- to be copied to the underlying buffer.public void putBytes(int index, byte[] src, int offset, int length)
MutableDirectBuffer
putBytes
in interface MutableDirectBuffer
index
- in the underlying buffer to start from.src
- to be copied to the underlying buffer.offset
- in the supplied buffer to begin the copy.length
- of the supplied buffer to copy.public void putBytes(int index, java.nio.ByteBuffer srcBuffer, int length)
MutableDirectBuffer
Buffer.position()
for a given length.
The source buffer will have its Buffer.position()
advanced as a result.
putBytes
in interface MutableDirectBuffer
index
- in the underlying buffer to start from.srcBuffer
- to copy the bytes from.length
- of the supplied buffer to copy.public void putBytes(int index, java.nio.ByteBuffer srcBuffer, int srcIndex, int length)
MutableDirectBuffer
The source buffer will not have its Buffer.position()
advanced as a result.
putBytes
in interface MutableDirectBuffer
index
- in the underlying buffer to start from.srcBuffer
- to copy the bytes from (does not change position).srcIndex
- in the source buffer from which the copy will begin.length
- of the bytes to be copied.public void putBytes(int index, DirectBuffer srcBuffer, int srcIndex, int length)
MutableDirectBuffer
DirectBuffer
into this MutableDirectBuffer
at given indices.putBytes
in interface MutableDirectBuffer
index
- in this buffer to begin putting the bytes.srcBuffer
- from which the bytes will be copied.srcIndex
- in the source buffer from which the byte copy will begin.length
- of the bytes to be copied.public char getChar(int index, java.nio.ByteOrder byteOrder)
DirectBuffer
getChar
in interface DirectBuffer
index
- in bytes from which to get.byteOrder
- of the value to be read.public void putChar(int index, char value, java.nio.ByteOrder byteOrder)
MutableDirectBuffer
putChar
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- to be writtenbyteOrder
- of the value when written.public char getChar(int index)
DirectBuffer
getChar
in interface DirectBuffer
index
- in bytes from which to get.public void putChar(int index, char value)
MutableDirectBuffer
putChar
in interface MutableDirectBuffer
index
- in bytes for where to put.value
- to be writtenpublic java.lang.String getStringAscii(int index)
DirectBuffer
getStringAscii
in interface DirectBuffer
index
- at which the String begins.public java.lang.String getStringAscii(int index, java.nio.ByteOrder byteOrder)
DirectBuffer
getStringAscii
in interface DirectBuffer
index
- at which the String begins.byteOrder
- for the length at the beginning of the String.public java.lang.String getStringAscii(int index, int length)
DirectBuffer
getStringAscii
in interface DirectBuffer
index
- at which the String begins.length
- of the String in bytes to decode.public int putStringAscii(int index, java.lang.String value)
MutableDirectBuffer
putStringAscii
in interface MutableDirectBuffer
index
- at which the String should be encoded.value
- of the String to be encoded.public int putStringAscii(int index, java.lang.String value, java.nio.ByteOrder byteOrder)
MutableDirectBuffer
putStringAscii
in interface MutableDirectBuffer
index
- at which the String should be encoded.value
- of the String to be encoded.byteOrder
- for the length prefix.public java.lang.String getStringWithoutLengthAscii(int index, int length)
DirectBuffer
getStringWithoutLengthAscii
in interface DirectBuffer
index
- at which the String begins.length
- of the String in bytes to decode.public int putStringWithoutLengthAscii(int index, java.lang.String value)
MutableDirectBuffer
putStringWithoutLengthAscii
in interface MutableDirectBuffer
index
- at which the String begins.value
- of the String to be encoded.public int putStringWithoutLengthAscii(int index, java.lang.String value, int valueOffset, int length)
MutableDirectBuffer
putStringWithoutLengthAscii
in interface MutableDirectBuffer
index
- at which the String begins.value
- of the String to be encoded.valueOffset
- in the value String to begin.length
- of the value String to encode. If this is greater than valueOffset - value length then the
lesser will be used.public java.lang.String getStringUtf8(int index)
DirectBuffer
getStringUtf8
in interface DirectBuffer
index
- at which the String begins.public java.lang.String getStringUtf8(int index, java.nio.ByteOrder byteOrder)
DirectBuffer
getStringUtf8
in interface DirectBuffer
index
- at which the String begins.byteOrder
- for the length at the beginning of the String.public java.lang.String getStringUtf8(int index, int length)
DirectBuffer
getStringUtf8
in interface DirectBuffer
index
- at which the String begins.length
- of the String in bytes to decode.public int putStringUtf8(int index, java.lang.String value)
MutableDirectBuffer
putStringUtf8
in interface MutableDirectBuffer
index
- at which the String should be encoded.value
- of the String to be encoded.public int putStringUtf8(int index, java.lang.String value, java.nio.ByteOrder byteOrder)
MutableDirectBuffer
putStringUtf8
in interface MutableDirectBuffer
index
- at which the String should be encoded.value
- of the String to be encoded.byteOrder
- for the length prefix.public int putStringUtf8(int index, java.lang.String value, int maxEncodedLength)
MutableDirectBuffer
putStringUtf8
in interface MutableDirectBuffer
index
- at which the String should be encoded.value
- of the String to be encoded.maxEncodedLength
- to be checked before writing to the buffer.public int putStringUtf8(int index, java.lang.String value, java.nio.ByteOrder byteOrder, int maxEncodedLength)
MutableDirectBuffer
putStringUtf8
in interface MutableDirectBuffer
index
- at which the String should be encoded.value
- of the String to be encoded.byteOrder
- for the length prefix.maxEncodedLength
- to be checked before writing to the buffer.public java.lang.String getStringWithoutLengthUtf8(int index, int length)
DirectBuffer
getStringWithoutLengthUtf8
in interface DirectBuffer
index
- at which the String begins.length
- of the String in bytes to decode.public int putStringWithoutLengthUtf8(int index, java.lang.String value)
MutableDirectBuffer
putStringWithoutLengthUtf8
in interface MutableDirectBuffer
index
- at which the String begins.value
- of the String to be encoded.public void boundsCheck(int index, int length)
DirectBuffer
boundsCheck
in interface DirectBuffer
index
- from which to check.length
- in bytes of the range to check.public int wrapAdjustment()
DirectBuffer
ByteBuffer
or a byte[].
You only need to use this adjustment if you plan to perform operations on the underlying byte array or byte buffer that rely on their indices.
wrapAdjustment
in interface DirectBuffer
DirectBuffer.byteArray()
,
DirectBuffer.byteBuffer()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(DirectBuffer that)
compareTo
in interface java.lang.Comparable<DirectBuffer>
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2014-2019 Real Logic Ltd. All Rights Reserved.