Package org.eclipse.jetty.io
Class ByteBufferAccumulator
- java.lang.Object
-
- org.eclipse.jetty.io.ByteBufferAccumulator
-
- All Implemented Interfaces:
java.lang.AutoCloseable
@Deprecated(since="2021-05-27") public class ByteBufferAccumulator extends java.lang.Object implements java.lang.AutoCloseable
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.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 suppliedByteBufferPool
or freshly allocated if one is not supplied. The methodensureBuffer(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:
ensureBuffer(int, int)
-
-
Constructor Summary
Constructors Constructor Description ByteBufferAccumulator()
Deprecated.ByteBufferAccumulator(ByteBufferPool bufferPool, boolean direct)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Deprecated.void
copyBuffer(java.nio.ByteBuffer buffer)
Deprecated.void
copyBytes(byte[] buf, int offset, int length)
Deprecated.java.nio.ByteBuffer
ensureBuffer(int minAllocationSize)
Deprecated.Get the last buffer of the accumulator, this can be written to directly to avoid copying into the accumulator.java.nio.ByteBuffer
ensureBuffer(int minSize, int minAllocationSize)
Deprecated.Get the last buffer of the accumulator, this can be written to directly to avoid copying into the accumulator.ByteBufferPool
getByteBufferPool()
Deprecated.int
getLength()
Deprecated.Get the amount of bytes which have been accumulated.java.nio.ByteBuffer
takeByteBuffer()
Deprecated.Take the combined buffer containing all content written to the accumulator.byte[]
toByteArray()
Deprecated.java.nio.ByteBuffer
toByteBuffer()
Deprecated.Take the combined buffer containing all content written to the accumulator.void
writeTo(java.io.OutputStream out)
Deprecated.void
writeTo(java.nio.ByteBuffer buffer)
Deprecated.
-
-
-
Constructor Detail
-
ByteBufferAccumulator
public ByteBufferAccumulator()
Deprecated.
-
ByteBufferAccumulator
public ByteBufferAccumulator(ByteBufferPool bufferPool, boolean direct)
Deprecated.
-
-
Method Detail
-
getLength
public int getLength()
Deprecated.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.
-
getByteBufferPool
public ByteBufferPool getByteBufferPool()
Deprecated.
-
ensureBuffer
public java.nio.ByteBuffer ensureBuffer(int minAllocationSize)
Deprecated.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
public java.nio.ByteBuffer ensureBuffer(int minSize, int minAllocationSize)
Deprecated.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.
-
copyBuffer
public void copyBuffer(java.nio.ByteBuffer buffer)
Deprecated.
-
takeByteBuffer
public java.nio.ByteBuffer takeByteBuffer()
Deprecated.Take the combined buffer containing all content written to the accumulator. The caller is responsible for releasing thisByteBuffer
back into theByteBufferPool
.- Returns:
- a buffer containing all content written to the accumulator.
- See Also:
toByteBuffer()
-
toByteBuffer
public java.nio.ByteBuffer toByteBuffer()
Deprecated.Take the combined buffer containing all content written to the accumulator. The returned buffer is still contained within the accumulator and will be released back to theByteBufferPool
when the accumulator is closed.- Returns:
- a buffer containing all content written to the accumulator.
- See Also:
takeByteBuffer()
,close()
-
toByteArray
public byte[] toByteArray()
Deprecated.- Returns:
- a newly allocated byte array containing all content written into the accumulator.
-
writeTo
public void writeTo(java.nio.ByteBuffer buffer)
Deprecated.
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
close
public void close()
Deprecated.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
-