CompositeReadableBuffer

ReadableBuffer implementation whose content is made up of one or more byte arrays.

Constructors

this
this()

Creates a default empty composite buffer

this
this(byte[] array, int offset)
Undocumented in source.
this
this(bool compactable)
Undocumented in source.

Members

Functions

append
CompositeReadableBuffer append(byte[] array)

Adds the given array into the composite buffer at the end. <p> The appended array is not copied so changes to the source array are visible in this buffer and vice versa. If this composite was empty than it would return true for the {@link #hasArray()} method until another array is appended. <p> Calling this method resets the limit to the new _capacity.

append
CompositeReadableBuffer append(CompositeReadableBuffer buffer)

Adds the given composite buffer contents (from current position, up to the limit) into this composite buffer at the end. The source buffer position will be set to its limit. <p> The appended buffer contents are not copied wherever possible, so changes to the source arrays are typically visible in this buffer and vice versa. Exceptions include where the source buffer position is not located at the start of its current backing array, or where the given buffer has a limit that doesn't encompass all of the last array used, and so the remainder of that arrays contents must be copied first to append here. <p> Calling this method resets the limit to the new _capacity.

append
CompositeReadableBuffer append(ReadableBuffer buffer)

Adds the given readable buffer contents (from current position, up to the limit) into this composite buffer at the end. The source buffer position will be set to its limit. <p> The appended buffer contents are not copied wherever possible, so changes to the source arrays are typically visible in this buffer and vice versa. Exceptions are where the source buffer is not backed by an array, or where the source buffer position is not located at the start of its backing array, and so the remainder of the contents must be copied first to append here. <p> Calling this method resets the limit to the new _capacity.

array
byte[] array()
Undocumented in source. Be warned that the author may not have intended to support it.
arrayOffset
int arrayOffset()
Undocumented in source. Be warned that the author may not have intended to support it.
byteBuffer
ByteBuffer byteBuffer()
Undocumented in source. Be warned that the author may not have intended to support it.
capacity
int capacity()
Undocumented in source. Be warned that the author may not have intended to support it.
clear
CompositeReadableBuffer clear()
Undocumented in source. Be warned that the author may not have intended to support it.
duplicate
CompositeReadableBuffer duplicate()
Undocumented in source. Be warned that the author may not have intended to support it.
flip
CompositeReadableBuffer flip()
Undocumented in source. Be warned that the author may not have intended to support it.
get
byte get()
Undocumented in source. Be warned that the author may not have intended to support it.
get
byte get(int index)
Undocumented in source. Be warned that the author may not have intended to support it.
get
CompositeReadableBuffer get(byte[] data)
Undocumented in source. Be warned that the author may not have intended to support it.
get
CompositeReadableBuffer get(byte[] data, int offset, int length)
Undocumented in source. Be warned that the author may not have intended to support it.
get
CompositeReadableBuffer get(WritableBuffer target)
Undocumented in source. Be warned that the author may not have intended to support it.
getArrays
List!(byte[]) getArrays()
Undocumented in source. Be warned that the author may not have intended to support it.
getCurrentArrayPosition
int getCurrentArrayPosition()

Gets the current position index in the current backing array, which represents the current buffer position.

getCurrentIndex
int getCurrentIndex()
Undocumented in source. Be warned that the author may not have intended to support it.
getDouble
double getDouble()
Undocumented in source. Be warned that the author may not have intended to support it.
getFloat
float getFloat()
Undocumented in source. Be warned that the author may not have intended to support it.
getInt
int getInt()
Undocumented in source. Be warned that the author may not have intended to support it.
getLong
long getLong()
Undocumented in source. Be warned that the author may not have intended to support it.
getShort
short getShort()
Undocumented in source. Be warned that the author may not have intended to support it.
hasArray
bool hasArray()
Undocumented in source. Be warned that the author may not have intended to support it.
hasRemaining
bool hasRemaining()
Undocumented in source. Be warned that the author may not have intended to support it.
hashCode
int hashCode()
Undocumented in source. Be warned that the author may not have intended to support it.
limit
CompositeReadableBuffer limit(int limit)
Undocumented in source. Be warned that the author may not have intended to support it.
limit
int limit()
Undocumented in source. Be warned that the author may not have intended to support it.
mark
CompositeReadableBuffer mark()
Undocumented in source. Be warned that the author may not have intended to support it.
opCmp
int opCmp(ReadableBuffer o)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Object other)
Undocumented in source. Be warned that the author may not have intended to support it.
position
CompositeReadableBuffer position(int pos)
Undocumented in source. Be warned that the author may not have intended to support it.
position
int position()
Undocumented in source. Be warned that the author may not have intended to support it.
readString
string readString()
Undocumented in source. Be warned that the author may not have intended to support it.
readUTF8
string readUTF8()
Undocumented in source. Be warned that the author may not have intended to support it.
reclaimRead
CompositeReadableBuffer reclaimRead()

