Top Description Inners Fields Constructors Methods
jakarta.ws.rs.core

public Class Cookie

extends Object
Class Inheritance
Known Direct Subclasses
jakarta.ws.rs.core.NewCookie
Imports
java.util.Objects, jakarta.ws.rs.ext.RuntimeDelegate, .RuntimeDelegate.HeaderDelegate

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.
Authors
Paul Sandoz, Marc Hadley
Since
1.0
See Also
IETF RFC 2109

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
Cookie.AbstractCookieBuilder<
the current AbstractCookieBuilder type.
T extends Cookie.AbstractCookieBuilder<T>
>

JAX-RS abstract Cookie builder class.

public static class
Cookie.Builder

JAX-RS Cookie builder class.

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_VERSION

Cookies using the default version correspond to RFC 2109.

private final String
private static final RuntimeDelegate.HeaderDelegate<Cookie>
HEADER_DELEGATE

Deprecated This field will be removed in a future version. See https://github.com/eclipse-ee4j/jaxrs-api/issues/607
private final String
private final String
private final String
private final int

Constructor Summary

AccessConstructor and Description

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true, if the object is a Cookie with the same value for all properties, false otherwise.
equals
(final Object
the object to compare to.
obj
)

Overrides java.lang.Object.equals.

Compare for equality.
public String

Returns:

the cookie domain.
getDomain
()

Get the domain of the cookie.

public String

Returns:

the cookie name.
getName
()

Get the name of the cookie.

public String

Returns:

the cookie path.
getPath
()

Get the path of the cookie.

public String

Returns:

the cookie value.
getValue
()

Get the value of the cookie.

public int

Returns:

the cookie version.
getVersion
()

Get the version of the cookie.

public int

Returns:

the cookie hash code.
hashCode
()

Overrides java.lang.Object.hashCode.

Generate a hash code by hashing all of the cookies properties.
public String

Returns:

a stringified cookie.
toString
()

Overrides java.lang.Object.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.
public static Cookie

Returns:

