Package javax.ws.rs.core
Class Cookie
- java.lang.Object
-
- javax.ws.rs.core.Cookie
-
- Direct Known Subclasses:
NewCookie
public class Cookie extends java.lang.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.- See Also:
- IETF RFC 2109
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_VERSION
Cookies using the default version correspond to RFC 2109.private static RuntimeDelegate.HeaderDelegate<Cookie>
delegate
private java.lang.String
domain
private java.lang.String
name
private java.lang.String
path
private java.lang.String
value
private int
version
-
Constructor Summary
Constructors Constructor Description Cookie(java.lang.String name, java.lang.String value)
Create a new instance.Cookie(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain)
Create a new instance.Cookie(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain, int version)
Create a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Compare for equalityjava.lang.String
getDomain()
Get the domain of the cookiejava.lang.String
getName()
Get the name of the cookiejava.lang.String
getPath()
Get the path of the cookiejava.lang.String
getValue()
Get the value of the cookieint
getVersion()
Get the version of the cookieint
hashCode()
Generate a hashcode by hashing all of the cookies propertiesjava.lang.String
toString()
Convert the cookie to a string suitable for use as the value of the corresponding HTTP header.static Cookie
valueOf(java.lang.String value)
Creates a new instance of Cookie by parsing the supplied string.
-
-
-
Field Detail
-
DEFAULT_VERSION
public static final int DEFAULT_VERSION
Cookies using the default version correspond to RFC 2109.- See Also:
- Constant Field Values
-
delegate
private static final RuntimeDelegate.HeaderDelegate<Cookie> delegate
-
name
private java.lang.String name
-
value
private java.lang.String value
-
version
private int version
-
path
private java.lang.String path
-
domain
private java.lang.String domain
-
-
Constructor Detail
-
Cookie
public Cookie(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain, int version)
Create a new instance.- Parameters:
name
- the name of the cookievalue
- the value of the cookiepath
- the URI path for which the cookie is validdomain
- the host domain for which the cookie is validversion
- the version of the specification to which the cookie complies- Throws:
java.lang.IllegalArgumentException
- if name is null
-
Cookie
public Cookie(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain)
Create a new instance.- Parameters:
name
- the name of the cookievalue
- the value of the cookiepath
- the URI path for which the cookie is validdomain
- the host domain for which the cookie is valid- Throws:
java.lang.IllegalArgumentException
- if name is null
-
Cookie
public Cookie(java.lang.String name, java.lang.String value)
Create a new instance.- Parameters:
name
- the name of the cookievalue
- the value of the cookie- Throws:
java.lang.IllegalArgumentException
- if name is null
-
-
Method Detail
-
valueOf
public static Cookie valueOf(java.lang.String value) throws java.lang.IllegalArgumentException
Creates a new instance of Cookie by 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 is null
-
getName
public java.lang.String getName()
Get the name of the cookie- Returns:
- the name
-
getValue
public java.lang.String getValue()
Get the value of the cookie- Returns:
- the value
-
getVersion
public int getVersion()
Get the version of the cookie- Returns:
- the version
-
getDomain
public java.lang.String getDomain()
Get the domain of the cookie- Returns:
- the domain
-
getPath
public java.lang.String getPath()
Get the path of the cookie- Returns:
- the path
-
toString
public java.lang.String toString()
Convert the cookie to a string suitable for use as the value of the corresponding HTTP header.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a stringified cookie
-
hashCode
public int hashCode()
Generate a hashcode by hashing all of the cookies properties- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hashcode
-
equals
public boolean equals(java.lang.Object obj)
Compare for equality- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to compare to- Returns:
- true if the object is a
Cookie
with the same value for all properties, false otherwise.
-
-