org.loom.resolution
Class AbstractHttpResolution

java.lang.Object
  extended by org.loom.resolution.AbstractHttpResolution
All Implemented Interfaces:
CacheableResolution, Resolution
Direct Known Subclasses:
AbstractFileResolution, AutocompleteResolution, BufferedImageResolution, ForwardResolutionImpl, HtmlResolution, HttpErrorResolution, JsonResolution, RedirectResolutionImpl, StringResolution

public abstract class AbstractHttpResolution
extends java.lang.Object
implements CacheableResolution

A response object with http headers.

Author:
Ignacio Coloma

Constructor Summary
AbstractHttpResolution()
           
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Adds a cookie
 void addCookie(java.lang.String name, java.lang.String value)
          Adds a cookie that will not be stored on disk (will be deleted when the browser is closed).
 void addCookie(java.lang.String name, java.lang.String value, int maxAge)
          Adds a cookie
 void addDateHeader(java.lang.String name, java.util.Date value)
          Add a date http header.
 void addHeader(java.lang.String name, java.lang.String value)
          Add a string http header.
 void addIntHeader(java.lang.String name, int value)
          Add an integer http header.
 boolean containsHeader(java.lang.String name)
           
 CacheControl getCacheControl()
           
 java.lang.String getCharset()
           
 java.lang.String getContentType()
           
abstract  void resolve(LoomServletRequest request, LoomServletResponse response)
          Write the response contents
 AbstractHttpResolution setCacheControl(CacheControl cacheControl)
          Sets the cache data to be sent to the browser
 void setCharset(java.lang.String charset)
           
 void setContentType(java.lang.String contentType)
           
 void setDateHeader(java.lang.String name, java.util.Date value)
          Set a date http header.
 void setDateHeaderIfNotPresent(java.lang.String name, java.util.Date value)
          Set a Date http header if it has not been set.
 void setHeader(java.lang.String name, java.lang.String value)
          Set a String http header.
 void setHeaderIfNotPresent(java.lang.String name, java.lang.String value)
          Set a String http header if it has not been set.
 void setIntHeader(java.lang.String name, int value)
          Set an integer http header.
 void setIntHeaderIfNotPresent(java.lang.String name, int value)
          Set an integer http header if it's not already set.
 void setJsonHeader(JsonMarshaller marshaller)
          sets the X-JSON http header
protected  void writeHeaders(LoomServletRequest request, LoomServletResponse response)
          Adds http headers to the response before resolving
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHttpResolution

public AbstractHttpResolution()
Method Detail

resolve

public abstract void resolve(LoomServletRequest request,
                             LoomServletResponse response)
                      throws java.io.IOException,
                             javax.servlet.ServletException
Description copied from interface: Resolution
Write the response contents

Specified by:
resolve in interface Resolution
Parameters:
request - the current request object
response - the current response object
Throws:
java.io.IOException
javax.servlet.ServletException

writeHeaders

protected void writeHeaders(LoomServletRequest request,
                            LoomServletResponse response)
Adds http headers to the response before resolving


addCookie

public void addCookie(java.lang.String name,
                      java.lang.String value)
Adds a cookie that will not be stored on disk (will be deleted when the browser is closed).

Parameters:
name - the name of the cookie
value - the value of the Cookie

addCookie

public void addCookie(java.lang.String name,
                      java.lang.String value,
                      int maxAge)
Adds a cookie

Parameters:
name - the name of the cookie
value - the value of the Cookie
maxAge - can be positive (number of seconds that it will be stored in the browser), zero (to delete the cookie from the browser) or a negative value (to indicate that the cookie should not be stored in disk and will be forgotten when the browser exists).

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Adds a cookie

Parameters:
cookie - the cookie to be added to the response

addHeader

public void addHeader(java.lang.String name,
                      java.lang.String value)
Add a string http header. If the header already exists a new value will be added.

Parameters:
name - the name of the http header
value - the value of the http header

addDateHeader

public void addDateHeader(java.lang.String name,
                          java.util.Date value)
Add a date http header. If the header already exists a new value will be added.

Parameters:
name - the name of the http header
value - the value of the http header

addIntHeader

public void addIntHeader(java.lang.String name,
                         int value)
Add an integer http header. If the header already exists a new value will be added.

Parameters:
name - the name of the http header
value - the value of the http header

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Set a String http header. If the header already exists it will be replaced.

Parameters:
name - the name of the http header
value - the value of the http header

setHeaderIfNotPresent

public void setHeaderIfNotPresent(java.lang.String name,
                                  java.lang.String value)
Set a String http header if it has not been set.

Parameters:
name - the name of the http header
value - the value of the http header

setDateHeader

public void setDateHeader(java.lang.String name,
                          java.util.Date value)
Set a date http header. If the header already exists it will be replaced.

Parameters:
name - the name of the http header
value - the value of the http header

setDateHeaderIfNotPresent

public void setDateHeaderIfNotPresent(java.lang.String name,
                                      java.util.Date value)
Set a Date http header if it has not been set.

Parameters:
name - the name of the http header
value - the value of the http header

setIntHeader

public void setIntHeader(java.lang.String name,
                         int value)
Set an integer http header. If the header already exists it will be replaced.

Parameters:
name - the name of the http header
value - the value of the http header

setIntHeaderIfNotPresent

public void setIntHeaderIfNotPresent(java.lang.String name,
                                     int value)
Set an integer http header if it's not already set.

Parameters:
name - the name of the http header
value - the value of the http header

setJsonHeader

public void setJsonHeader(JsonMarshaller marshaller)
sets the X-JSON http header

Parameters:
marshaller - the JSON object to be added as http header

containsHeader

public boolean containsHeader(java.lang.String name)
Parameters:
name - the http header name to check
Returns:
true if there is a http header with the provided name

getCacheControl

public CacheControl getCacheControl()

setCacheControl

public AbstractHttpResolution setCacheControl(CacheControl cacheControl)
Description copied from interface: CacheableResolution
Sets the cache data to be sent to the browser

Specified by:
setCacheControl in interface CacheableResolution
Parameters:
cacheControl - the cache data.
Returns:
this same instance, to allow easy chaining of invocations

getContentType

public java.lang.String getContentType()

setContentType

public void setContentType(java.lang.String contentType)

getCharset

public java.lang.String getCharset()

setCharset

public void setCharset(java.lang.String charset)


The Loom Framework 1.6-SNAPSHOT.
Licensed under the Apache License, Version 2.0 by Extrema Sistemas de Informacion S.L.