Package pcap.common.memory
Class UncheckedByteArray
java.lang.Object
pcap.common.memory.UncheckedByteArray
- All Implemented Interfaces:
Memory
@Inclubating public class UncheckedByteArray extends Object
- Author:
- Ardika Rommy Sanjaya
-
Field Summary
Fields Modifier and Type Field Description protected boolean
freed
-
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.UncheckedByteArray
copy(int index, int length)
Returns a copy of this buffer's sub-region.UncheckedByteArray
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
.UncheckedByteArray
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
.UncheckedByteArray
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 usingMemory.capacity(int)
orMemory.ensureWritable(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.UncheckedByteArray
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
.UncheckedByteArray
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
.UncheckedByteArray
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 seq, 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(...)
.UncheckedByteArray
setInt(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer.UncheckedByteArray
setIntLE(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer with Little Endian byte order .UncheckedByteArray
setLong(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer.UncheckedByteArray
setLongLE(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.UncheckedByteArray
setShort(int index, int value)
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer.UncheckedByteArray
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.UncheckedByteArray
slice(int index, int length)
Returns a slice of this buffer's sub-region.String
toString()
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.
-
Field Details
-
freed
protected boolean freed
-
-
Method Details
-
capacity
Description copied from interface:Memory
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
.
-
getByte
public byte getByte(int index)Description copied from interface:Memory
Gets a byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- byte value.
-
getShort
public short getShort(int index)Description copied from interface:Memory
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.
-
getShortLE
public short getShortLE(int index)Description copied from interface:Memory
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.
-
getInt
public int getInt(int index)Description copied from interface:Memory
Gets a 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- integer value.
-
getIntLE
public int getIntLE(int index)Description copied from interface:Memory
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.
-
getLong
public long getLong(int index)Description copied from interface:Memory
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.
-
getLongLE
public long getLongLE(int index)Description copied from interface:Memory
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.
-
getBytes
Description copied from interface:Memory
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:
index
- index.dst
- destination.dstIndex
- the first index of the destinationlength
- the number of bytes to transfer- Returns:
- this
Memory
.
-
getBytes
Description copied from interface:Memory
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.dstIndex
- the first index of the destinationlength
- the number of bytes to transfer- Returns:
- this
Memory
.
-
setByte
Description copied from interface:Memory
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
.
-
setShort
Description copied from interface:Memory
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
.
-
setShortLE
Description copied from interface:Memory
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
.
-
setInt
Description copied from interface:Memory
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
.
-
setIntLE
Description copied from interface:Memory
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
.
-
setLong
Description copied from interface:Memory
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
.
-
setLongLE
Description copied from interface:Memory
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
.
-
setBytes
Description copied from interface:Memory
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:
index
- index.src
- source.srcIndex
- the first index of the sourcelength
- the number of bytes to transfer- Returns:
- this
Memory
.
-
setBytes
Description copied from interface:Memory
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
.
-
copy
Description copied from interface:Memory
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
Description copied from interface:Memory
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
Description copied from interface:Memory
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
Description copied from interface:Memory
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
public boolean isDirect()Description copied from interface:Memory
Returnstrue
only if this buffer is an direct buffer, false otherwise. -
memoryAddress
public long memoryAddress()- Returns:
- returns the low-level memory address that point to the first byte of ths backing data.
-
release
public void release()Description copied from interface:Memory
Deallocate/freeing thisMemory
buffer. -
capacity
public int capacity() -
maxCapacity
public int maxCapacity()Description copied from interface:Memory
If a user attempts to increase the capacity of this buffer beyond the maximum capacity usingMemory.capacity(int)
orMemory.ensureWritable(int)
, those methods will raise anIllegalArgumentException
.- Specified by:
maxCapacity
in interfaceMemory
- Returns:
- returns the maximum allowed capacity of this buffer.
-
readerIndex
public int readerIndex()- Specified by:
readerIndex
in interfaceMemory
- Returns:
- returns the
readerIndex
of this buffer.
-
readerIndex
Description copied from interface:Memory
Sets thereaderIndex
of this buffer.- Specified by:
readerIndex
in interfaceMemory
- Parameters:
readerIndex
- reader index.- Returns:
- returns this
Memory
.
-
writerIndex
public int writerIndex()- Specified by:
writerIndex
in interfaceMemory
- Returns:
- returns the
writerIndex
of this buffer.
-
writerIndex
Description copied from interface:Memory
Sets thewriterIndex
of this buffer.- Specified by:
writerIndex
in interfaceMemory
- Parameters:
writerIndex
- writer index.- Returns:
- returns this
Memory
.
-
setIndex
Description copied from interface:Memory
Combination ofwriterIndex(...)
andreaderIndex(...)
. -
readableBytes
public int readableBytes()- Specified by:
readableBytes
in interfaceMemory
- Returns:
- returns the number of readable bytes which is equal to
(this.writerIndex - this.readerIndex)
.
-
writableBytes
public int writableBytes()- Specified by:
writableBytes
in interfaceMemory
- Returns:
- returns the number of writable bytes which is equal to
(this.capacity - this.writerIndex)
.
-
maxWritableBytes
public int maxWritableBytes()- Specified by:
maxWritableBytes
in interfaceMemory
- Returns:
- returns the maximum possible number of writable bytes, which is equal to
(this.maxCapacity - this.writerIndex)
.
-
isReadable
public boolean isReadable()- Specified by:
isReadable
in interfaceMemory
- Returns:
- returns
true
if and only if(this.writerIndex - this.readerIndex)
is greater than0
.
-
isReadable
public boolean isReadable(int numBytes)- Specified by:
isReadable
in interfaceMemory
- Returns:
- returns
true
if and only if this buffer contains equal to or more than the specified number of elements.
-
isWritable
public boolean isWritable()- Specified by:
isWritable
in interfaceMemory
- Returns:
- returns
true
if and only if(this.capacity - this.writerIndex)
is greater than0
.
-
isWritable
public boolean isWritable(int numBytes)- Specified by:
isWritable
in interfaceMemory
- Returns:
- returns
true
if and only if this buffer has enough room to allow writing the specified number of elements.
-
clear
Description copied from interface:Memory
Sets thereaderIndex
andwriterIndex
of this buffer to0
. This method is identical tosetIndex(0, 0)
. -
markReaderIndex
Description copied from interface:Memory
Marks the currentreaderIndex
in this buffer. You can reposition the currentreaderIndex
to the markedreaderIndex
by callingMemory.resetReaderIndex()
. The initial value of the markedreaderIndex
is0
.- Specified by:
markReaderIndex
in interfaceMemory
- Returns:
- this
Memory
.
-
resetReaderIndex
Description copied from interface:Memory
Repositions the currentreaderIndex
to the markedreaderIndex
in this buffer.- Specified by:
resetReaderIndex
in interfaceMemory
- Returns:
- this
Memory
.
-
markWriterIndex
Description copied from interface:Memory
Marks the currentwriterIndex
in this buffer. You can reposition the currentwriterIndex
to the markedwriterIndex
by callingMemory.resetWriterIndex()
. The initial value of the markedwriterIndex
is0
.- Specified by:
markWriterIndex
in interfaceMemory
- Returns:
- this
Memory
.
-
resetWriterIndex
Description copied from interface:Memory
Repositions the currentwriterIndex
to the markedwriterIndex
in this buffer.- Specified by:
resetWriterIndex
in interfaceMemory
- Returns:
- this
Memory
.
-
ensureWritable
Description copied from interface:Memory
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
.- Specified by:
ensureWritable
in interfaceMemory
- Parameters:
minWritableBytes
- the expected minimum number of writable bytes- Returns:
- this
Memory
.
-
getBoolean
public boolean getBoolean(int index)Description copied from interface:Memory
Gets a boolean at the specified absolute (@code index) in this buffer. This method does not modify thereaderIndex
orwriterIndex
of this buffer.- Specified by:
getBoolean
in interfaceMemory
- Returns:
- boolean value.
-
getUnsignedByte
public short getUnsignedByte(int index)Description copied from interface:Memory
Gets an unsigned byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getUnsignedByte
in interfaceMemory
- Returns:
- unsigned byte value stored in
short
.
-
getUnsignedShort
public int getUnsignedShort(int index)Description copied from interface:Memory
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getUnsignedShort
in interfaceMemory
- Returns:
- unsigned short value stored in
integer
.
-
getUnsignedShortLE
public int getUnsignedShortLE(int index)Description copied from interface:Memory
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.- Specified by:
getUnsignedShortLE
in interfaceMemory
- Returns:
- unsigned little endian short value stored in
integer
.
-
getUnsignedInt
public long getUnsignedInt(int index)Description copied from interface:Memory
Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
getUnsignedInt
in interfaceMemory
- Returns:
- unsigned integer value stored in
long
.
-
getUnsignedIntLE
public long getUnsignedIntLE(int index)Description copied from interface:Memory
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.- Specified by:
getUnsignedIntLE
in interfaceMemory
- Returns:
- unsigned little endian integer value stored in
long
.
-
getFloat
public float getFloat(int index)Description copied from interface:Memory
Gets a 32-bit floating point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer. -
getFloatLE
public float getFloatLE(int index)Description copied from interface:Memory
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.- Specified by:
getFloatLE
in interfaceMemory
- Returns:
- little endian float value.
-
getDouble
public double getDouble(int index)Description copied from interface:Memory
Gets a 64-bit floating point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer. -
getDoubleLE
public double getDoubleLE(int index)Description copied from interface:Memory
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.- Specified by:
getDoubleLE
in interfaceMemory
- Returns:
- little endian double value.
-
getBytes
Description copied from interface:Memory
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 withMemory.getBytes(int, Memory, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whileMemory.getBytes(int, Memory, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
). -
getBytes
Description copied from interface:Memory
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method is basically same withMemory.getBytes(int, Memory, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whileMemory.getBytes(int, Memory, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
). -
getBytes
Description copied from interface:Memory
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer -
getCharSequence
Description copied from interface:Memory
Gets aCharSequence
with the given length at the given index.- Specified by:
getCharSequence
in interfaceMemory
length
- the length to readcharset
- that should be used- Returns:
- the sequence
-
setBoolean
Description copied from interface:Memory
Sets the specified boolean at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Specified by:
setBoolean
in interfaceMemory
- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
.
-
setFloat
Description copied from interface:Memory
Sets the specified 32-bit floating-point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer. -
setFloatLE
Description copied from interface:Memory
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.- Specified by:
setFloatLE
in interfaceMemory
- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
.
-
setDouble
Description copied from interface:Memory
Sets the specified 64-bit floating-point number at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer. -
setDoubleLE
Description copied from interface:Memory
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.- Specified by:
setDoubleLE
in interfaceMemory
- Parameters:
index
- index.value
- value.- Returns:
- this
Memory
.
-
setBytes
Description copied from interface:Memory
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 withMemory.setBytes(int, Memory, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whileMemory.setBytes(int, Memory, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
). -
setBytes
Description copied from interface:Memory
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
. This method is basically same withMemory.setBytes(int, Memory, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whileMemory.setBytes(int, Memory, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
). -
setBytes
Description copied from interface:Memory
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer. -
setCharSequence
Description copied from interface:Memory
Writes the specifiedCharSequence
at the currentwriterIndex
and increases thewriterIndex
by the written bytes.- Specified by:
setCharSequence
in interfaceMemory
- Parameters:
index
- on which the sequence should be written.seq
- to write.charset
- that should be used.- Returns:
- this
Memory
.
-
readBoolean
public boolean readBoolean()Description copied from interface:Memory
Gets a boolean at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Specified by:
readBoolean
in interfaceMemory
- Returns:
- boolean value.
-
readByte
public byte readByte()Description copied from interface:Memory
Gets a byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer. -
readUnsignedByte
public short readUnsignedByte()Description copied from interface:Memory
Gets an unsigned byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Specified by:
readUnsignedByte
in interfaceMemory
- Returns:
- unsigned byte stored in
short
.
-
readShort
public short readShort()Description copied from interface:Memory
Gets a 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer. -
readShortLE
public short readShortLE()Description copied from interface:Memory
Gets a 16-bit short integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by2
in this buffer.- Specified by:
readShortLE
in interfaceMemory
- Returns:
- little endian short value.
-
readUnsignedShort
public int readUnsignedShort()Description copied from interface:Memory
Gets an unsigned 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.- Specified by:
readUnsignedShort
in interfaceMemory
- Returns:
- unsigned short value stored in
integer
.
-
readUnsignedShortLE
public int readUnsignedShortLE()Description copied from interface:Memory
Gets an unsigned 16-bit short integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by2
in this buffer.- Specified by:
readUnsignedShortLE
in interfaceMemory
- Returns:
- unsigned little endian short value stored in
integer
.
-
readInt
public int readInt()Description copied from interface:Memory
Gets a 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer. -
readIntLE
public int readIntLE()Description copied from interface:Memory
Gets a 32-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by4
in this buffer. -
readUnsignedInt
public long readUnsignedInt()Description copied from interface:Memory
Gets an unsigned 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.- Specified by:
readUnsignedInt
in interfaceMemory
- Returns:
- unsigned integer value.
-
readUnsignedIntLE
public long readUnsignedIntLE()Description copied from interface:Memory
Gets an unsigned 32-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.- Specified by:
readUnsignedIntLE
in interfaceMemory
- Returns:
- unsigned little endian integer value.
-
readFloat
public float readFloat()Description copied from interface:Memory
Gets a 32-bit floating point number at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer. -
readFloatLE
public float readFloatLE()Description copied from interface:Memory
Gets a 32-bit floating point number at the currentreaderIndex
in Little Endian Byte Order and increases thereaderIndex
by4
in this buffer.- Specified by:
readFloatLE
in interfaceMemory
- Returns:
- little endian float value.
-
readDouble
public double readDouble()Description copied from interface:Memory
Gets a 64-bit floating point number at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.- Specified by:
readDouble
in interfaceMemory
- Returns:
- double value.
-
readDoubleLE
public double readDoubleLE()Description copied from interface:Memory
Gets a 64-bit floating point number at the currentreaderIndex
in Little Endian Byte Order and increases thereaderIndex
by8
in this buffer.- Specified by:
readDoubleLE
in interfaceMemory
- Returns:
- little endian double value.
-
readLong
public long readLong()Description copied from interface:Memory
Gets a 64-bit integer at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer. -
readLongLE
public long readLongLE()Description copied from interface:Memory
Gets a 64-bit integer at the currentreaderIndex
in the Little Endian Byte Order and increases thereaderIndex
by8
in this buffer.- Specified by:
readLongLE
in interfaceMemory
- Returns:
- little endian long value.
-
readBytes
Description copied from interface:Memory
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 withMemory.readBytes(Memory, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whileMemory.readBytes(Memory, int, int)
does not. -
readBytes
Description copied from interface:Memory
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 withMemory.readBytes(Memory, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes (=length
) whileMemory.readBytes(Memory, int, int)
does not. -
readBytes
Description copied from interface:Memory
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
). -
readBytes
Description copied from interface:Memory
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
). -
readBytes
Description copied from interface:Memory
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
). -
skipBytes
Description copied from interface:Memory
Increases the currentreaderIndex
by the specifiedlength
in this buffer. -
readCharSequence
Description copied from interface:Memory
Gets aCharSequence
with the given length at the currentreaderIndex
and increases thereaderIndex
by the given length.- Specified by:
readCharSequence
in interfaceMemory
- Parameters:
length
- the length to readcharset
- that should be used- Returns:
- the char sequence.
-
writeBoolean
Description copied from interface:Memory
Sets the specified boolean at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.- Specified by:
writeBoolean
in interfaceMemory
- Returns:
- this
Memory
.
-
writeByte
Description copied from interface:Memory
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. -
writeShort
Description copied from interface:Memory
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.- Specified by:
writeShort
in interfaceMemory
- Returns:
- this
Memory
.
-
writeShortLE
Description copied from interface:Memory
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.- Specified by:
writeShortLE
in interfaceMemory
- Returns:
- this
Memory
.
-
writeInt
Description copied from interface:Memory
Sets the specified 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer. -
writeIntLE
Description copied from interface:Memory
Sets the specified 32-bit integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by4
in this buffer.- Specified by:
writeIntLE
in interfaceMemory
- Returns:
- this
Memory
.
-
writeLong
Description copied from interface:Memory
Sets the specified 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer. -
writeLongLE
Description copied from interface:Memory
Sets the specified 64-bit long integer at the currentwriterIndex
in the Little Endian Byte Order and increases thewriterIndex
by8
in this buffer.- Specified by:
writeLongLE
in interfaceMemory
- Returns:
- this
Memory
.
-
writeFloat
Description copied from interface:Memory
Sets the specified 32-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.- Specified by:
writeFloat
in interfaceMemory
- Returns:
- this
Memory
.
-
writeFloatLE
Description copied from interface:Memory
Sets the specified 32-bit floating point number at the currentwriterIndex
in Little Endian Byte Order and increases thewriterIndex
by4
in this buffer.- Specified by:
writeFloatLE
in interfaceMemory
- Returns:
- this
Memory
.
-
writeDoubleLE
Description copied from interface:Memory
Sets the specified 64-bit floating point number at the currentwriterIndex
in Little Endian Byte Order and increases thewriterIndex
by8
in this buffer.- Specified by:
writeDoubleLE
in interfaceMemory
- Returns:
- this
Memory
.
-
writeDouble
Description copied from interface:Memory
Sets the specified 64-bit floating point number at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.- Specified by:
writeDouble
in interfaceMemory
- Returns:
- this
Memory
.
-
writeBytes
Description copied from interface:Memory
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 withMemory.writeBytes(Memory, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whileMemory.writeBytes(Memory, int, int)
does not.- Specified by:
writeBytes
in interfaceMemory
- Returns:
- this
Memory
.
-
writeBytes
Description copied from interface:Memory
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 withMemory.writeBytes(Memory, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes (=length
) whileMemory.writeBytes(Memory, int, int)
does not.- Specified by:
writeBytes
in interfaceMemory
- Parameters:
src
- source.length
- the number of bytes to transfer.- Returns:
- this
Memory
.
-
writeBytes
Description copied from interface:Memory
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
).- Specified by:
writeBytes
in interfaceMemory
- Parameters:
src
- source.srcIndex
- the first index of the sourcelength
- the number of bytes to transfer- Returns:
- this
Memory
.
-
writeBytes
Description copied from interface:Memory
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
).- Specified by:
writeBytes
in interfaceMemory
- Parameters:
src
- source.- Returns:
- this
Memory
.
-
writeBytes
Description copied from interface:Memory
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
).- Specified by:
writeBytes
in interfaceMemory
- Parameters:
src
- source.srcIndex
- the first index of the sourcelength
- the number of bytes to transfer- Returns:
- this
Memory
.
-
writeCharSequence
Description copied from interface:Memory
Writes the specifiedCharSequence
at the currentwriterIndex
and increases thewriterIndex
by the written bytes. in this buffer.- Specified by:
writeCharSequence
in interfaceMemory
- Parameters:
sequence
- to write.charset
- that should be used.- Returns:
- the written number of bytes.
-
copy
Description copied from interface:Memory
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. -
slice
Description copied from interface:Memory
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. -
toString
-