public class Result
extends java.lang.Object
Constructor and Description |
---|
Result(int status)
Create a result with no entity.
|
Result(int status,
HttpEntity body)
Create a result.
|
Result(int status,
java.util.Map<java.lang.String,java.lang.String> headers)
Create a result with no body.
|
Result(int status,
java.util.Map<java.lang.String,java.lang.String> headers,
HttpEntity body)
Create a result.
|
Result(int status,
java.lang.String reasonPhrase,
java.util.Map<java.lang.String,java.lang.String> headers,
HttpEntity body)
Create a result.
|
Result(ResponseHeader header,
HttpEntity body)
Create a result from a Scala ResponseHeader and a body.
|
Result(ResponseHeader header,
HttpEntity body,
Http.Session session,
Http.Flash flash,
java.util.List<Http.Cookie> cookies)
Create a result from a Scala ResponseHeader and a body.
|
Modifier and Type | Method and Description |
---|---|
Result |
addingToSession(Http.Request request,
java.util.Map<java.lang.String,java.lang.String> values)
Adds values to the session.
|
Result |
addingToSession(Http.Request request,
java.lang.String key,
java.lang.String value)
Adds the given key and value to the session.
|
Result |
as(java.lang.String contentType)
Return a copy of the result with a different Content-Type header.
|
play.api.mvc.Result |
asScala()
Convert this result to a Scala result.
|
HttpEntity |
body()
Get the body of this result.
|
java.util.Optional<java.lang.String> |
charset()
Extracts the Charset of this Result value.
|
java.util.Optional<java.lang.String> |
contentType()
Extracts the Content-Type of this Result value.
|
Http.Cookie |
cookie(java.lang.String name)
Deprecated.
Deprecated as of 2.7.0. Use
getCookie(String) |
Http.Cookies |
cookies()
Extracts the Cookies (an iterator) from this result value.
|
Result |
discardingCookie(java.lang.String name)
Discard a cookie on the default path ("/") with no domain and that's not secure.
|
Result |
discardingCookie(java.lang.String name,
java.lang.String path)
Discard a cookie on the given path with no domain and not that's secure.
|
Result |
discardingCookie(java.lang.String name,
java.lang.String path,
java.lang.String domain)
Discard a cookie on the given path and domain that's not secure.
|
Result |
discardingCookie(java.lang.String name,
java.lang.String path,
java.lang.String domain,
boolean secure)
Discard a cookie in this result
|
Http.Flash |
flash()
Extracts the Flash values of this Result value.
|
Result |
flashing(java.util.Map<java.lang.String,java.lang.String> values)
Adds values to the flash.
|
Result |
flashing(java.lang.String key,
java.lang.String value)
Adds the given key and value to the flash.
|
java.util.Optional<Http.Cookie> |
getCookie(java.lang.String name)
Extracts a Cookie value from this Result value
|
protected ResponseHeader |
getHeader()
Get the response header
|
java.util.Optional<java.lang.String> |
header(java.lang.String header)
Extracts an Header value of this Result value.
|
java.util.Map<java.lang.String,java.lang.String> |
headers()
Extracts all Headers of this Result value.
|
java.util.Optional<java.lang.String> |
reasonPhrase()
Get the reason phrase, if it was set.
|
java.util.Optional<java.lang.String> |
redirectLocation()
Extracts the Location header of this Result value if this Result is a Redirect.
|
Result |
removingFromFlash(java.lang.String... keys)
Removes values from the flash.
|
Result |
removingFromSession(Http.Request request,
java.lang.String... keys)
Removes values from the session.
|
Http.Session |
session()
Extracts the Session of this Result value.
|
Http.Session |
session(Http.Request request) |
int |
status()
Get the status.
|
Result |
withCookies(Http.Cookie... newCookies)
Returns a copy of this result with the given cookies.
|
Result |
withFlash(Http.Flash flash)
Sets a new flash for this result, discarding the existing flash.
|
Result |
withFlash(java.util.Map<java.lang.String,java.lang.String> flash)
Sets a new flash for this result, discarding the existing flash.
|
Result |
withHeader(java.lang.String name,
java.lang.String value)
Return a copy of this result with the given header.
|
Result |
withHeaders(java.lang.String... nameValues)
Return a copy of this result with the given headers.
|
Result |
withLang(Lang lang,
MessagesApi messagesApi)
Returns a new result with the given lang set in a cookie.
|
Result |
withLang(java.util.Locale locale,
MessagesApi messagesApi)
Returns a new result with the given lang set in a cookie.
|
Result |
withNewFlash()
Discards the existing flash for this result.
|
Result |
withNewSession()
Discards the existing session for this result.
|
Result |
withoutHeader(java.lang.String name)
Discard a HTTP header in this result.
|
Result |
withoutLang(MessagesApi messagesApi)
Clears the lang cookie from this result.
|
Result |
withSession(Http.Session session)
Sets a new session for this result, discarding the existing session.
|
Result |
withSession(java.util.Map<java.lang.String,java.lang.String> session)
Sets a new session for this result, discarding the existing session.
|
public Result(ResponseHeader header, HttpEntity body, Http.Session session, Http.Flash flash, java.util.List<Http.Cookie> cookies)
header
- the response headerbody
- the response body.session
- the session set on the response.flash
- the flash object on the response.cookies
- the cookies set on the response.public Result(ResponseHeader header, HttpEntity body)
header
- the response headerbody
- the response body.public Result(int status, java.lang.String reasonPhrase, java.util.Map<java.lang.String,java.lang.String> headers, HttpEntity body)
status
- The status.reasonPhrase
- The reason phrase, if a non default reason phrase is required.headers
- The headers.body
- The body.public Result(int status, java.util.Map<java.lang.String,java.lang.String> headers, HttpEntity body)
status
- The status.headers
- The headers.body
- The body.public Result(int status, java.util.Map<java.lang.String,java.lang.String> headers)
status
- The status.headers
- The headers.public Result(int status, HttpEntity body)
status
- The status.body
- The entity.public Result(int status)
status
- The status.public int status()
public java.util.Optional<java.lang.String> reasonPhrase()
protected ResponseHeader getHeader()
public HttpEntity body()
public java.util.Optional<java.lang.String> redirectLocation()
public java.util.Optional<java.lang.String> header(java.lang.String header)
header
- the header name.public java.util.Map<java.lang.String,java.lang.String> headers()
The returned map is not modifiable.
public java.util.Optional<java.lang.String> contentType()
public java.util.Optional<java.lang.String> charset()
public Http.Flash flash()
public Result withFlash(Http.Flash flash)
flash
- the flash to set with this resultpublic Result withFlash(java.util.Map<java.lang.String,java.lang.String> flash)
flash
- the flash to set with this resultpublic Result withNewFlash()
public Result flashing(java.util.Map<java.lang.String,java.lang.String> values)
values
- A map with values to add to this result's flashpublic Result flashing(java.lang.String key, java.lang.String value)
key
- The key to add to this result's flashvalue
- The value to add to this result's flashpublic Result removingFromFlash(java.lang.String... keys)
keys
- Keys to remove from flashpublic Http.Session session()
public Http.Session session(Http.Request request)
request
- Current requestpublic Result withSession(Http.Session session)
session
- the session to set with this resultpublic Result withSession(java.util.Map<java.lang.String,java.lang.String> session)
session
- the session to set with this resultpublic Result withNewSession()
public Result addingToSession(Http.Request request, java.util.Map<java.lang.String,java.lang.String> values)
values
- A map with values to add to this result's sessionpublic Result addingToSession(Http.Request request, java.lang.String key, java.lang.String value)
key
- The key to add to this result's sessionvalue
- The value to add to this result's sessionpublic Result removingFromSession(Http.Request request, java.lang.String... keys)
keys
- Keys to remove from session@Deprecated public Http.Cookie cookie(java.lang.String name)
getCookie(String)
name
- the cookie's name.public java.util.Optional<Http.Cookie> getCookie(java.lang.String name)
name
- the cookie's name.public Http.Cookies cookies()
public Result withCookies(Http.Cookie... newCookies)
newCookies
- the cookies to add to the result.public Result discardingCookie(java.lang.String name)
name
- The name of the cookie to discard, must not be nullpublic Result discardingCookie(java.lang.String name, java.lang.String path)
name
- The name of the cookie to discard, must not be nullpath
- The path of the cookie to discard, may be nullpublic Result discardingCookie(java.lang.String name, java.lang.String path, java.lang.String domain)
name
- The name of the cookie to discard, must not be nullpath
- The path of the cookie te discard, may be nulldomain
- The domain of the cookie to discard, may be nullpublic Result discardingCookie(java.lang.String name, java.lang.String path, java.lang.String domain, boolean secure)
name
- The name of the cookie to discard, must not be nullpath
- The path of the cookie te discard, may be nulldomain
- The domain of the cookie to discard, may be nullsecure
- Whether the cookie to discard is securepublic Result withHeader(java.lang.String name, java.lang.String value)
name
- the header namevalue
- the header valuepublic Result withHeaders(java.lang.String... nameValues)
The headers are processed in pairs, so nameValues(0) is the first header's name, and nameValues(1) is the first header's value, nameValues(2) is second header's name, and so on.
nameValues
- the array of names and values.public Result withoutHeader(java.lang.String name)
name
- the header namepublic Result as(java.lang.String contentType)
contentType
- the content type to setpublic Result withLang(Lang lang, MessagesApi messagesApi)
public Result action() {
ok("Hello").withLang(Lang.forCode("es"), messagesApi);
}
Where messagesApi
were injected.lang
- the new langmessagesApi
- the messages api implementationMessagesApi.setLang(Result, Lang)
public Result withLang(java.util.Locale locale, MessagesApi messagesApi)
public Result action() {
ok("Hello").withLang(new Locale("es"), messagesApi);
}
Where messagesApi
were injected.locale
- the new langmessagesApi
- the messages api implementationMessagesApi.setLang(Result, Lang)
public Result withoutLang(MessagesApi messagesApi)
public Result action() {
ok("Hello").withoutLang(messagesApi);
}
Where messagesApi
were injected.messagesApi
- the messages api implementationMessagesApi.clearLang(Result)
public play.api.mvc.Result asScala()