Interface RetainableByteBuffer

All Superinterfaces:
Retainable
All Known Subinterfaces:
Content.Chunk, RetainableByteBuffer.Mutable
All Known Implementing Classes:
AbstractRetainableByteBuffer, ArrayByteBufferPool.Tracking.TrackedBuffer, Content.Chunk.Empty, RetainableByteBuffer.Abstract, RetainableByteBuffer.DynamicCapacity, RetainableByteBuffer.EmptyRetainableByteBuffer, RetainableByteBuffer.FixedCapacity, RetainableByteBuffer.NonRetainableByteBuffer, RetainableByteBuffer.Pooled, RetainableByteBuffer.Wrapper

public interface RetainableByteBuffer extends Retainable

An abstraction over ByteBuffers which provides:

When possible and optimal, implementations will avoid data copies. However, copies may be favoured over retaining large buffers with small content.

Accessing data in the buffer can be achieved via:

The RetainableByteBuffer APIs are non-modal, meaning that there is no need for any flip operation between a mutable method and an accessor method. ByteBuffer returned or passed to this API should be in "flush" mode, with valid data between the position and limit. The ByteBuffer returned from getByteBuffer() may used directly and switched to "fill" mode, but it is the callers responsibility to flip back to "flush" mode, before any RetainableByteBuffer APIs are used.

The RetainableByteBuffer APIs hide any notion of unused space before or after valid data. All indexing is relative to the first byte of data in the buffer and no manipulation of data pointers is directly supported.

The buffer may be large and the size() is represented as a long in new APIs. However, APIs that are tied to a single backing ByteBuffer may use integer representations of size and indexes.