Top Description Inners Fields Constructors Methods
org.apache.hc.core5.http.nio.support.classic

public abstract Class AbstractClassicEntityConsumer<T>

extends Object
implements AsyncEntityConsumer<T>
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.AsyncEntityConsumer, org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.ResourceHolder
Type Parameters
<T>
entity representation.
Imports
java.io.IOException, .InputStream, .UnsupportedEncodingException, java.nio.ByteBuffer, java.nio.charset.UnsupportedCharsetException, java.util.List, java.util.concurrent.Executor, java.util.concurrent.atomic.AtomicReference, org.apache.hc.core5.concurrent.FutureCallback, org.apache.hc.core5.http.ContentType, .EntityDetails, .Header, .HttpException, org.apache.hc.core5.http.nio.AsyncEntityConsumer, .CapacityChannel, org.apache.hc.core5.util.Args

AsyncEntityConsumer implementation that acts as a compatibility layer for classic InputStream based interfaces. Blocking input processing is executed through an Executor.
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private final SharedInputBuffer
private final AtomicReference<Exception>
private final Executor
private final AtomicReference<T>
private final AtomicReference<AbstractClassicEntityConsumer.State>

Constructor Summary

AccessConstructor and Description
public
AbstractClassicEntityConsumer(final int initialBufferSize, final Executor executor)

Method Summary

Modifier and TypeMethod and Description
public final void
consume(final ByteBuffer
data source.
src
)

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.consume.

Triggered to pass incoming data to the data consumer.
protected abstract T

Returns:

the result of entity processing.
consumeData
(ContentType
the entity content type
contentType
,
InputStream
the input stream
inputStream
)

Processes entity data from the given stream.

public final void
failed(final Exception
the cause of the failure.
cause
)

Implements org.apache.hc.core5.http.nio.AsyncEntityConsumer.failed.

Triggered to signal a failure in data processing.
public final T
getContent()

Implements org.apache.hc.core5.http.nio.AsyncEntityConsumer.getContent.

Returns the result of entity processing when it becomes available or null if the entity is still being received.
public final Exception
public void
public final void
streamEnd(final List<? extends Header>
data stream trailers.
trailers
)

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.streamEnd.

Triggered to signal termination of the data stream.
public final void
streamStart(final EntityDetails
the details of the incoming message entity.
entityDetails
,
final FutureCallback<T>
the result callback.
resultCallback
)

Implements org.apache.hc.core5.http.nio.AsyncEntityConsumer.streamStart.

Signals beginning of an incoming request entity stream.
public final void
updateCapacity(final CapacityChannel
the channel for capacity updates.
capacityChannel
)

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.updateCapacity.

Triggered to signal ability of the underlying data stream to receive data capacity update.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private final SharedInputBuffer buffer
exceptionRefback to summary
private final AtomicReference<Exception> exceptionRef
executorback to summary
private final Executor executor
resultRefback to summary
private final AtomicReference<T> resultRef
stateback to summary
private final AtomicReference<AbstractClassicEntityConsumer.State> state

Constructor Detail

AbstractClassicEntityConsumerback to summary
public AbstractClassicEntityConsumer(final int initialBufferSize, final Executor executor)

Method Detail

consumeback to summary
public final void consume(final ByteBuffer src) throws IOException

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.consume.

Doc from org.apache.hc.core5.http.nio.AsyncDataConsumer.consume.

Triggered to pass incoming data to the data consumer. The consumer must consume the entire content of the data buffer. The consumer must stop incrementing its capacity on the capacity channel if it is unable to accept more data. Once the data consumer has handled accumulated data or allocated more intermediate storage it can update its capacity information on the capacity channel.

Parameters
src:ByteBuffer

data source.

Annotations
@Override
consumeDataback to summary
protected abstract T consumeData(ContentType contentType, InputStream inputStream) throws IOException

Processes entity data from the given stream.

Parameters
contentType:ContentType

the entity content type

inputStream:InputStream

the input stream

Returns:T

the result of entity processing.

failedback to summary
public final void failed(final Exception cause)

Implements org.apache.hc.core5.http.nio.AsyncEntityConsumer.failed.

Doc from org.apache.hc.core5.http.nio.AsyncEntityConsumer.failed.

Triggered to signal a failure in data processing.

Parameters
cause:Exception

the cause of the failure.

Annotations
@Override
getContentback to summary
public final T getContent()

Implements org.apache.hc.core5.http.nio.AsyncEntityConsumer.getContent.

Doc from org.apache.hc.core5.http.nio.AsyncEntityConsumer.getContent.

Returns the result of entity processing when it becomes available or null if the entity is still being received.

Returns:T

the response processing result.

Annotations
@Override
getExceptionback to summary
public final Exception getException()
releaseResourcesback to summary
public void releaseResources()

Implements org.apache.hc.core5.http.nio.ResourceHolder.releaseResources.

Annotations
@Override
streamEndback to summary
public final void streamEnd(final List<? extends Header> trailers) throws HttpException, IOException

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.streamEnd.

Doc from org.apache.hc.core5.http.nio.AsyncDataConsumer.streamEnd.

Triggered to signal termination of the data stream.

Parameters
trailers:List<? extends Header>

data stream trailers.

Annotations
@Override
streamStartback to summary
public final void streamStart(final EntityDetails entityDetails, final FutureCallback<T> resultCallback) throws HttpException, IOException

Implements org.apache.hc.core5.http.nio.AsyncEntityConsumer.streamStart.

Doc from org.apache.hc.core5.http.nio.AsyncEntityConsumer.streamStart.

Signals beginning of an incoming request entity stream.

Parameters
entityDetails:EntityDetails

the details of the incoming message entity.

resultCallback:FutureCallback<T>

the result callback.

Annotations
@Override
updateCapacityback to summary
public final void updateCapacity(final CapacityChannel capacityChannel) throws IOException

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.updateCapacity.

Doc from org.apache.hc.core5.http.nio.AsyncDataConsumer.updateCapacity.

Triggered to signal ability of the underlying data stream to receive data capacity update. The data consumer can choose to write data immediately inside the call or asynchronously at some later point.

Parameters
capacityChannel:CapacityChannel

the channel for capacity updates.

Annotations
@Override
org.apache.hc.core5.http.nio.support.classic back to summary

private final Enum AbstractClassicEntityConsumer.State

extends Enum<AbstractClassicEntityConsumer.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final AbstractClassicEntityConsumer.State
public static final AbstractClassicEntityConsumer.State
public static final AbstractClassicEntityConsumer.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static AbstractClassicEntityConsumer.State
public static AbstractClassicEntityConsumer.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ACTIVEback to summary
public static final AbstractClassicEntityConsumer.State ACTIVE
COMPLETEDback to summary
public static final AbstractClassicEntityConsumer.State COMPLETED
IDLEback to summary
public static final AbstractClassicEntityConsumer.State IDLE

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static AbstractClassicEntityConsumer.State valueOf(String name)
valuesback to summary
public static AbstractClassicEntityConsumer.State[] values()