org.enhydra.servlet.connectionMethods.EnhydraDirector
Class DirectorResponse

java.lang.Object
  extended byorg.enhydra.servlet.connectionMethods.EnhydraDirector.DirectorResponse
All Implemented Interfaces:
org.apache.catalina.HttpResponse, javax.servlet.http.HttpServletResponse, org.apache.catalina.Response, javax.servlet.ServletResponse

public class DirectorResponse
extends java.lang.Object
implements org.apache.catalina.HttpResponse, javax.servlet.http.HttpServletResponse

Enhydra Director implementation of the response.

Author:
Milin Radivoj

Field Summary
protected  boolean appCommitted
           
protected  EnhydraDirectorConnection connection
           
protected  boolean error
           
protected  boolean included
           
protected  boolean suspended
           
protected  org.apache.catalina.Request wrappedRequest
           
 
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
 
Constructor Summary
DirectorResponse(EnhydraDirectorConnection res)
           
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Add the Cookie to this Response.
 void addDateHeader(java.lang.String name, long date)
          Adds a response header with the given name and date-value.
 void addHeader(java.lang.String name, java.lang.String value)
          Adds a response header with the given name and value.
 void addIntHeader(java.lang.String name, int value)
          Adds a response header with the given name and integer value.
 boolean containsHeader(java.lang.String name)
          Returns a boolean indicating whether the named response header has already been set.
 javax.servlet.ServletOutputStream createOutputStream()
          Create and return a ServletOutputStream to write the content associated with this Response.
 java.lang.String encodeRedirectUrl(java.lang.String url)
           
 java.lang.String encodeRedirectURL(java.lang.String url)
          Encodes the specified URL for use in the sendRedirect method or
 java.lang.String encodeUrl(java.lang.String url)
           
 java.lang.String encodeURL(java.lang.String url)
          Encodes the specified URL by including the session ID in it
 void finishResponse()
          Perform whatever actions are required to close the output
 void flushBuffer()
          Forces any content in the buffer to be written to the client.
 int getBufferSize()
          Returns the actual buffer size used for the response.
 java.lang.String getCharacterEncoding()
          Returns the name of the character encoding (MIME charset) used for the body sent in this response.
 org.apache.catalina.Connector getConnector()
          Return the Connector through which this Response is returned.
 int getContentCount()
          Return the number of bytes actually written to the output stream.
 int getContentLength()
          Return the content length that was set or calculated for this Response.
 java.lang.String getContentType()
          Returns the content type used for the MIME body sent in this response.
 org.apache.catalina.Context getContext()
          Return the Context with which this Response is associated.
 javax.servlet.http.Cookie[] getCookies()
          Get the Cookies associated with this Response.
 java.lang.String getHeader(java.lang.String name)
          Get the Header with the specified name associated with this Response.
 java.lang.String[] getHeaderNames()
          Get the Header Names associated with this Response.
 java.lang.String[] getHeaderValues(java.lang.String name)
          Get the Header Values with the specified name associated with this Response.
 boolean getIncluded()
          Return the "processing inside an include" flag.
 java.lang.String getInfo()
          Return descriptive information about this Response implementation
 java.util.Locale getLocale()
          Returns the locale specified for this response
 java.lang.String getMessage()
          Get the Message associated with this Response.
 javax.servlet.ServletOutputStream getOutputStream()
          Returns a ServletOutputStream suitable for writing binary data in the response.
 java.io.PrintWriter getReporter()
          Return a PrintWriter that can be used to render error messages
 org.apache.catalina.Request getRequest()
          Return the Request with which this Response is associated.
 javax.servlet.ServletResponse getResponse()
          Return the ServletResponse for which this object is the facade.
 int getStatus()
          Get the Status associated with this Response.
 java.io.OutputStream getStream()
          Return the output stream associated with this Response.
 java.io.PrintWriter getWriter()
          Returns a PrintWriter object that can send character text to the client.
 boolean isAppCommitted()
          Application commit flag accessor.
 boolean isCommitted()
          Returns a boolean indicating if the response has been committed.
 boolean isError()
          Error flag accessor.
 boolean isSuspended()
          Suspended flag accessor.
 void recycle()
          Release all object references, and initialize instance variables, in preparation for reuse of this object.
 void reset()
          Clears any data that exists in the buffer as well as the status code and headers.
 void reset(int status, java.lang.String message)
           
 void resetBuffer()
          Clears the content of the underlying buffer in the response without clearing headers or status code.
 void sendAcknowledgement()
          Send an acknowledgment of a request.
 void sendError(int sc)
          Sends an error response to the client using the specified status code
 void sendError(int sc, java.lang.String msg)
          Sends an error response to the client using the specified status.
 void sendRedirect(java.lang.String location)
          Sends a temporary redirect response to the client using the specified redirect location URL.
 void setAppCommitted(boolean appCommitted)
          Set the application commit flag.
 void setBufferSize(int size)
          Sets the preferred buffer size for the body of the response.
 void setCharacterEncoding(java.lang.String charset)
           
 void setConnector(org.apache.catalina.Connector connector)
          Set the Connector through which this Response is returned.
 void setContentLength(int len)
          Sets the length of the content body in the response
 void setContentType(java.lang.String type)
          Sets the content type of the response being sent to the client, if the response has not been committed yet.
 void setContext(org.apache.catalina.Context context)
          Set the Context with which this Response is associated.
 void setDateHeader(java.lang.String name, long date)
          Sets a response header with the given name and date-value.
 void setError()
          Set the error flag.
 void setHeader(java.lang.String name, java.lang.String value)
          Sets a response header with the given name and value.
 void setIncluded(boolean included)
          Set the "processing inside an include" flag.
 void setIntHeader(java.lang.String name, int value)
          Sets a response header with the given name and integer value.
 void setLocale(java.util.Locale loc)
          Sets the locale of the response, if the response has not been committed yet.
 void setRequest(org.apache.catalina.Request request)
          Set the Request with which this Response is associated.
 void setStatus(int sc)
          Sets the status code for this response.
 void setStatus(int sc, java.lang.String sm)
           
 void setStream(java.io.OutputStream stream)
          Set the output stream associated with this Response.
 void setSuspended(boolean suspended)
          Set the suspended flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

