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

public Class BasicCookieStore

extends Object
implements CookieStore, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.hc.client5.http.cookie.CookieStore
Annotations
@Contract
threading:SAFE
Imports
java.io.IOException, .ObjectInputStream, .Serializable, java.time.Instant, java.util.ArrayList, .Date, .Iterator, .List, .TreeSet, java.util.concurrent.locks.ReadWriteLock, .ReentrantReadWriteLock, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior

Default implementation of CookieStore
Since
4.0

Field Summary

Modifier and TypeField and Description
private final TreeSet<Cookie>
private transient ReadWriteLock
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addCookie(final Cookie
the cookie to be added
cookie
)

Implements org.apache.hc.client5.http.cookie.CookieStore.addCookie.

Adds an HTTP cookie, replacing any existing equivalent cookies.
public void
addCookies(final Cookie[]
the cookies to be added
cookies
)

Adds an array of HTTP cookies.

public void
public boolean

Returns:

true if any cookies were purged.
clearExpired
(final Date date)

Implements org.apache.hc.client5.http.cookie.CookieStore.clearExpired.

Removes all of cookies in this HTTP state that have expired by the specified date.
public boolean

Returns:

true if any cookies were purged.
clearExpired
(final Instant instant)

Overrides default org.apache.hc.client5.http.cookie.CookieStore.clearExpired.

Removes all of cookies in this HTTP state that have expired by the specified date.
public List<Cookie>

Returns:

an array of cookies.
getCookies
()

Implements org.apache.hc.client5.http.cookie.CookieStore.getCookies.

Returns an immutable array of cookies that this HTTP state currently contains.
private void
public String
toString()

Overrides java.lang.Object.toString.

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

Field Detail

cookiesback to summary
private final TreeSet<Cookie> cookies
lockback to summary
private transient ReadWriteLock lock
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

BasicCookieStoreback to summary
public BasicCookieStore()

Method Detail

addCookieback to summary
public void addCookie(final Cookie cookie)

Implements org.apache.hc.client5.http.cookie.CookieStore.addCookie.

Adds an HTTP cookie, replacing any existing equivalent cookies. If the given cookie has already expired it will not be added, but existing values will still be removed.

Parameters
cookie:Cookie

the cookie to be added

Annotations
@Override
See Also
addCookies(Cookie[])
addCookiesback to summary
public void addCookies(final Cookie[] cookies)

Adds an array of HTTP cookies. Cookies are added individually and in the given array order. If any of the given cookies has already expired it will not be added, but existing values will still be removed.

Parameters
cookies:Cookie[]

the cookies to be added

See Also
addCookie(Cookie)
clearback to summary
public void clear()

Implements org.apache.hc.client5.http.cookie.CookieStore.clear.

Clears all cookies.

Annotations
@Override
clearExpiredback to summary
public boolean clearExpired(final Date date)

Implements org.apache.hc.client5.http.cookie.CookieStore.clearExpired.

Removes all of cookies in this HTTP state that have expired by the specified date.

Returns:boolean

true if any cookies were purged.

Annotations
@Override
@SuppressWarnings:deprecation
See Also
Cookie#isExpired(Date)
clearExpiredback to summary
public boolean clearExpired(final Instant instant)

Overrides default org.apache.hc.client5.http.cookie.CookieStore.clearExpired.

Removes all of cookies in this HTTP state that have expired by the specified date.

Returns:boolean

true if any cookies were purged.

Annotations
@Override
Since
5.2
See Also
Cookie#isExpired(Instant)
getCookiesback to summary
public List<Cookie> getCookies()

Implements org.apache.hc.client5.http.cookie.CookieStore.getCookies.

Returns an immutable array of cookies that this HTTP state currently contains.

Returns:List<Cookie>

an array of cookies.

Annotations
@Override
readObjectback to summary
private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException
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