com.caucho.portal.generic.context
Class AbstractResponseHandler

java.lang.Object
  extended by com.caucho.portal.generic.context.AbstractResponseHandler
All Implemented Interfaces:
ResponseHandler
Direct Known Subclasses:
BufferedResponseHandler, CachingResponseHandler, RendererResponseHandler

public class AbstractResponseHandler
extends java.lang.Object
implements ResponseHandler

A ResponseHandler that wraps another ResponseHandler. Derived classes override the print() and write() methods to intercept the output. flushBuffer(), reset(), and resetBuffer() DO NOT propagate to the wrapped stream (they do nothing in the implementations for this class)


Field Summary
protected  java.io.OutputStream _outputStream
           
protected  java.io.OutputStream _outputStreamOut
           
protected  java.io.PrintWriter _writer
           
protected  java.io.PrintWriter _writerOut
           
protected static java.util.logging.Logger log
           
 
Constructor Summary
AbstractResponseHandler()
           
AbstractResponseHandler(ResponseHandler successor)
           
 
Method Summary
 void addProperty(java.lang.String name, java.lang.String value)
          Add a value to a property to be returned to the client.
protected  void checkErrorOrFail()
           
 void finish()
           
 void flushBuffer()
          flushBuffer(), reset(), and resetBuffer() DO NOT propagate to the wrapped stream (they do nothing in the implementations for this class)
 int getBufferSize()
           
 java.lang.String getCharacterEncoding()
          Get the character encoding of the writer.
 java.lang.String getContentType()
          Get the type previously set with setContentType or null if the type has not been set.
 java.lang.Exception getErrorCause()
          Return an exception if this ResponseHandler has failed.
 java.util.Locale getLocale()
           
 java.io.OutputStream getOutputStream()
           
 ResponseHandler getSuccessor()
          Get the handler that this handler wraps, if any
protected  java.io.OutputStream getUnderlyingOutputStream()
           
protected  java.io.PrintWriter getUnderlyingWriter()
           
 java.io.PrintWriter getWriter()
          Get a writer that sends output to the client of the connection.
 boolean isCommitted()
           
 boolean isError()
           
 void open(ResponseHandler successor)
           
protected  void print(char c)
          Write a char out to the underlying Writer
protected  void print(char[] buf, int off, int len)
          Write chars out to the underlying Writer
protected  void print(java.lang.String str, int off, int len)
          Write chars out to the underlying Writer
 void reset()
          flushBuffer(), reset(), and resetBuffer() DO NOT propagate to the wrapped stream (they do nothing in the implementations for this class)
 void resetBuffer()
          flushBuffer(), reset(), and resetBuffer() DO NOT propagate to the wrapped stream (they do nothing in the implementations for this class)
 void setBufferSize(int bufferSize)
           
 void setCharacterEncoding(java.lang.String enc)
          Set the character encoding of the writer.
 void setContentType(java.lang.String contentType)
           
protected  void setError(java.lang.Exception cause)
          Set an error with a cause.
 void setLocale(java.util.Locale locale)
           
 void setProperty(java.lang.String name, java.lang.String value)
          Set a property to be returned to the client.
protected  void write(byte b)
          Write a byte out to the underlying OutputStream
protected  void write(byte[] buf, int off, int len)
          Write bytes out to the underlying OutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final java.util.logging.Logger log

_writer

protected java.io.PrintWriter _writer

_outputStream

protected java.io.OutputStream _outputStream

_writerOut

protected java.io.PrintWriter _writerOut

_outputStreamOut

protected java.io.OutputStream _outputStreamOut
Constructor Detail

AbstractResponseHandler

public AbstractResponseHandler()

AbstractResponseHandler

public AbstractResponseHandler(ResponseHandler successor)
Method Detail

open

public void open(ResponseHandler successor)

finish

public void finish()
            throws java.io.IOException
Specified by:
finish in interface ResponseHandler
Throws:
java.io.IOException

getSuccessor

public ResponseHandler getSuccessor()
Description copied from interface: ResponseHandler
Get the handler that this handler wraps, if any

Specified by:
getSuccessor in interface ResponseHandler

setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Description copied from interface: ResponseHandler
Set a property to be returned to the client. "properties" correspond to HTTP headers in the response for HTTP connections.

Specified by:
setProperty in interface ResponseHandler
See Also:
javax.portlet.PortletResponse#setProperty

addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value)
Description copied from interface: ResponseHandler
Add a value to a property to be returned to the client. "properties" correspond to HTTP headers in the response for HTTP connections.

Specified by:
addProperty in interface ResponseHandler
See Also:
javax.portlet.PortletResponse#addProperty

setCharacterEncoding

public void setCharacterEncoding(java.lang.String enc)
                          throws java.io.UnsupportedEncodingException
Description copied from interface: ResponseHandler
Set the character encoding of the writer.

Specified by:
setCharacterEncoding in interface ResponseHandler
Throws:
java.io.UnsupportedEncodingException

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Description copied from interface: ResponseHandler
Get the character encoding of the writer.

Specified by:
getCharacterEncoding in interface ResponseHandler

setContentType

public void setContentType(java.lang.String contentType)
Specified by:
setContentType in interface ResponseHandler

getContentType

public java.lang.String getContentType()
Description copied from interface: ResponseHandler
Get the type previously set with setContentType or null if the type has not been set.

Specified by:
getContentType in interface ResponseHandler

setLocale

public void setLocale(java.util.Locale locale)
Specified by:
setLocale in interface ResponseHandler

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface ResponseHandler

isCommitted

public boolean isCommitted()
Specified by:
isCommitted in interface ResponseHandler

getWriter

public java.io.PrintWriter getWriter()
                              throws java.io.IOException
Description copied from interface: ResponseHandler
Get a writer that sends output to the client of the connection.

Specified by:
getWriter in interface ResponseHandler
Throws:
java.io.IOException

getUnderlyingWriter

protected java.io.PrintWriter getUnderlyingWriter()

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Specified by:
getOutputStream in interface ResponseHandler
Throws:
java.io.IOException

getUnderlyingOutputStream

protected java.io.OutputStream getUnderlyingOutputStream()

setError

protected void setError(java.lang.Exception cause)
Set an error with a cause.


getErrorCause

public java.lang.Exception getErrorCause()
Return an exception if this ResponseHandler has failed.


isError

public boolean isError()

checkErrorOrFail

protected void checkErrorOrFail()
                         throws java.io.IOException
Throws:
java.io.IOException

setBufferSize

public void setBufferSize(int bufferSize)
Specified by:
setBufferSize in interface ResponseHandler

getBufferSize

public int getBufferSize()
Specified by:
getBufferSize in interface ResponseHandler

reset

public void reset()
flushBuffer(), reset(), and resetBuffer() DO NOT propagate to the wrapped stream (they do nothing in the implementations for this class)

Specified by:
reset in interface ResponseHandler

resetBuffer

public void resetBuffer()
flushBuffer(), reset(), and resetBuffer() DO NOT propagate to the wrapped stream (they do nothing in the implementations for this class)

Specified by:
resetBuffer in interface ResponseHandler

flushBuffer

public void flushBuffer()
                 throws java.io.IOException
flushBuffer(), reset(), and resetBuffer() DO NOT propagate to the wrapped stream (they do nothing in the implementations for this class)

Specified by:
flushBuffer in interface ResponseHandler
Throws:
java.io.IOException

print

protected void print(char[] buf,
                     int off,
                     int len)
              throws java.io.IOException
Write chars out to the underlying Writer

Throws:
java.io.IOException

print

protected void print(java.lang.String str,
                     int off,
                     int len)
              throws java.io.IOException
Write chars out to the underlying Writer

Throws:
java.io.IOException

print

protected void print(char c)
              throws java.io.IOException
Write a char out to the underlying Writer

Throws:
java.io.IOException

write

protected void write(byte[] buf,
                     int off,
                     int len)
              throws java.io.IOException
Write bytes out to the underlying OutputStream

Throws:
java.io.IOException

write

protected void write(byte b)
              throws java.io.IOException
Write a byte out to the underlying OutputStream

Throws:
java.io.IOException