Top Description Fields Constructors Methods
org.apache.hc.core5.http.nio.entity

public abstract Class AbstractCharDataConsumer

extends Object
implements AsyncDataConsumer
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.ResourceHolder
Known Direct Subclasses
org.apache.hc.core5.http.nio.entity.AbstractCharAsyncEntityConsumer
Imports
java.io.IOException, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, .CharsetDecoder, .CoderResult, .StandardCharsets, java.util.List, org.apache.hc.core5.http.Header, .HttpException, org.apache.hc.core5.http.config.CharCodingConfig, org.apache.hc.core5.http.nio.AsyncDataConsumer, .CapacityChannel, org.apache.hc.core5.util.Args

Abstract text data consumer.
Since
5.0

Field Summary

Modifier and TypeField and Description
private volatile ByteBuffer
private final CharBuffer
private final CharCodingConfig
private volatile Charset
private volatile CharsetDecoder
protected static final int
private static final ByteBuffer

Constructor Summary

AccessConstructor and Description
protected
AbstractCharDataConsumer(final int bufSize, final CharCodingConfig charCodingConfig)

public

Method Summary

Modifier and TypeMethod and Description
protected abstract int

Returns:

the number of bytes this consumer is prepared to process.
capacityIncrement
()

Triggered to obtain the capacity increment.

private void
checkResult(final CoderResult result)

protected abstract void
completed()

Triggered to signal completion of data processing.

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 void
data(CharBuffer
the data packet.
src
,
boolean
flag indicating whether this data packet is the last in the data stream.
endOfStream
)

Triggered to pass incoming data packet to the data consumer.

private void
doDecode(final boolean endOfStream)

private CharsetDecoder
protected final void
setCharset(final Charset charset)

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
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

byteBufferback to summary
private volatile ByteBuffer byteBuffer
charBufferback to summary
private final CharBuffer charBuffer
charCodingConfigback to summary
private final CharCodingConfig charCodingConfig
charsetback to summary
private volatile Charset charset
charsetDecoderback to summary
private volatile CharsetDecoder charsetDecoder
DEF_BUF_SIZEback to summary
protected static final int DEF_BUF_SIZE
EMPTY_BINback to summary
private static final ByteBuffer EMPTY_BIN

Constructor Detail

AbstractCharDataConsumerback to summary
protected AbstractCharDataConsumer(final int bufSize, final CharCodingConfig charCodingConfig)
AbstractCharDataConsumerback to summary
public AbstractCharDataConsumer()

Method Detail

capacityIncrementback to summary
protected abstract int capacityIncrement()

Triggered to obtain the capacity increment.

Returns:int

the number of bytes this consumer is prepared to process.

checkResultback to summary
private void checkResult(final CoderResult result) throws IOException
completedback to summary
protected abstract void completed() throws IOException

Triggered to signal completion of data processing.

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
databack to summary
protected abstract void data(CharBuffer src, boolean endOfStream) throws IOException

Triggered to pass incoming data packet to the data consumer.

Parameters
src:CharBuffer

the data packet.

endOfStream:boolean

flag indicating whether this data packet is the last in the data stream.

doDecodeback to summary
private void doDecode(final boolean endOfStream) throws IOException
getCharsetDecoderback to summary
private CharsetDecoder getCharsetDecoder()
setCharsetback to summary
protected final void setCharset(final Charset charset)
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
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