Top Description Fields Constructors Methods
org.apache.hc.client5.http.impl.cookie

public final Class BasicClientCookie

extends Object
implements SetCookie, Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable, org.apache.hc.client5.http.cookie.SetCookie, org.apache.hc.client5.http.cookie.Cookie
Imports
java.io.Serializable, java.time.Instant, java.util.Date, .HashMap, .Locale, .Map, org.apache.hc.client5.http.cookie.SetCookie, org.apache.hc.client5.http.utils.DateUtils, org.apache.hc.core5.util.Args

Default implementation of SetCookie.
Since
4.0

Field Summary

Modifier and TypeField and Description
private Map<String, String>
attribs

Cookie attributes as specified by the origin server

private String
cookieDomain

Domain attribute.

private Instant
private String
cookiePath

Path attribute.

private Instant
private boolean
httpOnly

The httpOnly flag.

private boolean
isSecure

My secure flag.

private final String
name

Cookie name

private static final long
private String
value

Cookie value

Constructor Summary

AccessConstructor and Description
public
BasicClientCookie(final String
The name.
name
,
final String
The value.
value
)

Default Constructor taking a name and a value.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public boolean
public String
public Date
getCreationDate()

Implements org.apache.hc.client5.http.cookie.Cookie.getCreationDate.

Deprecated Use getCreationInstant().
Returns creation time of the cookie.
public Instant
getCreationInstant()

Overrides default org.apache.hc.client5.http.cookie.Cookie.getCreationInstant.

Returns creation time of the cookie.
public String

Returns:

the value of the domain attribute
getDomain
()

Implements org.apache.hc.client5.http.cookie.Cookie.getDomain.

Returns domain attribute of the cookie.
public Date

Returns:

Expiration Date, or null.
getExpiryDate
()

Implements org.apache.hc.client5.http.cookie.Cookie.getExpiryDate.

Deprecated Use getExpiryInstant()
Returns the expiration Date of the cookie, or null if none exists.
public Instant
getExpiryInstant()

Overrides default org.apache.hc.client5.http.cookie.Cookie.getExpiryInstant.

Returns the expiration Instant of the cookie, or null if none exists.
public String

Returns:

String name The name
getName
()

Implements org.apache.hc.client5.http.cookie.Cookie.getName.

Returns the name.
public String

Returns:

The value of the path attribute.
getPath
()

Implements org.apache.hc.client5.http.cookie.Cookie.getPath.

Returns the path attribute of the cookie
public String

Returns:

String value The current value.
getValue
()

Implements org.apache.hc.client5.http.cookie.Cookie.getValue.

Returns the value.
public boolean

Returns:

true if the cookie has expired.
isExpired
(final Date
Current time
date
)

Implements org.apache.hc.client5.http.cookie.Cookie.isExpired.

Deprecated Use isExpired(Instant)
Returns true if this cookie has expired.
public boolean

Returns:

true if the cookie has expired.
isExpired
(final Instant
Current time
instant
)

Overrides default org.apache.hc.client5.http.cookie.Cookie.isExpired.

Returns true if this cookie has expired.
public boolean

Returns:

true if this Cookie has been marked as httpOnly, false otherwise
isHttpOnly
()

Overrides default org.apache.hc.client5.http.cookie.Cookie.isHttpOnly.

Checks whether this Cookie has been marked as httpOnly.
public boolean

Returns:

false if the cookie should be discarded at the end of the "session"; true otherwise
isPersistent
()

Implements org.apache.hc.client5.http.cookie.Cookie.isPersistent.

Returns false if the cookie should be discarded at the end of the "session"; true otherwise.
public boolean

Returns:

true if this cookie should only be sent over secure connections.
isSecure
()

Implements org.apache.hc.client5.http.cookie.Cookie.isSecure.

Indicates whether this cookie requires a secure connection.
public boolean
removeAttribute(final String name)

public void
setAttribute(final String name, final String value)

public void
setCreationDate(final Date creationDate)

Deprecated Use setCreationDate(Instant)
public void
setCreationDate(final Instant creationDate)

public void
setDomain(final String
The value of the domain attribute
domain
)

Implements org.apache.hc.client5.http.cookie.SetCookie.setDomain.

Sets the domain attribute.
public void
setExpiryDate(final Date
the Date after which this cookie is no longer valid.
expiryDate
)

Implements org.apache.hc.client5.http.cookie.SetCookie.setExpiryDate.

