Class ByteBufferAccumulator
java.lang.Object
org.eclipse.jetty.io.ByteBufferAccumulator
- All Implemented Interfaces:
AutoCloseable
@Deprecated(forRemoval=true)
public class ByteBufferAccumulator
extends Object
implements AutoCloseable
Deprecated, for removal: This API element is subject to removal in a future version.
Accumulates data into a list of ByteBuffers which can then be combined into a single buffer or written to an OutputStream.
The buffer list automatically grows as data is written to it, the buffers are taken from the
supplied
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.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version.ByteBufferAccumulator
(ByteBufferPool bufferPool, boolean direct) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Deprecated, for removal: This API element is subject to removal in a future version.void
copyBuffer
(ByteBuffer source) Deprecated, for removal: This API element is subject to removal in a future version.void
copyBytes
(byte[] buf, int offset, int length) Deprecated, for removal: This API element is subject to removal in a future version.ensureBuffer
(int minAllocationSize) Deprecated, for removal: This API element is subject to removal in a future version.Get the last buffer of the accumulator, this can be written to directly to avoid copying into the accumulator.ensureBuffer
(int minSize, int minAllocationSize) Deprecated, for removal: This API element is subject to removal in a future version.Get the last buffer of the accumulator, this can be written to directly to avoid copying into the accumulator.int
Deprecated, for removal: This API element is subject to removal in a future version.Get the amount of bytes which have been accumulated.Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Take the combined buffer containing all content written to the accumulator.byte[]
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Take the combined buffer containing all content written to the accumulator.void
writeTo
(OutputStream out) Deprecated, for removal: This API element is subject to removal in a future version.void
writeTo
(ByteBuffer byteBuffer) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
ByteBufferAccumulator
public ByteBufferAccumulator()Deprecated, for removal: This API element is subject to removal in a future version. -
ByteBufferAccumulator
Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
getLength
public int getLength()Deprecated, for removal: This API element is subject to removal in a future version.Get the amount of bytes which have been accumulated. This will add up the remaining of each buffer in the accumulator.- Returns:
- the total length of the content in the accumulator.
-
ensureBuffer
Deprecated, for removal: This API element is subject to removal in a future version.Get the last buffer of the accumulator, this can be written to directly to avoid copying into the accumulator.- Parameters:
minAllocationSize
- new buffers will be allocated to have at least this size.- Returns:
- a buffer with at least
minSize
space to write into.
-
ensureBuffer
Deprecated, for removal: This API element is subject to removal in a future version.Get the last buffer of the accumulator, this can be written to directly to avoid copying into the accumulator.- Parameters:
minSize
- the smallest amount of remaining space before a new buffer is allocated.minAllocationSize
- new buffers will be allocated to have at least this size.- Returns:
- a buffer with at least
minSize
space to write into.
-
copyBytes
public void copyBytes(byte[] buf, int offset, int length) Deprecated, for removal: This API element is subject to removal in a future version. -
copyBuffer
Deprecated, for removal: This API element is subject to removal in a future version. -
takeRetainableByteBuffer
Deprecated, for removal: This API element is subject to removal in a future version.Take the combined buffer containing all content written to the accumulator. The caller is responsible for releasing thisRetainableByteBuffer
.- Returns:
- a buffer containing all content written to the accumulator.
- See Also:
-
takeByteBuffer
Deprecated, for removal: This API element is subject to removal in a future version. -
toRetainableByteBuffer
Deprecated, for removal: This API element is subject to removal in a future version.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.- Returns:
- a buffer containing all content written to the accumulator.
- See Also:
-
toByteArray
public byte[] toByteArray()Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- a newly allocated byte array containing all content written into the accumulator.
-
writeTo
Deprecated, for removal: This API element is subject to removal in a future version. -
writeTo
Deprecated, for removal: This API element is subject to removal in a future version.- Throws:
IOException
-
close
public void close()Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
close
in interfaceAutoCloseable
-
RetainableByteBuffer.DynamicCapacity