Top Description Fields Constructors Methods
io.netty.handler.codec.http.cookie

public Class DefaultCookie

extends Object
implements Cookie
Class Inheritance
All Implemented Interfaces
io.netty.handler.codec.http.cookie.Cookie, java.lang.Comparable
Known Direct Subclasses
io.netty.handler.codec.http.DefaultCookie
Imports
io.netty.handler.codec.http.cookie.CookieHeaderNames.SameSite

The default Cookie implementation.

Field Summary

Modifier and TypeField and Description
private String
private boolean
private long
private final String
private boolean
private String
private CookieHeaderNames.SameSite
private boolean
private String
private boolean

Constructor Summary

AccessConstructor and Description
public
DefaultCookie(String name, String value)

Creates a new cookie with the specified name and value.

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(Cookie
the object to be compared.
c
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.
public String
domain()

Implements io.netty.handler.codec.http.cookie.Cookie.domain.

Returns the domain of this Cookie.
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public boolean
isHttpOnly()

Implements io.netty.handler.codec.http.cookie.Cookie.isHttpOnly.

Checks to see if this Cookie can only be accessed via HTTP.
public boolean

Returns:

True if this Cookie is partitioned, otherwise false
isPartitioned
()

Checks to see if this Cookie is partitioned

public boolean
isSecure()

Implements io.netty.handler.codec.http.cookie.Cookie.isSecure.

Checks to see if this Cookie is secure
public long
maxAge()

Implements io.netty.handler.codec.http.cookie.Cookie.maxAge.

Returns the maximum age of this Cookie in seconds or Cookie#UNDEFINED_MAX_AGE if unspecified
public String
name()

Implements io.netty.handler.codec.http.cookie.Cookie.name.

Returns the name of this Cookie.
public String
path()

Implements io.netty.handler.codec.http.cookie.Cookie.path.

Returns the path of this Cookie.
public CookieHeaderNames.SameSite

Returns:

same-site-flag value
sameSite
()

Checks to see if this Cookie can be sent along cross-site requests.

public void
setDomain(String
The domain to use
domain
)

Implements io.netty.handler.codec.http.cookie.Cookie.setDomain.

Sets the domain of this Cookie.
public void
setHttpOnly(boolean
True if the Cookie is HTTP only, otherwise false.
httpOnly
)

Implements io.netty.handler.codec.http.cookie.Cookie.setHttpOnly.

Determines if this Cookie is HTTP only.
public void
setMaxAge(long
The maximum age of this Cookie in seconds
maxAge
)

Implements io.netty.handler.codec.http.cookie.Cookie.setMaxAge.

Sets the maximum age of this Cookie in seconds.
public void
setPartitioned(boolean
True if this Cookie is to be partitioned, otherwise false
partitioned
)

Sets the Partitioned attribute of this Cookie

public void
setPath(String
The path to use for this Cookie
path
)

Implements io.netty.handler.codec.http.cookie.Cookie.setPath.

Sets the path of this Cookie.
public void
setSameSite(CookieHeaderNames.SameSite
same-site-flag value
sameSite
)

Determines if this this Cookie can be sent along cross-site requests.

public void
setSecure(boolean
True if this Cookie is to be secure, otherwise false
secure
)

Implements io.netty.handler.codec.http.cookie.Cookie.setSecure.

Sets the security getStatus of this Cookie
public void
setValue(String
The value to set
value
)

Implements io.netty.handler.codec.http.cookie.Cookie.setValue.

Sets the value of this Cookie.
public void
setWrap(boolean
true if wrap
wrap
)

Implements io.netty.handler.codec.http.cookie.Cookie.setWrap.

Sets true if the value of this Cookie is to be wrapped with double quotes.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
protected String

Returns:

the trimmed, validated attribute value
validateValue
(String
attribute name
name
,
String
attribute value
value
)

Deprecated CookieUtil is package private, will be removed once old Cookie API is dropped
Validate a cookie attribute value, throws a IllegalArgumentException otherwise.
public String
value()

Implements io.netty.handler.codec.http.cookie.Cookie.value.

Returns the value of this Cookie.
public boolean
wrap()

Implements io.netty.handler.codec.http.cookie.Cookie.wrap.

Returns true if the raw value of this Cookie, was wrapped with double quotes in original Set-Cookie header.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

domainback to summary
private String domain
httpOnlyback to summary
private boolean httpOnly
maxAgeback to summary
private long maxAge
nameback to summary
private final String name
partitionedback to summary
private boolean partitioned
pathback to summary
private String path
sameSiteback to summary
private CookieHeaderNames.SameSite sameSite
secureback to summary
private boolean secure
valueback to summary
private String value
wrapback to summary
private boolean wrap

Constructor Detail

DefaultCookieback to summary
public DefaultCookie(String name, String value)

Creates a new cookie with the specified name and value.

Method Detail

compareToback to summary
public int compareTo(Cookie c)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
c:Cookie

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
domainback to summary
public String domain()

Implements io.netty.handler.codec.http.cookie.Cookie.domain.

Doc from io.netty.handler.codec.http.cookie.Cookie.domain.

Returns the domain of this Cookie.

Returns:String

The domain of this Cookie

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isHttpOnlyback to summary
public boolean isHttpOnly()

Implements io.netty.handler.codec.http.cookie.Cookie.isHttpOnly.

Doc from io.netty.handler.codec.http.cookie.Cookie.isHttpOnly.

Checks to see if this Cookie can only be accessed via HTTP. If this returns true, the Cookie cannot be accessed through client side script - But only if the browser supports it. For more information, please look here

Returns:boolean

True if this Cookie is HTTP-only or false if it isn't

Annotations
@Override
isPartitionedback to summary
public boolean isPartitioned()

Checks to see if this Cookie is partitioned

Returns:boolean

True if this Cookie is partitioned, otherwise false

isSecureback to summary
public boolean isSecure()

Implements io.netty.handler.codec.http.cookie.Cookie.isSecure.

Doc from io.netty.handler.codec.http.cookie.Cookie.isSecure.

Checks to see if this Cookie is secure

Returns:boolean

True if this Cookie is secure, otherwise false

Annotations
@Override
maxAgeback to summary
public long maxAge()

Implements io.netty.handler.codec.http.cookie.Cookie.maxAge.

Doc from io.netty.handler.codec.http.cookie.Cookie.maxAge.

Returns the maximum age of this Cookie in seconds or Cookie#UNDEFINED_MAX_AGE if unspecified

Returns:long

The maximum age of this Cookie

Annotations
@Override
nameback to summary
public String name()

Implements io.netty.handler.codec.http.cookie.Cookie.name.

Doc from io.netty.handler.codec.http.cookie.Cookie.name.

Returns the name of this Cookie.

Returns:String

The name of this Cookie

Annotations
@Override
pathback to summary
public String path()

Implements io.netty.handler.codec.http.cookie.Cookie.path.

Doc from io.netty.handler.codec.http.cookie.Cookie.path.

Returns the path of this Cookie.

Returns:String

The Cookie's path

Annotations
@Override
sameSiteback to summary
public CookieHeaderNames.SameSite sameSite()

Checks to see if this Cookie can be sent along cross-site requests. For more information, please look here

Returns:CookieHeaderNames.SameSite

same-site-flag value

setDomainback to summary
public void setDomain(String domain)

Implements io.netty.handler.codec.http.cookie.Cookie.setDomain.

Doc from io.netty.handler.codec.http.cookie.Cookie.setDomain.

Sets the domain of this Cookie.

Parameters
domain:String

The domain to use

Annotations
@Override
setHttpOnlyback to summary
public void setHttpOnly(boolean httpOnly)

Implements io.netty.handler.codec.http.cookie.Cookie.setHttpOnly.

Doc from io.netty.handler.codec.http.cookie.Cookie.setHttpOnly.

Determines if this Cookie is HTTP only. If set to true, this Cookie cannot be accessed by a client side script. However, this works only if the browser supports it. For information, please look here.

Parameters
httpOnly:boolean

True if the Cookie is HTTP only, otherwise false.

Annotations
@Override
setMaxAgeback to summary
public void setMaxAge(long maxAge)

Implements io.netty.handler.codec.http.cookie.Cookie.setMaxAge.

Doc from io.netty.handler.codec.http.cookie.Cookie.setMaxAge.

Sets the maximum age of this Cookie in seconds. If an age of 0 is specified, this Cookie will be automatically removed by browser because it will expire immediately. If Cookie#UNDEFINED_MAX_AGE is specified, this Cookie will be removed when the browser is closed.

Parameters
maxAge:long

The maximum age of this Cookie in seconds

Annotations
@Override
setPartitionedback to summary
public void setPartitioned(boolean partitioned)

Sets the Partitioned attribute of this Cookie

Parameters
partitioned:boolean

True if this Cookie is to be partitioned, otherwise false

setPathback to summary
public void setPath(String path)

Implements io.netty.handler.codec.http.cookie.Cookie.setPath.

Doc from io.netty.handler.codec.http.cookie.Cookie.setPath.

Sets the path of this Cookie.

Parameters
path:String

The path to use for this Cookie

Annotations
@Override
setSameSiteback to summary
public void setSameSite(CookieHeaderNames.SameSite sameSite)

Determines if this this Cookie can be sent along cross-site requests. For more information, please look here

Parameters
sameSite:CookieHeaderNames.SameSite

same-site-flag value

setSecureback to summary
public void setSecure(boolean secure)

Implements io.netty.handler.codec.http.cookie.Cookie.setSecure.

Doc from io.netty.handler.codec.http.cookie.Cookie.setSecure.

Sets the security getStatus of this Cookie

Parameters
secure:boolean

True if this Cookie is to be secure, otherwise false

Annotations
@Override
setValueback to summary
public void setValue(String value)

Implements io.netty.handler.codec.http.cookie.Cookie.setValue.

Doc from io.netty.handler.codec.http.cookie.Cookie.setValue.

Sets the value of this Cookie.

Parameters
value:String

The value to set

Annotations
@Override
setWrapback to summary
public void setWrap(boolean wrap)

Implements io.netty.handler.codec.http.cookie.Cookie.setWrap.

Doc from io.netty.handler.codec.http.cookie.Cookie.setWrap.

Sets true if the value of this Cookie is to be wrapped with double quotes.

Parameters
wrap:boolean

true if wrap

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
validateValueback to summary
protected String validateValue(String name, String value)

Deprecated

CookieUtil is package private, will be removed once old Cookie API is dropped

Validate a cookie attribute value, throws a IllegalArgumentException otherwise. Only intended to be used by io.netty.handler.codec.http.DefaultCookie.

Parameters
name:String

attribute name

value:String

attribute value

Returns:String

the trimmed, validated attribute value

Annotations
@Deprecated
valueback to summary
public String value()

Implements io.netty.handler.codec.http.cookie.Cookie.value.

Doc from io.netty.handler.codec.http.cookie.Cookie.value.

Returns the value of this Cookie.

Returns:String

The value of this Cookie

Annotations
@Override
wrapback to summary
public boolean wrap()

Implements io.netty.handler.codec.http.cookie.Cookie.wrap.

Doc from io.netty.handler.codec.http.cookie.Cookie.wrap.

Returns true if the raw value of this Cookie, was wrapped with double quotes in original Set-Cookie header.

Returns:boolean

If the value of this Cookie is to be wrapped

Annotations
@Override