org.apache.commons.messagelet.impl
Class ServletResponseImpl

java.lang.Object
  extended by org.apache.commons.messagelet.impl.ServletResponseImpl
All Implemented Interfaces:
javax.servlet.ServletResponse
Direct Known Subclasses:
HttpServletResponseImpl

public class ServletResponseImpl
extends Object
implements javax.servlet.ServletResponse

Based on the ResponseBase code from Catalina.

Version:
$Revision: 155459 $ $Date: 2005-02-26 13:24:44 +0000 (Sat, 26 Feb 2005) $
Author:
Craig R. McClanahan, James Strachan

Field Summary
protected  byte[] buffer
          The buffer through which all of our output bytes are passed.
protected  int bufferCount
          The number of data bytes currently in the buffer.
protected  boolean committed
          Has this response been committed yet?
protected  int contentCount
          The actual number of bytes written to this Response.
protected  int contentLength
          The content length associated with this Response.
protected  String contentType
          The content type associated with this Response.
protected  String encoding
          The character encoding associated with this Response.
protected  boolean error
          Error flag.
protected  boolean included
          Are we currently processing inside a RequestDispatcher.include()?
protected  Locale locale
          The Locale associated with this Response.
protected  OutputStream output
          The output stream associated with this Response.
protected  javax.servlet.ServletOutputStream stream
          The ServletOutputStream that has been returned by getOutputStream(), if any.
protected  PrintWriter writer
          The PrintWriter that has been returned by getWriter(), if any.
 
Constructor Summary
ServletResponseImpl()
           
 
Method Summary
 javax.servlet.ServletOutputStream createOutputStream()
          Create and return a ServletOutputStream to write the content associated with this Response.
 void finishResponse()
          Perform whatever actions are required to flush and close the output stream or writer, in a single operation.
 void flushBuffer()
          Flush the buffer and commit this response.
 int getBufferSize()
          Return the actual buffer size used for this Response.
 String getCharacterEncoding()
          Return the character encoding used for this Response.
 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.
 String getContentType()
          Return the content type that was set or calculated for this response, or null if no content type was set.
 Locale getLocale()
          Return the Locale assigned to this response.
 javax.servlet.ServletOutputStream getOutputStream()
          Return the servlet output stream associated with this Response.
 OutputStream getStream()
          Return the output stream associated with this Response.
 PrintWriter getWriter()
          Return the writer associated with this Response.
 boolean isCommitted()
          Has the output of this response already been committed?
 void reset()
          Clear any content written to the buffer.
 void resetBuffer()
          Reset the data buffer but not any status or header information.
 void setBufferSize(int size)
          Set the buffer size to be used for this Response.
 void setContentLength(int length)
          Set the content length (in bytes) for this Response.
 void setContentType(String type)
          Set the content type for this Response.
 void setLocale(Locale locale)
          Set the Locale that is appropriate for this response, including setting the appropriate character encoding.
 void setStream(OutputStream stream)
          Set the output stream associated with this Response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected byte[] buffer
The buffer through which all of our output bytes are passed.


bufferCount

protected int bufferCount
The number of data bytes currently in the buffer.


committed

protected boolean committed
Has this response been committed yet?


contentCount

protected int contentCount
The actual number of bytes written to this Response.


contentLength

protected int contentLength
The content length associated with this Response.


contentType

protected String contentType
The content type associated with this Response.


encoding

protected String encoding
The character encoding associated with this Response.


included

protected boolean included
Are we currently processing inside a RequestDispatcher.include()?


locale

protected Locale locale
The Locale associated with this Response.


output

protected OutputStream output
The output stream associated with this Response.


stream

protected javax.servlet.ServletOutputStream stream
The ServletOutputStream that has been returned by getOutputStream(), if any.


writer

protected PrintWriter writer
The PrintWriter that has been returned by getWriter(), if any.


error

protected boolean error
Error flag. True if the response is an error report.

Constructor Detail

ServletResponseImpl

public ServletResponseImpl()
Method Detail

getContentCount

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


getStream

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


setStream

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

Parameters:
stream - The new output stream

createOutputStream

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

Throws:
IOException - if an input/output error occurs

finishResponse

public void finishResponse()
                    throws IOException
Perform whatever actions are required to flush and close the output stream or writer, in a single operation.

Throws:
IOException - if an input/output error occurs

getContentLength

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


getContentType

public String getContentType()
Return the content type that was set or calculated for this response, or null if no content type was set.


flushBuffer

public void flushBuffer()
                 throws IOException
Flush the buffer and commit this response.

Specified by:
flushBuffer in interface javax.servlet.ServletResponse
Throws:
IOException - if an input/output error occurs

getBufferSize

public int getBufferSize()
Return the actual buffer size used for this Response.

Specified by:
getBufferSize in interface javax.servlet.ServletResponse

getCharacterEncoding

public String getCharacterEncoding()
Return the character encoding used for this Response.

Specified by:
getCharacterEncoding in interface javax.servlet.ServletResponse

getOutputStream

public javax.servlet.ServletOutputStream getOutputStream()
                                                  throws IOException
Return the servlet output stream associated with this Response.

Specified by:
getOutputStream in interface javax.servlet.ServletResponse
Throws:
IllegalStateException - if getWriter has already been called for this response
IOException - if an input/output error occurs

getLocale

public Locale getLocale()
Return the Locale assigned to this response.

Specified by:
getLocale in interface javax.servlet.ServletResponse

getWriter

public PrintWriter getWriter()
                      throws IOException
Return the writer associated with this Response.

Specified by:
getWriter in interface javax.servlet.ServletResponse
Throws:
IllegalStateException - if getOutputStream has already been called for this response
IOException - if an input/output error occurs

isCommitted

public boolean isCommitted()
Has the output of this response already been committed?

Specified by:
isCommitted in interface javax.servlet.ServletResponse

reset

public void reset()
Clear any content written to the buffer.

Specified by:
reset in interface javax.servlet.ServletResponse
Throws:
IllegalStateException - if this response has already been committed

resetBuffer

public void resetBuffer()
Reset the data buffer but not any status or header information.

Specified by:
resetBuffer in interface javax.servlet.ServletResponse
Throws:
IllegalStateException - if the response has already been committed

setBufferSize

public void setBufferSize(int size)
Set the buffer size to be used for this Response.

Specified by:
setBufferSize in interface javax.servlet.ServletResponse
Parameters:
size - The new buffer size
Throws:
IllegalStateException - if this method is called after output has been committed for this response

setContentLength

public void setContentLength(int length)
Set the content length (in bytes) for this Response.

Specified by:
setContentLength in interface javax.servlet.ServletResponse
Parameters:
length - The new content length

setContentType

public void setContentType(String type)
Set the content type for this Response.

Specified by:
setContentType in interface javax.servlet.ServletResponse
Parameters:
type - The new content type

setLocale

public void setLocale(Locale locale)
Set the Locale that is appropriate for this response, including setting the appropriate character encoding.

Specified by:
setLocale in interface javax.servlet.ServletResponse
Parameters:
locale - The new locale


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.