Compact the buffer dropping arrays that have been consumed by previous reads from this Composite buffer. The limit is reset to the new _capacity

remaining
int remaining()
Undocumented in source. Be warned that the author may not have intended to support it.
reset
CompositeReadableBuffer reset()
Undocumented in source. Be warned that the author may not have intended to support it.
rewind
CompositeReadableBuffer rewind()
Undocumented in source. Be warned that the author may not have intended to support it.
slice
CompositeReadableBuffer slice()
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

EMPTY_BUFFER
ByteBuffer EMPTY_BUFFER()
Undocumented in source. Be warned that the author may not have intended to support it.
EMPTY_LIST
List!(byte[]) EMPTY_LIST()
Undocumented in source. Be warned that the author may not have intended to support it.
EMPTY_SLICE
CompositeReadableBuffer EMPTY_SLICE()
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From ReadableBuffer

capacity
int capacity()

Returns the capacity of the backing buffer of this ReadableBuffer @return the capacity of the backing buffer of this ReadableBuffer

hasArray
bool hasArray()

Returns true if this ReadableBuffer is backed by an array which can be accessed by the {@link #array()} and {@link #arrayOffset()} methods.

array
byte[] array()

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.

arrayOffset
int arrayOffset()

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.

reclaimRead
ReadableBuffer reclaimRead()

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.

get
byte get()

Reads the byte at the current position and advances the position by 1.

get
byte get(int index)

Reads the byte at the given index, the buffer position is not affected.

getInt
int getInt()

Reads four bytes from the buffer and returns them as an integer value. The buffer position is advanced by four byes.

getLong
long getLong()

Reads eight bytes from the buffer and returns them as an long value. The buffer position is advanced by eight byes.

getShort
short getShort()

Reads two bytes from the buffer and returns them as an short value. The buffer position is advanced by two byes.

getFloat
float getFloat()

Reads four bytes from the buffer and returns them as an float value. The buffer position is advanced by four byes.

getDouble
double getDouble()

Reads eight bytes from the buffer and returns them as an double value. The buffer position is advanced by eight byes.

get
ReadableBuffer get(byte[] target, int offset, int length)

A bulk read method that copies bytes from this buffer into the target byte array.

get
ReadableBuffer get(byte[] target)

A bulk read method that copies bytes from this buffer into the target byte array.

get
ReadableBuffer get(WritableBuffer target)

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.

slice
ReadableBuffer slice()

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.

flip
ReadableBuffer flip()

Sets the buffer limit to the current position and the position is set to zero, the mark value reset to undefined.

limit
ReadableBuffer limit(int limit)

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.

limit
int limit()

@return the current value of this buffer's limit.

position
ReadableBuffer position(int position)

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.

position
int position()

@return the current position from which the next read operation will start.

mark
ReadableBuffer mark()

Mark the current position of this buffer which can be returned to after a read operation by calling {@link #reset()}.

reset
ReadableBuffer reset()

Reset the buffer's position to a previously marked value, the mark should remain set after calling this method.

rewind
ReadableBuffer rewind()

Resets the buffer position to zero and clears and previously set mark.

clear
ReadableBuffer clear()

Resets the buffer position to zero and sets the limit to the buffer capacity, the mark value is discarded if set.

remaining
int remaining()

@return the remaining number of readable bytes in this buffer.

hasRemaining
bool hasRemaining()

@return true if there are readable bytes still remaining in this buffer.

duplicate
ReadableBuffer duplicate()

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.

byteBuffer
ByteBuffer byteBuffer()

@return a ByteBuffer view of the current readable portion of this buffer.

readUTF8
string readUTF8()

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.

opCmp
int opCmp(ReadableBuffer o)

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.

Meta