com.sonalb.net.http.cookie
Class CookieJar

java.lang.Object
  extended by com.sonalb.net.http.cookie.CookieJar
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable, java.util.Collection

public class CookieJar
extends java.lang.Object
implements java.util.Collection, java.io.Serializable

Container for Cookie objects. Each CookieJar is independent of any request. This means that a single CookieJar can hold all the cookies for a number of requests and servers.

Author:
Sonal Bansal
See Also:
Serialized Form

Constructor Summary
CookieJar()
          Creates an empty CookieJar.
CookieJar(java.util.Collection c)
          Creates a CookieJar, and populates it with Cookies from input Collection.
 
Method Summary
 boolean add(java.lang.Object o)
           
 boolean addAll(java.util.Collection c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 CookieJar getCookies(CookieMatcher cm)
          Gets all Cookies that match the given CookieMatcher.
 CookieJar getCookies(java.lang.String cookieName)
          Gets all Cookies with the given name.
 CookieJar getVersionCookies(java.lang.String ver)
          Gets all Cookies having given version.
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
 void removeCookies(CookieMatcher cm)
          Removes all cookies that match the given CookieMatcher.
 boolean retainAll(java.util.Collection c)
           
 int size()
           
 java.lang.Object[] toArray()
           
 java.lang.Object[] toArray(java.lang.Object[] array)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

CookieJar

public CookieJar()
Creates an empty CookieJar.


CookieJar

public CookieJar(java.util.Collection c)
Creates a CookieJar, and populates it with Cookies from input Collection. All the objects in the input Collection NEED NOT be Cookie objects.

Parameters:
c - the input Collection
Method Detail

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Collection

addAll

public boolean addAll(java.util.Collection c)
Specified by:
addAll in interface java.util.Collection

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Collection

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection

toArray

public java.lang.Object[] toArray(java.lang.Object[] array)
Specified by:
toArray in interface java.util.Collection

clear

public void clear()
Specified by:
clear in interface java.util.Collection

removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.Collection

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.Collection

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection

removeCookies

public void removeCookies(CookieMatcher cm)
Removes all cookies that match the given CookieMatcher.

Parameters:
cm - the CookieMatcher

size

public int size()
Specified by:
size in interface java.util.Collection

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection

getCookies

public CookieJar getCookies(CookieMatcher cm)
Gets all Cookies that match the given CookieMatcher.

Parameters:
cm - the CookieMatcher
Returns:
the CookieJar with matching cookies; always non-null

getCookies

public CookieJar getCookies(java.lang.String cookieName)
Gets all Cookies with the given name.

Parameters:
cookieName - the cookie name
Returns:
the CookieJar with matching cookies; always non-null

getVersionCookies

public CookieJar getVersionCookies(java.lang.String ver)
Gets all Cookies having given version.

Parameters:
ver - the version
Returns:
the CookieJar with Cookies; always non-null

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object