Class AsyncCharConsumer<T>

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.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

      Fields 
      Modifier and Type Field Description
      private java.nio.ByteBuffer bbuf  
      private java.nio.CharBuffer cbuf  
      private java.nio.charset.CharsetDecoder chardecoder  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.nio.charset.CharsetDecoder createDecoder​(org.apache.http.entity.ContentType contentType)
      Invoked to create a @{link CharsetDecoder} for contentType.
      private void handleDecodingResult​(java.nio.charset.CoderResult result, org.apache.http.nio.IOControl ioctrl)  
      protected abstract void onCharReceived​(java.nio.CharBuffer buf, org.apache.http.nio.IOControl ioctrl)
      Invoked to process a chunk of content.
      protected void onContentReceived​(org.apache.http.nio.ContentDecoder decoder, org.apache.http.nio.IOControl ioctrl)  
      protected void onEntityEnclosed​(org.apache.http.HttpEntity entity, org.apache.http.entity.ContentType contentType)  
      protected void releaseResources()  
      • Methods inherited from class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer

        buildResult, cancel, close, consumeContent, failed, getContentType, getException, getResult, isDone, onClose, onResponseReceived, responseCompleted, responseReceived
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • bbuf

        private final java.nio.ByteBuffer bbuf
      • cbuf

        private final java.nio.CharBuffer cbuf
      • chardecoder

        private java.nio.charset.CharsetDecoder chardecoder
    • Constructor Detail

      • AsyncCharConsumer

        public AsyncCharConsumer​(int bufSize)
      • AsyncCharConsumer

        public AsyncCharConsumer()
    • Method Detail

      • onCharReceived

        protected abstract void onCharReceived​(java.nio.CharBuffer buf,
                                               org.apache.http.nio.IOControl ioctrl)
                                        throws java.io.IOException
        Invoked to process a chunk of content. The IOControl interface 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:
        java.io.IOException - in case of an I/O error
      • createDecoder

        protected java.nio.charset.CharsetDecoder createDecoder​(org.apache.http.entity.ContentType contentType)
        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 java.io.IOException
        Specified by:
        onEntityEnclosed in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
        Throws:
        java.io.IOException
      • onContentReceived

        protected final void onContentReceived​(org.apache.http.nio.ContentDecoder decoder,
                                               org.apache.http.nio.IOControl ioctrl)
                                        throws java.io.IOException
        Specified by:
        onContentReceived in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
        Throws:
        java.io.IOException
      • handleDecodingResult

        private void handleDecodingResult​(java.nio.charset.CoderResult result,
                                          org.apache.http.nio.IOControl ioctrl)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • releaseResources

        protected void releaseResources()
        Specified by:
        releaseResources in class org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>