Deprecated Use {setExpiryDate(Instant)}
Sets expiration date.
public void
setExpiryDate(final Instant
the Instant after which this cookie is no longer valid.
expiryInstant
)

Overrides default org.apache.hc.client5.http.cookie.SetCookie.setExpiryDate.

Sets expiration date.
public void
setHttpOnly(final boolean
true if this cookie is to be marked as httpOnly, false otherwise
httpOnly
)

Overrides default org.apache.hc.client5.http.cookie.SetCookie.setHttpOnly.

Sets the http-only attribute of the cookie.
public void
setPath(final String
The value of the path attribute
path
)

Implements org.apache.hc.client5.http.cookie.SetCookie.setPath.

Sets the path attribute.
public void
setSecure(final boolean
The value of the secure attribute
secure
)

Implements org.apache.hc.client5.http.cookie.SetCookie.setSecure.

Sets the secure attribute of the cookie.
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attribsback to summary
private Map<String, String> attribs

Cookie attributes as specified by the origin server

cookieDomainback to summary
private String cookieDomain

Domain attribute.

cookieExpiryDateback to summary
private Instant cookieExpiryDate

Expiration Instant.

cookiePathback to summary
private String cookiePath

Path attribute.

creationDateback to summary
private Instant creationDate
httpOnlyback to summary
private boolean httpOnly

The httpOnly flag.

isSecureback to summary
private boolean isSecure

My secure flag.

nameback to summary
private final String name

Cookie name

serialVersionUIDback to summary
private static final long serialVersionUID
valueback to summary
private String value

Cookie value

Constructor Detail

BasicClientCookieback to summary
public BasicClientCookie(final String name, final String value)

Default Constructor taking a name and a value. The value may be null.

Parameters
name:String

The name.

value:String

The value.

Method Detail

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
Exceptions
CloneNotSupportedException:
if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
containsAttributeback to summary
public boolean containsAttribute(final String name)

Implements org.apache.hc.client5.http.cookie.Cookie.containsAttribute.

Annotations
@Override
getAttributeback to summary
public String getAttribute(final String name)

Implements org.apache.hc.client5.http.cookie.Cookie.getAttribute.

Annotations
@Override
getCreationDateback to summary
public Date getCreationDate()

Implements org.apache.hc.client5.http.cookie.Cookie.getCreationDate.

Doc from org.apache.hc.client5.http.cookie.Cookie.getCreationDate.

Deprecated

Use getCreationInstant().

Returns creation time of the cookie.

Annotations
@Deprecated
@Override
Since
4.4
getCreationInstantback to summary
public Instant getCreationInstant()

Overrides default org.apache.hc.client5.http.cookie.Cookie.getCreationInstant.

Doc from org.apache.hc.client5.http.cookie.Cookie.getCreationInstant.

Returns creation time of the cookie.

Annotations
@Override
Since
5.2
getDomainback to summary
public String getDomain()

Implements org.apache.hc.client5.http.cookie.Cookie.getDomain.

Returns domain attribute of the cookie.

Returns:String

the value of the domain attribute

Annotations
@Override
See Also
setDomain(java.lang.String)
getExpiryDateback to summary
public Date getExpiryDate()

Implements org.apache.hc.client5.http.cookie.Cookie.getExpiryDate.

Deprecated

Use getExpiryInstant()

Returns the expiration Date of the cookie, or null if none exists.

Note

the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.

Returns:Date

Expiration Date, or null.

Annotations
@Deprecated
@Override
See Also
setExpiryDate(java.util.Date)
getExpiryInstantback to summary
public Instant getExpiryInstant()

Overrides default org.apache.hc.client5.http.cookie.Cookie.getExpiryInstant.

Doc from org.apache.hc.client5.http.cookie.Cookie.getExpiryInstant.

Returns the expiration Instant of the cookie, or null if none exists.

Note

the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.

Returns:Instant

Expiration Instant, or null.

Annotations
@Override
getNameback to summary
public String getName()

Implements org.apache.hc.client5.http.cookie.Cookie.getName.

Returns the name.

Returns:String

String name The name

Annotations
@Override
getPathback to summary
public String getPath()

Implements org.apache.hc.client5.http.cookie.Cookie.getPath.

Returns the path attribute of the cookie

Returns:String

The value of the path attribute.

Annotations
@Override
See Also
setPath(java.lang.String)
getValueback to summary
public String getValue()

Implements org.apache.hc.client5.http.cookie.Cookie.getValue.

Returns the value.

Returns:String

