Package jakarta.ws.rs.core
Class Cookie
- java.lang.Object
-
- jakarta.ws.rs.core.Cookie
-
- Direct Known Subclasses:
NewCookie
public class Cookie extends Object
Represents the value of a HTTP cookie, transferred in a request. RFC 2109 specifies the legal characters for name, value, path and domain. The default version of 1 corresponds to RFC 2109.- Since:
- 1.0
- Author:
- Paul Sandoz, Marc Hadley
- See Also:
- IETF RFC 2109
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Cookie.AbstractCookieBuilder<T extends Cookie.AbstractCookieBuilder<T>>
JAX-RS abstractCookie
builder class.static class
Cookie.Builder
JAX-RSCookie
builder class.
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_VERSION
Cookies using the default version correspond to RFC 2109.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Cookie(Cookie.AbstractCookieBuilder<?> builder)
Create a new instance from the suppliedCookie.AbstractCookieBuilder
instance.Cookie(String name, String value)
Deprecated.This constructor will be removed in a future version.Cookie(String name, String value, String path, String domain)
Deprecated.This constructor will be removed in a future version.Cookie(String name, String value, String path, String domain, int version)
Deprecated.This constructor will be removed in a future version.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(Object obj)
Compare for equality.String
getDomain()
Get the domain of the cookie.String
getName()
Get the name of the cookie.String
getPath()
Get the path of the cookie.String
getValue()
Get the value of the cookie.int
getVersion()
Get the version of the cookie.int
hashCode()
Generate a hash code by hashing all of the cookies properties.String
toString()
Deprecated.The format of the toString() method is subject to change in a future version.static Cookie
valueOf(String value)
Deprecated.This method will be removed in a future version.
-
-
-
Field Detail
-
DEFAULT_VERSION
public static final int DEFAULT_VERSION
Cookies using the default version correspond to RFC 2109.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Cookie
@Deprecated public Cookie(String name, String value, String path, String domain, int version) throws IllegalArgumentException
Deprecated.This constructor will be removed in a future version. Please useCookie.Builder
instead.Create a new instance.- Parameters:
name
- the name of the cookie.value
- the value of the cookie.path
- the URI path for which the cookie is valid.domain
- the host domain for which the cookie is valid.version
- the version of the specification to which the cookie complies.- Throws:
IllegalArgumentException
- if name isnull
.
-
Cookie
@Deprecated public Cookie(String name, String value, String path, String domain) throws IllegalArgumentException
Deprecated.This constructor will be removed in a future version. Please useCookie.Builder
instead.Create a new instance.- Parameters:
name
- the name of the cookie.value
- the value of the cookie.path
- the URI path for which the cookie is valid.domain
- the host domain for which the cookie is valid.- Throws:
IllegalArgumentException
- if name isnull
.
-
Cookie
@Deprecated public Cookie(String name, String value) throws IllegalArgumentException
Deprecated.This constructor will be removed in a future version. Please useCookie.Builder
instead.Create a new instance.- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Throws:
IllegalArgumentException
- if name isnull
.
-
Cookie
protected Cookie(Cookie.AbstractCookieBuilder<?> builder) throws IllegalArgumentException
Create a new instance from the suppliedCookie.AbstractCookieBuilder
instance.- Parameters:
builder
- the builder.- Throws:
IllegalArgumentException
- ifbuilder.name
isnull
.- Since:
- 3.1
-
-
Method Detail
-
valueOf
@Deprecated public static Cookie valueOf(String value)
Deprecated.This method will be removed in a future version. Please use RuntimeDelegate.getInstance().createHeaderDelegate(Cookie.class).fromString(value) instead.Creates a new instance ofCookie
by parsing the supplied string.- Parameters:
value
- the cookie string.- Returns:
- the newly created
Cookie
. - Throws:
IllegalArgumentException
- if the supplied string cannot be parsed or isnull
.
-
getName
public String getName()
Get the name of the cookie.- Returns:
- the cookie name.
-
getValue
public String getValue()
Get the value of the cookie.- Returns:
- the cookie value.
-
getVersion
public int getVersion()
Get the version of the cookie.- Returns:
- the cookie version.
-
getDomain
public String getDomain()
Get the domain of the cookie.- Returns:
- the cookie domain.
-
getPath
public String getPath()
Get the path of the cookie.- Returns:
- the cookie path.
-
toString
@Deprecated public String toString()
Deprecated.The format of the toString() method is subject to change in a future version. Please use RuntimeDelegate.getInstance().createHeaderDelegate(Cookie.class).toString(value) instead if you rely on the format of this method.Convert the cookie to a string suitable for use as the value of the corresponding HTTP header.
-
hashCode
public int hashCode()
Generate a hash code by hashing all of the cookies properties.
-
-