Returns the primitive array that backs this buffer if one exists and the buffer is not read-only. The caller should have checked the {@link #hasArray()} method before calling this method.
Returns the offset into the backing array of the first element in the buffer. The caller should have checked the {@link #hasArray()} method before calling this method.
@return a ByteBuffer view of the current readable portion of this buffer.
Returns the capacity of the backing buffer of this ReadableBuffer @return the capacity of the backing buffer of this ReadableBuffer
Resets the buffer position to zero and sets the limit to the buffer capacity, the mark value is discarded if set.
Creates a duplicate {@link ReadableBuffer} to this instance. <p> The duplicated buffer will have the same position, limit and mark as this buffer. The two buffers share the same backing data.
Sets the buffer limit to the current position and the position is set to zero, the mark value reset to undefined.
Reads the byte at the current position and advances the position by 1.
Reads the byte at the given index, the buffer position is not affected.
A bulk read method that copies bytes from this buffer into the target byte array.
A bulk read method that copies bytes from this buffer into the target byte array.
Copy data from this buffer to the target buffer starting from the current position and continuing until either this buffer's remaining bytes are consumed or the target is full.
Reads eight bytes from the buffer and returns them as an double value. The buffer position is advanced by eight byes.
Reads four bytes from the buffer and returns them as an float value. The buffer position is advanced by four byes.
Reads four bytes from the buffer and returns them as an integer value. The buffer position is advanced by four byes.
Reads eight bytes from the buffer and returns them as an long value. The buffer position is advanced by eight byes.
Reads two bytes from the buffer and returns them as an short value. The buffer position is advanced by two byes.
Returns true if this ReadableBuffer is backed by an array which can be accessed by the {@link #array()} and {@link #arrayOffset()} methods.
@return true if there are readable bytes still remaining in this buffer.
Sets the current read limit of this buffer to the given value. If the buffer mark value is defined and is larger than the limit the mark will be discarded. If the position is larger than the new limit it will be reset to the new limit.
@return the current value of this buffer's limit.
Mark the current position of this buffer which can be returned to after a read operation by calling {@link #reset()}.
Decodes a String from the buffer using the provided {@link CharsetDecoder} starting the decode at the current position and reading until the limit is reached. The position is advanced to the limit once this method returns. If there is no bytes remaining in the buffer when this method is called a null is returned.
Sets the current position of this buffer to the given value. If the buffer mark value is defined and is larger than the newly set position is must be discarded.
@return the current position from which the next read operation will start.
Reads a UTF-8 encoded String from the buffer starting the decode at the current position and reading until the limit is reached. The position is advanced to the limit once this method returns. If there is no bytes remaining in the buffer when this method is called a null is returned.
Compact the backing storage of this ReadableBuffer, possibly freeing previously-read portions of pooled data or reducing the number of backing arrays if present. <p> This is an optional operation and care should be taken in its implementation.
@return the remaining number of readable bytes in this buffer.
Reset the buffer's position to a previously marked value, the mark should remain set after calling this method.
Resets the buffer position to zero and clears and previously set mark.
Creates a new ReadableBuffer instance that is a view of the readable portion of this buffer. The position will be set to zero and the limit and the reported capacity will match the value returned by this buffer's {@link #remaining()} method, the mark will be undefined.
Interface to abstract a buffer, similar to {@link WritableBuffer}