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 the readerIndex and writerIndex of this buffer to 0.
    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 this Memory 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 absolute index in this buffer.
    Memory getBytes​(int index, byte[] dst)
    Transfers this buffer's data to the specified destination starting at the specified absolute index.
    Memory getBytes​(int index, byte[] dst, int dstIndex, int length)
    Transfers this buffer's data to the specified destination starting at the specified absolute index.
    Memory getBytes​(int index, Memory dst)
    Transfers this buffer's data to the specified destination starting at the specified absolute index 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 absolute index.
    Memory getBytes​(int index, Memory dst, int dstIndex, int length)
    Transfers this buffer's data to the specified destination starting at the specified absolute index.
    CharSequence getCharSequence​(int index, int length, Charset charset)
    Gets a CharSequence with the given length at the given index.
    double getDouble​(int index)
    Gets a 64-bit floating point number at the specified absolute index in this buffer.
    double getDoubleLE​(int index)
    Gets a 64-bit floating point number at the specified absolute index in this buffer in Little Endian Byte Order.
    float getFloat​(int index)
    Gets a 32-bit floating point number at the specified absolute index in this buffer.
    float getFloatLE​(int index)
    Gets a 32-bit floating point number at the specified absolute index in this buffer in Little Endian Byte Order.
    int getInt​(int index)
    Gets a 32-bit integer at the specified absolute index in this buffer.
    int getIntLE​(int index)
    Gets a 32-bit integer at the specified absolute index in this buffer with Little Endian Byte Order.
    long getLong​(int index)
    Gets a 64-bit long integer at the specified absolute index in this buffer.
    long getLongLE​(int index)
    Gets a 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order.
    short getShort​(int index)
    Gets a 16-bit short integer at the specified absolute index in this buffer.
    short getShortLE​(int index)
    Gets a 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
    short getUnsignedByte​(int index)
    Gets an unsigned byte at the specified absolute index in this buffer.
    long getUnsignedInt​(int index)
    Gets an unsigned 32-bit integer at the specified absolute index in this buffer.
    long getUnsignedIntLE​(int index)
    Gets an unsigned 32-bit integer at the specified absolute index in this buffer in Little Endian Byte Order.
    int getUnsignedShort​(int index)
    Gets an unsigned 16-bit short integer at the specified absolute index in this buffer.
    int getUnsignedShortLE​(int index)
    Gets an unsigned 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.
    boolean isDirect()
    Returns true 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 current readerIndex in this buffer.
    Memory markWriterIndex()
    Marks the current writerIndex in this buffer.
    int maxCapacity()
    If a user attempts to increase the capacity of this buffer beyond the maximum capacity using capacity(int) or ensureWritable(int), those methods will raise an IllegalArgumentException.
    int maxWritableBytes()  
    long memoryAddress()  
    ByteBuffer nioBuffer()
    Exposes this Memory buffer's as an NIO ByteBuffer's.
    int readableBytes()  
    boolean readBoolean()
    Gets a boolean at the current readerIndex and increases the readerIndex by 1 in this buffer.
    byte readByte()
    Gets a byte at the current readerIndex and increases the readerIndex by 1 in this buffer.
    Memory readBytes​(byte[] dst)
    Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex 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 current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).
    Memory readBytes​(Memory dst)
    Transfers this buffer's data to the specified destination starting at the current readerIndex until the destination becomes non-writable, and increases the readerIndex 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 current readerIndex and increases the readerIndex 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 current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).
    CharSequence readCharSequence​(int length, Charset charset)
    Gets a CharSequence with the given length at the current readerIndex and increases the readerIndex by the given length.
    double readDouble()
    Gets a 64-bit floating point number at the current readerIndex and increases the readerIndex by 8 in this buffer.
    double readDoubleLE()
    Gets a 64-bit floating point number at the current readerIndex in Little Endian Byte Order and increases the readerIndex by 8 in this buffer.
    int readerIndex()  
    Memory readerIndex​(int readerIndex)
    Sets the readerIndex of this buffer.
    float readFloat()
    Gets a 32-bit floating point number at the current readerIndex and increases the readerIndex by 4 in this buffer.
    float readFloatLE()
    Gets a 32-bit floating point number at the current readerIndex in Little Endian Byte Order and increases the readerIndex by 4 in this buffer.
    int readInt()
    Gets a 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.
    int readIntLE()
    Gets a 32-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 4 in this buffer.
    long readLong()
    Gets a 64-bit integer at the current readerIndex and increases the readerIndex by 8 in this buffer.
    long readLongLE()
    Gets a 64-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 8 in this buffer.
    short readShort()
    Gets a 16-bit short integer at the current readerIndex and increases the readerIndex by 2 in this buffer.
    short readShortLE()
    Gets a 16-bit short integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 2 in this buffer.
    short readUnsignedByte()
    Gets an unsigned byte at the current readerIndex and increases the readerIndex by 1 in this buffer.
    long readUnsignedInt()
    Gets an unsigned 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.
    long readUnsignedIntLE()
    Gets an unsigned 32-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 4 in this buffer.
    int readUnsignedShort()
    Gets an unsigned 16-bit short integer at the current readerIndex and increases the readerIndex by 2 in this buffer.
    int readUnsignedShortLE()
    Gets an unsigned 16-bit short integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 2 in this buffer.
    void release()
    Deallocate/freeing this Memory buffer.
    Memory resetReaderIndex()
    Repositions the current readerIndex to the marked readerIndex in this buffer.
    Memory resetWriterIndex()
    Repositions the current writerIndex to the marked writerIndex in this buffer.
    Memory setBoolean​(int index, boolean value)
    Sets the specified boolean at the specified absolute index in this buffer.
    Memory setByte​(int index, int value)
    Sets the specified byte at the specified absolute index in this buffer.
    Memory setBytes​(int index, byte[] src)
    Transfers the specified source array's data to this buffer starting at the specified absolute index.
    Memory setBytes​(int index, byte[] src, int srcIndex, int length)
    Transfers the specified source array's data to this buffer starting at the specified absolute index.
    Memory setBytes​(int index, Memory src)
    Transfers the specified source buffer's data to this buffer starting at the specified absolute index 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 absolute index.
    Memory setBytes​(int index, Memory src, int srcIndex, int length)
    Transfers the specified source buffer's data to this buffer starting at the specified absolute index.
    Memory setCharSequence​(int index, CharSequence sequence, Charset charset)
    Writes the specified CharSequence at the current writerIndex and increases the writerIndex by the written bytes.
    Memory setDouble​(int index, double value)
    Sets the specified 64-bit floating-point number at the specified absolute index in this buffer.
    Memory setDoubleLE​(int index, double value)
    Sets the specified 64-bit floating-point number at the specified absolute index 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 absolute index in this buffer.
    Memory setFloatLE​(int index, float value)
    Sets the specified 32-bit floating-point number at the specified absolute index in this buffer in Little Endian Byte Order.
    Memory setIndex​(int readerIndex, int writerIndex)
    Combination of writerIndex(...) and readerIndex(...).
    Memory setInt​(int index, int value)
    Sets the specified 32-bit integer at the specified absolute index in this buffer.
    Memory setIntLE​(int index, int value)
    Sets the specified 32-bit integer at the specified absolute index in this buffer with Little Endian byte order .
    Memory setLong​(int index, long value)
    Sets the specified 64-bit long integer at the specified absolute index in this buffer.
    Memory setLongLE​(int index, long value)
    Sets the specified 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order.
    Memory setShort​(int index, int value)
    Sets the specified 16-bit short integer at the specified absolute index in this buffer.
    Memory setShortLE​(int index, int value)
    Sets the specified 16-bit short integer at the specified absolute index in this buffer with the Little Endian Byte Order.
    Memory skipBytes​(int length)
    Increases the current readerIndex by the specified length 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 current writerIndex and increases the writerIndex by 1 in this buffer.
    Memory writeByte​(int value)
    Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.
    Memory writeBytes​(byte[] src)
    Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex 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 current writerIndex and increases the writerIndex 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 current writerIndex until the source buffer becomes unreadable, and increases the writerIndex 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 current writerIndex and increases the writerIndex 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 current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
    Memory writeCharSequence​(CharSequence sequence, Charset charset)
    Writes the specified CharSequence at the current writerIndex and increases the writerIndex by the written bytes.
    Memory writeDouble​(double value)
    Sets the specified 64-bit floating point number at the current writerIndex and increases the writerIndex by 8 in this buffer.
    Memory writeDoubleLE​(double value)
    Sets the specified 64-bit floating point number at the current writerIndex in Little Endian Byte Order and increases the writerIndex by 8 in this buffer.
    Memory writeFloat​(float value)
    Sets the specified 32-bit floating point number at the current writerIndex and increases the writerIndex by 4 in this buffer.
    Memory writeFloatLE​(float value)
    Sets the specified 32-bit floating point number at the current writerIndex in Little Endian Byte Order and increases the writerIndex by 4 in this buffer.
    Memory writeInt​(int value)
    Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
    Memory writeIntLE​(int value)
    Sets the specified 32-bit integer at the current writerIndex in the Little Endian Byte Order and increases the writerIndex by 4 in this buffer.
    Memory writeLong​(long value)
    Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.
    Memory writeLongLE​(long value)
    Sets the specified 64-bit long integer at the current writerIndex in the Little Endian Byte Order and increases the writerIndex by 8 in this buffer.
    int writerIndex()  
    Memory writerIndex​(int writerIndex)
    Sets the writerIndex of this buffer.
    Memory writeShort​(int value)
    Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer.
    Memory writeShortLE​(int value)
    Sets the specified 16-bit short integer in the Little Endian Byte Order at the current writerIndex and increases the writerIndex by 2 in this buffer.
  • Method Details

    • capacity

      int capacity()
      Returns:
      returns the number of bytes (octets) this buffer can contain.
    • capacity

      Memory capacity​(int newCapacity)
      Adjusts the capacity of this buffer. If the newCapacity is less than the current capacity, the content of this buffer is truncated. If the newCapacity 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 using capacity(int) or ensureWritable(int), those methods will raise an IllegalArgumentException.
      Returns:
      returns the maximum allowed capacity of this buffer.
    • readerIndex

      int readerIndex()
      Returns:
      returns the readerIndex of this buffer.
    • readerIndex

      Memory readerIndex​(int readerIndex)
      Sets the readerIndex of this buffer.
      Parameters:
      readerIndex - reader index.
      Returns:
      returns this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified readerIndex is less than 0 or greater than this.writerIndex
    • writerIndex

      int writerIndex()
      Returns:
      returns the writerIndex of this buffer.
    • writerIndex

      Memory writerIndex​(int writerIndex)
      Sets the writerIndex of this buffer.
      Parameters:
      writerIndex - writer index.
      Returns:
      returns this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified writerIndex is less than this.readerIndex or greater than this.capacity
    • setIndex

      Memory setIndex​(int readerIndex, int writerIndex)
      Combination of writerIndex(...) and readerIndex(...).
      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 than 0.
    • 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 than 0.
    • 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 the readerIndex and writerIndex of this buffer to 0. This method is identical to setIndex(0, 0).
      Returns:
      this Memory.
    • markReaderIndex

      Memory markReaderIndex()
      Marks the current readerIndex in this buffer. You can reposition the current readerIndex to the marked readerIndex by calling resetReaderIndex(). The initial value of the marked readerIndex is 0.
      Returns:
      this Memory.
    • resetReaderIndex

      Memory resetReaderIndex()
      Repositions the current readerIndex to the marked readerIndex in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the current writerIndex is less than the marked readerIndex
    • markWriterIndex

      Memory markWriterIndex()
      Marks the current writerIndex in this buffer. You can reposition the current writerIndex to the marked writerIndex by calling resetWriterIndex(). The initial value of the marked writerIndex is 0.
      Returns:
      this Memory.
    • resetWriterIndex

      Memory resetWriterIndex()
      Repositions the current writerIndex to the marked writerIndex in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the current readerIndex is greater than the marked writerIndex
    • ensureWritable

      Memory ensureWritable​(int minWritableBytes)
      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 an IllegalArgumentException.
      Parameters:
      minWritableBytes - the expected minimum number of writable bytes
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if writerIndex() + minWritableBytes > maxCapacity()
    • getBoolean

      boolean getBoolean​(int index)
      Gets a boolean at the specified absolute (@code index) in this buffer. This method does not modify the readerIndex or writerIndex of this buffer.
      Returns:
      boolean value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 1 is greater than this.capacity
    • getByte

      byte getByte​(int index)
      Gets a byte at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      byte value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 1 is greater than this.capacity
    • getUnsignedByte

      short getUnsignedByte​(int index)
      Gets an unsigned byte at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      unsigned byte value stored in short.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 1 is greater than this.capacity
    • getShort

      short getShort​(int index)
      Gets a 16-bit short integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      short value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 2 is greater than this.capacity
    • getShortLE

      short getShortLE​(int index)
      Gets a 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      little endian short value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 2 is greater than this.capacity
    • getUnsignedShort

      int getUnsignedShort​(int index)
      Gets an unsigned 16-bit short integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      unsigned short value stored in integer.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 2 is greater than this.capacity
    • getUnsignedShortLE

      int getUnsignedShortLE​(int index)
      Gets an unsigned 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      unsigned little endian short value stored in integer.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 2 is greater than this.capacity
    • getInt

      int getInt​(int index)
      Gets a 32-bit integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      integer value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • getIntLE

      int getIntLE​(int index)
      Gets a 32-bit integer at the specified absolute index in this buffer with Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      little endian integer value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • getUnsignedInt

      long getUnsignedInt​(int index)
      Gets an unsigned 32-bit integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      unsigned integer value stored in long.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • getUnsignedIntLE

      long getUnsignedIntLE​(int index)
      Gets an unsigned 32-bit integer at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      unsigned little endian integer value stored in long.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • getLong

      long getLong​(int index)
      Gets a 64-bit long integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      long value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 8 is greater than this.capacity
    • getLongLE

      long getLongLE​(int index)
      Gets a 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      little endian long value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 8 is greater than this.capacity
    • getFloat

      float getFloat​(int index)
      Gets a 32-bit floating point number at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      float value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • getFloatLE

      float getFloatLE​(int index)
      Gets a 32-bit floating point number at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      little endian float value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • getDouble

      double getDouble​(int index)
      Gets a 64-bit floating point number at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      double value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 8 is greater than this.capacity
    • getDoubleLE

      double getDoubleLE​(int index)
      Gets a 64-bit floating point number at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      little endian double value.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 8 is greater than this.capacity
    • getBytes

      Memory getBytes​(int index, Memory dst)
      Transfers this buffer's data to the specified destination starting at the specified absolute index until the destination becomes non-writable. This method is basically same with getBytes(int, Memory, int, int), except that this method increases the writerIndex of the destination by the number of the transferred bytes while getBytes(int, Memory, int, int) does not. This method does not modify readerIndex or writerIndex of the source buffer (i.e. this).
      Parameters:
      index - index.
      dst - destination.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or if index + dst.writableBytes is greater than this.capacity
    • getBytes

      Memory getBytes​(int index, Memory dst, int length)
      Transfers this buffer's data to the specified destination starting at the specified absolute index. This method is basically same with getBytes(int, Memory, int, int), except that this method increases the writerIndex of the destination by the number of the transferred bytes while getBytes(int, Memory, int, int) does not. This method does not modify readerIndex or writerIndex of the source buffer (i.e. this).
      Parameters:
      length - the number of bytes to transfer
      index - index.
      dst - destination.
      length - length.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0, if index + length is greater than this.capacity, or if length is greater than dst.writableBytes
    • getBytes

      Memory getBytes​(int index, Memory dst, int dstIndex, int length)
      Transfers this buffer's data to the specified destination starting at the specified absolute index. This method does not modify readerIndex or writerIndex of both the source (i.e. this) and the destination.
      Parameters:
      dstIndex - the first index of the destination
      length - the number of bytes to transfer
      index - index.
      dst - destination.
      dstIndex - destination index.
      length - length.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0, if the specified dstIndex is less than 0, if index + length is greater than this.capacity, or if dstIndex + length is greater than dst.capacity
    • getBytes

      Memory getBytes​(int index, byte[] dst)
      Transfers this buffer's data to the specified destination starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer
      Parameters:
      index - index.
      dst - destination.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or if index + dst.length is greater than this.capacity
    • getBytes

      Memory getBytes​(int index, byte[] dst, int dstIndex, int length)
      Transfers this buffer's data to the specified destination starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      dstIndex - the first index of the destination
      length - the number of bytes to transfer
      index - index.
      dst - destination.
      dstIndex - destinationIndex.
      length - length.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0, if the specified dstIndex is less than 0, if index + length is greater than this.capacity, or if dstIndex + length is greater than dst.length
    • getCharSequence

      CharSequence getCharSequence​(int index, int length, Charset charset)
      Gets a CharSequence with the given length at the given index.
      Parameters:
      length - the length to read
      charset - that should be used
      Returns:
      the sequence
      Throws:
      IndexOutOfBoundsException - if length is greater than this.readableBytes
    • setBoolean

      Memory setBoolean​(int index, boolean value)
      Sets the specified boolean at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 1 is greater than this.capacity
    • setByte

      Memory setByte​(int index, int value)
      Sets the specified byte at the specified absolute index in this buffer. The 24 high-order bits of the specified value are ignored. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 1 is greater than this.capacity
    • setShort

      Memory setShort​(int index, int value)
      Sets the specified 16-bit short integer at the specified absolute index in this buffer. The 16 high-order bits of the specified value are ignored. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 2 is greater than this.capacity
    • setShortLE

      Memory setShortLE​(int index, int value)
      Sets the specified 16-bit short integer at the specified absolute index in this buffer with the Little Endian Byte Order. The 16 high-order bits of the specified value are ignored. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 2 is greater than this.capacity
    • setInt

      Memory setInt​(int index, int value)
      Sets the specified 32-bit integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • setIntLE

      Memory setIntLE​(int index, int value)
      Sets the specified 32-bit integer at the specified absolute index in this buffer with Little Endian byte order . This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • setLong

      Memory setLong​(int index, long value)
      Sets the specified 64-bit long integer at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 8 is greater than this.capacity
    • setLongLE

      Memory setLongLE​(int index, long value)
      Sets the specified 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 8 is greater than this.capacity
    • setFloat

      Memory setFloat​(int index, float value)
      Sets the specified 32-bit floating-point number at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • setFloatLE

      Memory setFloatLE​(int index, float value)
      Sets the specified 32-bit floating-point number at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 4 is greater than this.capacity
    • setDouble

      Memory setDouble​(int index, double value)
      Sets the specified 64-bit floating-point number at the specified absolute index in this buffer. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 8 is greater than this.capacity
    • setDoubleLE

      Memory setDoubleLE​(int index, double value)
      Sets the specified 64-bit floating-point number at the specified absolute index in this buffer in Little Endian Byte Order. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      value - value.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or index + 8 is greater than this.capacity
    • setBytes

      Memory setBytes​(int index, Memory src)
      Transfers the specified source buffer's data to this buffer starting at the specified absolute index until the source buffer becomes unreadable. This method is basically same with setBytes(int, Memory, int, int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes while setBytes(int, Memory, int, int) does not. This method does not modify readerIndex or writerIndex of the source buffer (i.e. this).
      Parameters:
      index - index.
      src - source.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or if index + src.readableBytes is greater than this.capacity
    • setBytes

      Memory setBytes​(int index, Memory src, int length)
      Transfers the specified source buffer's data to this buffer starting at the specified absolute index. This method is basically same with setBytes(int, Memory, int, int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes while setBytes(int, Memory, int, int) does not. This method does not modify readerIndex or writerIndex of the source buffer (i.e. this).
      Parameters:
      length - the number of bytes to transfer
      index - index.
      src - source.
      length - length.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0, if index + length is greater than this.capacity, or if length is greater than src.readableBytes
    • setBytes

      Memory setBytes​(int index, Memory src, int srcIndex, int length)
      Transfers the specified source buffer's data to this buffer starting at the specified absolute index. This method does not modify readerIndex or writerIndex of both the source (i.e. this) and the destination.
      Parameters:
      srcIndex - the first index of the source
      length - the number of bytes to transfer
      index - index.
      src - source.
      srcIndex - source index.
      length - length.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0, if the specified srcIndex is less than 0, if index + length is greater than this.capacity, or if srcIndex + length is greater than src.capacity
    • setBytes

      Memory setBytes​(int index, byte[] src)
      Transfers the specified source array's data to this buffer starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      src - source.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0 or if index + src.length is greater than this.capacity
    • setBytes

      Memory setBytes​(int index, byte[] src, int srcIndex, int length)
      Transfers the specified source array's data to this buffer starting at the specified absolute index. This method does not modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      src - source.
      srcIndex - source index.
      length - length.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified index is less than 0, if the specified srcIndex is less than 0, if index + length is greater than this.capacity, or if srcIndex + length is greater than src.length
    • setCharSequence

      Memory setCharSequence​(int index, CharSequence sequence, Charset charset)
      Writes the specified CharSequence at the current writerIndex and increases the writerIndex 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 - if this.writableBytes is not large enough to write the whole sequence
    • readBoolean

      boolean readBoolean()
      Gets a boolean at the current readerIndex and increases the readerIndex by 1 in this buffer.
      Returns:
      boolean value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 1
    • readByte

      byte readByte()
      Gets a byte at the current readerIndex and increases the readerIndex by 1 in this buffer.
      Returns:
      byte value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 1
    • readUnsignedByte

      short readUnsignedByte()
      Gets an unsigned byte at the current readerIndex and increases the readerIndex by 1 in this buffer.
      Returns:
      unsigned byte stored in short.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 1
    • readShort

      short readShort()
      Gets a 16-bit short integer at the current readerIndex and increases the readerIndex by 2 in this buffer.
      Returns:
      short value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 2
    • readShortLE

      short readShortLE()
      Gets a 16-bit short integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 2 in this buffer.
      Returns:
      little endian short value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 2
    • readUnsignedShort

      int readUnsignedShort()
      Gets an unsigned 16-bit short integer at the current readerIndex and increases the readerIndex by 2 in this buffer.
      Returns:
      unsigned short value stored in integer.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 2
    • readUnsignedShortLE

      int readUnsignedShortLE()
      Gets an unsigned 16-bit short integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 2 in this buffer.
      Returns:
      unsigned little endian short value stored in integer.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 2
    • readInt

      int readInt()
      Gets a 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.
      Returns:
      integer value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 4
    • readIntLE

      int readIntLE()
      Gets a 32-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 4 in this buffer.
      Returns:
      little endian integer value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 4
    • readUnsignedInt

      long readUnsignedInt()
      Gets an unsigned 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.
      Returns:
      unsigned integer value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 4
    • readUnsignedIntLE

      long readUnsignedIntLE()
      Gets an unsigned 32-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 4 in this buffer.
      Returns:
      unsigned little endian integer value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 4
    • readLong

      long readLong()
      Gets a 64-bit integer at the current readerIndex and increases the readerIndex by 8 in this buffer.
      Returns:
      long value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 8
    • readLongLE

      long readLongLE()
      Gets a 64-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 8 in this buffer.
      Returns:
      little endian long value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 8
    • readFloat

      float readFloat()
      Gets a 32-bit floating point number at the current readerIndex and increases the readerIndex by 4 in this buffer.
      Returns:
      float value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 4
    • readFloatLE

      float readFloatLE()
      Gets a 32-bit floating point number at the current readerIndex in Little Endian Byte Order and increases the readerIndex by 4 in this buffer.
      Returns:
      little endian float value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 4
    • readDouble

      double readDouble()
      Gets a 64-bit floating point number at the current readerIndex and increases the readerIndex by 8 in this buffer.
      Returns:
      double value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 8
    • readDoubleLE

      double readDoubleLE()
      Gets a 64-bit floating point number at the current readerIndex in Little Endian Byte Order and increases the readerIndex by 8 in this buffer.
      Returns:
      little endian double value.
      Throws:
      IndexOutOfBoundsException - if this.readableBytes is less than 8
    • readBytes

      Memory readBytes​(Memory dst)
      Transfers this buffer's data to the specified destination starting at the current readerIndex until the destination becomes non-writable, and increases the readerIndex by the number of the transferred bytes. This method is basically same with readBytes(Memory, int, int), except that this method increases the writerIndex of the destination by the number of the transferred bytes while readBytes(Memory, int, int) does not.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if dst.writableBytes is greater than this.readableBytes
    • readBytes

      Memory readBytes​(Memory dst, int length)
      Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length). This method is basically same with readBytes(Memory, int, int), except that this method increases the writerIndex of the destination by the number of the transferred bytes (= length) while readBytes(Memory, int, int) does not.
      Throws:
      IndexOutOfBoundsException - if length is greater than this.readableBytes or if length is greater than dst.writableBytes
    • readBytes

      Memory readBytes​(Memory dst, int dstIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).
      Parameters:
      dst - destination.
      dstIndex - the first index of the destination
      length - the number of bytes to transfer
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified dstIndex is less than 0, if length is greater than this.readableBytes, or if dstIndex + length is greater than dst.capacity
    • readBytes

      Memory readBytes​(byte[] dst)
      Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= dst.length).
      Parameters:
      dst - destination.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if dst.length is greater than this.readableBytes
    • readBytes

      Memory readBytes​(byte[] dst, int dstIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).
      Parameters:
      dst - destination.
      dstIndex - the first index of the destination
      length - the number of bytes to transfer
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified dstIndex is less than 0, if length is greater than this.readableBytes, or if dstIndex + length is greater than dst.length
    • skipBytes

      Memory skipBytes​(int length)
      Increases the current readerIndex by the specified length in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if length is greater than this.readableBytes
    • readCharSequence

      CharSequence readCharSequence​(int length, Charset charset)
      Gets a CharSequence with the given length at the current readerIndex and increases the readerIndex by the given length.
      Parameters:
      length - the length to read
      charset - that should be used
      Returns:
      the char sequence.
      Throws:
      IndexOutOfBoundsException - if length is greater than this.readableBytes
    • writeBoolean

      Memory writeBoolean​(boolean value)
      Sets the specified boolean at the current writerIndex and increases the writerIndex by 1 in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 1
    • writeByte

      Memory writeByte​(int value)
      Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer. The 24 high-order bits of the specified value are ignored.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 1
    • writeShort

      Memory writeShort​(int value)
      Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer. The 16 high-order bits of the specified value are ignored.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 2
    • writeShortLE

      Memory writeShortLE​(int value)
      Sets the specified 16-bit short integer in the Little Endian Byte Order at the current writerIndex and increases the writerIndex by 2 in this buffer. The 16 high-order bits of the specified value are ignored.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 2
    • writeInt

      Memory writeInt​(int value)
      Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 4
    • writeIntLE

      Memory writeIntLE​(int value)
      Sets the specified 32-bit integer at the current writerIndex in the Little Endian Byte Order and increases the writerIndex by 4 in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 4
    • writeLong

      Memory writeLong​(long value)
      Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 8
    • writeLongLE

      Memory writeLongLE​(long value)
      Sets the specified 64-bit long integer at the current writerIndex in the Little Endian Byte Order and increases the writerIndex by 8 in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 8
    • writeFloat

      Memory writeFloat​(float value)
      Sets the specified 32-bit floating point number at the current writerIndex and increases the writerIndex by 4 in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 4
    • writeFloatLE

      Memory writeFloatLE​(float value)
      Sets the specified 32-bit floating point number at the current writerIndex in Little Endian Byte Order and increases the writerIndex by 4 in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 4
    • writeDouble

      Memory writeDouble​(double value)
      Sets the specified 64-bit floating point number at the current writerIndex and increases the writerIndex by 8 in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 8
    • writeDoubleLE

      Memory writeDoubleLE​(double value)
      Sets the specified 64-bit floating point number at the current writerIndex in Little Endian Byte Order and increases the writerIndex by 8 in this buffer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if this.writableBytes is less than 8
    • writeBytes

      Memory writeBytes​(Memory src)
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes. This method is basically same with writeBytes(Memory, int, int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes while writeBytes(Memory, int, int) does not.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if src.readableBytes is greater than this.writableBytes
    • writeBytes

      Memory writeBytes​(Memory src, int length)
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length). This method is basically same with writeBytes(Memory, int, int), except that this method increases the readerIndex of the source buffer by the number of the transferred bytes (= length) while writeBytes(Memory, int, int) does not.
      Parameters:
      src - source.
      length - the number of bytes to transfer.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if length is greater than this.writableBytes or if length is greater then src.readableBytes
    • writeBytes

      Memory writeBytes​(Memory src, int srcIndex, int length)
      Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
      Parameters:
      src - source.
      srcIndex - the first index of the source
      length - the number of bytes to transfer
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified srcIndex is less than 0, if srcIndex + length is greater than src.capacity, or if length is greater than this.writableBytes
    • writeBytes

      Memory writeBytes​(byte[] src)
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= src.length).
      Parameters:
      src - source.
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if src.length is greater than this.writableBytes
    • writeBytes

      Memory writeBytes​(byte[] src, int srcIndex, int length)
      Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).
      Parameters:
      src - source.
      srcIndex - the first index of the source
      length - the number of bytes to transfer
      Returns:
      this Memory.
      Throws:
      IndexOutOfBoundsException - if the specified srcIndex is less than 0, if srcIndex + length is greater than src.length, or if length is greater than this.writableBytes
    • writeCharSequence

      Memory writeCharSequence​(CharSequence sequence, Charset charset)
      Writes the specified CharSequence at the current writerIndex and increases the writerIndex by the written bytes. in this buffer.
      Parameters:
      sequence - to write.
      charset - that should be used.
      Returns:
      the written number of bytes.
      Throws:
      IndexOutOfBoundsException - if this.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 to copy(readerIndex(), readableBytes()). This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      copied Memory buffer's.
    • copy

      Memory copy​(int index, int length)
      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 modify readerIndex or writerIndex 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 to slice(readerIndex(), readableBytes()). This method does not modify readerIndex or writerIndex of this buffer.
      Returns:
      returns sliced Memory buffer's.
    • slice

      Memory slice​(int index, int length)
      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 modify readerIndex or writerIndex of this buffer.
      Parameters:
      index - index.
      length - length.
      Returns:
      returns sliced Memory buffer's.
    • duplicate

      Memory duplicate()
      Duplicate the this Memory 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 this Memory buffer's as an NIO ByteBuffer'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 modify readerIndex or writerIndex 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()
      Returns true 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 this Memory buffer.