Class BasicCookieStore
- java.lang.Object
-
- org.apache.hc.client5.http.cookie.BasicCookieStore
-
- All Implemented Interfaces:
java.io.Serializable
,CookieStore
@Contract(threading=SAFE) public class BasicCookieStore extends java.lang.Object implements CookieStore, java.io.Serializable
Default implementation ofCookieStore
- Since:
- 4.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.TreeSet<Cookie>
cookies
private java.util.concurrent.locks.ReadWriteLock
lock
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description BasicCookieStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCookie(Cookie cookie)
Adds anHTTP cookie
, replacing any existing equivalent cookies.void
addCookies(Cookie[] cookies)
Adds an array ofHTTP cookies
.void
clear()
Clears all cookies.boolean
clearExpired(java.time.Instant instant)
Removes all ofcookies
in this HTTP state that have expired by the specifieddate
.boolean
clearExpired(java.util.Date date)
Removes all ofcookies
in this HTTP state that have expired by the specifieddate
.java.util.List<Cookie>
getCookies()
Returns an immutable array ofcookies
that this HTTP state currently contains.private void
readObject(java.io.ObjectInputStream stream)
java.lang.String
toString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
cookies
private final java.util.TreeSet<Cookie> cookies
-
lock
private transient java.util.concurrent.locks.ReadWriteLock lock
-
-
Method Detail
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
addCookie
public void addCookie(Cookie cookie)
Adds anHTTP 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.- Specified by:
addCookie
in interfaceCookieStore
- Parameters:
cookie
- thecookie
to be added- See Also:
addCookies(Cookie[])
-
addCookies
public void addCookies(Cookie[] cookies)
Adds an array ofHTTP 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
- thecookies
to be added- See Also:
addCookie(Cookie)
-
getCookies
public java.util.List<Cookie> getCookies()
Returns an immutable array ofcookies
that this HTTP state currently contains.- Specified by:
getCookies
in interfaceCookieStore
- Returns:
- an array of
cookies
.
-
clearExpired
public boolean clearExpired(java.util.Date date)
Removes all ofcookies
in this HTTP state that have expired by the specifieddate
.- Specified by:
clearExpired
in interfaceCookieStore
- Returns:
- true if any cookies were purged.
- See Also:
Cookie.isExpired(Date)
-
clearExpired
public boolean clearExpired(java.time.Instant instant)
Removes all ofcookies
in this HTTP state that have expired by the specifieddate
.- Specified by:
clearExpired
in interfaceCookieStore
- Returns:
- true if any cookies were purged.
- Since:
- 5.2
- See Also:
Cookie.isExpired(Instant)
-
clear
public void clear()
Clears all cookies.- Specified by:
clear
in interfaceCookieStore
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-