org.loom.resolution
Class RedirectResolutionImpl

java.lang.Object
  extended by org.loom.resolution.AbstractHttpResolution
      extended by org.loom.resolution.RedirectResolutionImpl
All Implemented Interfaces:
CacheableResolution, HttpResolution, RedirectResolution, Resolution

public class RedirectResolutionImpl
extends AbstractHttpResolution
implements RedirectResolution

Redirect resolution implementation.


Constructor Summary
RedirectResolutionImpl(java.lang.Class<? extends Action> actionClass, java.lang.String event)
           
RedirectResolutionImpl(java.lang.String url)
           
RedirectResolutionImpl(java.lang.String action, java.lang.String event)
           
 
Method Summary
 RedirectResolution add(java.lang.String name, java.lang.Object value)
          Add a parameter to the redirected url
 RedirectResolution addCookie(javax.servlet.http.Cookie cookie)
          Adds a cookie
 RedirectResolution 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).
 RedirectResolution addCookie(java.lang.String name, java.lang.String value, int maxAge)
          Adds a cookie
 RedirectResolution addHeader(java.lang.String name, java.lang.Object value)
          Add a http header.
 RedirectResolution addParameter(java.lang.String name, java.lang.Object value)
          Add a parameter to the redirected url
 RedirectResolution addProperty(java.lang.String property)
          Add an action property as a parameter.
 RedirectResolution addPropertyParameter(java.lang.String propertyName)
          Add an action property as a parameter.
 boolean isPermanent()
           
 RedirectResolution permanent()
          Invoke this method to perform a permanent redirect (301) instead of a temporary redirect (302).
 java.util.List<java.lang.String> remove(java.lang.String name)
          Remove a GET parameter
 java.util.List<java.lang.String> removeParameter(java.lang.String name)
          Remove a GET parameter
 RedirectResolution replace(java.lang.String name, java.lang.Object value)
          Replace a parameter value.
 RedirectResolution replaceParameter(java.lang.String name, java.lang.Object value)
          Replace a parameter value.
 void resolve(LoomServletRequest request, LoomServletResponse response)
          Write the response contents
 RedirectResolution setCacheControl(CacheControl cacheControl)
          Sets the cache data to be sent to the browser
 RedirectResolution setCharset(java.lang.String charset)
          Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.
 RedirectResolution 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.
 RedirectResolution setHash(java.lang.String hash)
          Add a hash to the URL.
 RedirectResolution setHeader(java.lang.String name, java.lang.Object value)
          Set a String http header.
 RedirectResolution setHeaderIfNotPresent(java.lang.String name, java.lang.Object value)
          Set a String http header if it has not been set.
 RedirectResolution setHostname(java.lang.String hostname)
          Set to not null to override the request server name
 RedirectResolution setIncludeRequestParameters(boolean addCurrentRequestParameters)
          true to append to the generated URL all current request parameters, default false.
 RedirectResolution setPort(java.lang.Integer port)
          Set to not null to override the request port
 RedirectResolution setScheme(java.lang.String scheme)
          Set to not null to override the request scheme.
 
Methods inherited from class org.loom.resolution.AbstractHttpResolution
addDateHeader, addIntHeader, containsHeader, getCacheControl, getCharset, getContentType, setDateHeader, setDateHeaderIfNotPresent, setIntHeader, setIntHeaderIfNotPresent, setJsonHeader, writeHeaders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RedirectResolutionImpl

public RedirectResolutionImpl(java.lang.String url)

RedirectResolutionImpl

public RedirectResolutionImpl(java.lang.String action,
                              java.lang.String event)

RedirectResolutionImpl

public RedirectResolutionImpl(java.lang.Class<? extends Action> actionClass,
                              java.lang.String event)
Method Detail

add

public RedirectResolution add(java.lang.String name,
                              java.lang.Object value)
Description copied from interface: RedirectResolution
Add a parameter to the redirected url

Specified by:
add in interface RedirectResolution
Parameters:
name - the name of the parameter
value - the value of the parameter
Returns:
This same instance

addParameter

public RedirectResolution addParameter(java.lang.String name,
                                       java.lang.Object value)
Description copied from interface: RedirectResolution
Add a parameter to the redirected url

Specified by:
addParameter in interface RedirectResolution
Parameters:
name - the name of the parameter
value - the value of the parameter
Returns:
This same instance

addProperty

public RedirectResolution addProperty(java.lang.String property)
Description copied from interface: RedirectResolution
Add an action property as a parameter. The property value will be retrieved from the current action and its name and value appended to the resulting URL.

Specified by:
addProperty in interface RedirectResolution
Parameters:
property - the name of the action property to be added.
Returns:
This same instance

addPropertyParameter

public RedirectResolution addPropertyParameter(java.lang.String propertyName)
Description copied from interface: RedirectResolution
Add an action property as a parameter. The property value will be retrieved from the current action and its name and value appended to the resulting URL.

