Class ByteBufferAggregator

java.lang.Object
org.eclipse.jetty.io.ByteBufferAggregator

@Deprecated(forRemoval=true) public class ByteBufferAggregator extends Object
Deprecated, for removal: This API element is subject to removal in a future version.

Aggregates data into a single ByteBuffer of a specified maximum size.

The buffer automatically grows as data is written to it, up until it reaches the specified maximum size. Once the buffer is full, the aggregator will not aggregate any more bytes until its buffer is taken out, after which a new aggregate/take buffer cycle can start.

The buffers are taken from the supplied ByteBufferPool or freshly allocated if one is not supplied.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ByteBufferAggregator(ByteBufferPool bufferPool, boolean direct, int startSize, int maxSize)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a ByteBuffer aggregator.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Aggregates the given ByteBuffer.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the currently aggregated length.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Takes the buffer out of the aggregator.
    Deprecated, for removal: This API element is subject to removal in a future version.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ByteBufferAggregator

      public ByteBufferAggregator(ByteBufferPool bufferPool, boolean direct, int startSize, int maxSize)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a ByteBuffer aggregator.
      Parameters:
      bufferPool - The ByteBufferPool from which to acquire the buffers
      direct - whether to get direct buffers
      startSize - the starting size of the buffer
      maxSize - the maximum size of the buffer which must be greater than startSize
  • Method Details

    • length

      public int length()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the currently aggregated length.
      Returns:
      The current total aggregated bytes.
    • aggregate

      public boolean aggregate(ByteBuffer buffer)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Aggregates the given ByteBuffer. This copies bytes up to the specified maximum size, at which time this method returns true and takeRetainableByteBuffer() must be called for this method to accept aggregating again.
      Parameters:
      buffer - the buffer to copy into this aggregator; its position is updated according to the number of aggregated bytes
      Returns:
      true if the aggregator's buffer is full and should be taken, false otherwise
    • takeRetainableByteBuffer

      public RetainableByteBuffer takeRetainableByteBuffer()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Takes the buffer out of the aggregator. Once the buffer has been taken out, the aggregator resets itself and a new buffer will be acquired from the pool during the next aggregate(ByteBuffer) call.
      Returns:
      the aggregated buffer, or null if nothing has been buffered yet
    • toString

      public String toString()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      toString in class Object