@Loggable(value=1) public final class CookieBuilder extends Object
It is a convenient cookie builder for JAX-RS responses, for example:
Response.ok().cookie(
new CookieBuilder(this.uriInfo().getBaseUri())
.name("my-cookie")
.value("some value of the cookie")
.temporary()
.build()
);
When you want to instruct the client to delete the cookie:
Response.ok().cookie(
new CookieBuilder(this.uriInfo().getBaseUri())
.name("my-cookie")
.build()
);
It is much more convenient than new NewCookie(..) from JAX-RS.
The class is mutable and thread-safe.
| Constructor and Description |
|---|
CookieBuilder(URI uri)
Public ctor.
|
CookieBuilder(javax.ws.rs.core.UriBuilder builder)
Public ctor.
|
| Modifier and Type | Method and Description |
|---|---|
javax.ws.rs.core.NewCookie |
build()
Build cookie.
|
CookieBuilder |
days(int days)
Make this cookie temporary, with certain pre-defined age in days.
|
CookieBuilder |
name(String txt)
Named like this.
|
CookieBuilder |
path(String txt)
Set path.
|
CookieBuilder |
temporary()
Make this cookie temporary, with 90 days age.
|
CookieBuilder |
value(Object object)
With value like this.
|
public CookieBuilder(@NotNull
URI uri)
uri - The URIpublic CookieBuilder(@NotNull
javax.ws.rs.core.UriBuilder builder)
builder - The URI builderpublic CookieBuilder name(@NotNull String txt)
txt - The namepublic CookieBuilder value(@NotNull Object object)
object - The valuepublic CookieBuilder path(@NotNull String txt)
txt - The pathpublic CookieBuilder temporary()
public CookieBuilder days(int days)
days - How many days to livepublic javax.ws.rs.core.NewCookie build()
Copyright © 2011–2014 ReXSL.com. All rights reserved.