Specified by:
addPropertyParameter in interface RedirectResolution
Parameters:
propertyName - the name of the action property to be added.
Returns:
This same instance

setHash

public RedirectResolution setHash(java.lang.String hash)
Description copied from interface: RedirectResolution
Add a hash to the URL. A hash is the URL part after the '#'

Specified by:
setHash in interface RedirectResolution
Parameters:
hash - The hash to be added
Returns:
This same instance

resolve

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

Specified by:
resolve in interface Resolution
Specified by:
resolve in class AbstractHttpResolution
Parameters:
request - the current request object
response - the current response object
Throws:
java.io.IOException

permanent

public RedirectResolution permanent()
Description copied from interface: RedirectResolution
Invoke this method to perform a permanent redirect (301) instead of a temporary redirect (302).

Specified by:
permanent in interface RedirectResolution

isPermanent

public boolean isPermanent()

remove

public java.util.List<java.lang.String> remove(java.lang.String name)
Description copied from interface: RedirectResolution
Remove a GET parameter

Specified by:
remove in interface RedirectResolution
Parameters:
name - the name of the Parameter to remove
Returns:
the list of removed values

removeParameter

public java.util.List<java.lang.String> removeParameter(java.lang.String name)
Description copied from interface: RedirectResolution
Remove a GET parameter

Specified by:
removeParameter in interface RedirectResolution
Parameters:
name - the name of the Parameter to remove
Returns:
the list of removed values

replace

public RedirectResolution replace(java.lang.String name,
                                  java.lang.Object value)
Description copied from interface: RedirectResolution
Replace a parameter value. If the parameter is multiple, all of them will be removed and a single value will be inserted instead.

Specified by:
replace in interface RedirectResolution
Parameters:
name - the name of the parameter to be replaced.
value - the new value of the parameter. If null, the parameter will just be removed.

replaceParameter

public RedirectResolution replaceParameter(java.lang.String name,
                                           java.lang.Object value)
Description copied from interface: RedirectResolution
Replace a parameter value. If the parameter is multiple, all of them will be removed and a single value will be inserted instead.

Specified by:
replaceParameter in interface RedirectResolution
Parameters:
name - the name of the parameter to be replaced.
value - the new value of the parameter. If null, the parameter will just be removed.

setScheme

public RedirectResolution setScheme(java.lang.String scheme)
Description copied from interface: RedirectResolution
Set to not null to override the request scheme.

Specified by:
setScheme in interface RedirectResolution
Parameters:
scheme - the scheme name, without colon: "http", "https", etc. Use the empty String to generate a protocol-less URL, e.g. "//myhost.com/resource.html"

setHostname

public RedirectResolution setHostname(java.lang.String hostname)
Description copied from interface: RedirectResolution
Set to not null to override the request server name

Specified by:
setHostname in interface RedirectResolution

setPort

public RedirectResolution setPort(java.lang.Integer port)
Description copied from interface: RedirectResolution
Set to not null to override the request port

Specified by:
setPort in interface RedirectResolution

setIncludeRequestParameters

public RedirectResolution setIncludeRequestParameters(boolean addCurrentRequestParameters)
Description copied from interface: RedirectResolution
true to append to the generated URL all current request parameters, default false. Parameters added to this RedirectResolution instance will override the value included in the request.

Specified by:
setIncludeRequestParameters in interface RedirectResolution

addCookie

public RedirectResolution 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
Specified by:
addCookie in interface RedirectResolution
Overrides:
addCookie in class AbstractHttpResolution
Parameters:
name - the name of the cookie
value - the value of the Cookie

addCookie

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

Specified by:
addCookie in interface HttpResolution
Specified by:
addCookie in interface RedirectResolution
Overrides:
addCookie in class AbstractHttpResolution
Parameters:
cookie - the cookie to be added to the response

addHeader

public RedirectResolution 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
Specified by:
addHeader in interface RedirectResolution
Overrides:
addHeader in class AbstractHttpResolution
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.

setHeader

public RedirectResolution 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
Specified by:
setHeader in interface RedirectResolution
Overrides:
setHeader in class AbstractHttpResolution
Parameters:
name - the name of the http header
value - the value of the http header

setHeaderIfNotPresent

public RedirectResolution 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
Specified by:
setHeaderIfNotPresent in interface RedirectResolution
Overrides:
setHeaderIfNotPresent in class AbstractHttpResolution
Parameters:
name - the name of the http header
value - the value of the http header

setCharset

public RedirectResolution 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
Specified by:
setCharset in interface RedirectResolution
Overrides:
setCharset in class AbstractHttpResolution

setContentType

public RedirectResolution 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
Specified by:
setContentType in interface RedirectResolution
Overrides:
setContentType in class AbstractHttpResolution

setCacheControl

public RedirectResolution 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
Specified by:
setCacheControl in interface RedirectResolution
Overrides:
setCacheControl in class AbstractHttpResolution
Parameters:
cacheControl - the cache data.
Returns:
this same instance, to allow easy chaining of invocations