the newly created Cookie.
valueOf
(final String
the cookie 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 of Cookie by parsing the supplied string.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

DEFAULT_VERSIONback to summary
public static final int DEFAULT_VERSION

Cookies using the default version correspond to RFC 2109.

domainback to summary
private final String domain
HEADER_DELEGATEback to summary
private static final RuntimeDelegate.HeaderDelegate<Cookie> HEADER_DELEGATE

Deprecated

This field will be removed in a future version. See https://github.com/eclipse-ee4j/jaxrs-api/issues/607

Annotations
@Deprecated
nameback to summary
private final String name
pathback to summary
private final String path
valueback to summary
private final String value
versionback to summary
private final int version

Constructor Detail

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Compare for equality.

Parameters
obj:Object

the object to compare to.

Returns:boolean

true, if the object is a Cookie with the same value for all properties, false otherwise.

Annotations
@SuppressWarnings:StringEquality, RedundantIfStatement
@Override
getDomainback to summary
public String getDomain()

Get the domain of the cookie.

Returns:String

the cookie domain.

getNameback to summary
public String getName()

Get the name of the cookie.

Returns:String

the cookie name.

getPathback to summary
public String getPath()

Get the path of the cookie.

Returns:String

the cookie path.

getValueback to summary
public String getValue()

Get the value of the cookie.

Returns:String

the cookie value.

getVersionback to summary
public int getVersion()

Get the version of the cookie.

Returns:int

the cookie version.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Generate a hash code by hashing all of the cookies properties.

Returns:int

the cookie hash code.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.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.

Returns:String

a stringified cookie.

Annotations
@Override
@Deprecated
valueOfback to summary
public static Cookie valueOf(final 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 of Cookie by parsing the supplied string.

Parameters
value:String

the cookie string.

Returns:Cookie

the newly created Cookie.

Annotations
@Deprecated
Exceptions
IllegalArgumentException:
if the supplied string cannot be parsed or is null.
jakarta.ws.rs.core back to summary

public abstract Class Cookie.AbstractCookieBuilder<T extends Cookie.AbstractCookieBuilder<T>>

extends Object
Class Inheritance
Known Direct Subclasses
jakarta.ws.rs.core.NewCookie.AbstractNewCookieBuilder, jakarta.ws.rs.core.Cookie.Builder
Type Parameters
<T>
the current AbstractCookieBuilder type.

JAX-RS abstract Cookie builder class.
Since
3.1

Field Summary

Modifier and TypeField and Description
private String
private final String
private String
private String
private int

Constructor Summary

AccessConstructor and Description
public
AbstractCookieBuilder(String
the name of the cookie.
name
)

Create a new instance.

Method Summary

Modifier and TypeMethod and Description
public abstract Cookie

Returns:

a new Cookie instance.
build
()

Build a new Cookie instance using all the configuration previously specified in this builder.

public T

Returns:

the updated builder instance.
domain
(String
the host domain for which the cookie is valid.
domain
)

Set the domain of the cookie.

public T

Returns:

the updated builder instance.
path
(String
the URI path for which the cookie is valid.
path
)

Set the path of the cookie.

private T
self()

public T

Returns:

the updated builder instance.
value
(String
the value of the cookie.
value
)

Set the value of the cookie.

public T

Returns:

the updated builder instance.
version
(int
the version of the specification to which the cookie complies.
version
)

Set the version of the cookie.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

domainback to summary
private String domain
nameback to summary
private final String name
pathback to summary
private String path
valueback to summary
private String value
versionback to summary
private int version

Constructor Detail

AbstractCookieBuilderback to summary
public AbstractCookieBuilder(String name)

Create a new instance.

Parameters
name:String

the name of the cookie.

Method Detail

buildback to summary
public abstract Cookie build()

Build a new Cookie instance using all the configuration previously specified in this builder.

Returns:Cookie

a new Cookie instance.

Exceptions
IllegalArgumentException:
if name is null.
domainback to summary
public T domain(String domain)

Set the domain of the cookie.

Parameters
domain:String

the host domain for which the cookie is valid.

Returns:T

the updated builder instance.

pathback to summary
public T path(String path)

Set the path of the cookie.

Parameters
path:String

the URI path for which the cookie is valid.

Returns:T

the updated builder instance.

selfback to summary
private T self()
Annotations
@SuppressWarnings:unchecked
valueback to summary
public T value(String value)

Set the value of the cookie.

Parameters
value:String

the value of the cookie.

Returns:T

the updated builder instance.

versionback to summary
public T version(int version)

Set the version of the cookie. Defaults to Cookie#DEFAULT_VERSION

Parameters
version:int

the version of the specification to which the cookie complies.

Returns:T

the updated builder instance.

jakarta.ws.rs.core back to summary

public Class Cookie.Builder

extends Cookie.AbstractCookieBuilder<Cookie.Builder>
Class Inheritance

JAX-RS Cookie builder class.

Cookie builder provides methods that let you conveniently configure and subsequently build a new Cookie instance.

For example:
Cookie cookie = new Cookie.Builder("name")
        .path("/")
        .domain("domain.com")
        .build();
Since
3.1

Constructor Summary

AccessConstructor and Description
public
Builder(String
the name of the cookie.
name
)

Create a new instance.

Method Summary

Modifier and TypeMethod and Description
public Cookie
build()

Implements abstract jakarta.ws.rs.core.Cookie.AbstractCookieBuilder.build.

Build a new Cookie instance using all the configuration previously specified in this builder.
Inherited from jakarta.ws.rs.core.Cookie.AbstractCookieBuilder:
domainpathvalueversion

Constructor Detail

Builderback to summary
public Builder(String name)

Create a new instance.

Parameters
name:String

the name of the cookie.

Method Detail

buildback to summary
public Cookie build()

Implements abstract jakarta.ws.rs.core.Cookie.AbstractCookieBuilder.build.

Doc from jakarta.ws.rs.core.Cookie.AbstractCookieBuilder.build.

Build a new Cookie instance using all the configuration previously specified in this builder.

Returns:Cookie

a new Cookie instance.

Annotations
@Override