org.loom.resolution
Class AbstractHttpResolution

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

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

A response object with http headers.


Constructor Summary
AbstractHttpResolution()
           
 
Method Summary
 HttpResolution addCookie(javax.servlet.http.Cookie cookie)
          Adds a cookie
 HttpResolution 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).
 HttpResolution addCookie(java.lang.String name, java.lang.String value, int maxAge)
          Adds a cookie
 void addDateHeader(java.lang.String name, java.util.Date value)
          Deprecated. use addHeader(String, Object) instead
 HttpResolution addHeader(java.lang.String name, java.lang.Object value)
          Add a http header.
 void addIntHeader(java.lang.String name, int value)
          Deprecated. use addHeader(String, Object) instead
 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
 HttpResolution setCacheControl(CacheControl cacheControl)
          Sets the cache data to be sent to the browser
 HttpResolution setCharset(java.lang.String charset)
          Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.
 HttpResolution setContentType(java.lang.String contentType)
          Sets the content type of the response being sent to the client, if the response has not been committed yet.
 void setDateHeader(java.lang.String name, java.util.Date value)
          Deprecated. use setHeader(String, Object) instead
 void setDateHeaderIfNotPresent(java.lang.String name, java.util.Date value)
          Deprecated. use setHeaderIfNotPresent(String, Object) instead
 HttpResolution setHeader(java.lang.String name, java.lang.Object value)
          Set a String http header.
 HttpResolution setHeaderIfNotPresent(java.lang.String name, java.lang.Object value)
          Set a String http header if it has not been set.
 void setIntHeader(java.lang.String name, int value)
          Deprecated. use setHeader(String, Object) instead
 void setIntHeaderIfNotPresent(java.lang.String name, int value)
          Deprecated. use setHeaderIfNotPresent(String, Object) instead
 void setJsonHeader(JsonMarshaller marshaller)
          Deprecated. use jackson instead
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 HttpResolution addCookie(java.lang.String name,
                                java.lang.String value)
Description copied from interface: HttpResolution
Adds a cookie that will not be stored on disk (will be deleted when the browser is closed).

Specified by:
addCookie in interface HttpResolution
Parameters:
name - the name of the cookie
value - the value of the Cookie

addCookie

public HttpResolution addCookie(java.lang.String name,
                                java.lang.String value,
                                int maxAge)
Description copied from interface: HttpResolution
Adds a cookie

Specified by:
addCookie in interface HttpResolution
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 HttpResolution addCookie(javax.servlet.http.Cookie cookie)
Description copied from interface: HttpResolution
Adds a cookie

Specified by:
addCookie in interface HttpResolution
Parameters:
cookie - the cookie to be added to the response

addHeader

public HttpResolution addHeader(java.lang.String name,
                                java.lang.Object value)
Description copied from interface: HttpResolution
Add a http header. If the header already exists a new value will be added.

Specified by:
addHeader in interface HttpResolution
Parameters:
name - the name of the http header
value - the value of the http header. Date, int and String are supported. Anything else will be cast to toString(). Null will be ignored.

addDateHeader

public void addDateHeader(java.lang.String name,
                          java.util.Date value)
Deprecated. use addHeader(String, Object) instead

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)
Deprecated. use addHeader(String, Object) instead

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 HttpResolution setHeader(java.lang.String name,
                                java.lang.Object value)
Description copied from interface: HttpResolution
Set a String http header. If the header already exists it will be replaced.

Specified by:
setHeader in interface HttpResolution
Parameters:
name - the name of the http header
value - the value of the http header

setHeaderIfNotPresent

public HttpResolution setHeaderIfNotPresent(java.lang.String name,
                                            java.lang.Object value)
Description copied from interface: HttpResolution
Set a String http header if it has not been set.

Specified by:
setHeaderIfNotPresent in interface HttpResolution
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)
Deprecated. use setHeader(String, Object) instead

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)
Deprecated. use setHeaderIfNotPresent(String, Object) instead

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)
Deprecated. use setHeader(String, Object) instead

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)
Deprecated. use setHeaderIfNotPresent(String, Object) instead

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)
Deprecated. use jackson instead

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 HttpResolution setCacheControl(CacheControl cacheControl)
Description copied from interface: CacheableResolution
Sets the cache data to be sent to the browser

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

getContentType

public java.lang.String getContentType()

setContentType

public HttpResolution setContentType(java.lang.String contentType)
Description copied from interface: HttpResolution
Sets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example, text/html;charset=UTF-8. Notice that #setCharset(String) can also be used for this.

Specified by:
setContentType in interface HttpResolution

getCharset

public java.lang.String getCharset()

setCharset

public HttpResolution setCharset(java.lang.String charset)
Description copied from interface: HttpResolution
Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.

Specified by:
setCharset in interface HttpResolution