org.apache.wicket.protocol.http
Class BufferedWebResponse

java.lang.Object
  extended by org.apache.wicket.request.Response
      extended by org.apache.wicket.request.http.WebResponse
          extended by org.apache.wicket.protocol.http.BufferedWebResponse
All Implemented Interfaces:
IMetaDataBufferingWebResponse

public class BufferedWebResponse
extends WebResponse
implements IMetaDataBufferingWebResponse

Subclass of WebResponse that buffers the actions and performs those on another response.

Author:
Matej Knopp
See Also:
writeTo(WebResponse)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.request.http.WebResponse
WebResponse.CacheScope
 
Field Summary
 
Fields inherited from class org.apache.wicket.request.http.WebResponse
MAX_CACHE_DURATION
 
Constructor Summary
BufferedWebResponse(WebResponse originalResponse)
          Construct.
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Add a cookie to the web response
 void addHeader(java.lang.String name, java.lang.String value)
          Add a value to the servlet response stream.
 void clearCookie(javax.servlet.http.Cookie cookie)
          Convenience method for clearing a cookie.
 java.lang.String encodeRedirectURL(java.lang.CharSequence url)
          Encodes urls used to redirect.
 java.lang.String encodeURL(java.lang.CharSequence url)
          Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
 void flush()
          Flushes the response.
 java.lang.Object getContainerResponse()
          Provides access to the low-level container response object that implementaion of this Response delegate to.
 java.lang.CharSequence getText()
          Returns the text already written to this response.
 boolean isRedirect()
           
 void reset()
          Called when the Response needs to reset itself.
 void sendError(int sc, java.lang.String msg)
          Send error status code with optional message.
 void sendRedirect(java.lang.String url)
          Redirects the response to specified URL.
 void setContentLength(long length)
          Set the content length on the response, if appropriate in the subclass.
 void setContentType(java.lang.String mimeType)
          Set the content type on the response, if appropriate in the subclass.
 void setDateHeader(java.lang.String name, Time date)
          Set a header to the date value in the servlet response stream.
 void setHeader(java.lang.String name, java.lang.String value)
          Set a header to the string value in the servlet response stream.
 void setStatus(int sc)
          Sets the status code for this response.
 void setText(java.lang.CharSequence text)
          Replaces the text in this response
 java.lang.String toString()
           
 void write(byte[] array)
          Writes the buffer to output.
 void write(java.lang.CharSequence sequence)
          Writes the CharSequence to output.
 void writeMetaData(WebResponse response)
          transfer cookie operations (add, clear) to given web response
 void writeTo(WebResponse response)
          Writes the content of the buffer to the specified response.
 
Methods inherited from class org.apache.wicket.request.http.WebResponse
disableCaching, enableCaching, setAttachmentHeader, setInlineHeader, setLastModifiedTime
 
Methods inherited from class org.apache.wicket.request.Response
close
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BufferedWebResponse

public BufferedWebResponse(WebResponse originalResponse)
Construct.

Parameters:
originalResponse -
Method Detail

writeMetaData

public void writeMetaData(WebResponse response)
transfer cookie operations (add, clear) to given web response

Specified by:
writeMetaData in interface IMetaDataBufferingWebResponse
Parameters:
response - web response that should receive the current cookie operation

encodeURL

public java.lang.String encodeURL(java.lang.CharSequence url)
Description copied from class: Response
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.

Specified by:
encodeURL in class Response
Returns:
encoded URL

encodeRedirectURL

public java.lang.String encodeRedirectURL(java.lang.CharSequence url)
Description copied from class: WebResponse
Encodes urls used to redirect. Sometimes rules for encoding URLs for redirecting differ from encoding URLs for links, so this method is broken out away form Response.encodeURL(CharSequence).

Specified by:
encodeRedirectURL in class WebResponse
Returns:
encoded URL

reset

public void reset()
Description copied from class: Response
Called when the Response needs to reset itself. Subclasses can empty there buffer or build up state.

Overrides:
reset in class Response

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Description copied from class: WebResponse
Add a cookie to the web response

Specified by:
addCookie in class WebResponse

clearCookie

public void clearCookie(javax.servlet.http.Cookie cookie)
Description copied from class: WebResponse
Convenience method for clearing a cookie.

Specified by:
clearCookie in class WebResponse
Parameters:
cookie - The cookie to set
See Also:
WebResponse.addCookie(Cookie)

setContentLength

public void setContentLength(long length)
Description copied from class: WebResponse
Set the content length on the response, if appropriate in the subclass. This default implementation does nothing.

Specified by:
setContentLength in class WebResponse
Parameters:
length - The length of the content

setContentType

public void setContentType(java.lang.String mimeType)
Description copied from class: WebResponse
Set the content type on the response, if appropriate in the subclass. This default implementation does nothing.

Specified by:
setContentType in class WebResponse
Parameters:
mimeType - The mime type

setDateHeader

public void setDateHeader(java.lang.String name,
                          Time date)
Description copied from class: WebResponse
Set a header to the date value in the servlet response stream.

Specified by:
setDateHeader in class WebResponse

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Description copied from class: WebResponse
Set a header to the string value in the servlet response stream.

Specified by:
setHeader in class WebResponse

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Description copied from class: WebResponse
Add a value to the servlet response stream.

Specified by:
addHeader in class WebResponse

write

public void write(java.lang.CharSequence sequence)
Description copied from class: Response
Writes the CharSequence to output.

Specified by:
write in class Response

getText

public java.lang.CharSequence getText()
Returns the text already written to this response.

Returns:
text

setText

public void setText(java.lang.CharSequence text)
Replaces the text in this response

Parameters:
text -

write

public void write(byte[] array)
Description copied from class: Response
Writes the buffer to output.

Specified by:
write in class Response

sendRedirect

public void sendRedirect(java.lang.String url)
Description copied from class: WebResponse
Redirects the response to specified URL. The implementation is responsible for properly encoding the URL. Implementations of this method should run passed in url parameters throu the #encodeRedirectURL(String) method.

Specified by:
sendRedirect in class WebResponse

setStatus

public void setStatus(int sc)
Description copied from class: WebResponse
Sets the status code for this response.

Specified by:
setStatus in class WebResponse
Parameters:
sc - status code

sendError

public void sendError(int sc,
                      java.lang.String msg)
Description copied from class: WebResponse
Send error status code with optional message.

Specified by:
sendError in class WebResponse

writeTo

public void writeTo(WebResponse response)
Writes the content of the buffer to the specified response. Also sets the properties and and headers.

Parameters:
response -

isRedirect

public boolean isRedirect()
Specified by:
isRedirect in class WebResponse
Returns:
true is WebResponse.sendRedirect(String) was called, false otherwise.

flush

public void flush()
Description copied from class: WebResponse
Flushes the response.

Specified by:
flush in class WebResponse

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getContainerResponse

public java.lang.Object getContainerResponse()
Description copied from class: Response
Provides access to the low-level container response object that implementaion of this Response delegate to. This allows users to access features provided by the container response but not by generalized Wicket Response objects.

Specified by:
getContainerResponse in class Response
Returns:
low-level container response object, or null if none


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.