protected EnhydraDirectorConnection connection

wrappedRequest

protected org.apache.catalina.Request wrappedRequest

appCommitted

protected boolean appCommitted

included

protected boolean included

suspended

protected boolean suspended

error

protected boolean error
Constructor Detail

DirectorResponse

public DirectorResponse(EnhydraDirectorConnection res)
Method Detail

getConnector

public org.apache.catalina.Connector getConnector()
Return the Connector through which this Response is returned.

Specified by:
getConnector in interface org.apache.catalina.Response

setConnector

public void setConnector(org.apache.catalina.Connector connector)
Set the Connector through which this Response is returned.

Specified by:
setConnector in interface org.apache.catalina.Response

getContentCount

public int getContentCount()
Return the number of bytes actually written to the output stream.

Specified by:
getContentCount in interface org.apache.catalina.Response

getContext

public org.apache.catalina.Context getContext()
Return the Context with which this Response is associated.

Specified by:
getContext in interface org.apache.catalina.Response

setContext

public void setContext(org.apache.catalina.Context context)
Set the Context with which this Response is associated.

Specified by:
setContext in interface org.apache.catalina.Response

setAppCommitted

public void setAppCommitted(boolean appCommitted)
Set the application commit flag.

Specified by:
setAppCommitted in interface org.apache.catalina.Response

isAppCommitted

public boolean isAppCommitted()
Application commit flag accessor.

Specified by:
isAppCommitted in interface org.apache.catalina.Response

getIncluded

public boolean getIncluded()
Return the "processing inside an include" flag.

Specified by:
getIncluded in interface org.apache.catalina.Response

setIncluded

public void setIncluded(boolean included)
Set the "processing inside an include" flag.

Specified by:
setIncluded in interface org.apache.catalina.Response

getInfo

public java.lang.String getInfo()
Return descriptive information about this Response implementation

Specified by:
getInfo in interface org.apache.catalina.Response

getRequest

public org.apache.catalina.Request getRequest()
Return the Request with which this Response is associated.

Specified by:
getRequest in interface org.apache.catalina.Response

setRequest

public void setRequest(org.apache.catalina.Request request)
Set the Request with which this Response is associated.

Specified by:
setRequest in interface org.apache.catalina.Response

getResponse

public javax.servlet.ServletResponse getResponse()
Return the ServletResponse for which this object is the facade.

Specified by:
getResponse in interface org.apache.catalina.Response

getStream

public java.io.OutputStream getStream()
Return the output stream associated with this Response.

