Class HttpAuWriter

  • All Implemented Interfaces:
    AuWriter

    public class HttpAuWriter
    extends java.lang.Object
    implements AuWriter
    The writer used to write the output back to the client.
    Since:
    3.0.1
    Author:
    tomyeh
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpAuWriter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close​(java.lang.Object request, java.lang.Object response)
      Closes the writer and flush the result to client.
      java.lang.Object complete()
      Indicates the writing has been completed.
      protected void flush​(java.lang.Object request, java.lang.Object response, boolean bCompress)
      Flush the result of responses to client.
      boolean isCompress()
      Returns whether to compress the output.
      AuWriter open​(java.lang.Object request, java.lang.Object response)
      Opens the connection.
      void resend​(java.lang.Object prevContent)
      Resend the content of the previous request returned by AuWriter.complete().
      protected byte[] restore​(java.lang.Object data)
      Called to decode the last response for repeated request before retrieving.
      protected java.lang.Object save​(byte[] data)
      Called to encode the last response for repeated request before storing.
      void setCompress​(boolean compress)
      Sets whether to compress the output with GZIP.
      void write​(java.util.Collection<AuResponse> responses)
      Generates a list of responses to the output.
      void write​(AuResponse response)
      Generates the specified the response to the output.
      void writeResponseId​(int resId)
      Generates the response ID to the output.
      • Methods inherited from class java.lang.Object

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

      • HttpAuWriter

        public HttpAuWriter()
    • Method Detail

      • isCompress

        public boolean isCompress()
        Returns whether to compress the output.
        Since:
        3.6.3
      • setCompress

        public void setCompress​(boolean compress)
        Description copied from interface: AuWriter
        Sets whether to compress the output with GZIP.

        Default: true.

        Specified by:
        setCompress in interface AuWriter
      • open

        public AuWriter open​(java.lang.Object request,
                             java.lang.Object response)
                      throws java.io.IOException
        Opens the connection.

        Default: it creates an object to store the responses.

        Specified by:
        open in interface AuWriter
        Parameters:
        request - the request (HttpServletRequest if HTTP)
        response - the response (HttpServletResponse if HTTP)
        Returns:
        this object
        Throws:
        java.io.IOException
      • close

        public void close​(java.lang.Object request,
                          java.lang.Object response)
                   throws java.io.IOException
        Description copied from interface: AuWriter
        Closes the writer and flush the result to client.
        Specified by:
        close in interface AuWriter
        Parameters:
        request - the request (HttpServletRequest if HTTP)
        response - the response (HttpServletResponse if HTTP)
        Throws:
        java.io.IOException
      • flush

        protected void flush​(java.lang.Object request,
                             java.lang.Object response,
                             boolean bCompress)
                      throws java.io.IOException
        Flush the result of responses to client.
        Parameters:
        bCompress - whether to compress (if allowed).
        Throws:
        java.io.IOException
        Since:
        5.0.4
      • save

        protected java.lang.Object save​(byte[] data)
        Called to encode the last response for repeated request before storing.

        Default: does nothing but return the input argument, data. The derived class might override this method to compress it.

        Since:
        5.0.4
        See Also:
        restore(java.lang.Object)
      • restore

        protected byte[] restore​(java.lang.Object data)
        Called to decode the last response for repeated request before retrieving.

        Default: does nothing but return the input argument, data. The derived class might override this method to uncompress it.

        Parameters:
        data - the data returned by save(byte[])
        Returns:
        the byte array that is passed to save(byte[]).
        Since:
        5.0.4
      • write

        public void write​(AuResponse response)
                   throws java.io.IOException
        Description copied from interface: AuWriter
        Generates the specified the response to the output.
        Specified by:
        write in interface AuWriter
        Throws:
        java.io.IOException
      • write

        public void write​(java.util.Collection<AuResponse> responses)
                   throws java.io.IOException
        Description copied from interface: AuWriter
        Generates a list of responses to the output.
        Specified by:
        write in interface AuWriter
        Throws:
        java.io.IOException