public final class Cookies extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Cookies.Attributes |
static class |
Cookies.Converter |
| Modifier and Type | Method and Description |
|---|---|
AttributesDefinition |
defaults()
Retrieve the default attributes of this instance
|
Map<String,String> |
get()
Retrieves all cookies
|
String |
get(String name)
Retrieves a cookie
By default, assumes the characters not allowed in each cookie name are encoded with each one's UTF-8 Hex equivalent using percent-encoding. |
<T> T |
get(String name,
Class<T> dataType)
Retrieves a cookie and parse it using the given dataType instance
|
<T> T |
get(String name,
com.fasterxml.jackson.core.type.TypeReference<T> typeRef)
Retrieves a cookie and parse it using the given type reference.
|
static Cookies |
initFromServlet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
void |
remove(String name)
Remove an existing cookie using the default attributes
|
void |
remove(String name,
AttributesDefinition attributes)
Remove an existing cookie
By default, assumes the characters not allowed in each cookie name are encoded with each one's UTF-8 Hex equivalent using percent-encoding. |
void |
set(String name,
boolean value)
Create or update an existing cookie using the default attributes and serializing the typed value
|
void |
set(String name,
boolean value,
AttributesDefinition attributes)
Create or update an existing cookie extending the default attributes and serializing the typed value
|
void |
set(String name,
CookieValue value)
Create or update an existing cookie extending the default attributes and serializing the typed value
|
void |
set(String name,
CookieValue value,
AttributesDefinition attributes)
Create or update an existing cookie extending the default attributes and serializing the typed value
|
void |
set(String name,
int value)
Create or update an existing cookie using the default attributes and serializing the typed value
|
void |
set(String name,
int value,
AttributesDefinition attributes)
Create or update an existing cookie extending the default attributes and serializing the typed value
|
<T> void |
set(String name,
List<T> value)
Create or update an existing cookie using the default attributes and serializing the typed value
|
<T> void |
set(String name,
List<T> value,
AttributesDefinition attributes)
Create or update an existing cookie extending the default attributes and serializing the typed value
|
void |
set(String name,
String value)
Create or update an existing cookie using the default attributes
|
void |
set(String name,
String value,
AttributesDefinition attributes)
Create or update an existing cookie extending the default attributes
By default, the characters not allowed in the cookie name or value are encoded with each one's UTF-8 Hex equivalent using percent-encoding. |
Cookies |
withConverter(ConverterStrategy converter)
Create a new instance of the api that overrides the default decoding implementation
All methods that rely in a proper decoding to work, such as remove(String, AttributesDefinition) and get(String), will run the converter first
for each cookie. |
public static Cookies initFromServlet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
public String get(String name)
null if the cookie doesn't existpublic <T> T get(String name, Class<T> dataType) throws CookieParseException
CookieParseException - If there's an error while parsing the cookie name using the given dataTypepublic <T> T get(String name, com.fasterxml.jackson.core.type.TypeReference<T> typeRef) throws CookieParseException
CookieParseException - If there's an error while parsing the cookie name using the given dataTypeget(String, Class)public Map<String,String> get()
get(String)public void set(String name, String value, AttributesDefinition attributes)
get(String)public void set(String name, int value, AttributesDefinition attributes) throws CookieSerializationException
public void set(String name, boolean value, AttributesDefinition attributes) throws CookieSerializationException
public <T> void set(String name, List<T> value, AttributesDefinition attributes) throws CookieSerializationException
public void set(String name, CookieValue value, AttributesDefinition attributes) throws CookieSerializationException
public void set(String name, String value)
public void set(String name, int value) throws CookieSerializationException
CookieSerializationExceptionset(String, String)public void set(String name, boolean value)
set(String, String)public <T> void set(String name, List<T> value) throws CookieSerializationException
CookieSerializationExceptionset(String, String)public void set(String name, CookieValue value) throws CookieSerializationException
CookieSerializationExceptionset(String, String)public void remove(String name, AttributesDefinition attributes)
attributes - You must pass the exact same path, domain and secure attributes that were used to set
the cookie, unless you're relying on the default attributesget(String)public void remove(String name)
remove(String, AttributesDefinition)public AttributesDefinition defaults()
public Cookies withConverter(ConverterStrategy converter)
remove(String, AttributesDefinition) and get(String), will run the converter first
for each cookie.Copyright © 2015. All rights reserved.