Package org.agrona
Interface MutableDirectBuffer
- All Superinterfaces:
Comparable<DirectBuffer>,DirectBuffer
- All Known Subinterfaces:
AtomicBuffer
- All Known Implementing Classes:
AbstractMutableDirectBuffer,ExpandableArrayBuffer,ExpandableDirectByteBuffer,UnsafeBuffer
Abstraction over a range of buffer types that allows fields to be written in native typed fashion.
ByteOrder of a wrapped buffer is not applied to the MutableDirectBuffer.
To control ByteOrder use the appropriate method with a ByteOrder overload.
-
Field Summary
Fields inherited from interface org.agrona.DirectBuffer
DISABLE_ARRAY_CONTENT_PRINTOUT_PROP_NAME, DISABLE_BOUNDS_CHECKS_PROP_NAME, SHOULD_BOUNDS_CHECK, STR_HEADER_LEN -
Method Summary
Modifier and TypeMethodDescriptionbooleanIs this buffer expandable to accommodate putting data into it beyond the current capacity?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 index, 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 interface java.lang.Comparable
compareToMethods inherited from interface org.agrona.DirectBuffer
addressOffset, boundsCheck, byteArray, byteBuffer, capacity, checkLimit, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, getChar, getChar, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringUtf8, getStringUtf8, getStringUtf8, getStringWithoutLengthAscii, getStringWithoutLengthAscii, getStringWithoutLengthUtf8, parseIntAscii, parseLongAscii, parseNaturalIntAscii, parseNaturalLongAscii, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrapAdjustment
-
Method Details
-
isExpandable
boolean isExpandable()Is this buffer expandable to accommodate putting data into it beyond the current capacity?- Returns:
- true is the underlying storage can expand otherwise false.
-
setMemory
void setMemory(int index, int length, byte value) Set a region of memory to a given byte value.- Parameters:
index- at which to start.length- of the run of bytes to set.value- the memory will be set to.
-
putLong
Put a value to a given index.- Parameters:
index- in bytes for where to put.value- for at a given index.byteOrder- of the value when written.
-
putLong
void putLong(int index, long value) Put a value to a given index.- Parameters:
index- in bytes for where to put.value- for at a given index.
-
putInt
Put a value to a given index.- Parameters:
index- in bytes for where to put.value- to be written.byteOrder- of the value when written.
-
putInt
void putInt(int index, int value) Put a value to a given index.- Parameters:
index- in bytes for where to put.value- for at a given index.
-
putIntAscii
int putIntAscii(int index, int value) Puts an ASCII encoded int into the buffer.- 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
int putNaturalIntAscii(int index, int value) Puts an ASCII encoded int sized natural number into the buffer.- 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
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- Parameters:
index- the offset to start encoding at.length- the maximum length to encode.value- the value to encode.- Throws:
NumberFormatException- if the value won't fit within the length.
-
putNaturalIntAsciiFromEnd
int putNaturalIntAsciiFromEnd(int value, int endExclusive) Encode a natural number starting at its end position.- Parameters:
value- the natural number to encode.endExclusive- index after the last character encoded.- Returns:
- startInclusive index of first character encoded.
-
putNaturalLongAscii
int putNaturalLongAscii(int index, long value) Puts an ASCII encoded long sized natural number into the buffer.- 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
int putLongAscii(int index, long value) Puts an ASCII encoded long integer into the buffer.- 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.
-
putDouble
Put a value to a given index.- Parameters:
index- in bytes for where to put.value- to be written.byteOrder- of the value when written.
-
putDouble
void putDouble(int index, double value) Put a value to a given index.- Parameters:
index- in bytes for where to put.value- to be written.
-
putFloat
Put a value to a given index.- Parameters:
index- in bytes for where to put.value- to be written.byteOrder- of the value when written.
-
putFloat
void putFloat(int index, float value) Put a value to a given index.- Parameters:
index- in bytes for where to put.value- to be written.
-
putShort
Put a value to a given index.- Parameters:
index- in bytes for where to put.value- to be written.byteOrder- of the value when written.
-
putShort
void putShort(int index, short value) Put a value to a given index.- Parameters:
index- in bytes for where to put.value- to be written.
-
putChar
Put a value to a given index.- Parameters:
index- in bytes for where to put.value- to be written.byteOrder- of the value when written.
-
putChar
void putChar(int index, char value) Put a value to a given index.- Parameters:
index- in bytes for where to put.value- to be written.
-
putByte
void putByte(int index, byte value) Put a value to a given index.- Parameters:
index- in bytes for where to put.value- to be written.
-
putBytes
void putBytes(int index, byte[] src) Put an array of src into the underlying buffer.- Parameters:
index- in the underlying buffer to start from.src- to be copied into the underlying buffer.
-
putBytes
void putBytes(int index, byte[] src, int offset, int length) Put an array into the underlying buffer.- 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.- 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.- 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.- 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.
-
putStringAscii
Encode aStringas ASCII bytes to the buffer with a length prefix.- 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.- 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.- 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.- 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.
-
putStringWithoutLengthAscii
Encode aStringas ASCII bytes in the buffer without a length prefix.- 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.- 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.- 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.- 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.
-
putStringUtf8
Encode aStringas UTF-8 bytes to the buffer with a length prefix.- 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.- 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.- 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.
- Throws:
IllegalArgumentException- if the encoded bytes are greater than maxEncodedLength.
-
putStringUtf8
Encode aStringas UTF-8 bytes the buffer with a length prefix with a maximum encoded size check.- 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.
- Throws:
IllegalArgumentException- if the encoded bytes are greater than maxEncodedLength.
-
putStringWithoutLengthUtf8
Encode aStringas UTF-8 bytes in the buffer without a length prefix.- Parameters:
index- at which the String begins.value- of the String to be encoded.- Returns:
- the number of bytes encoded.
-