Specified by:
getStream in interface org.apache.catalina.Response

setStream

public void setStream(java.io.OutputStream stream)
Set the output stream associated with this Response.

Specified by:
setStream in interface org.apache.catalina.Response

setSuspended

public void setSuspended(boolean suspended)
Set the suspended flag.

Specified by:
setSuspended in interface org.apache.catalina.Response

isSuspended

public boolean isSuspended()
Suspended flag accessor.

Specified by:
isSuspended in interface org.apache.catalina.Response

setError

public void setError()
Set the error flag.

Specified by:
setError in interface org.apache.catalina.Response

isError

public boolean isError()
Error flag accessor.

Specified by:
isError in interface org.apache.catalina.Response

createOutputStream

public javax.servlet.ServletOutputStream createOutputStream()
                                                     throws java.io.IOException
Create and return a ServletOutputStream to write the content associated with this Response.

Specified by:
createOutputStream in interface org.apache.catalina.Response
Throws:
java.io.IOException

finishResponse

public void finishResponse()
                    throws java.io.IOException
Perform whatever actions are required to close the output

Specified by:
finishResponse in interface org.apache.catalina.Response
Throws:
java.io.IOException

getContentLength

public int getContentLength()
Return the content length that was set or calculated for this Response.

Specified by:
getContentLength in interface org.apache.catalina.Response

getReporter

public java.io.PrintWriter getReporter()
                                throws java.io.IOException
Return a PrintWriter that can be used to render error messages

Specified by:
getReporter in interface org.apache.catalina.Response
Throws:
java.io.IOException

recycle

public void recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.

Specified by:
recycle in interface org.apache.catalina.Response

sendAcknowledgement

public void sendAcknowledgement()
                         throws java.io.IOException
Send an acknowledgment of a request.

Specified by:
sendAcknowledgement in interface org.apache.catalina.Response
Throws:
java.io.IOException

getCookies

public javax.servlet.http.Cookie[] getCookies()
Get the Cookies associated with this Response.

Specified by:
getCookies in interface org.apache.catalina.HttpResponse

getHeader

public java.lang.String getHeader(java.lang.String name)
Get the Header with the specified name associated with this Response.

Specified by:
getHeader in interface org.apache.catalina.HttpResponse

getHeaderNames

public java.lang.String[] getHeaderNames()
Get the Header Names associated with this Response.

Specified by:
getHeaderNames in interface org.apache.catalina.HttpResponse

getHeaderValues

public java.lang.String[] getHeaderValues(java.lang.String name)
Get the Header Values with the specified name associated with this Response.

Specified by:
getHeaderValues in interface org.apache.catalina.HttpResponse

getMessage

public java.lang.String getMessage()
Get the Message associated with this Response.

Specified by:
getMessage in interface org.apache.catalina.HttpResponse

getStatus

public int getStatus()
Get the Status associated with this Response.

Specified by:
getStatus in interface org.apache.catalina.HttpResponse

reset

public void reset(int status,
                  java.lang.String message)
Specified by:
reset in interface org.apache.catalina.HttpResponse

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Add the Cookie to this Response.

Specified by:
addCookie in interface javax.servlet.http.HttpServletResponse

containsHeader

public boolean containsHeader(java.lang.String name)
Returns a boolean indicating whether the named response header has already been set.

Specified by:
containsHeader in interface javax.servlet.http.HttpServletResponse

encodeURL

public java.lang.String encodeURL(java.lang.String url)
Encodes the specified URL by including the session ID in it

Specified by:
encodeURL in interface javax.servlet.http.HttpServletResponse

encodeRedirectURL

public java.lang.String encodeRedirectURL(java.lang.String url)
Encodes the specified URL for use in the sendRedirect method or

Specified by:
encodeRedirectURL in interface javax.servlet.http.HttpServletResponse

encodeUrl

public java.lang.String encodeUrl(java.lang.String url)
Specified by:
encodeUrl in interface javax.servlet.http.HttpServletResponse

encodeRedirectUrl

public java.lang.String encodeRedirectUrl(java.lang.String url)
Specified by:
encodeRedirectUrl in interface javax.servlet.http.HttpServletResponse

sendError

public void sendError(int sc,
                      java.lang.String msg)
               throws java.io.IOException
Sends an error response to the client using the specified status.

Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
Throws:
java.io.IOException

sendError