String value The current value.

Annotations
@Override
isExpiredback to summary
public boolean isExpired(final Date date)

Implements org.apache.hc.client5.http.cookie.Cookie.isExpired.

Deprecated

Use isExpired(Instant)

Returns true if this cookie has expired.

Parameters
date:Date

Current time

Returns:boolean

true if the cookie has expired.

Annotations
@Deprecated
@Override
isExpiredback to summary
public boolean isExpired(final Instant instant)

Overrides default org.apache.hc.client5.http.cookie.Cookie.isExpired.

Returns true if this cookie has expired.

Parameters
instant:Instant

Current time

Returns:boolean

true if the cookie has expired.

Annotations
@Override
isHttpOnlyback to summary
public boolean isHttpOnly()

Overrides default org.apache.hc.client5.http.cookie.Cookie.isHttpOnly.

Doc from org.apache.hc.client5.http.cookie.Cookie.isHttpOnly.

Checks whether this Cookie has been marked as httpOnly.

The default implementation returns false.

Returns:boolean

true if this Cookie has been marked as httpOnly, false otherwise

Annotations
@Override
Since
5.2
See Also
setHttpOnly(boolean)
isPersistentback to summary
public boolean isPersistent()

Implements org.apache.hc.client5.http.cookie.Cookie.isPersistent.

Returns false if the cookie should be discarded at the end of the "session"; true otherwise.

Returns:boolean

false if the cookie should be discarded at the end of the "session"; true otherwise

Annotations
@Override
isSecureback to summary
public boolean isSecure()

Implements org.apache.hc.client5.http.cookie.Cookie.isSecure.

Doc from org.apache.hc.client5.http.cookie.Cookie.isSecure.

Indicates whether this cookie requires a secure connection.

Returns:boolean

true if this cookie should only be sent over secure connections.

Annotations
@Override
See Also
setSecure(boolean)
removeAttributeback to summary
public boolean removeAttribute(final String name)
Since
4.4
setAttributeback to summary
public void setAttribute(final String name, final String value)
setCreationDateback to summary
public void setCreationDate(final Date creationDate)

Deprecated

Use setCreationDate(Instant)

Annotations
@Deprecated
Since
4.4
setCreationDateback to summary
public void setCreationDate(final Instant creationDate)
Since
5.2
setDomainback to summary
public void setDomain(final String domain)

Implements org.apache.hc.client5.http.cookie.SetCookie.setDomain.

Sets the domain attribute.

Parameters
domain:String

The value of the domain attribute

Annotations
@Override
See Also
getDomain
setExpiryDateback to summary
public void setExpiryDate(final Date expiryDate)

Implements org.apache.hc.client5.http.cookie.SetCookie.setExpiryDate.

Deprecated

Use {setExpiryDate(Instant)}

Sets expiration date.

Note

the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.

Parameters
expiryDate:Date

the Date after which this cookie is no longer valid.

Annotations
@Deprecated
@Override
setExpiryDateback to summary
public void setExpiryDate(final Instant expiryInstant)

Overrides default org.apache.hc.client5.http.cookie.SetCookie.setExpiryDate.

Sets expiration date.

Note

the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.

Parameters
expiryInstant:Instant

the Instant after which this cookie is no longer valid.

Annotations
@Override
Since
5.2
See Also
getExpiryInstant()
setHttpOnlyback to summary
public void setHttpOnly(final boolean httpOnly)

Overrides default org.apache.hc.client5.http.cookie.SetCookie.setHttpOnly.

Sets the http-only attribute of the cookie.

Parameters
httpOnly:boolean

true if this cookie is to be marked as httpOnly, false otherwise

Annotations
@Override
Since
5.2
setPathback to summary
public void setPath(final String path)

Implements org.apache.hc.client5.http.cookie.SetCookie.setPath.

Sets the path attribute.

Parameters
path:String

The value of the path attribute

Annotations
@Override
See Also
getPath
setSecureback to summary
public void setSecure(final boolean secure)

Implements org.apache.hc.client5.http.cookie.SetCookie.setSecure.

Sets the secure attribute of the cookie.

When true the cookie should only be sent using a secure protocol (https). This should only be set when the cookie's originating server used a secure protocol to set the cookie's value.

Parameters
secure:boolean

The value of the secure attribute

Annotations
@Override
See Also
isSecure()
setValueback to summary
public void setValue(final String value)

Implements org.apache.hc.client5.http.cookie.SetCookie.setValue.

Sets the value

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