Class AbstractMutableDirectBuffer
- All Implemented Interfaces:
Comparable<DirectBuffer>,DirectBuffer,MutableDirectBuffer
- Direct Known Subclasses:
ExpandableArrayBuffer,ExpandableDirectByteBuffer,UnsafeBuffer
MutableDirectBuffer interface.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longNative address for off-heap buffer or a pointer to the beginning of the byte array.protected byte[]Byte array reference for on-heap buffers.protected intBuffer capacity in bytes.Fields inherited from interface org.agrona.DirectBuffer
DISABLE_ARRAY_CONTENT_PRINTOUT_PROP_NAME, DISABLE_BOUNDS_CHECKS_PROP_NAME, SHOULD_BOUNDS_CHECK, STR_HEADER_LEN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReads the underlying offset to the memory address.voidboundsCheck(int index, int length) Check that a given length of bytes is within the bounds from a given index.protected final voidboundsCheck0(int index, int length) Perform bound checks.byte[]Get the underlyingbyte[]if one exists.intcapacity()Get the capacity of the underlying buffer.voidcheckLimit(int limit) Check that a given limit is not greater than the capacity of a buffer from a given offset.intcompareTo(DirectBuffer that) protected abstract voidensureCapacity(int index, int length) A hook to ensure the underlying buffer has enough capacity for writing data into the buffer.booleanbytegetByte(int index) Get the value at a given index.voidgetBytes(int index, byte[] dst) Get from the underlying buffer into a supplied byte array.voidgetBytes(int index, byte[] dst, int offset, int length) Get bytes from the underlying buffer into a supplied byte array.voidgetBytes(int index, ByteBuffer dstBuffer, int length) Get from the underlying buffer into a suppliedByteBuffercurrentBuffer.position().voidgetBytes(int index, ByteBuffer dstBuffer, int dstOffset, int length) Get from the underlying buffer into a suppliedByteBufferat an offset.voidgetBytes(int index, MutableDirectBuffer dstBuffer, int dstIndex, int length) Get bytes from thisDirectBufferinto the providedMutableDirectBufferat given indices.chargetChar(int index) Get the value at a given index.charGet the value at a given index.doublegetDouble(int index) Get the value at a given index.doubleGet the value at a given index.floatgetFloat(int index) Get the value at a given index.floatGet the value at a given index.intgetInt(int index) Get the value at a given index.intGet the value at a given index.longgetLong(int index) Get the value at a given index.longGet the value at a given index.shortgetShort(int index) Get the value at a given index.shortGet the value at a given index.getStringAscii(int index) Get a String from bytes encoded in ASCII format that is length prefixed.getStringAscii(int index, int length) Get part of a String from bytes encoded in ASCII format that is length prefixed.intgetStringAscii(int index, int length, Appendable appendable) Get part of a String from bytes encoded in ASCII format that is length prefixed and append to anAppendable.intgetStringAscii(int index, Appendable appendable) Get a String from bytes encoded in ASCII format that is length prefixed and append to anAppendable.intgetStringAscii(int index, Appendable appendable, ByteOrder byteOrder) Get a String from bytes encoded in ASCII format that is length prefixed and append to anAppendable.getStringAscii(int index, ByteOrder byteOrder) Get a String from bytes encoded in ASCII format that is length prefixed.getStringUtf8(int index) Get a String from bytes encoded in UTF-8 format that is length prefixed.getStringUtf8(int index, int length) Get part of String from bytes encoded in UTF-8 format that is length prefixed.getStringUtf8(int index, ByteOrder byteOrder) Get a String from bytes encoded in UTF-8 format that is length prefixed.getStringWithoutLengthAscii(int index, int length) Get an encoded ASCII String from the buffer that does not have a length prefix.intgetStringWithoutLengthAscii(int index, int length, Appendable appendable) Get an encoded ASCII String from the buffer that does not have a length prefix and append to anAppendable.getStringWithoutLengthUtf8(int index, int length) Get an encoded UTF-8 String from the buffer that does not have a length prefix.inthashCode()intparseIntAscii(int index, int length) Parse the ASCII encoded integer value at a given index.longparseLongAscii(int index, int length) Parse the ASCII encoded long integer value at a given index.intparseNaturalIntAscii(int index, int length) Parse the ASCII encoded int sized natural value at a given index.longparseNaturalLongAscii(int index, int length) Parse the ASCII encoded long sized natural value at a given index.voidputByte(int index, byte value) Put a value to a given index.voidputBytes(int index, byte[] src) Put an array of src into the underlying buffer.voidputBytes(int index, byte[] src, int offset, int length) Put an array into the underlying buffer.voidputBytes(int index, ByteBuffer srcBuffer, int length) Put bytes into the underlying buffer for the view.voidputBytes(int index, ByteBuffer srcBuffer, int srcIndex, int length) Put bytes into the underlying buffer for the view.voidputBytes(int index, DirectBuffer srcBuffer, int srcIndex, int length) Put bytes from a sourceDirectBufferinto thisMutableDirectBufferat given indices.voidputChar(int index, char value) Put a value to a given index.voidPut a value to a given index.voidputDouble(int index, double value) Put a value to a given index.voidPut a value to a given index.voidputFloat(int index, float value) Put a value to a given index.voidPut a value to a given index.voidputInt(int index, int value) Put a value to a given index.voidPut a value to a given index.intputIntAscii(int index, int value) Puts an ASCII encoded int into the buffer.voidputLong(int index, long value) Put a value to a given index.voidPut a value to a given index.intputLongAscii(int index, long value) Puts an ASCII encoded long integer into the buffer.intputNaturalIntAscii(int index, int value) Puts an ASCII encoded int sized natural number into the buffer.intputNaturalIntAsciiFromEnd(int value, int endExclusive) Encode a natural number starting at its end position.intputNaturalLongAscii(int index, long value) Puts an ASCII encoded long sized natural number into the buffer.voidputNaturalPaddedIntAscii(int offset, int length, int value) Encode a natural number with a specified maximum length.voidputShort(int index, short value) Put a value to a given index.voidPut a value to a given index.intputStringAscii(int index, CharSequence value) Encode aCharSequenceas ASCII bytes to the buffer with a length prefix.intputStringAscii(int index, CharSequence value, ByteOrder byteOrder) Encode aCharSequenceas ASCII bytes to the buffer with a length prefix.intputStringAscii(int index, String value) Encode aStringas ASCII bytes to the buffer with a length prefix.intputStringAscii(int index, String value, ByteOrder byteOrder) Encode aStringas ASCII bytes to the buffer with a length prefix.intputStringUtf8(int index, String value) Encode aStringas UTF-8 bytes to the buffer with a length prefix.intputStringUtf8(int index, String value, int maxEncodedLength) Encode aStringas UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.intputStringUtf8(int index, String value, ByteOrder byteOrder) Encode aStringas UTF-8 bytes to the buffer with a length prefix.intputStringUtf8(int index, String value, ByteOrder byteOrder, int maxEncodedLength) Encode aStringas UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.intputStringWithoutLengthAscii(int index, CharSequence value) Encode aCharSequenceas ASCII bytes in the buffer without a length prefix.intputStringWithoutLengthAscii(int index, CharSequence value, int valueOffset, int length) Encode aCharSequenceas ASCII bytes in the buffer without a length prefix taking a range of the value.intputStringWithoutLengthAscii(int index, String value) Encode aStringas ASCII bytes in the buffer without a length prefix.intputStringWithoutLengthAscii(int index, String value, int valueOffset, int length) Encode aStringas ASCII bytes in the buffer without a length prefix taking a range of the value.intputStringWithoutLengthUtf8(int index, String value) Encode aStringas UTF-8 bytes in the buffer without a length prefix.voidsetMemory(int index, int length, byte value) Set a region of memory to a given byte value.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.agrona.DirectBuffer
byteBuffer, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrapAdjustmentMethods inherited from interface org.agrona.MutableDirectBuffer
isExpandable
-
Field Details
-
byteArray
protected byte[] byteArrayByte array reference for on-heap buffers. -
addressOffset
protected long addressOffsetNative address for off-heap buffer or a pointer to the beginning of the byte array. -
capacity
protected int capacityBuffer capacity in bytes.
-
-
Constructor Details
-
AbstractMutableDirectBuffer
protected AbstractMutableDirectBuffer()Default constructor.
-
-
Method Details
-
byteArray
public byte[] byteArray()Get the underlyingbyte[]if one exists.NB: there may not be a one-to-one mapping between indices on this buffer and the underlying
byte[], seeDirectBuffer.wrapAdjustment().- Specified by:
byteArrayin interfaceDirectBuffer- Returns:
- the underlying
byte[]if one exists. - See Also:
-
addressOffset
public long addressOffset()Reads the underlying offset to the memory address.- Specified by:
addressOffsetin interfaceDirectBuffer- Returns:
- the underlying offset to the memory address.
-
capacity
public int capacity()Get the capacity of the underlying buffer.- Specified by:
capacityin interfaceDirectBuffer- Returns:
- the capacity of the underlying buffer in bytes.
-
checkLimit
public void checkLimit(int limit) Check that a given limit is not greater than the capacity of a buffer from a given offset.Can be overridden in a DirectBuffer subclass to enable an extensible buffer or handle retry after a flush.
- Specified by:
checkLimitin interfaceDirectBuffer- Parameters:
limit- up to which access is required.
-
setMemory
public void setMemory(int index, int length, byte value) Set a region of memory to a given byte value.- Specified by:
setMemoryin interfaceMutableDirectBuffer- Parameters:
index- at which to start.length- of the run of bytes to set.value- the memory will be set to.
-
getLong
Get the value at a given index.- Specified by:
getLongin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.byteOrder- of the value to be read.- Returns:
- the value for at a given index.
-
putLong
Put a value to a given index.- Specified by:
putLongin interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- for at a given index.byteOrder- of the value when written.
-
getLong
public long getLong(int index) Get the value at a given index.- Specified by:
getLongin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.- Returns:
- the value for at a given index.
-
putLong
public void putLong(int index, long value) Put a value to a given index.- Specified by:
putLongin interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- for at a given index.
-
getInt
Get the value at a given index.- Specified by:
getIntin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.byteOrder- of the value to be read.- Returns:
- the value at a given index.
-
putInt
Put a value to a given index.- Specified by:
putIntin interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- to be written.byteOrder- of the value when written.
-
getInt
public int getInt(int index) Get the value at a given index.- Specified by:
getIntin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.- Returns:
- the value for a given index.
-
putInt
public void putInt(int index, int value) Put a value to a given index.- Specified by:
putIntin interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- for at a given index.
-
getDouble
Get the value at a given index.- Specified by:
getDoublein interfaceDirectBuffer- Parameters:
index- in bytes from which to get.byteOrder- of the value to be read.- Returns:
- the value at a given index.
-
putDouble
Put a value to a given index.- Specified by:
putDoublein interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- to be written.byteOrder- of the value when written.
-
getDouble
public double getDouble(int index) Get the value at a given index.- Specified by:
getDoublein interfaceDirectBuffer- Parameters:
index- in bytes from which to get.- Returns:
- the value at a given index.
-
putDouble
public void putDouble(int index, double value) Put a value to a given index.- Specified by:
putDoublein interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- to be written.
-
getFloat
Get the value at a given index.- Specified by:
getFloatin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.byteOrder- of the value to be read.- Returns:
- the value at a given index.
-
putFloat
Put a value to a given index.- Specified by:
putFloatin interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- to be written.byteOrder- of the value when written.
-
getFloat
public float getFloat(int index) Get the value at a given index.- Specified by:
getFloatin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.- Returns:
- the value at a given index.
-
putFloat
public void putFloat(int index, float value) Put a value to a given index.- Specified by:
putFloatin interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- to be written.
-
getShort
Get the value at a given index.- Specified by:
getShortin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.byteOrder- of the value to be read.- Returns:
- the value at a given index.
-
putShort
Put a value to a given index.- Specified by:
putShortin interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- to be written.byteOrder- of the value when written.
-
getShort
public short getShort(int index) Get the value at a given index.- Specified by:
getShortin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.- Returns:
- the value at a given index.
-
putShort
public void putShort(int index, short value) Put a value to a given index.- Specified by:
putShortin interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- to be written.
-
getByte
public byte getByte(int index) Get the value at a given index.- Specified by:
getBytein interfaceDirectBuffer- Parameters:
index- in bytes from which to get.- Returns:
- the value at a given index.
-
putByte
public void putByte(int index, byte value) Put a value to a given index.- Specified by:
putBytein interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- to be written.
-
getBytes
public void getBytes(int index, byte[] dst) Get from the underlying buffer into a supplied byte array. This method will try to fill the supplied byte array.- Specified by:
getBytesin interfaceDirectBuffer- Parameters:
index- in the underlying buffer to start from.dst- into which the dst will be copied.
-
getBytes
public void getBytes(int index, byte[] dst, int offset, int length) Get bytes from the underlying buffer into a supplied byte array.- Specified by:
getBytesin interfaceDirectBuffer- Parameters:
index- 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.
-
getBytes
Get bytes from thisDirectBufferinto the providedMutableDirectBufferat given indices.- Specified by:
getBytesin interfaceDirectBuffer- Parameters:
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.
-
getBytes
Get from the underlying buffer into a suppliedByteBuffercurrentBuffer.position().The destination buffer will have its
Buffer.position()advanced as a result.- Specified by:
getBytesin interfaceDirectBuffer- Parameters:
index- in the underlying buffer to start from.dstBuffer- into which the bytes will be copied.length- of the supplied buffer to use.
-
getBytes
Get from the underlying buffer into a suppliedByteBufferat an offset.The destination buffer will not have its
Buffer.position()advanced as a result.- Specified by:
getBytesin interfaceDirectBuffer- Parameters:
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.
-
putBytes
public void putBytes(int index, byte[] src) Put an array of src into the underlying buffer.- Specified by:
putBytesin interfaceMutableDirectBuffer- Parameters:
index- in the underlying buffer to start from.src- to be copied into the underlying buffer.
-
putBytes
public void putBytes(int index, byte[] src, int offset, int length) Put an array into the underlying buffer.- Specified by:
putBytesin interfaceMutableDirectBuffer- Parameters:
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.
-
putBytes
Put bytes into the underlying buffer for the view. Bytes will be copied from currentBuffer.position()for a given length.The source buffer will have its
Buffer.position()advanced as a result.- Specified by:
putBytesin interfaceMutableDirectBuffer- Parameters:
index- in the underlying buffer to start from.srcBuffer- to copy the bytes from.length- of the supplied buffer to copy.
-
putBytes
Put bytes into the underlying buffer for the view. Bytes will be copied from the buffer index to the buffer index + length.The source buffer will not have its
Buffer.position()advanced as a result.- Specified by:
putBytesin interfaceMutableDirectBuffer- Parameters:
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.
-
putBytes
Put bytes from a sourceDirectBufferinto thisMutableDirectBufferat given indices.- Specified by:
putBytesin interfaceMutableDirectBuffer- Parameters:
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.
-
getChar
Get the value at a given index.- Specified by:
getCharin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.byteOrder- of the value to be read.- Returns:
- the value at a given index.
-
putChar
Put a value to a given index.- Specified by:
putCharin interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- to be written.byteOrder- of the value when written.
-
getChar
public char getChar(int index) Get the value at a given index.- Specified by:
getCharin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.- Returns:
- the value at a given index.
-
putChar
public void putChar(int index, char value) Put a value to a given index.- Specified by:
putCharin interfaceMutableDirectBuffer- Parameters:
index- in bytes for where to put.value- to be written.
-
getStringAscii
Get a String from bytes encoded in ASCII format that is length prefixed.- Specified by:
getStringAsciiin interfaceDirectBuffer- Parameters:
index- at which the String begins.- Returns:
- the String as represented by the ASCII encoded bytes.
-
getStringAscii
Get a String from bytes encoded in ASCII format that is length prefixed and append to anAppendable.- Specified by:
getStringAsciiin interfaceDirectBuffer- Parameters:
index- at which the String begins.appendable- to append the chars to.- Returns:
- the number of bytes copied.
-
getStringAscii
Get a String from bytes encoded in ASCII format that is length prefixed.- Specified by:
getStringAsciiin interfaceDirectBuffer- Parameters:
index- at which the String begins.byteOrder- for the length at the beginning of the String.- Returns:
- the String as represented by the ASCII encoded bytes.
-
getStringAscii
Get a String from bytes encoded in ASCII format that is length prefixed and append to anAppendable.- Specified by:
getStringAsciiin interfaceDirectBuffer- Parameters:
index- at which the String begins.appendable- to append the chars to.byteOrder- for the length at the beginning of the String.- Returns:
- the number of bytes copied.
-
getStringAscii
Get part of a String from bytes encoded in ASCII format that is length prefixed.- Specified by:
getStringAsciiin interfaceDirectBuffer- Parameters:
index- at which the String begins.length- of the String in bytes to decode.- Returns:
- the String as represented by the ASCII encoded bytes.
-
getStringAscii
Get part of a String from bytes encoded in ASCII format that is length prefixed and append to anAppendable.- Specified by:
getStringAsciiin interfaceDirectBuffer- Parameters:
index- at which the String begins.length- of the String in bytes to decode.appendable- to append the chars to.- Returns:
- the number of bytes copied.
-
putStringAscii
Encode aStringas ASCII bytes to the buffer with a length prefix.- Specified by:
putStringAsciiin interfaceMutableDirectBuffer- Parameters:
index- at which the String should be encoded.value- of the String to be encoded.- Returns:
- the number of bytes put into the buffer.
-
putStringAscii
Encode aCharSequenceas ASCII bytes to the buffer with a length prefix.- Specified by:
putStringAsciiin interfaceMutableDirectBuffer- Parameters:
index- at which the CharSequence should be encoded.value- of the CharSequence to be encoded.- Returns:
- the number of bytes put into the buffer.
-
putStringAscii
Encode aStringas ASCII bytes to the buffer with a length prefix.- Specified by:
putStringAsciiin interfaceMutableDirectBuffer- Parameters:
index- at which the String should be encoded.value- of the String to be encoded.byteOrder- for the length prefix.- Returns:
- the number of bytes put into the buffer.
-
putStringAscii
Encode aCharSequenceas ASCII bytes to the buffer with a length prefix.- Specified by:
putStringAsciiin interfaceMutableDirectBuffer- Parameters:
index- at which the CharSequence should be encoded.value- of the CharSequence to be encoded.byteOrder- for the length prefix.- Returns:
- the number of bytes put into the buffer.
-
getStringWithoutLengthAscii
Get an encoded ASCII String from the buffer that does not have a length prefix.- Specified by:
getStringWithoutLengthAsciiin interfaceDirectBuffer- Parameters:
index- at which the String begins.length- of the String in bytes to decode.- Returns:
- the String as represented by the Ascii encoded bytes.
-
getStringWithoutLengthAscii
Get an encoded ASCII String from the buffer that does not have a length prefix and append to anAppendable.- Specified by:
getStringWithoutLengthAsciiin interfaceDirectBuffer- Parameters:
index- at which the String begins.length- of the String in bytes to decode.appendable- to append the chars to.- Returns:
- the number of bytes copied.
-
putStringWithoutLengthAscii
Encode aStringas ASCII bytes in the buffer without a length prefix.- Specified by:
putStringWithoutLengthAsciiin interfaceMutableDirectBuffer- Parameters:
index- at which the String begins.value- of the String to be encoded.- Returns:
- the number of bytes encoded.
-
putStringWithoutLengthAscii
Encode aCharSequenceas ASCII bytes in the buffer without a length prefix.- Specified by:
putStringWithoutLengthAsciiin interfaceMutableDirectBuffer- Parameters:
index- at which the CharSequence begins.value- of the CharSequence to be encoded.- Returns:
- the number of bytes encoded.
-
putStringWithoutLengthAscii
Encode aStringas ASCII bytes in the buffer without a length prefix taking a range of the value.- Specified by:
putStringWithoutLengthAsciiin interfaceMutableDirectBuffer- Parameters:
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.- Returns:
- the number of bytes encoded.
-
putStringWithoutLengthAscii
Encode aCharSequenceas ASCII bytes in the buffer without a length prefix taking a range of the value.- Specified by:
putStringWithoutLengthAsciiin interfaceMutableDirectBuffer- Parameters:
index- 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.- Returns:
- the number of bytes encoded.
-
getStringUtf8
Get a String from bytes encoded in UTF-8 format that is length prefixed.- Specified by:
getStringUtf8in interfaceDirectBuffer- Parameters:
index- at which the String begins.- Returns:
- the String as represented by the UTF-8 encoded bytes.
-
getStringUtf8
Get a String from bytes encoded in UTF-8 format that is length prefixed.- Specified by:
getStringUtf8in interfaceDirectBuffer- Parameters:
index- at which the String begins.byteOrder- for the length at the beginning of the String.- Returns:
- the String as represented by the UTF-8 encoded bytes.
-
getStringUtf8
Get part of String from bytes encoded in UTF-8 format that is length prefixed.- Specified by:
getStringUtf8in interfaceDirectBuffer- Parameters:
index- at which the String begins.length- of the String in bytes to decode.- Returns:
- the String as represented by the UTF-8 encoded bytes.
-
putStringUtf8
Encode aStringas UTF-8 bytes to the buffer with a length prefix.- Specified by:
putStringUtf8in interfaceMutableDirectBuffer- Parameters:
index- at which the String should be encoded.value- of the String to be encoded.- Returns:
- the number of bytes put into the buffer.
-
putStringUtf8
Encode aStringas UTF-8 bytes to the buffer with a length prefix.- Specified by:
putStringUtf8in interfaceMutableDirectBuffer- Parameters:
index- at which the String should be encoded.value- of the String to be encoded.byteOrder- for the length prefix.- Returns:
- the number of bytes put into the buffer.
-
putStringUtf8
Encode aStringas UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.- Specified by:
putStringUtf8in interfaceMutableDirectBuffer- Parameters:
index- at which the String should be encoded.value- of the String to be encoded.maxEncodedLength- to be checked before writing to the buffer.- Returns:
- the number of bytes put into the buffer.
-
putStringUtf8
Encode aStringas UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.- Specified by:
putStringUtf8in interfaceMutableDirectBuffer- Parameters:
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.- Returns:
- the number of bytes put into the buffer.
-
getStringWithoutLengthUtf8
Get an encoded UTF-8 String from the buffer that does not have a length prefix.- Specified by:
getStringWithoutLengthUtf8in interfaceDirectBuffer- Parameters:
index- at which the String begins.length- of the String in bytes to decode.- Returns:
- the String as represented by the UTF-8 encoded bytes.
-
putStringWithoutLengthUtf8
Encode aStringas UTF-8 bytes in the buffer without a length prefix.- Specified by:
putStringWithoutLengthUtf8in interfaceMutableDirectBuffer- Parameters:
index- at which the String begins.value- of the String to be encoded.- Returns:
- the number of bytes encoded.
-
parseNaturalIntAscii
public int parseNaturalIntAscii(int index, int length) Parse the ASCII encoded int sized natural value at a given index.- Specified by:
parseNaturalIntAsciiin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.length- the length in bytes to parse.- Returns:
- the value at a given index.
-
parseNaturalLongAscii
public long parseNaturalLongAscii(int index, int length) Parse the ASCII encoded long sized natural value at a given index.- Specified by:
parseNaturalLongAsciiin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.length- the length in bytes to parse.- Returns:
- the value at a given index.
-
parseIntAscii
public int parseIntAscii(int index, int length) Parse the ASCII encoded integer value at a given index.- Specified by:
parseIntAsciiin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.length- the length in bytes to parse.- Returns:
- the value at a given index.
-
parseLongAscii
public long parseLongAscii(int index, int length) Parse the ASCII encoded long integer value at a given index.- Specified by:
parseLongAsciiin interfaceDirectBuffer- Parameters:
index- in bytes from which to get.length- the length in bytes to parse.- Returns:
- the value at a given index.
-
putIntAscii
public int putIntAscii(int index, int value) Puts an ASCII encoded int into the buffer.- Specified by:
putIntAsciiin interfaceMutableDirectBuffer- Parameters:
index- the offset at which to put the int.value- the int to write.- Returns:
- the number of bytes that the int took up encoded.
-
putNaturalIntAscii
public int putNaturalIntAscii(int index, int value) Puts an ASCII encoded int sized natural number into the buffer.- Specified by:
putNaturalIntAsciiin interfaceMutableDirectBuffer- Parameters:
index- the offset at which to put the int.value- the int to write.- Returns:
- the number of bytes that the int took up encoded.
-
putNaturalPaddedIntAscii
public void putNaturalPaddedIntAscii(int offset, int length, int value) Encode a natural number with a specified maximum length.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- Specified by:
putNaturalPaddedIntAsciiin interfaceMutableDirectBuffer- Parameters:
offset- the offset to start encoding at.length- the maximum length to encode.value- the value to encode.
-
putNaturalIntAsciiFromEnd
public int putNaturalIntAsciiFromEnd(int value, int endExclusive) Encode a natural number starting at its end position.- Specified by:
putNaturalIntAsciiFromEndin interfaceMutableDirectBuffer- Parameters:
value- the natural number to encode.endExclusive- index after the last character encoded.- Returns:
- startInclusive index of first character encoded.
-
putNaturalLongAscii
public int putNaturalLongAscii(int index, long value) Puts an ASCII encoded long sized natural number into the buffer.- Specified by:
putNaturalLongAsciiin interfaceMutableDirectBuffer- Parameters:
index- the offset at which to put the int.value- the int to write.- Returns:
- the number of bytes that the int took up encoded.
-
putLongAscii
public int putLongAscii(int index, long value) Puts an ASCII encoded long integer into the buffer.- Specified by:
putLongAsciiin interfaceMutableDirectBuffer- Parameters:
index- the offset at which to put the int.value- the int to write.- Returns:
- the number of bytes that the int took up encoded.
-
boundsCheck
public void boundsCheck(int index, int length) Check that a given length of bytes is within the bounds from a given index.- Specified by:
boundsCheckin interfaceDirectBuffer- Parameters:
index- from which to check.length- in bytes of the range to check.
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<DirectBuffer>
-
boundsCheck0
protected final void boundsCheck0(int index, int length) Perform bound checks.- Parameters:
index- to verify.length- to verify.
-
ensureCapacity
protected abstract void ensureCapacity(int index, int length) A hook to ensure the underlying buffer has enough capacity for writing data into the buffer.- Parameters:
index- at which write occurs.length- in bytes.
-