public void sendError(int sc)
               throws java.io.IOException
Sends an error response to the client using the specified status code

Specified by:
sendError in interface javax.servlet.http.HttpServletResponse
Throws:
java.io.IOException

sendRedirect

public void sendRedirect(java.lang.String location)
                  throws java.io.IOException
Sends a temporary redirect response to the client using the specified redirect location URL.

Specified by:
sendRedirect in interface javax.servlet.http.HttpServletResponse
Throws:
java.io.IOException

setDateHeader

public void setDateHeader(java.lang.String name,
                          long date)
Sets a response header with the given name and date-value.

Specified by:
setDateHeader in interface javax.servlet.http.HttpServletResponse

addDateHeader

public void addDateHeader(java.lang.String name,
                          long date)
Adds a response header with the given name and date-value.

Specified by:
addDateHeader in interface javax.servlet.http.HttpServletResponse

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Sets a response header with the given name and value.

Specified by:
setHeader in interface javax.servlet.http.HttpServletResponse

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Adds a response header with the given name and value.

Specified by:
addHeader in interface javax.servlet.http.HttpServletResponse

setIntHeader

public void setIntHeader(java.lang.String name,
                         int value)
Sets a response header with the given name and integer value.

Specified by:
setIntHeader in interface javax.servlet.http.HttpServletResponse

addIntHeader

public void addIntHeader(java.lang.String name,
                         int value)
Adds a response header with the given name and integer value.

Specified by:
addIntHeader in interface javax.servlet.http.HttpServletResponse

setStatus

public void setStatus(int sc)
Sets the status code for this response.

Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse

setStatus

public void setStatus(int sc,
                      java.lang.String sm)
Specified by:
setStatus in interface javax.servlet.http.HttpServletResponse

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Returns the name of the character encoding (MIME charset) used for the body sent in this response.

Specified by:
getCharacterEncoding in interface javax.servlet.ServletResponse

getContentType

public java.lang.String getContentType()
Returns the content type used for the MIME body sent in this response.

Specified by:
getContentType in interface org.apache.catalina.Response

getOutputStream

public javax.servlet.ServletOutputStream getOutputStream()
                                                  throws java.io.IOException
Returns a ServletOutputStream suitable for writing binary data in the response.

Specified by:
getOutputStream in interface javax.servlet.ServletResponse
Throws:
java.io.IOException

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Returns a PrintWriter object that can send character text to the client.

Specified by:
getWriter in interface javax.servlet.ServletResponse
Throws:
java.io.IOException

setCharacterEncoding

public void setCharacterEncoding(java.lang.String charset)
Specified by:
setCharacterEncoding in interface javax.servlet.ServletResponse

setContentLength

public void setContentLength(int len)
Sets the length of the content body in the response

Specified by:
setContentLength in interface javax.servlet.ServletResponse

setContentType

public void setContentType(java.lang.String type)
Sets the content type of the response being sent to the client, if the response has not been committed yet.

Specified by:
setContentType in interface javax.servlet.ServletResponse

setBufferSize

public void setBufferSize(int size)
Sets the preferred buffer size for the body of the response.

Specified by:
setBufferSize in interface javax.servlet.ServletResponse

getBufferSize

public int getBufferSize()
Returns the actual buffer size used for the response.

Specified by:
getBufferSize in interface javax.servlet.ServletResponse

flushBuffer

public void flushBuffer()
                 throws java.io.IOException
Forces any content in the buffer to be written to the client.

Specified by:
flushBuffer in interface javax.servlet.ServletResponse
Throws:
java.io.IOException

resetBuffer

public void resetBuffer()
Clears the content of the underlying buffer in the response without clearing headers or status code.

Specified by:
resetBuffer in interface org.apache.catalina.Response

isCommitted

public boolean isCommitted()
Returns a boolean indicating if the response has been committed.

Specified by:
isCommitted in interface javax.servlet.ServletResponse

reset

public void reset()
Clears any data that exists in the buffer as well as the status code and headers.

Specified by:
reset in interface javax.servlet.ServletResponse

setLocale

public void setLocale(java.util.Locale loc)
Sets the locale of the response, if the response has not been committed yet.

Specified by:
setLocale in interface javax.servlet.ServletResponse

getLocale

public java.util.Locale getLocale()
Returns the locale specified for this response

Specified by:
getLocale in interface javax.servlet.ServletResponse