Top Description Inners Fields Constructors Methods
org.eclipse.jetty.io

public Class ChunkAccumulator

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.ArrayList, .List, .Objects, java.util.concurrent.CompletableFuture, org.eclipse.jetty.io.Content.Chunk, org.eclipse.jetty.util.BufferUtil, .CompletableTask

An accumulator of Content.Chunks used to facilitate minimal copy aggregation of multiple chunks.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class

Field Summary

Modifier and TypeField and Description
private final List<Content.Chunk>
private int
private static final ByteBufferPool

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the Chunk had content and was added to the accumulator.
add
(Content.Chunk
The Chunk to accumulate. If a reference is kept to the chunk (rather than a copy), it will be retained.
chunk
)

Add a Chunk to the accumulator.

public void
public int

Returns:

The total length in bytes.
length
()

Get the total length of the accumulated Chunks.

public CompletableFuture<byte[]>
public CompletableFuture<byte[]>
readAll(Content.Source source, int maxSize)

public CompletableFuture<RetainableByteBuffer>
readAll(Content.Source
The Content.Source to read
source
,
ByteBufferPool
The ByteBufferPool to acquire the buffer from, or null for a non Retainable buffer
pool
,
boolean
True if the buffer should be direct.
direct
,
int
The maximum size to read, or -1 for no limit
maxSize
)

Returns: A CompletableFuture that will be completed when the complete content is read or failed if the max size is exceeded or there is a read error.

public byte[]
take()

public RetainableByteBuffer
take(ByteBufferPool pool, boolean direct)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_chunksback to summary
private final List<Content.Chunk> _chunks
_lengthback to summary
private int _length
NON_POOLINGback to summary
private static final ByteBufferPool NON_POOLING

Constructor Detail

ChunkAccumulatorback to summary
public ChunkAccumulator()

Method Detail

addback to summary
public boolean add(Content.Chunk chunk)

Add a Chunk to the accumulator.

Parameters
chunk:Content.Chunk

The Chunk to accumulate. If a reference is kept to the chunk (rather than a copy), it will be retained.

Returns:boolean

true if the Chunk had content and was added to the accumulator.

Exceptions
ArithmeticException:
if more that Integer#MAX_VALUE bytes are added.
IllegalArgumentException:
if the passed Chunk is a failure.
closeback to summary
public void close()
lengthback to summary
public int length()

Get the total length of the accumulated Chunks.

Returns:int

The total length in bytes.

readAllback to summary
public CompletableFuture<byte[]> readAll(Content.Source source)
readAllback to summary
public CompletableFuture<byte[]> readAll(Content.Source source, int maxSize)
readAllback to summary
public CompletableFuture<RetainableByteBuffer> readAll(Content.Source source, ByteBufferPool pool, boolean direct, int maxSize)
Parameters
source:Content.Source

The Content.Source to read

pool:ByteBufferPool

The ByteBufferPool to acquire the buffer from, or null for a non Retainable buffer

direct:boolean

True if the buffer should be direct.

maxSize:int

The maximum size to read, or -1 for no limit

Returns:CompletableFuture<RetainableByteBuffer>

A CompletableFuture that will be completed when the complete content is read or failed if the max size is exceeded or there is a read error.

takeback to summary
public byte[] take()
takeback to summary
public RetainableByteBuffer take(ByteBufferPool pool, boolean direct)
org.eclipse.jetty.io back to summary

private abstract Class ChunkAccumulator.AccumulatorTask<T>

extends CompletableTask<T>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ChunkAccumulator
private final int
private final Content.Source

Constructor Summary

AccessConstructor and Description
private
AccumulatorTask(Content.Source source, int maxLength)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

protected abstract T
take(ChunkAccumulator accumulator)

Inherited from org.eclipse.jetty.util.CompletableTask:
start

Field Detail

_accumulatorback to summary
private final ChunkAccumulator _accumulator
_maxLengthback to summary
private final int _maxLength
_sourceback to summary
private final Content.Source _source

Constructor Detail

AccumulatorTaskback to summary
private AccumulatorTask(Content.Source source, int maxLength)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
takeback to summary
protected abstract T take(ChunkAccumulator accumulator)