|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.loom.resolution.AbstractHttpResolution
org.loom.resolution.JacksonResolution
public class JacksonResolution
A resolution that uses Jackson to serialize a JSON response.
Constructor Summary | |
---|---|
JacksonResolution(org.codehaus.jackson.map.ObjectMapper mapper,
java.lang.Object contents)
|
Method Summary | |
---|---|
JacksonResolution |
addCookie(javax.servlet.http.Cookie cookie)
Adds a cookie |
JacksonResolution |
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). |
JacksonResolution |
addCookie(java.lang.String name,
java.lang.String value,
int maxAge)
Adds a cookie |
JacksonResolution |
addHeader(java.lang.String name,
java.lang.Object value)
Add a http header. |
java.lang.Object |
getContents()
|
org.codehaus.jackson.map.ObjectMapper |
getMapper()
|
void |
resolve(LoomServletRequest request,
LoomServletResponse response)
Write the response contents |
JacksonResolution |
setCacheControl(CacheControl cacheControl)
Sets the cache data to be sent to the browser |
JacksonResolution |
setCharset(java.lang.String charset)
Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8. |
JacksonResolution |
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. |
JacksonResolution |
setHeader(java.lang.String name,
java.lang.Object value)
Set a String http header. |
JacksonResolution |
setHeaderIfNotPresent(java.lang.String name,
java.lang.Object value)
Set a String http header if it has not been set. |
java.lang.String |
toString()
|
JacksonResolution |
withView(java.lang.Class<?> viewClass)
Specify the jackson view to use for serializing |
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, wait, wait, wait |
Constructor Detail |
---|
public JacksonResolution(org.codehaus.jackson.map.ObjectMapper mapper, java.lang.Object contents)
Method Detail |
---|
public void resolve(LoomServletRequest request, LoomServletResponse response) throws java.io.IOException, javax.servlet.ServletException
Resolution
resolve
in interface Resolution
resolve
in class AbstractHttpResolution
request
- the current request objectresponse
- the current response object
java.io.IOException
javax.servlet.ServletException
public java.lang.String toString()
toString
in class java.lang.Object
public JacksonResolution withView(java.lang.Class<?> viewClass)
public org.codehaus.jackson.map.ObjectMapper getMapper()
public java.lang.Object getContents()
public JacksonResolution addCookie(java.lang.String name, java.lang.String value)
HttpResolution
addCookie
in interface HttpResolution
addCookie
in class AbstractHttpResolution
name
- the name of the cookievalue
- the value of the Cookiepublic JacksonResolution addCookie(java.lang.String name, java.lang.String value, int maxAge)
HttpResolution
addCookie
in interface HttpResolution
addCookie
in class AbstractHttpResolution
name
- the name of the cookievalue
- the value of the CookiemaxAge
- 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).public JacksonResolution addCookie(javax.servlet.http.Cookie cookie)
HttpResolution
addCookie
in interface HttpResolution
addCookie
in class AbstractHttpResolution
cookie
- the cookie to be added to the responsepublic JacksonResolution addHeader(java.lang.String name, java.lang.Object value)
HttpResolution
addHeader
in interface HttpResolution
addHeader
in class AbstractHttpResolution
name
- the name of the http headervalue
- the value of the http header. Date, int and String are supported. Anything else will be cast to toString(). Null will be ignored.public JacksonResolution setHeader(java.lang.String name, java.lang.Object value)
HttpResolution
setHeader
in interface HttpResolution
setHeader
in class AbstractHttpResolution
name
- the name of the http headervalue
- the value of the http headerpublic JacksonResolution setHeaderIfNotPresent(java.lang.String name, java.lang.Object value)
HttpResolution
setHeaderIfNotPresent
in interface HttpResolution
setHeaderIfNotPresent
in class AbstractHttpResolution
name
- the name of the http headervalue
- the value of the http headerpublic JacksonResolution setCharset(java.lang.String charset)
HttpResolution
setCharset
in interface HttpResolution
setCharset
in class AbstractHttpResolution
public JacksonResolution setContentType(java.lang.String contentType)
HttpResolution
text/html;charset=UTF-8
.
Notice that #setCharset(String) can also be used for this.
setContentType
in interface HttpResolution
setContentType
in class AbstractHttpResolution
public JacksonResolution setCacheControl(CacheControl cacheControl)
CacheableResolution
setCacheControl
in interface CacheableResolution
setCacheControl
in interface HttpResolution
setCacheControl
in class AbstractHttpResolution
cacheControl
- the cache data.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |