Package cloud.piranha

Class DefaultWebApplicationResponse

  • java.lang.Object
    • java.io.OutputStream
      • javax.servlet.ServletOutputStream
        • cloud.piranha.DefaultWebApplicationResponse
  • All Implemented Interfaces:
    cloud.piranha.api.WebApplicationResponse, javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse
    Direct Known Subclasses:
    DefaultWebApplicationServerResponse


    public class DefaultWebApplicationResponse
    extends javax.servlet.ServletOutputStream
    implements cloud.piranha.api.WebApplicationResponse
    The default WebApplicationResponse.
    Author:
    Manfred Riem (mriem@manorrock.com)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean bodyOnly
      Stores the body only flag.
      protected byte[] buffer
      Stores the buffer.
      protected java.lang.String characterEncoding
      Stores the character encoding.
      protected boolean characterEncodingSet
      Stores if the character encoding has been set manually.
      protected boolean committed
      Stores the committed flag.
      protected long contentLength
      Stores the content length.
      protected java.lang.String contentType
      Stores the content type.
      protected boolean contentTypeSet
      Stores if the content type has been set manually.
      protected java.util.List<javax.servlet.http.Cookie> cookies
      Stores the cookies.
      protected boolean gotOutput
      Stores if we acquired the output stream.
      protected boolean gotWriter
      Stores if we acquired the writer.
      protected DefaultHttpHeaderManager headerManager
      Stores the header manager.
      protected int index
      Stores the index.
      protected java.util.Locale locale
      Stores the locale.
      protected java.io.OutputStream outputStream
      Stores the output stream.
      protected int status
      Stores the status code.
      protected java.lang.String statusMessage
      Stores the status message.
      protected cloud.piranha.api.WebApplication webApplication
      Stores the web application.
      protected java.io.PrintWriter writer
      Stores the writer.
      • Fields inherited from interface javax.servlet.http.HttpServletResponse

        SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addCookie​(javax.servlet.http.Cookie cookie)
      Add the cookie.
      void addDateHeader​(java.lang.String name, long date)
      Add the date header.
      void addHeader​(java.lang.String name, java.lang.String value)
      Add the header.
      void addIntHeader​(java.lang.String name, int value)
      Add the integer header.
      void close​()
      Close the output stream.
      boolean containsHeader​(java.lang.String name)
      Contains the given header.
      java.lang.String encodeRedirectUrl​(java.lang.String url)
      Deprecated.  
      java.lang.String encodeRedirectURL​(java.lang.String url)
      Encode the redirect URL.
      java.lang.String encodeUrl​(java.lang.String url)
      Deprecated.  
      java.lang.String encodeURL​(java.lang.String url)
      Encode the URL.
      void flush​()
      Flush the output stream.
      void flushBuffer​()
      Flush the buffer.
      int getBufferSize​()
      Get the buffer size.
      java.lang.String getCharacterEncoding​()
      Get the character encoding.
      long getContentLength​()
      Get the content length.
      java.lang.String getContentType​()
      Get the content type.
      java.util.Collection<javax.servlet.http.Cookie> getCookies​()
      Get the cookies.
      java.lang.String getHeader​(java.lang.String name)
      Get the header.
      java.util.Collection<java.lang.String> getHeaderNames​()
      Get the header names.
      java.util.Collection<java.lang.String> getHeaders​(java.lang.String name)
      Get the headers.
      java.util.Locale getLocale​()
      Get the locale.
      javax.servlet.ServletOutputStream getOutputStream​()
      Get the output stream.
      int getStatus​()
      Get the status.
      java.lang.String getStatusMessage​()
      Get the status message.
      java.io.OutputStream getUnderlyingOutputStream​()
      Get the underlying output stream.
      cloud.piranha.api.WebApplication getWebApplication​()
      Get the web application.
      java.io.PrintWriter getWriter​()
      Get the writer.
      boolean isBodyOnly​()
      Is body only.
      boolean isCommitted​()
      Is committed.
      boolean isReady​()
      Is the output stream ready?
      void reset​()
      Reset the response.
      void resetBuffer​()
      Reset the buffer.
      void sendError​(int status)
      Send an error.
      void sendError​(int status, java.lang.String statusMessage)
      Send the error.
      void sendRedirect​(java.lang.String location)
      Send the redirect.
      void setBodyOnly​(boolean bodyOnly)
      Set the body only flag.
      void setBufferSize​(int bufferSize)
      Set the buffer size.
      void setCharacterEncoding​(java.lang.String characterEncoding)
      Set the character encoding.
      void setCommitted​(boolean committed)
      Set the committed.
      void setContentLength​(int contentLength)
      Set the content length.
      void setContentLengthLong​(long contentLength)
      Set the content length.
      void setContentType​(java.lang.String type)
      Set the content type.
      void setDateHeader​(java.lang.String name, long date)
      Set the date header.
      void setHeader​(java.lang.String name, java.lang.String value)
      Set the header.
      void setIntHeader​(java.lang.String name, int value)
      Set the int header.
      void setLocale​(java.util.Locale locale)
      Set the locale.
      void setOutputStream​(javax.servlet.ServletOutputStream outputStream)
      Set the output stream.
      void setStatus​(int status)
      Set the status.
      void setStatus​(int status, java.lang.String statusMessage)
      Deprecated.  
      void setUnderlyingOutputStream​(java.io.OutputStream outputStream)
      Set the underlying output stream.
      void setWebApplication​(cloud.piranha.api.WebApplication webApplication)
      Set the web application.
      void setWriteListener​(javax.servlet.WriteListener listener)
      Set the write listener.
      protected void verifyNotCommitted​(java.lang.String methodName)
      Verify we are not committed.
      void write​(int integer)
      Write the integer.
      • Methods inherited from interface javax.servlet.http.HttpServletResponse

        getTrailerFields, setTrailerFields
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from class java.io.OutputStream

        write, write
      • Methods inherited from class javax.servlet.ServletOutputStream

        print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
    • Field Detail

      • bodyOnly

        protected boolean bodyOnly
        Stores the body only flag.
      • buffer

        protected byte[] buffer
        Stores the buffer.
      • characterEncoding

        protected java.lang.String characterEncoding
        Stores the character encoding.
      • characterEncodingSet

        protected boolean characterEncodingSet
        Stores if the character encoding has been set manually.
      • committed

        protected boolean committed
        Stores the committed flag.
      • contentLength

        protected long contentLength
        Stores the content length.
      • contentType

        protected java.lang.String contentType
        Stores the content type.
      • contentTypeSet

        protected boolean contentTypeSet
        Stores if the content type has been set manually.
      • cookies

        protected java.util.List<javax.servlet.http.Cookie> cookies
        Stores the cookies.
      • gotOutput

        protected boolean gotOutput
        Stores if we acquired the output stream.
      • gotWriter

        protected boolean gotWriter
        Stores if we acquired the writer.
      • index

        protected int index
        Stores the index.
      • locale

        protected java.util.Locale locale
        Stores the locale.
      • writer

        protected java.io.PrintWriter writer
        Stores the writer.
      • outputStream

        protected java.io.OutputStream outputStream
        Stores the output stream.
      • status

        protected int status
        Stores the status code.
      • statusMessage

        protected java.lang.String statusMessage
        Stores the status message.
      • webApplication

        protected cloud.piranha.api.WebApplication webApplication
        Stores the web application.
    • Constructor Detail

      • DefaultWebApplicationResponse

        public DefaultWebApplicationResponse​()
        Constructor.
    • Method Detail

      • addCookie

        public void addCookie​(javax.servlet.http.Cookie cookie)
        Add the cookie.
        Specified by:
        addCookie in interface javax.servlet.http.HttpServletResponse
        Parameters:
        cookie - the cookie.
      • addDateHeader

        public void addDateHeader​(java.lang.String name,
                                  long date)
        Add the date header.
        Specified by:
        addDateHeader in interface javax.servlet.http.HttpServletResponse
        Parameters:
        name - the header name.
        date - the header date value.
      • addHeader

        public void addHeader​(java.lang.String name,
                              java.lang.String value)
        Add the header.
        Specified by:
        addHeader in interface javax.servlet.http.HttpServletResponse
        Parameters:
        name - the name.
        value - the value.
      • addIntHeader

        public void addIntHeader​(java.lang.String name,
                                 int value)
        Add the integer header.
        Specified by:
        addIntHeader in interface javax.servlet.http.HttpServletResponse
        Parameters:
        name - the name of the header.
        value - the value of the header.
      • containsHeader

        public boolean containsHeader​(java.lang.String name)
        Contains the given header.
        Specified by:
        containsHeader in interface javax.servlet.http.HttpServletResponse
        Parameters:
        name - the header name.
        Returns:
        true if there, false otherwise.
      • encodeRedirectURL

        public java.lang.String encodeRedirectURL​(java.lang.String url)
        Encode the redirect URL.
        Specified by:
        encodeRedirectURL in interface javax.servlet.http.HttpServletResponse
        Parameters:
        url - the url.
        Returns:
        the encoded redirect url.
      • encodeRedirectUrl

        public java.lang.String encodeRedirectUrl​(java.lang.String url)
        Deprecated. 
        Encode the redirect url.
        Specified by:
        encodeRedirectUrl in interface javax.servlet.http.HttpServletResponse
        Parameters:
        url - the url.
        Returns:
        the encoded redirect url.
      • encodeURL

        public java.lang.String encodeURL​(java.lang.String url)
        Encode the URL.
        Specified by:
        encodeURL in interface javax.servlet.http.HttpServletResponse
        Parameters:
        url - the URL.
        Returns:
        the encoded url.
      • encodeUrl

        public java.lang.String encodeUrl​(java.lang.String url)
        Deprecated. 
        Encode the url.
        Specified by:
        encodeUrl in interface javax.servlet.http.HttpServletResponse
        Parameters:
        url - the url.
        Returns:
        the encoded url.
      • flushBuffer

        public void flushBuffer​()
                         throws java.io.IOException
        Flush the buffer.
        Specified by:
        flushBuffer in interface javax.servlet.ServletResponse
        Throws:
        java.io.IOException - when an I/O error occurs.
      • getCharacterEncoding

        public java.lang.String getCharacterEncoding​()
        Get the character encoding.
        Specified by:
        getCharacterEncoding in interface javax.servlet.ServletResponse
        Returns:
        the character encoding.
      • getBufferSize

        public int getBufferSize​()
        Get the buffer size.
        Specified by:
        getBufferSize in interface javax.servlet.ServletResponse
        Returns:
        the buffer size.
      • getContentLength

        public long getContentLength​()
        Get the content length.
        Returns:
        the content length.
      • getContentType

        public java.lang.String getContentType​()
        Get the content type.
        Specified by:
        getContentType in interface javax.servlet.ServletResponse
        Returns:
        the content type.
      • getHeader

        public java.lang.String getHeader​(java.lang.String name)
        Get the header.
        Specified by:
        getHeader in interface javax.servlet.http.HttpServletResponse
        Parameters:
        name - the header name.
        Returns:
        the value.
      • getHeaderNames

        public java.util.Collection<java.lang.String> getHeaderNames​()
        Get the header names.
        Specified by:
        getHeaderNames in interface javax.servlet.http.HttpServletResponse
        Returns:
        the collection.
      • getHeaders

        public java.util.Collection<java.lang.String> getHeaders​(java.lang.String name)
        Get the headers.
        Specified by:
        getHeaders in interface javax.servlet.http.HttpServletResponse
        Parameters:
        name - the name of the header.
        Returns:
        the collection.
      • getLocale

        public java.util.Locale getLocale​()
        Get the locale.
        Specified by:
        getLocale in interface javax.servlet.ServletResponse
        Returns:
        the locale.
      • getOutputStream

        public javax.servlet.ServletOutputStream getOutputStream​()
                                                          throws java.io.IOException
        Get the output stream.
        Specified by:
        getOutputStream in interface javax.servlet.ServletResponse
        Returns:
        the output stream.
        Throws:
        java.io.IOException - when an I/O error occurs.
      • getStatus

        public int getStatus​()
        Get the status.
        Specified by:
        getStatus in interface javax.servlet.http.HttpServletResponse
        Returns:
        the status.
      • getStatusMessage

        public java.lang.String getStatusMessage​()
        Get the status message.
        Returns:
        the status message.
      • getWebApplication

        public cloud.piranha.api.WebApplication getWebApplication​()
        Get the web application.
        Returns:
        the web application.
      • getWriter

        public java.io.PrintWriter getWriter​()
                                      throws java.io.IOException
        Get the writer.
        Specified by:
        getWriter in interface javax.servlet.ServletResponse
        Returns:
        the writer.
        Throws:
        java.io.IOException - when an I/O error occurs.
      • isBodyOnly

        public boolean isBodyOnly​()
        Is body only.
        Returns:
        true if we are only sending the body, false otherwise.
      • isCommitted

        public boolean isCommitted​()
        Is committed.
        Specified by:
        isCommitted in interface javax.servlet.ServletResponse
        Returns:
        the committed flag.
      • reset

        public void reset​()
        Reset the response.
        Specified by:
        reset in interface javax.servlet.ServletResponse
      • resetBuffer

        public void resetBuffer​()
        Reset the buffer.
        Specified by:
        resetBuffer in interface javax.servlet.ServletResponse
      • sendError

        public void sendError​(int status)
                       throws java.io.IOException
        Send an error.
        Specified by:
        sendError in interface javax.servlet.http.HttpServletResponse
        Parameters:
        status - the error code.
        Throws:
        java.io.IOException - when an I/O error occurs.
      • sendError

        public void sendError​(int status,
                              java.lang.String statusMessage)
                       throws java.io.IOException
        Send the error.
        Specified by:
        sendError in interface javax.servlet.http.HttpServletResponse
        Parameters:
        status - the status code.
        statusMessage - the message.
        Throws:
        java.io.IOException - when an I/O error occurs.
      • sendRedirect

        public void sendRedirect​(java.lang.String location)
                          throws java.io.IOException
        Send the redirect.
        Specified by:
        sendRedirect in interface javax.servlet.http.HttpServletResponse
        Parameters:
        location - the location.
        Throws:
        java.io.IOException - when an I/O error occurs.
      • setBodyOnly

        public void setBodyOnly​(boolean bodyOnly)
        Set the body only flag.
        Parameters:
        bodyOnly - flag.
      • setBufferSize

        public void setBufferSize​(int bufferSize)
        Set the buffer size.
        Specified by:
        setBufferSize in interface javax.servlet.ServletResponse
        Parameters:
        bufferSize - the buffer size.
      • setCharacterEncoding

        public void setCharacterEncoding​(java.lang.String characterEncoding)
        Set the character encoding.
        Specified by:
        setCharacterEncoding in interface javax.servlet.ServletResponse
        Parameters:
        characterEncoding - the character encoding.
      • setCommitted

        public void setCommitted​(boolean committed)
        Set the committed.
        Parameters:
        committed - the committed flag.
      • setContentLength

        public void setContentLength​(int contentLength)
        Set the content length.
        Specified by:
        setContentLength in interface javax.servlet.ServletResponse
        Parameters:
        contentLength - the content length.
      • setContentLengthLong

        public void setContentLengthLong​(long contentLength)
        Set the content length.
        Specified by:
        setContentLengthLong in interface javax.servlet.ServletResponse
        Parameters:
        contentLength - the content length.
      • setContentType

        public void setContentType​(java.lang.String type)
        Set the content type.
        Specified by:
        setContentType in interface javax.servlet.ServletResponse
        Parameters:
        type - the content type.
      • setDateHeader

        public void setDateHeader​(java.lang.String name,
                                  long date)
        Set the date header.
        Specified by:
        setDateHeader in interface javax.servlet.http.HttpServletResponse
        Parameters:
        name - the header name.
        date - the date.
      • setHeader

        public void setHeader​(java.lang.String name,
                              java.lang.String value)
        Set the header.
        Specified by:
        setHeader in interface javax.servlet.http.HttpServletResponse
        Parameters:
        name - the name.
        value - the value.
      • setIntHeader

        public void setIntHeader​(java.lang.String name,
                                 int value)
        Set the int header.
        Specified by:
        setIntHeader in interface javax.servlet.http.HttpServletResponse
        Parameters:
        name - the header name.
        value - the header value.
      • setLocale

        public void setLocale​(java.util.Locale locale)
        Set the locale.
        Specified by:
        setLocale in interface javax.servlet.ServletResponse
        Parameters:
        locale - the locale.
      • setOutputStream

        public void setOutputStream​(javax.servlet.ServletOutputStream outputStream)
        Set the output stream.
        Parameters:
        outputStream - the output stream.
      • setStatus

        public void setStatus​(int status)
        Set the status.
        Specified by:
        setStatus in interface javax.servlet.http.HttpServletResponse
        Parameters:
        status - the status code.
      • setStatus

        public void setStatus​(int status,
                              java.lang.String statusMessage)
        Deprecated. 
        Set the status.
        Specified by:
        setStatus in interface javax.servlet.http.HttpServletResponse
        Parameters:
        status - the status.
        statusMessage - the message
      • setWebApplication

        public void setWebApplication​(cloud.piranha.api.WebApplication webApplication)
        Set the web application.
        Parameters:
        webApplication - the web application.
      • verifyNotCommitted

        protected void verifyNotCommitted​(java.lang.String methodName)
        Verify we are not committed.
        Parameters:
        methodName - the method we are checking for.
      • getCookies

        public java.util.Collection<javax.servlet.http.Cookie> getCookies​()
        Get the cookies.
        Specified by:
        getCookies in interface cloud.piranha.api.WebApplicationResponse
        Returns:
        the cookies.
      • getUnderlyingOutputStream

        public java.io.OutputStream getUnderlyingOutputStream​()
        Get the underlying output stream.
        Specified by:
        getUnderlyingOutputStream in interface cloud.piranha.api.WebApplicationResponse
        Returns:
        the underlying output stream.
      • setUnderlyingOutputStream

        public void setUnderlyingOutputStream​(java.io.OutputStream outputStream)
        Set the underlying output stream.
        Specified by:
        setUnderlyingOutputStream in interface cloud.piranha.api.WebApplicationResponse
        Parameters:
        outputStream - the underlying output stream.
      • close

        public void close​()
                   throws java.io.IOException
        Close the output stream.
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException - when an I/O error occurs.
      • flush

        public void flush​()
                   throws java.io.IOException
        Flush the output stream.
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException - when an I/O error occurs.
      • isReady

        public boolean isReady​()
        Is the output stream ready?
        Specified by:
        isReady in class javax.servlet.ServletOutputStream
        Returns:
        true if it is, false otherwise.
      • setWriteListener

        public void setWriteListener​(javax.servlet.WriteListener listener)
        Set the write listener.
        Specified by:
        setWriteListener in class javax.servlet.ServletOutputStream
        Parameters:
        listener - the write listener.
      • write

        public void write​(int integer)
                   throws java.io.IOException
        Write the integer.
        Specified by:
        write in class java.io.OutputStream
        Parameters:
        integer - the integer.
        Throws:
        java.io.IOException - when an I/O error occurs.

Copyright © 2020 Piranha Cloud. All rights reserved.