ByteBufferPool or freshly allocated if one is not supplied.
The method ensureBuffer(int, int) is used to write directly to the last buffer stored in the buffer list,
if there is less than a certain amount of space available in that buffer then a new one will be allocated and returned instead.
ensureBuffer(int, int)
| Modifier and Type | Field and Description |
|---|---|
| private final ByteBufferPool | |
| private final List | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements java. |
| public void | |
| public void | |
| public RetainableByteBuffer | Returns: a buffer with at leastminSize space to write into.new buffers will be allocated to have at least this size. minAllocationSize)Get the last buffer of the accumulator, this can be written to directly to avoid copying into the accumulator. |
| public RetainableByteBuffer | Returns: a buffer with at leastminSize space to write into.the smallest amount of remaining space before a new buffer is allocated. minSize, int new buffers will be allocated to have at least this size. minAllocationSize)Get the last buffer of the accumulator, this can be written to directly to avoid copying into the accumulator. |
| public int | Returns: the total length of the content in the accumulator.Get the amount of bytes which have been accumulated. |
| public ByteBuffer | |
| public RetainableByteBuffer | Returns: a buffer containing all content written to the accumulator.Take the combined buffer containing all content written to the accumulator. |
| public byte[] | Returns: a newly allocated byte array containing all content written into the accumulator.
|
| public RetainableByteBuffer | Returns: a buffer containing all content written to the accumulator.Take the combined buffer containing all content written to the accumulator. |
| public void | |
| public void |
| _bufferPool | back to summary |
|---|---|
| private final ByteBufferPool _bufferPool | |
| _buffers | back to summary |
|---|---|
| private final List<RetainableByteBuffer> _buffers | |
| _direct | back to summary |
|---|---|
| private final boolean _direct | |
| ByteBufferAccumulator | back to summary |
|---|---|
| public ByteBufferAccumulator() | |
| ByteBufferAccumulator | back to summary |
|---|---|
| public ByteBufferAccumulator(ByteBufferPool bufferPool, boolean direct) | |
| close | back to summary |
|---|---|
| public void close() Implements java. Doc from java. Closes this resource, relinquishing any underlying resources.
This method is invoked automatically on objects managed by the
| |
| copyBuffer | back to summary |
|---|---|
| public void copyBuffer(ByteBuffer source) | |
| copyBytes | back to summary |
|---|---|
| public void copyBytes(byte[] buf, int offset, int length) | |
| ensureBuffer | back to summary |
|---|---|
| public RetainableByteBuffer ensureBuffer(int minAllocationSize) Get the last buffer of the accumulator, this can be written to directly to avoid copying into the accumulator.
| |
| ensureBuffer | back to summary |
|---|---|
| public RetainableByteBuffer ensureBuffer(int minSize, int minAllocationSize) Get the last buffer of the accumulator, this can be written to directly to avoid copying into the accumulator.
| |
| getLength | back to summary |
|---|---|
| public int getLength() Get the amount of bytes which have been accumulated. This will add up the remaining of each buffer in the accumulator.
| |
| takeByteBuffer | back to summary |
|---|---|
| public ByteBuffer takeByteBuffer() | |
| takeRetainableByteBuffer | back to summary |
|---|---|
| public RetainableByteBuffer takeRetainableByteBuffer() Take the combined buffer containing all content written to the accumulator.
The caller is responsible for releasing this
| |
| toByteArray | back to summary |
|---|---|
public byte[] toByteArray()
| |
| toRetainableByteBuffer | back to summary |
|---|---|
| public RetainableByteBuffer toRetainableByteBuffer() Take the combined buffer containing all content written to the accumulator. The returned buffer is still contained within the accumulator and will be released when the accumulator is closed.
| |
| writeTo | back to summary |
|---|---|
| public void writeTo(ByteBuffer byteBuffer) | |
| writeTo | back to summary |
|---|---|
| public void writeTo(OutputStream out) throws IOException | |