Class AbstractCharResponseConsumer<T>

  • Type Parameters:
    T - response message representation.
    All Implemented Interfaces:
    org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.AsyncResponseConsumer<T>, org.apache.hc.core5.http.nio.ResourceHolder

    public abstract class AbstractCharResponseConsumer<T>
    extends org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer
    implements org.apache.hc.core5.http.nio.AsyncResponseConsumer<T>
    Abstract response consumer that processes response body data as a character stream.
    Since:
    5.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.nio.charset.Charset defaultCharset  
      private org.apache.hc.core5.concurrent.FutureCallback<T> resultCallback  
      • Fields inherited from class org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer

        DEF_BUF_SIZE
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract T buildResult()
      Triggered to generate object that represents a result of response message processing.
      protected void completed()  
      void consumeResponse​(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.EntityDetails entityDetails, org.apache.hc.core5.http.protocol.HttpContext context, org.apache.hc.core5.concurrent.FutureCallback<T> resultCallback)  
      void failed​(java.lang.Exception cause)  
      void informationResponse​(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.protocol.HttpContext context)  
      protected abstract void start​(org.apache.hc.core5.http.HttpResponse response, org.apache.hc.core5.http.ContentType contentType)
      Triggered to signal the beginning of data processing.
      • Methods inherited from class org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer

        capacityIncrement, consume, data, setCharset, streamEnd, updateCapacity
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.hc.core5.http.nio.AsyncDataConsumer

        consume, streamEnd, updateCapacity
      • Methods inherited from interface org.apache.hc.core5.http.nio.ResourceHolder

        releaseResources
    • Field Detail

      • resultCallback

        private volatile org.apache.hc.core5.concurrent.FutureCallback<T> resultCallback
      • defaultCharset

        private final java.nio.charset.Charset defaultCharset
    • Constructor Detail

      • AbstractCharResponseConsumer

        public AbstractCharResponseConsumer()
      • AbstractCharResponseConsumer

        protected AbstractCharResponseConsumer​(int bufSize,
                                               org.apache.hc.core5.http.config.CharCodingConfig charCodingConfig)
    • Method Detail

      • start

        protected abstract void start​(org.apache.hc.core5.http.HttpResponse response,
                                      org.apache.hc.core5.http.ContentType contentType)
                               throws org.apache.hc.core5.http.HttpException,
                                      java.io.IOException
        Triggered to signal the beginning of data processing.
        Parameters:
        response - the response message head
        contentType - the content type of the response body, or null if the response does not enclose a response entity.
        Throws:
        org.apache.hc.core5.http.HttpException
        java.io.IOException
      • buildResult

        protected abstract T buildResult()
                                  throws java.io.IOException
        Triggered to generate object that represents a result of response message processing.
        Returns:
        the result of response processing.
        Throws:
        java.io.IOException
      • informationResponse

        public void informationResponse​(org.apache.hc.core5.http.HttpResponse response,
                                        org.apache.hc.core5.http.protocol.HttpContext context)
                                 throws org.apache.hc.core5.http.HttpException,
                                        java.io.IOException
        Specified by:
        informationResponse in interface org.apache.hc.core5.http.nio.AsyncResponseConsumer<T>
        Throws:
        org.apache.hc.core5.http.HttpException
        java.io.IOException
      • consumeResponse

        public final void consumeResponse​(org.apache.hc.core5.http.HttpResponse response,
                                          org.apache.hc.core5.http.EntityDetails entityDetails,
                                          org.apache.hc.core5.http.protocol.HttpContext context,
                                          org.apache.hc.core5.concurrent.FutureCallback<T> resultCallback)
                                   throws org.apache.hc.core5.http.HttpException,
                                          java.io.IOException
        Specified by:
        consumeResponse in interface org.apache.hc.core5.http.nio.AsyncResponseConsumer<T>
        Throws:
        org.apache.hc.core5.http.HttpException
        java.io.IOException
      • completed

        protected final void completed()
                                throws java.io.IOException
        Specified by:
        completed in class org.apache.hc.core5.http.nio.entity.AbstractCharDataConsumer
        Throws:
        java.io.IOException
      • failed

        public void failed​(java.lang.Exception cause)
        Specified by:
        failed in interface org.apache.hc.core5.http.nio.AsyncResponseConsumer<T>