public abstract class AbstractMutableDirectBuffer extends Object implements MutableDirectBuffer
MutableDirectBuffer interface.| Modifier and Type | Field and Description |
|---|---|
protected long |
addressOffset |
protected byte[] |
byteArray |
protected int |
capacity |
DISABLE_ARRAY_CONTENT_PRINTOUT_PROP_NAME, DISABLE_BOUNDS_CHECKS_PROP_NAME, SHOULD_BOUNDS_CHECK, STR_HEADER_LEN| Constructor and Description |
|---|
AbstractMutableDirectBuffer() |
| Modifier and Type | Method and Description |
|---|---|
long |
addressOffset()
Reads the underlying offset 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.
|
protected void |
boundsCheck0(int index,
int length) |
byte[] |
byteArray()
Get the underlying
byte[] 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) |
protected abstract void |
ensureCapacity(int index,
int length) |
boolean |
equals(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,
ByteBuffer dstBuffer,
int length)
Get from the underlying buffer into a supplied
ByteBuffer current Buffer.position(). |
void |
getBytes(int index,
ByteBuffer dstBuffer,
int dstOffset,
int length)
Get from the underlying buffer into a supplied
ByteBuffer at an 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,
ByteOrder byteOrder)
Get the value at a given index.
|
double |
getDouble(int index)
Get the value at a given index.
|
double |
getDouble(int index,
ByteOrder byteOrder)
Get the value at a given index.
|
float |
getFloat(int index)
Get the value at a given index.
|
float |
getFloat(int index,
ByteOrder byteOrder)
Get the value at a given index.
|
int |
getInt(int index)
Get the value at a given index.
|
int |
getInt(int index,
ByteOrder byteOrder)
Get the value at a given index.
|
long |
getLong(int index)
Get the value at a given index.
|
long |
getLong(int index,
ByteOrder byteOrder)
Get the value at a given index.
|
short |
getShort(int index)
Get the value at a given index.
|
short |
getShort(int index,
ByteOrder byteOrder)
Get the value at a given index.
|
String |
getStringAscii(int index)
Get a String from bytes encoded in ASCII format that is length prefixed.
|
int |
getStringAscii(int index,
Appendable appendable)
Get a String from bytes encoded in ASCII format that is length prefixed and append to an
Appendable. |
int |
getStringAscii(int index,
Appendable appendable,
ByteOrder byteOrder)
Get a String from bytes encoded in ASCII format that is length prefixed and append to an
Appendable. |
String |
getStringAscii(int index,
ByteOrder byteOrder)
Get a String from bytes encoded in ASCII format that is length prefixed.
|
String |
getStringAscii(int index,
int length)
Get part of a String from bytes encoded in ASCII format that is length prefixed.
|
int |
getStringAscii(int index,
int length,
Appendable appendable)
Get part of a String from bytes encoded in ASCII format that is length prefixed and append to an
Appendable. |
String |
getStringUtf8(int index)
Get a String from bytes encoded in UTF-8 format that is length prefixed.
|
String |
getStringUtf8(int index,
ByteOrder byteOrder)
Get a String from bytes encoded in UTF-8 format that is length prefixed.
|
String |
getStringUtf8(int index,
int length)
Get part of String from bytes encoded in UTF-8 format that is length prefixed.
|
String |
getStringWithoutLengthAscii(int index,
int length)
Get an encoded ASCII String from the buffer that does not have a length prefix.
|
int |
getStringWithoutLengthAscii(int index,
int length,
Appendable appendable)
Get an encoded ASCII String from the buffer that does not have a length prefix and append to an
Appendable. |
String |
getStringWithoutLengthUtf8(int index,
int length)
Get an encoded UTF-8 String from the buffer that does not have a length prefix.
|
int |
hashCode() |
int |
parseIntAscii(int index,
int length)
Parse the ASCII encoded integer value at a given index.
|
long |
parseLongAscii(int index,
int length)
Parse the ASCII encoded long integer value at a given index.
|
int |
parseNaturalIntAscii(int index,
int length)
Parse the ASCII encoded int sized natural value at a given index.
|
long |
parseNaturalLongAscii(int index,
int length)
Parse 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,
ByteBuffer srcBuffer,
int length)
Put bytes into the underlying buffer for the view.
|
void |
putBytes(int index,
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,
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,
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,
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,
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,
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,
ByteOrder byteOrder)
Put a value to a given index.
|
int |
putStringAscii(int index,
CharSequence value)
Encode a
CharSequence as ASCII bytes to the buffer with a length prefix. |
int |
putStringAscii(int index,
CharSequence value,
ByteOrder byteOrder)
Encode a
CharSequence as ASCII bytes to the buffer with a length prefix. |
int |
putStringAscii(int index,
String value)
Encode a
String as ASCII bytes to the buffer with a length prefix. |
int |
putStringAscii(int index,
String value,
ByteOrder byteOrder)
Encode a
String as ASCII bytes to the buffer with a length prefix. |
int |
putStringUtf8(int index,
String value)
Encode a
String as UTF-8 bytes to the buffer with a length prefix. |
int |
putStringUtf8(int index,
String value,
ByteOrder byteOrder)
Encode a
String as UTF-8 bytes to the buffer with a length prefix. |
int |
putStringUtf8(int index,
String value,
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,
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,
CharSequence value)
Encode a
CharSequence as ASCII bytes in the buffer without a length prefix. |
int |
putStringWithoutLengthAscii(int index,
CharSequence value,
int valueOffset,
int length)
Encode a
CharSequence as ASCII bytes in the buffer without a length prefix taking a range of the value. |
int |
putStringWithoutLengthAscii(int index,
String value)
Encode a
String as ASCII bytes in the buffer without a length prefix. |
int |
putStringWithoutLengthAscii(int index,
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,
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.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitisExpandablebyteBuffer, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrapAdjustmentprotected byte[] byteArray
protected long addressOffset
protected int capacity
public byte[] byteArray()
byte[] 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().
byteArray in interface DirectBufferbyte[] if one exists.DirectBuffer.wrap(byte[]),
DirectBuffer.wrap(byte[], int, int),
DirectBuffer.wrap(ByteBuffer),
DirectBuffer.wrap(ByteBuffer, int, int)public long addressOffset()
addressOffset in interface DirectBufferpublic int capacity()
capacity in interface DirectBufferpublic void checkLimit(int limit)
Can be overridden in a DirectBuffer subclass to enable an extensible buffer or handle retry after a flush.
checkLimit in interface DirectBufferlimit - up to which access is required.public void setMemory(int index,
int length,
byte value)
setMemory in interface MutableDirectBufferindex - at which to start.length - of the run of bytes to set.value - the memory will be set to.public long getLong(int index,
ByteOrder byteOrder)
getLong in interface DirectBufferindex - in bytes from which to get.byteOrder - of the value to be read.public void putLong(int index,
long value,
ByteOrder byteOrder)
putLong in interface MutableDirectBufferindex - in bytes for where to put.value - for at a given index.byteOrder - of the value when written.public long getLong(int index)
getLong in interface DirectBufferindex - in bytes from which to get.public void putLong(int index,
long value)
putLong in interface MutableDirectBufferindex - in bytes for where to put.value - for at a given index.public int getInt(int index,
ByteOrder byteOrder)
getInt in interface DirectBufferindex - in bytes from which to get.byteOrder - of the value to be read.public void putInt(int index,
int value,
ByteOrder byteOrder)
putInt in interface MutableDirectBufferindex - in bytes for where to put.value - to be written.byteOrder - of the value when written.public int getInt(int index)
getInt in interface DirectBufferindex - in bytes from which to get.public void putInt(int index,
int value)
putInt in interface MutableDirectBufferindex - in bytes for where to put.value - for at a given index.public double getDouble(int index,
ByteOrder byteOrder)
getDouble in interface DirectBufferindex - in bytes from which to get.byteOrder - of the value to be read.public void putDouble(int index,
double value,
ByteOrder byteOrder)
putDouble in interface MutableDirectBufferindex - in bytes for where to put.value - to be written.byteOrder - of the value when written.public double getDouble(int index)
getDouble in interface DirectBufferindex - in bytes from which to get.public void putDouble(int index,
double value)
putDouble in interface MutableDirectBufferindex - in bytes for where to put.value - to be written.public float getFloat(int index,
ByteOrder byteOrder)
getFloat in interface DirectBufferindex - in bytes from which to get.byteOrder - of the value to be read.public void putFloat(int index,
float value,
ByteOrder byteOrder)
putFloat in interface MutableDirectBufferindex - in bytes for where to put.value - to be written.byteOrder - of the value when written.public float getFloat(int index)
getFloat in interface DirectBufferindex - in bytes from which to get.public void putFloat(int index,
float value)
putFloat in interface MutableDirectBufferindex - in bytes for where to put.value - to be written.public short getShort(int index,
ByteOrder byteOrder)
getShort in interface DirectBufferindex - in bytes from which to get.byteOrder - of the value to be read.public void putShort(int index,
short value,
ByteOrder byteOrder)
putShort in interface MutableDirectBufferindex - in bytes for where to put.value - to be written.byteOrder - of the value when written.public short getShort(int index)
getShort in interface DirectBufferindex - in bytes from which to get.public void putShort(int index,
short value)
putShort in interface MutableDirectBufferindex - in bytes for where to put.value - to be written.public byte getByte(int index)
getByte in interface DirectBufferindex - in bytes from which to get.public void putByte(int index,
byte value)
putByte in interface MutableDirectBufferindex - in bytes for where to put.value - to be written.public void getBytes(int index,
byte[] dst)
getBytes in interface DirectBufferindex - 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)
getBytes in interface DirectBufferindex - in the underlying buffer to start from.dst - into which the bytes will be copied.offset - in the supplied buffer to start the copy.length - of the supplied buffer to use.public void getBytes(int index,
MutableDirectBuffer dstBuffer,
int dstIndex,
int length)
DirectBuffer into the provided MutableDirectBuffer at given indices.getBytes in interface DirectBufferindex - 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,
ByteBuffer dstBuffer,
int length)
ByteBuffer current Buffer.position().
The destination buffer will have its Buffer.position() advanced as a result.
getBytes in interface DirectBufferindex - 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,
ByteBuffer dstBuffer,
int dstOffset,
int length)
ByteBuffer at an offset.
The destination buffer will not have its Buffer.position() advanced as a result.
getBytes in interface DirectBufferindex - 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)
putBytes in interface MutableDirectBufferindex - in the underlying buffer to start from.src - to be copied into the underlying buffer.public void putBytes(int index,
byte[] src,
int offset,
int length)
putBytes in interface MutableDirectBufferindex - 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,
ByteBuffer srcBuffer,
int length)
Buffer.position() for a given length.
The source buffer will have its Buffer.position() advanced as a result.
putBytes in interface MutableDirectBufferindex - 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,
ByteBuffer srcBuffer,
int srcIndex,
int length)
The source buffer will not have its Buffer.position() advanced as a result.
putBytes in interface MutableDirectBufferindex - 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)
DirectBuffer into this MutableDirectBuffer at given indices.putBytes in interface MutableDirectBufferindex - 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,
ByteOrder byteOrder)
getChar in interface DirectBufferindex - in bytes from which to get.byteOrder - of the value to be read.public void putChar(int index,
char value,
ByteOrder byteOrder)
putChar in interface MutableDirectBufferindex - in bytes for where to put.value - to be written.byteOrder - of the value when written.public char getChar(int index)
getChar in interface DirectBufferindex - in bytes from which to get.public void putChar(int index,
char value)
putChar in interface MutableDirectBufferindex - in bytes for where to put.value - to be written.public String getStringAscii(int index)
getStringAscii in interface DirectBufferindex - at which the String begins.public int getStringAscii(int index,
Appendable appendable)
Appendable.getStringAscii in interface DirectBufferindex - at which the String begins.appendable - to append the chars to.public String getStringAscii(int index, ByteOrder byteOrder)
getStringAscii in interface DirectBufferindex - at which the String begins.byteOrder - for the length at the beginning of the String.public int getStringAscii(int index,
Appendable appendable,
ByteOrder byteOrder)
Appendable.getStringAscii in interface DirectBufferindex - at which the String begins.appendable - to append the chars to.byteOrder - for the length at the beginning of the String.public String getStringAscii(int index, int length)
getStringAscii in interface DirectBufferindex - at which the String begins.length - of the String in bytes to decode.public int getStringAscii(int index,
int length,
Appendable appendable)
Appendable.getStringAscii in interface DirectBufferindex - at which the String begins.length - of the String in bytes to decode.appendable - to append the chars to.public int putStringAscii(int index,
String value)
String as ASCII bytes to the buffer with a length prefix.putStringAscii in interface MutableDirectBufferindex - at which the String should be encoded.value - of the String to be encoded.public int putStringAscii(int index,
CharSequence value)
CharSequence as ASCII bytes to the buffer with a length prefix.putStringAscii in interface MutableDirectBufferindex - at which the CharSequence should be encoded.value - of the CharSequence to be encoded.public int putStringAscii(int index,
String value,
ByteOrder byteOrder)
String as ASCII bytes to the buffer with a length prefix.putStringAscii in interface MutableDirectBufferindex - at which the String should be encoded.value - of the String to be encoded.byteOrder - for the length prefix.public int putStringAscii(int index,
CharSequence value,
ByteOrder byteOrder)
CharSequence as ASCII bytes to the buffer with a length prefix.putStringAscii in interface MutableDirectBufferindex - at which the CharSequence should be encoded.value - of the CharSequence to be encoded.byteOrder - for the length prefix.public String getStringWithoutLengthAscii(int index, int length)
getStringWithoutLengthAscii in interface DirectBufferindex - at which the String begins.length - of the String in bytes to decode.public int getStringWithoutLengthAscii(int index,
int length,
Appendable appendable)
Appendable.getStringWithoutLengthAscii in interface DirectBufferindex - at which the String begins.length - of the String in bytes to decode.appendable - to append the chars to.public int putStringWithoutLengthAscii(int index,
String value)
String as ASCII bytes in the buffer without a length prefix.putStringWithoutLengthAscii in interface MutableDirectBufferindex - at which the String begins.value - of the String to be encoded.public int putStringWithoutLengthAscii(int index,
CharSequence value)
CharSequence as ASCII bytes in the buffer without a length prefix.putStringWithoutLengthAscii in interface MutableDirectBufferindex - at which the CharSequence begins.value - of the CharSequence to be encoded.public int putStringWithoutLengthAscii(int index,
String value,
int valueOffset,
int length)
String as ASCII bytes in the buffer without a length prefix taking a range of the value.putStringWithoutLengthAscii in interface MutableDirectBufferindex - 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 int putStringWithoutLengthAscii(int index,
CharSequence value,
int valueOffset,
int length)
CharSequence as ASCII bytes in the buffer without a length prefix taking a range of the value.putStringWithoutLengthAscii in interface MutableDirectBufferindex - at which the CharSequence begins.value - of the CharSequence to be encoded.valueOffset - in the value CharSequence to begin.length - of the value CharSequence to encode. If this is greater than valueOffset - value length then the
lesser will be used.public String getStringUtf8(int index)
getStringUtf8 in interface DirectBufferindex - at which the String begins.public String getStringUtf8(int index, ByteOrder byteOrder)
getStringUtf8 in interface DirectBufferindex - at which the String begins.byteOrder - for the length at the beginning of the String.public String getStringUtf8(int index, int length)
getStringUtf8 in interface DirectBufferindex - at which the String begins.length - of the String in bytes to decode.public int putStringUtf8(int index,
String value)
String as UTF-8 bytes to the buffer with a length prefix.putStringUtf8 in interface MutableDirectBufferindex - at which the String should be encoded.value - of the String to be encoded.public int putStringUtf8(int index,
String value,
ByteOrder byteOrder)
String as UTF-8 bytes to the buffer with a length prefix.putStringUtf8 in interface MutableDirectBufferindex - at which the String should be encoded.value - of the String to be encoded.byteOrder - for the length prefix.public int putStringUtf8(int index,
String value,
int maxEncodedLength)
String as UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.putStringUtf8 in interface MutableDirectBufferindex - 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,
String value,
ByteOrder byteOrder,
int maxEncodedLength)
String as UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.putStringUtf8 in interface MutableDirectBufferindex - 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 String getStringWithoutLengthUtf8(int index, int length)
getStringWithoutLengthUtf8 in interface DirectBufferindex - at which the String begins.length - of the String in bytes to decode.public int putStringWithoutLengthUtf8(int index,
String value)
String as UTF-8 bytes in the buffer without a length prefix.putStringWithoutLengthUtf8 in interface MutableDirectBufferindex - at which the String begins.value - of the String to be encoded.public int parseNaturalIntAscii(int index,
int length)
parseNaturalIntAscii in interface DirectBufferindex - in bytes from which to get.length - the length in bytes to parse.public long parseNaturalLongAscii(int index,
int length)
parseNaturalLongAscii in interface DirectBufferindex - in bytes from which to get.length - the length in bytes to parse.public int parseIntAscii(int index,
int length)
parseIntAscii in interface DirectBufferindex - in bytes from which to get.length - the length in bytes to parse.public long parseLongAscii(int index,
int length)
parseLongAscii in interface DirectBufferindex - in bytes from which to get.length - the length in bytes to parse.public int putIntAscii(int index,
int value)
putIntAscii in interface MutableDirectBufferindex - the offset at which to put the int.value - the int to write.public int putNaturalIntAscii(int index,
int value)
putNaturalIntAscii in interface MutableDirectBufferindex - the offset at which to put the int.value - the int to write.public void putNaturalPaddedIntAscii(int offset,
int length,
int value)
If ascii encoding of the number is less than the specified length then the start will be
pre-padded with zeros, if the value takes up more space than the allowed length then a
will be thrown.NumberFormatException
putNaturalPaddedIntAscii in interface MutableDirectBufferoffset - the offset to start encoding at.length - the maximum length to encode.value - the value to encode.public int putNaturalIntAsciiFromEnd(int value,
int endExclusive)
putNaturalIntAsciiFromEnd in interface MutableDirectBuffervalue - the natural number to encode.endExclusive - index after the last character encoded.public int putNaturalLongAscii(int index,
long value)
putNaturalLongAscii in interface MutableDirectBufferindex - the offset at which to put the int.value - the int to write.public int putLongAscii(int index,
long value)
putLongAscii in interface MutableDirectBufferindex - the offset at which to put the int.value - the int to write.public void boundsCheck(int index,
int length)
boundsCheck in interface DirectBufferindex - from which to check.length - in bytes of the range to check.public int compareTo(DirectBuffer that)
compareTo in interface Comparable<DirectBuffer>protected final void boundsCheck0(int index,
int length)
protected abstract void ensureCapacity(int index,
int length)
Copyright © 2014-2022 Real Logic Limited. All Rights Reserved.