Class AsyncCharConsumer<T>
java.lang.Object
org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
org.apache.http.nio.client.methods.AsyncCharConsumer<T>
- All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.concurrent.Cancellable, org.apache.http.nio.protocol.HttpAsyncResponseConsumer<T>
public abstract class AsyncCharConsumer<T>
extends org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
HttpAsyncResponseConsumer implementation that
provides convenience methods for processing of textual content entities enclosed
in an HTTP response.- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteBufferprivate final CharBufferprivate CharsetDecoder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected CharsetDecodercreateDecoder(org.apache.http.entity.ContentType contentType) Invoked to create a @{link CharsetDecoder} for contentType.private voidhandleDecodingResult(CoderResult result, org.apache.http.nio.IOControl ioctrl) protected abstract voidonCharReceived(CharBuffer buf, org.apache.http.nio.IOControl ioctrl) Invoked to process achunkof content.protected final voidonContentReceived(org.apache.http.nio.ContentDecoder decoder, org.apache.http.nio.IOControl ioctrl) protected final voidonEntityEnclosed(org.apache.http.HttpEntity entity, org.apache.http.entity.ContentType contentType) protected voidMethods inherited from class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer
buildResult, cancel, close, consumeContent, failed, getContentType, getException, getResult, isDone, onClose, onResponseReceived, responseCompleted, responseReceived
-
Field Details
-
bbuf
-
cbuf
-
chardecoder
-
-
Constructor Details
-
AsyncCharConsumer
public AsyncCharConsumer(int bufSize) -
AsyncCharConsumer
public AsyncCharConsumer()
-
-
Method Details
-
onCharReceived
protected abstract void onCharReceived(CharBuffer buf, org.apache.http.nio.IOControl ioctrl) throws IOException Invoked to process achunkof content. TheIOControlinterface can be used to suspend input events if the consumer is temporarily unable to consume more content.- Parameters:
buf- chunk of content.ioctrl- I/O control of the underlying connection.- Throws:
IOException- in case of an I/O error
-
createDecoder
Invoked to create a @{link CharsetDecoder} for contentType. This allows to use different default charsets for different content types and set appropriate coding error actions.- Parameters:
contentType- response Content-Type or null if not specified.- Returns:
- content decoder.
- Since:
- 4.1
-
onEntityEnclosed
protected final void onEntityEnclosed(org.apache.http.HttpEntity entity, org.apache.http.entity.ContentType contentType) throws IOException - Specified by:
onEntityEnclosedin classorg.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>- Throws:
IOException
-
onContentReceived
protected final void onContentReceived(org.apache.http.nio.ContentDecoder decoder, org.apache.http.nio.IOControl ioctrl) throws IOException - Specified by:
onContentReceivedin classorg.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>- Throws:
IOException
-
handleDecodingResult
private void handleDecodingResult(CoderResult result, org.apache.http.nio.IOControl ioctrl) throws IOException - Throws:
IOException
-
releaseResources
protected void releaseResources()- Specified by:
releaseResourcesin classorg.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
-