public class

InMemoryCookieStore

extends Object
implements CookieStore
java.lang.Object
   ↳ sun.net.www.protocol.http.InMemoryCookieStore

Class Overview

A simple in-memory java.net.CookieStore implementation

Summary

Public Constructors
InMemoryCookieStore()
The default ctor
Public Methods
void add(URI uri, HttpCookie cookie)
Add one cookie into cookie store.
List<HttpCookie> get(URI uri)
Get all cookies, which: 1) given uri domain-matches with, or, associated with given uri when added to the cookie store.
List<HttpCookie> getCookies()
Get all cookies in cookie store, except those have expired
List<URI> getURIs()
Get all URIs, which are associated with at least one cookie of this cookie store.
boolean remove(URI uri, HttpCookie ck)
Remove a cookie from store
boolean removeAll()
Remove all cookies in this cookie store.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.net.CookieStore

Public Constructors

public InMemoryCookieStore ()

The default ctor

Public Methods

public void add (URI uri, HttpCookie cookie)

Add one cookie into cookie store.

Parameters
uri the uri this cookie associated with. if null, this cookie will not be associated with an URI
cookie the cookie to store

public List<HttpCookie> get (URI uri)

Get all cookies, which: 1) given uri domain-matches with, or, associated with given uri when added to the cookie store. 3) not expired. See RFC 2965 sec. 3.3.4 for more detail.

Returns
  • an immutable list of HttpCookie, return empty list if no cookies match the given URI

public List<HttpCookie> getCookies ()

Get all cookies in cookie store, except those have expired

Returns
  • an immutable list of http cookies; return empty list if there's no http cookie in store

public List<URI> getURIs ()

Get all URIs, which are associated with at least one cookie of this cookie store.

Returns
  • an immutable list of URIs; return empty list if no cookie in this cookie store is associated with an URI

public boolean remove (URI uri, HttpCookie ck)

Remove a cookie from store

Parameters
uri the uri this cookie associated with. if null, the cookie to be removed is not associated with an URI when added; if not null, the cookie to be removed is associated with the given URI when added.
ck the cookie to remove
Returns
  • true if this store contained the specified cookie

public boolean removeAll ()

Remove all cookies in this cookie store.

Returns
  • true if this store changed as a result of the call