public class HttpCookies
extends java.lang.Object
Encapsulates a map of HTTP cookies.
Modifier and Type | Field and Description |
---|---|
static HttpCookies |
empty |
Constructor and Description |
---|
HttpCookies() |
Modifier and Type | Method and Description |
---|---|
void |
addAll(HttpCookies other)
Add all of the cookies from another cookies object into this cookies object.
|
void |
clear()
Clear all the cookies.
|
HttpCookies |
concurrent()
Return a thread-safe cookies object that delegates to this cookies object.
|
HttpCookies |
copy()
Return a copy of these cookies.
|
boolean |
delete(java.lang.String name)
Delete the value of a cookie, if present.
|
StringMap.EntryList |
entries()
Return the cookie entries (name/value pairs).
|
java.lang.String |
get(java.lang.String name)
Return (nullable) The value of a cookie, or
null if not found. |
boolean |
has(java.lang.String name)
Return
true if a specified cookie exists. |
StringList |
keys()
Return the cookie names.
|
void |
set(java.lang.String name,
java.lang.String value)
Set the value of a cookie.
|
int |
size()
Return the number of cookies.
|
StringMap.EntryList |
sortedEntries()
Return the cookie entries (name/value pairs) sorted by name (case insensitive).
|
java.lang.String |
toString()
Return cookies as a JSON string.
|
public static final HttpCookies empty
public void addAll(HttpCookies other)
Add all of the cookies from another cookies object into this cookies object.
other
- Another cookies object.public void clear()
Clear all the cookies.
public HttpCookies concurrent()
Return a thread-safe cookies object that delegates to this cookies object. A regular HttpCookies object is not thread-safe for concurrent read/write access. This function will return a thread-safe wrapper.
public HttpCookies copy()
Return a copy of these cookies.
public boolean delete(java.lang.String name)
Delete the value of a cookie, if present.
name
- Cookie name.true
if a cookie was deleted.public StringMap.EntryList entries()
Return the cookie entries (name/value pairs).
public java.lang.String get(java.lang.String name)
Return (nullable) The value of a cookie, or null
if not found.
name
- Cookie name.null
if not found.public boolean has(java.lang.String name)
Return true
if a specified cookie exists.
name
- Cookie name.true
if a specified cookie exists.public StringList keys()
Return the cookie names.
public void set(java.lang.String name, java.lang.String value)
Set the value of a cookie.
name
- Cookie name.value
- Cookie value.public int size()
Return the number of cookies.
public StringMap.EntryList sortedEntries()
Return the cookie entries (name/value pairs) sorted by name (case insensitive).
public java.lang.String toString()
Return cookies as a JSON string.
toString
in class java.lang.Object