Constructors
ByteBufferSource Codeshared ByteBuffer({Byte*} initialData)

Allocates a new ByteBuffer filled with the given initialData. The capacity of the new buffer will be the number of bytes given. The returned buffer will be ready to be read, with its position set to 0 and its limit set to the buffer capacity.

ofArraySource Codeshared ofArray(Array<Byte> initialArray)

Creates a ByteBuffer initally backed by the given initialArray. The capacity of the new buffer will be the size of the array. The returned buffer will be ready to be read, with its position set to 0 and its limit set to the buffer capacity.

ofSizeSource Codeshared ofSize(Integer initialCapacity)

Allocates a new zeroed ByteBuffer of the given initialCapacity.

Attributes
arraySource Codeshared actual Array<Byte> array

The current underlying Array of the buffer. Any changes made to the buffer will be reflected in this array, and vice versa.

Reallocations caused by a call to Buffer.resize() will cause any prior references obtained though this attribute to become stale.

Refines Buffer.array
capacitySource Codeshared actual Integer capacity

The underlying array maximum capacity. Both the Buffer.position and Buffer.limit cannot exceed the capacity. You can Buffer.resize() the array to change the Buffer.capacity.

implementationSource Codeshared actual Object? implementation

The platform-specific implementation object, if any.

limitSource Codeshared actual variable Integer limit

The limit at which to stop reading and writing. The limit will always be greater or equal to the Buffer.position and smaller or equal to the Buffer.capacity.

Refines Buffer.limit
positionSource Codeshared actual variable Integer position

The current position index within this buffer. Starts at 0 and grows with each Buffer.get() or Buffer.put() operation, until it reaches the Buffer.limit.

Inherited Attributes
Attributes inherited from: Buffer<Element>
Attributes inherited from: Object
Methods
clearSource Codeshared actual void clear()

Resets the Buffer.position to 0 and the Buffer.limit to the Buffer.capacity. Use this after reading to start writing to a clear buffer.

Refines Buffer.clear
flipSource Codeshared actual void flip()

Flips this buffer after a write operation, so that it is ready to be read.

This will and set its Buffer.limit to the current Buffer.position, and reset its Buffer.position to 0. This essentially means that you will be able to read from the beginning of the buffer until the last object you Buffer.put() in it when writing.

Refines Buffer.flip
getSource Codeshared actual Byte get()

Reads an object from this buffer at the current Buffer.position. Increases the Buffer.position by 1.

Refines Buffer.get
putSource Codeshared actual void put(Byte element)

Writes an object to this buffer at the current Buffer.position. Increases the Buffer.position by 1.

Refines Buffer.put
resizeSource Codeshared actual void resize(Integer newSize, Boolean growLimit)

Resizes the underlying array, by growing or shrinking it. This implies a new array allocation and copy.

The Buffer.position will only be affected if the newSize is smaller than the Buffer.position, in which case the Buffer.position will be reset down to the newSize (at the end of the buffer).

The Buffer.limit will be brought down to the newSize if it would otherwise exceed it (when shrinking the buffer below the old Buffer.limit), effectively making the new Buffer.limit be at the end of the buffer.

If you are growing the array, the Buffer.limit will not be changed unless the optional parameter growLimit is set to true (defaults to false), because when you are writing it makes sense to grow the limit, but when you are reading it usually does not, as growing a buffer does not generate new meaningful data.

Inherited Methods
Methods inherited from: Buffer<Element>
Methods inherited from: Object