- java.lang.Object
-
- jakarta.ws.rs.core.Cookie
-
- Direct Known Subclasses:
NewCookie
public class Cookie extends java.lang.ObjectRepresents 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
- See Also:
- IETF RFC 2109
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCookie.AbstractCookieBuilder<T extends Cookie.AbstractCookieBuilder<T>>JAX-RS abstractCookiebuilder class.static classCookie.BuilderJAX-RSCookiebuilder class.
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_VERSIONCookies using the default version correspond to RFC 2109.private java.lang.Stringdomainprivate static RuntimeDelegate.HeaderDelegate<Cookie>HEADER_DELEGATEDeprecated.This field will be removed in a future version.private java.lang.Stringnameprivate java.lang.Stringpathprivate java.lang.Stringvalueprivate intversion
-
Constructor Summary
Constructors Modifier Constructor Description protectedCookie(Cookie.AbstractCookieBuilder<?> builder)Create a new instance from the suppliedCookie.AbstractCookieBuilderinstance.Cookie(java.lang.String name, java.lang.String value)Deprecated.This constructor will be removed in a future version.Cookie(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain)Deprecated.This constructor will be removed in a future version.Cookie(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.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 booleanequals(java.lang.Object obj)Compare for equality.java.lang.StringgetDomain()Get the domain of the cookie.java.lang.StringgetName()Get the name of the cookie.java.lang.StringgetPath()Get the path of the cookie.java.lang.StringgetValue()Get the value of the cookie.intgetVersion()Get the version of the cookie.inthashCode()Generate a hash code by hashing all of the cookies properties.java.lang.StringtoString()Deprecated.The format of the toString() method is subject to change in a future version.static CookievalueOf(java.lang.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
-
HEADER_DELEGATE
@Deprecated private static final RuntimeDelegate.HeaderDelegate<Cookie> HEADER_DELEGATE
Deprecated.This field will be removed in a future version. See https://github.com/jakartaee/rest/issues/607
-
name
private final java.lang.String name
-
value
private final java.lang.String value
-
version
private final int version
-
path
private final java.lang.String path
-
domain
private final java.lang.String domain
-
-
Constructor Detail
-
Cookie
@Deprecated public Cookie(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain, int version) throws java.lang.IllegalArgumentExceptionDeprecated.This constructor will be removed in a future version. Please useCookie.Builderinstead.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:
java.lang.IllegalArgumentException- if name isnull.
-
Cookie
@Deprecated public Cookie(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain) throws java.lang.IllegalArgumentExceptionDeprecated.This constructor will be removed in a future version. Please useCookie.Builderinstead.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:
java.lang.IllegalArgumentException- if name isnull.
-
Cookie
@Deprecated public Cookie(java.lang.String name, java.lang.String value) throws java.lang.IllegalArgumentExceptionDeprecated.This constructor will be removed in a future version. Please useCookie.Builderinstead.Create a new instance.- Parameters:
name- the name of the cookie.value- the value of the cookie.- Throws:
java.lang.IllegalArgumentException- if name isnull.
-
Cookie
protected Cookie(Cookie.AbstractCookieBuilder<?> builder) throws java.lang.IllegalArgumentException
Create a new instance from the suppliedCookie.AbstractCookieBuilderinstance.- Parameters:
builder- the builder.- Throws:
java.lang.IllegalArgumentException- ifbuilder.nameisnull.- Since:
- 3.1
-
-
Method Detail
-
valueOf
@Deprecated public static Cookie valueOf(java.lang.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 ofCookieby parsing the supplied string.- Parameters:
value- the cookie string.- Returns:
- the newly created
Cookie. - Throws:
java.lang.IllegalArgumentException- if the supplied string cannot be parsed or isnull.
-
getName
public java.lang.String getName()
Get the name of the cookie.- Returns:
- the cookie name.
-
getValue
public java.lang.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 java.lang.String getDomain()
Get the domain of the cookie.- Returns:
- the cookie domain.
-
getPath
public java.lang.String getPath()
Get the path of the cookie.- Returns:
- the cookie path.
-
toString
@Deprecated public java.lang.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.- Overrides:
toStringin classjava.lang.Object- Returns:
- a stringified cookie.
-
hashCode
public int hashCode()
Generate a hash code by hashing all of the cookies properties.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the cookie hash code.
-
equals
public boolean equals(java.lang.Object obj)
Compare for equality.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to compare to.- Returns:
true, if the object is aCookiewith the same value for all properties,falseotherwise.
-
-