ccc.web.rendering
Class Response

java.lang.Object
  extended by ccc.web.rendering.Response

public class Response
extends java.lang.Object

A CCC response. TODO: Never cache secure resources (i.e. with an ACL). TODO: The Response#write() method IS NOT THE PLACE for thumbnail code. TODO: _headers should be a set not a map.

Author:
Civic Computing Ltd.

Constructor Summary
Response(Body body)
          Constructor.
 
Method Summary
 void dontCache()
          Configure headers to prevent caching of this response.
 Body getBody()
          Accessor.
 java.util.Map<java.lang.String,Header> getHeaders()
          Accessor.
 void setCharSet(java.lang.String charset)
          Mutator.
 void setDescription(java.lang.String description)
          Mutator.
 void setDisposition(java.lang.String disposition)
          Mutator.
 void setEtag(java.lang.String tag, boolean weak)
          Set an ETag for the response.
 void setExpiry(Duration expiry)
          Mutator.
 void setLastModified(java.util.Date dateModified)
          Set a 'last modified' date for the response.
 void setLength(long length)
          Mutator.
 void setMimeType(MimeType mType)
          Mutator.
 void write(javax.servlet.http.HttpServletResponse httpResponse, Context context, TextProcessor processor)
          Write the response using the servlet API.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Response

public Response(Body body)
Constructor.

Parameters:
body - The response's body.
Method Detail

setDescription

public void setDescription(java.lang.String description)
Mutator.

Parameters:
description - The new description.

setLength

public void setLength(long length)
Mutator.

Parameters:
length - The size of the response's body, in bytes.

setCharSet

public void setCharSet(java.lang.String charset)
Mutator.

Parameters:
charset - The new character set.

setMimeType

public void setMimeType(MimeType mType)
Mutator.

Parameters:
mType - The mime type for the response.

setExpiry

public void setExpiry(Duration expiry)
Mutator.

Parameters:
expiry - The response's expiry time, as a Duration.

setDisposition

public void setDisposition(java.lang.String disposition)
Mutator.

Parameters:
disposition - The new disposition for this response.

getBody

public Body getBody()
Accessor.

Returns:
The response's body.

getHeaders

public java.util.Map<java.lang.String,Header> getHeaders()
Accessor.

Returns:
The response's headers.

write

public void write(javax.servlet.http.HttpServletResponse httpResponse,
                  Context context,
                  TextProcessor processor)
           throws java.io.IOException
Write the response using the servlet API.

Parameters:
httpResponse - The servlet response.
processor - The text processor used to render the body.
context - The context for the response.
Throws:
java.io.IOException - Thrown if writing fails.

setEtag

public void setEtag(java.lang.String tag,
                    boolean weak)
Set an ETag for the response.

The specified tag will be quoted before it is sent.

Parameters:
tag - The entity tag to set.
weak - True if this is a weak entity tag, false otherwise.

setLastModified

public void setLastModified(java.util.Date dateModified)
Set a 'last modified' date for the response.

Parameters:
dateModified - The last time the response body was modified.

dontCache

public void dontCache()
Configure headers to prevent caching of this response.



Copyright © 2010. All Rights Reserved.