Package pcap.common.memory
Interface Memory
- All Known Implementing Classes:
Stream
,UncheckedByteArray
@Inclubating public interface Memory
Used to wrap low-level memory address.
Creation of a buffer
It is recommended to create a new buffer using the helper methods in Memories
rather
than calling an individual implementation's constructor.
- Author:
- Ardika Rommy Sanjaya
-
Method Summary
Modifier and Type Method Description int
capacity()
Memory
capacity(int newCapacity)
Adjusts the capacity of this buffer.Memory
clear()
Sets thereaderIndex
andwriterIndex
of this buffer to0
.Memory
copy()
Returns a copy of this buffer's readable bytes.Memory
copy(int index, int length)
Returns a copy of this buffer's sub-region.Memory
duplicate()
Duplicate the thisMemory
buffer.Memory
ensureWritable(int minWritableBytes)
Makes sure the number of the writable bytes is equal to or greater than the specified value.boolean
getBoolean(int index)
Gets a boolean at the specified absolute (@code index) in this buffer.byte
getByte(int index)
Gets a byte at the specified absoluteindex
in this buffer.Memory
getBytes(int index, byte[] dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.Memory
getBytes(int index, byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.Memory
getBytes(int index, Memory dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination becomes non-writable.Memory
getBytes(int index, Memory dst, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.Memory
getBytes(int index, Memory dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.CharSequence
getCharSequence(int index, int length, Charset charset)
Gets aCharSequence
with the given length at the given index.double
getDouble(int index)
Gets a 64-bit floating point number at the specified absoluteindex
in this buffer.double
getDoubleLE(int index)
Gets a 64-bit floating point number at the specified absoluteindex
in this buffer in Little Endian Byte Order.float
getFloat(int index)
Gets a 32-bit floating point number at the specified absoluteindex
in this buffer.float
getFloatLE(int index)
Gets a 32-bit floating point number at the specified absoluteindex
in this buffer in Little Endian Byte Order.int
getInt(int index)
Gets a 32-bit integer at the specified absoluteindex
in this buffer.int
getIntLE(int index)
Gets a 32-bit integer at the specified absoluteindex
in this buffer with Little Endian Byte Order.long
getLong(int index)
Gets a 64-bit long integer at the specified absoluteindex
in this buffer.long
getLongLE(int index)
Gets a 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.short
getShort(int index)
Gets a 16-bit short integer at the specified absoluteindex
in this buffer.short
getShortLE(int index)
Gets a 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.short
getUnsignedByte(int index)
Gets an unsigned byte at the specified absoluteindex
in this buffer.long
getUnsignedInt(int index)
Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer.long
getUnsignedIntLE(int index)
Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.int
getUnsignedShort(int index)
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer.int
getUnsignedShortLE(int index)
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.boolean
isDirect()
Returnstrue
only if this buffer is an direct buffer, false otherwise.boolean
isReadable()
boolean
isReadable(int numBytes)
boolean
isWritable()
boolean
isWritable(int numBytes)
Memory
markReaderIndex()
Marks the currentreaderIndex
in this buffer.Memory
markWriterIndex()
Marks the currentwriterIndex
in this buffer.int
maxCapacity()
If a user attempts to increase the capacity of this buffer beyond the maximum capacity usingcapacity(int)
orensureWritable(int)
, those methods will raise anIllegalArgumentException
.int
maxWritableBytes()
long
memoryAddress()
ByteBuffer
nioBuffer()
Exposes thisMemory
buffer's as an NIOByteBuffer
's.int
readableBytes()
boolean
readBoolean()
Gets a boolean at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.byte
readByte()
Gets a byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.Memory
readBytes(byte[] dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=dst.length
).Memory
readBytes(byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).Memory
readBytes(Memory dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination becomes non-writable, and increases thereaderIndex
by the number of the transferred bytes.Memory
readBytes(Memory dst, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).Memory
readBytes(Memory dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).CharSequence
readCharSequence(int length, Charset charset)
Gets aCharSequence
with the given length at the currentreaderIndex
and increases thereaderIndex
by the given length.double
readDouble()
Gets a 64-bit floating point number at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.double
readDoubleLE()
Gets a 64-bit floating point number at the currentreaderIndex
in Little Endian Byte Order and increases thereaderIndex
by8
in this buffer.int
readerIndex()
Memory
readerIndex(int readerIndex)
Sets thereaderIndex
of this buffer.float
readFloat()
Gets a 32-bit floating point number at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.float
readFloatLE()
Gets a 32-bit floating point number at the currentreaderIndex
in Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.int
readInt()
Gets a 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.int
readIntLE()
Gets a 32-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.long
readLong()
Gets a 64-bit integer at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.long
readLongLE()
Gets a 64-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by8
in this buffer.short
readShort()
Gets a 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.short
readShortLE()
Gets a 16-bit short integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by2
in this buffer.short
readUnsignedByte()
Gets an unsigned byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.long
readUnsignedInt()
Gets an unsigned 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.long
readUnsignedIntLE()
Gets an unsigned 32-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.int
readUnsignedShort()
Gets an unsigned 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.int
readUnsignedShortLE()
Gets an unsigned 16-bit short integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by2
in this buffer.void
release()
Deallocate/freeing thisMemory
buffer.Memory
resetReaderIndex()
Repositions the currentreaderIndex
to the markedreaderIndex
in this buffer.Memory
resetWriterIndex()
Repositions the currentwriterIndex
to the markedwriterIndex
in this buffer.Memory
setBoolean(int index, boolean value)
Sets the specified boolean at the specified absoluteindex
in this buffer.Memory
setByte(int index, int value)
Sets the specified byte at the specified absoluteindex
in this buffer.Memory
setBytes(int index, byte[] src)
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.Memory
setBytes(int index, byte[] src, int srcIndex, int length)
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.Memory
setBytes(int index, Memory src)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer becomes unreadable.Memory
setBytes(int index, Memory src, int length)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.Memory
setBytes(int index, Memory src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.Memory
setCharSequence(int index, CharSequence sequence, Charset charset)
Writes the specifiedCharSequence
at the currentwriterIndex
and increases thewriterIndex
by the written bytes.Memory
setDouble(int index, double value)
Sets the specified 64-bit floating-point number at the specified absoluteindex
in this buffer.Memory
setDoubleLE(int index, double value)
Sets the specified 64-bit floating-point number at the specified absoluteindex
in this buffer in Little Endian Byte Order.Memory
setFloat(int index, float value)
Sets the specified 32-bit floating-point number at the specified absoluteindex
in this buffer.Memory
setFloatLE(int index, float value)
Sets the specified 32-bit floating-point number at the specified absoluteindex
in this buffer in Little Endian Byte Order.Memory
setIndex(int readerIndex, int writerIndex)
Combination ofwriterIndex(...)
andreaderIndex(...)
.Memory
setInt(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer.Memory
setIntLE(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer with Little Endian byte order .Memory
setLong(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer.Memory
setLongLE(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.Memory
setShort(int index, int value)
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer.Memory
setShortLE(int index, int value)
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer with the Little Endian Byte Order.Memory
skipBytes(int length)
Increases the currentreaderIndex
by the specifiedlength
in this buffer.Memory
slice()
Returns a slice of this buffer's readable bytes.Memory
slice(int index, int length)
Returns a slice of this buffer's sub-region.int
writableBytes()
Memory
writeBoolean(boolean value)
Sets the specified boolean at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.Memory
writeByte(int value)
Sets the specified byte at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.Memory
writeBytes(byte[] src)
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=src.length
).Memory
writeBytes(byte[] src, int srcIndex, int length)
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).Memory
writeBytes(Memory src)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer becomes unreadable, and increases thewriterIndex
by the number of the transferred bytes.Memory
writeBytes(Memory src, int length)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).Memory
writeBytes(Memory src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).Memory
writeCharSequence(CharSequence sequence, Charset charset)
Writes the specifiedCharSequence
at the currentwriterIndex
and increases thewriterIndex
by the written bytes.Memory
writeDouble(double value)
Sets the specified 64-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.Memory
writeDoubleLE(double value)
Sets the specified 64-bit floating point number at the currentwriterIndex
in Little Endian Byte Order and increases thewriterIndex
by8
in this buffer.Memory
writeFloat(float value)
Sets the specified 32-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.Memory
writeFloatLE(float value)
Sets the specified 32-bit floating point number at the currentwriterIndex
in Little Endian Byte Order and increases thewriterIndex
by4
in this buffer.Memory
writeInt(int value)
Sets the specified 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.Memory
writeIntLE(int value)
Sets the specified 32-bit integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by4
in this buffer.Memory
writeLong(long value)
Sets the specified 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.Memory
writeLongLE(long value)
Sets the specified 64-bit long integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by8
in this buffer.int
writerIndex()
Memory
writerIndex(int writerIndex)
Sets thewriterIndex
of this buffer.Memory
writeShort(int value)
Sets the specified 16-bit short integer at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.Memory
writeShortLE(int value)
Sets the specified 16-bit short integer in the Little Endian Byte Order at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.
-
Method Details
-
capacity
int capacity()- Returns:
- returns the number of bytes (octets) this buffer can contain.
-
capacity
Adjusts the capacity of this buffer. If thenewCapacity
is less than the current capacity, the content of this buffer is truncated. If thenewCapacity
is greater than the current capacity, the buffer is appended with unspecified data whose length is(newCapacity - currentCapacity)
.- Parameters:
newCapacity
- new capacity.- Returns:
- returns this
Memory
.
-
maxCapacity
int maxCapacity()If a user attempts to increase the capacity of this buffer beyond the maximum capacity usingcapacity(int)
orensureWritable(int)
, those methods will raise anIllegalArgumentException
.- Returns:
- returns the maximum allowed capacity of this buffer.
-
readerIndex
int readerIndex()- Returns:
- returns the
readerIndex
of this buffer.
-
readerIndex
Sets thereaderIndex
of this buffer.- Parameters:
readerIndex
- reader index.- Returns:
- returns this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedreaderIndex
is less than0
or greater thanthis.writerIndex
-
writerIndex
int writerIndex()- Returns:
- returns the
writerIndex
of this buffer.
-
writerIndex
Sets thewriterIndex
of this buffer.- Parameters:
writerIndex
- writer index.- Returns:
- returns this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedwriterIndex
is less thanthis.readerIndex
or greater thanthis.capacity
-
setIndex
Combination ofwriterIndex(...)
andreaderIndex(...)
.- Parameters:
readerIndex
- reader index.writerIndex
- writer index.- Returns:
- returns this
Memory
.
-
readableBytes
int readableBytes()- Returns:
- returns the number of readable bytes which is equal to
(this.writerIndex - this.readerIndex)
.
-
writableBytes
int writableBytes()- Returns:
- returns the number of writable bytes which is equal to
(this.capacity - this.writerIndex)
.
-
maxWritableBytes
int maxWritableBytes()- Returns:
- returns the maximum possible number of writable bytes, which is equal to
(this.maxCapacity - this.writerIndex)
.
-
isReadable
boolean isReadable()- Returns:
- returns
true
if and only if(this.writerIndex - this.readerIndex)
is greater than0
.
-
isReadable
boolean isReadable(int numBytes)- Returns:
- returns
true
if and only if this buffer contains equal to or more than the specified number of elements.
-
isWritable
boolean isWritable()- Returns:
- returns
true
if and only if(this.capacity - this.writerIndex)
is greater than0
.
-
isWritable
boolean isWritable(int numBytes)- Returns:
- returns
true
if and only if this buffer has enough room to allow writing the specified number of elements.
-
clear
Memory clear()Sets thereaderIndex
andwriterIndex
of this buffer to0
. This method is identical tosetIndex(0, 0)
.- Returns:
- this
Memory
.
-
markReaderIndex
Memory markReaderIndex()Marks the currentreaderIndex
in this buffer. You can reposition the currentreaderIndex
to the markedreaderIndex
by callingresetReaderIndex()
. The initial value of the markedreaderIndex
is0
.- Returns:
- this
Memory
.
-
resetReaderIndex
Memory resetReaderIndex()Repositions the currentreaderIndex
to the markedreaderIndex
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the currentwriterIndex
is less than the markedreaderIndex
-
markWriterIndex
Memory markWriterIndex()Marks the currentwriterIndex
in this buffer. You can reposition the currentwriterIndex
to the markedwriterIndex
by callingresetWriterIndex()
. The initial value of the markedwriterIndex
is0
.- Returns:
- this
Memory
.
-
resetWriterIndex
Memory resetWriterIndex()Repositions the currentwriterIndex
to the markedwriterIndex
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the currentreaderIndex
is greater than the markedwriterIndex
-
ensureWritable
Makes sure the number of the writable bytes is equal to or greater than the specified value. If there is enough writable bytes in this buffer, this method returns with no side effect. Otherwise, it raises anIllegalArgumentException
.- Parameters:
minWritableBytes
- the expected minimum number of writable bytes- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifwriterIndex()
+minWritableBytes
>maxCapacity()
-
getBoolean
boolean getBoolean(int index)Gets a boolean at the specified absolute (@code index) in this buffer. This method does not modify thereaderIndex
orwriterIndex
of this buffer.- Returns:
- boolean value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 1
is greater thanthis.capacity
-
getByte
byte getByte(int index)Gets a byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- byte value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 1
is greater thanthis.capacity
-
getUnsignedByte
short getUnsignedByte(int index)Gets an unsigned byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- unsigned byte value stored in
short
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 1
is greater thanthis.capacity
-
getShort
short getShort(int index)Gets a 16-bit short integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- short value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
getShortLE
short getShortLE(int index)Gets a 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- little endian short value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
getUnsignedShort
int getUnsignedShort(int index)Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- unsigned short value stored in
integer
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
getUnsignedShortLE
int getUnsignedShortLE(int index)Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- unsigned little endian short value stored in
integer
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
getInt
int getInt(int index)Gets a 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- integer value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
getIntLE
int getIntLE(int index)Gets a 32-bit integer at the specified absoluteindex
in this buffer with Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- little endian integer value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
getUnsignedInt
long getUnsignedInt(int index)Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- unsigned integer value stored in
long
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
getUnsignedIntLE
long getUnsignedIntLE(int index)Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- unsigned little endian integer value stored in
long
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
getLong
long getLong(int index)Gets a 64-bit long integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- long value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
getLongLE
long getLongLE(int index)Gets a 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- little endian long value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
getFloat
float getFloat(int index)Gets a 32-bit floating point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- float value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
getFloatLE
float getFloatLE(int index)Gets a 32-bit floating point number at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- little endian float value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
getDouble
double getDouble(int index)Gets a 64-bit floating point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- double value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
getDoubleLE
double getDoubleLE(int index)Gets a 64-bit floating point number at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- little endian double value.
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
getBytes
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination becomes non-writable. This method is basically same withgetBytes(int, Memory, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whilegetBytes(int, Memory, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).- Parameters:
index
- index.dst
- destination.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
or ifindex + dst.writableBytes
is greater thanthis.capacity
-
getBytes
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method is basically same withgetBytes(int, Memory, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whilegetBytes(int, Memory, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).- Parameters:
length
- the number of bytes to transferindex
- index.dst
- destination.length
- length.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, ifindex + length
is greater thanthis.capacity
, or iflength
is greater thandst.writableBytes
-
getBytes
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of both the source (i.e.this
) and the destination.- Parameters:
dstIndex
- the first index of the destinationlength
- the number of bytes to transferindex
- index.dst
- destination.dstIndex
- destination index.length
- length.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, if the specifieddstIndex
is less than0
, ifindex + length
is greater thanthis.capacity
, or ifdstIndex + length
is greater thandst.capacity
-
getBytes
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer- Parameters:
index
- index.dst
- destination.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
or ifindex + dst.length
is greater thanthis.capacity
-
getBytes
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
dstIndex
- the first index of the destinationlength
- the number of bytes to transferindex
- index.dst
- destination.dstIndex
- destinationIndex.length
- length.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, if the specifieddstIndex
is less than0
, ifindex + length
is greater thanthis.capacity
, or ifdstIndex + length
is greater thandst.length
-
getCharSequence
Gets aCharSequence
with the given length at the given index.- Parameters:
length
- the length to readcharset
- that should be used- Returns:
- the sequence
- Throws:
IndexOutOfBoundsException
- iflength
is greater thanthis.readableBytes
-
setBoolean
Sets the specified boolean at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 1
is greater thanthis.capacity
-
setByte
Sets the specified byte at the specified absoluteindex
in this buffer. The 24 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 1
is greater thanthis.capacity
-
setShort
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
setShortLE
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer with the Little Endian Byte Order. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
setInt
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
setIntLE
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer with Little Endian byte order . This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
setLong
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
setLongLE
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
setFloat
Sets the specified 32-bit floating-point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
setFloatLE
Sets the specified 32-bit floating-point number at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
setDouble
Sets the specified 64-bit floating-point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
setDoubleLE
Sets the specified 64-bit floating-point number at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
setBytes
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer becomes unreadable. This method is basically same withsetBytes(int, Memory, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whilesetBytes(int, Memory, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).- Parameters:
index
- index.src
- source.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
or ifindex + src.readableBytes
is greater thanthis.capacity
-
setBytes
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
. This method is basically same withsetBytes(int, Memory, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whilesetBytes(int, Memory, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).- Parameters:
length
- the number of bytes to transferindex
- index.src
- source.length
- length.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, ifindex + length
is greater thanthis.capacity
, or iflength
is greater thansrc.readableBytes
-
setBytes
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of both the source (i.e.this
) and the destination.- Parameters:
srcIndex
- the first index of the sourcelength
- the number of bytes to transferindex
- index.src
- source.srcIndex
- source index.length
- length.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, if the specifiedsrcIndex
is less than0
, ifindex + length
is greater thanthis.capacity
, or ifsrcIndex + length
is greater thansrc.capacity
-
setBytes
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.src
- source.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
or ifindex + src.length
is greater thanthis.capacity
-
setBytes
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.src
- source.srcIndex
- source index.length
- length.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, if the specifiedsrcIndex
is less than0
, ifindex + length
is greater thanthis.capacity
, or ifsrcIndex + length
is greater thansrc.length
-
setCharSequence
Writes the specifiedCharSequence
at the currentwriterIndex
and increases thewriterIndex
by the written bytes.- Parameters:
index
- on which the sequence should be written.sequence
- to write.charset
- that should be used.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is not large enough to write the whole sequence
-
readBoolean
boolean readBoolean()Gets a boolean at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Returns:
- boolean value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than1
-
readByte
byte readByte()Gets a byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Returns:
- byte value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than1
-
readUnsignedByte
short readUnsignedByte()Gets an unsigned byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Returns:
- unsigned byte stored in
short
. - Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than1
-
readShort
short readShort()Gets a 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.- Returns:
- short value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than2
-
readShortLE
short readShortLE()Gets a 16-bit short integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by2
in this buffer.- Returns:
- little endian short value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than2
-
readUnsignedShort
int readUnsignedShort()Gets an unsigned 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.- Returns:
- unsigned short value stored in
integer
. - Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than2
-
readUnsignedShortLE
int readUnsignedShortLE()Gets an unsigned 16-bit short integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by2
in this buffer.- Returns:
- unsigned little endian short value stored in
integer
. - Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than2
-
readInt
int readInt()Gets a 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.- Returns:
- integer value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than4
-
readIntLE
int readIntLE()Gets a 32-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.- Returns:
- little endian integer value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than4
-
readUnsignedInt
long readUnsignedInt()Gets an unsigned 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.- Returns:
- unsigned integer value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than4
-
readUnsignedIntLE
long readUnsignedIntLE()Gets an unsigned 32-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.- Returns:
- unsigned little endian integer value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than4
-
readLong
long readLong()Gets a 64-bit integer at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.- Returns:
- long value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than8
-
readLongLE
long readLongLE()Gets a 64-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by8
in this buffer.- Returns:
- little endian long value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than8
-
readFloat
float readFloat()Gets a 32-bit floating point number at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.- Returns:
- float value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than4
-
readFloatLE
float readFloatLE()Gets a 32-bit floating point number at the currentreaderIndex
in Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.- Returns:
- little endian float value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than4
-
readDouble
double readDouble()Gets a 64-bit floating point number at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.- Returns:
- double value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than8
-
readDoubleLE
double readDoubleLE()Gets a 64-bit floating point number at the currentreaderIndex
in Little Endian Byte Order and increases thereaderIndex
by8
in this buffer.- Returns:
- little endian double value.
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than8
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination becomes non-writable, and increases thereaderIndex
by the number of the transferred bytes. This method is basically same withreadBytes(Memory, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whilereadBytes(Memory, int, int)
does not.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifdst.writableBytes
is greater thanthis.readableBytes
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
). This method is basically same withreadBytes(Memory, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes (=length
) whilereadBytes(Memory, int, int)
does not.- Throws:
IndexOutOfBoundsException
- iflength
is greater thanthis.readableBytes
or iflength
is greater thandst.writableBytes
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).- Parameters:
dst
- destination.dstIndex
- the first index of the destinationlength
- the number of bytes to transfer- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifieddstIndex
is less than0
, iflength
is greater thanthis.readableBytes
, or ifdstIndex + length
is greater thandst.capacity
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=dst.length
).- Parameters:
dst
- destination.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifdst.length
is greater thanthis.readableBytes
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).- Parameters:
dst
- destination.dstIndex
- the first index of the destinationlength
- the number of bytes to transfer- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifieddstIndex
is less than0
, iflength
is greater thanthis.readableBytes
, or ifdstIndex + length
is greater thandst.length
-
skipBytes
Increases the currentreaderIndex
by the specifiedlength
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- iflength
is greater thanthis.readableBytes
-
readCharSequence
Gets aCharSequence
with the given length at the currentreaderIndex
and increases thereaderIndex
by the given length.- Parameters:
length
- the length to readcharset
- that should be used- Returns:
- the char sequence.
- Throws:
IndexOutOfBoundsException
- iflength
is greater thanthis.readableBytes
-
writeBoolean
Sets the specified boolean at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than1
-
writeByte
Sets the specified byte at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer. The 24 high-order bits of the specified value are ignored.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than1
-
writeShort
Sets the specified 16-bit short integer at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer. The 16 high-order bits of the specified value are ignored.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than2
-
writeShortLE
Sets the specified 16-bit short integer in the Little Endian Byte Order at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer. The 16 high-order bits of the specified value are ignored.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than2
-
writeInt
Sets the specified 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than4
-
writeIntLE
Sets the specified 32-bit integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by4
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than4
-
writeLong
Sets the specified 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than8
-
writeLongLE
Sets the specified 64-bit long integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by8
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than8
-
writeFloat
Sets the specified 32-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than4
-
writeFloatLE
Sets the specified 32-bit floating point number at the currentwriterIndex
in Little Endian Byte Order and increases thewriterIndex
by4
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than4
-
writeDouble
Sets the specified 64-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than8
-
writeDoubleLE
Sets the specified 64-bit floating point number at the currentwriterIndex
in Little Endian Byte Order and increases thewriterIndex
by8
in this buffer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than8
-
writeBytes
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer becomes unreadable, and increases thewriterIndex
by the number of the transferred bytes. This method is basically same withwriteBytes(Memory, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whilewriteBytes(Memory, int, int)
does not.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifsrc.readableBytes
is greater thanthis.writableBytes
-
writeBytes
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
). This method is basically same withwriteBytes(Memory, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes (=length
) whilewriteBytes(Memory, int, int)
does not.- Parameters:
src
- source.length
- the number of bytes to transfer.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- iflength
is greater thanthis.writableBytes
or iflength
is greater thensrc.readableBytes
-
writeBytes
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).- Parameters:
src
- source.srcIndex
- the first index of the sourcelength
- the number of bytes to transfer- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedsrcIndex
is less than0
, ifsrcIndex + length
is greater thansrc.capacity
, or iflength
is greater thanthis.writableBytes
-
writeBytes
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=src.length
).- Parameters:
src
- source.- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- ifsrc.length
is greater thanthis.writableBytes
-
writeBytes
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).- Parameters:
src
- source.srcIndex
- the first index of the sourcelength
- the number of bytes to transfer- Returns:
- this
Memory
. - Throws:
IndexOutOfBoundsException
- if the specifiedsrcIndex
is less than0
, ifsrcIndex + length
is greater thansrc.length
, or iflength
is greater thanthis.writableBytes
-
writeCharSequence
Writes the specifiedCharSequence
at the currentwriterIndex
and increases thewriterIndex
by the written bytes. in this buffer.- Parameters:
sequence
- to write.charset
- that should be used.- Returns:
- the written number of bytes.
- Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is not large enough to write the whole sequence
-
copy
Memory copy()Returns a copy of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method is identical tocopy(readerIndex(), readableBytes())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- copied
Memory
buffer's.
-
copy
Returns a copy of this buffer's sub-region. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.length
- length.- Returns:
- copied
Memory
buffer's.
-
slice
Memory slice()Returns a slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical toslice(readerIndex(), readableBytes())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- returns sliced
Memory
buffer's.
-
slice
Returns a slice of this buffer's sub-region. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- index.length
- length.- Returns:
- returns sliced
Memory
buffer's.
-
duplicate
Memory duplicate()Duplicate the thisMemory
buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks- Returns:
- returns duplicated
Memory
.
-
nioBuffer
ByteBuffer nioBuffer()Exposes thisMemory
buffer's as an NIOByteBuffer
's. The returned buffer either share or contains the copied content of this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity and returned NIO buffer has no cleaner.- Returns:
- returns direct
ByteBuffer
with no cleaner.
-
isDirect
boolean isDirect()Returnstrue
only if this buffer is an direct buffer, false otherwise. -
memoryAddress
long memoryAddress()- Returns:
- returns the low-level memory address that point to the first byte of ths backing data.
-
release
void release()Deallocate/freeing thisMemory
buffer.
-