ice.util.net
Class CookieManager

java.lang.Object
  extended byjava.beans.VetoableChangeSupport
      extended byice.util.net.CookieManager
All Implemented Interfaces:
CookieSet, Serializable

public class CookieManager
extends VetoableChangeSupport
implements CookieSet

This class provides support for file cookies. It should NOT be used manually. If a cookieManager is needed, use ice.net.CookieManager instead.

See Also:
Serialized Form

Constructor Summary
protected CookieManager()
           
 
Method Summary
 void addCookie(Cookie c)
          Add one cookie to the list of cookies maintained by the CookieManager.
 void addCookie(String documentUrl, String s)
           
 void addVetoableChangeListener(VetoableChangeListener vc)
          Register a listener for Cookie events.
protected  void applyAllCookies(URL url, URLConnection uc)
          Apply any cookies found for this URL.
 Enumeration elements()
          Returns an Enumeration of Cookie objects.
protected  boolean extractAllCookies(URL url, URLConnection uc)
          Extracts any and all cookies found for this URL, and stores them.
 Cookie[] getAllCookies()
          Returns an array of Cookie objects.
 String getCookieStr(String documentUrl)
           
static CookieManager getInstance()
           
 int getMaxCookieSize()
          Get the maximum allowed size for a single cookie.
 int getMaxNumberOfCookies()
          Get the maximum allowed number of cookies.
 int getMaxTotalCookieSize()
          Return the total maximum size allowed for cookies.
 boolean isEnabled()
          Returns true if cookies are enabled.
 void readCookies(ObjectInput in)
          Reads cookies from an object stream
 void removeAllCookies()
          Removes all cookies.
 void removeAllExpiredCookies()
          Remove all cookies which has expired.
 void removeAllSessionCookies()
          Remove all session cookies, that is all cookies that are only valid for the current session.
 void setEnabled(boolean enable)
          Enable/Disable cookies.
 void setMaxCookieSize(int newSize)
          Set the maximum size of cookies in bytes.
 void setMaxNumberOfCookies(int maxCount)
          Set the maximum allowed number of cookies.
 void setMaxTotalCookieSize(int newSize)
          Set the maximum total size of all cookies in bytes.
 void writeCookies(ObjectOutput out)
          Writes all stored cookies to an object stream
 
Methods inherited from class java.beans.VetoableChangeSupport
addVetoableChangeListener, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getVetoableChangeListeners, getVetoableChangeListeners, hasListeners, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CookieManager

protected CookieManager()
Method Detail

getInstance

public static CookieManager getInstance()

getMaxTotalCookieSize

public int getMaxTotalCookieSize()
Return the total maximum size allowed for cookies.


setMaxTotalCookieSize

public void setMaxTotalCookieSize(int newSize)
Set the maximum total size of all cookies in bytes.


setMaxCookieSize

public void setMaxCookieSize(int newSize)
Set the maximum size of cookies in bytes.


getMaxCookieSize

public int getMaxCookieSize()
Get the maximum allowed size for a single cookie.


setMaxNumberOfCookies

public void setMaxNumberOfCookies(int maxCount)
Set the maximum allowed number of cookies.


getMaxNumberOfCookies

public int getMaxNumberOfCookies()
Get the maximum allowed number of cookies.


setEnabled

public void setEnabled(boolean enable)
Enable/Disable cookies.


isEnabled

public boolean isEnabled()
Returns true if cookies are enabled.


elements

public Enumeration elements()
Returns an Enumeration of Cookie objects.

Returns:
An Enumeration of Cookies.

getAllCookies

public Cookie[] getAllCookies()
Returns an array of Cookie objects.

Returns:
An array of Cookies.
See Also:
elements()

extractAllCookies

protected boolean extractAllCookies(URL url,
                                    URLConnection uc)
Extracts any and all cookies found for this URL, and stores them.

Parameters:
url - The actual url.
uc - The URLconenction we extract cookies from.
Returns:
True if any cookies were found.
See Also:
applyAllCookies(java.net.URL, java.net.URLConnection)

removeAllCookies

public void removeAllCookies()
Removes all cookies.


removeAllSessionCookies

public void removeAllSessionCookies()
Remove all session cookies, that is all cookies that are only valid for the current session.


removeAllExpiredCookies

public void removeAllExpiredCookies()
Remove all cookies which has expired.


addCookie

public void addCookie(Cookie c)
Add one cookie to the list of cookies maintained by the CookieManager.


addCookie

public void addCookie(String documentUrl,
                      String s)
Specified by:
addCookie in interface CookieSet

getCookieStr

public String getCookieStr(String documentUrl)
Specified by:
getCookieStr in interface CookieSet

applyAllCookies

protected void applyAllCookies(URL url,
                               URLConnection uc)
Apply any cookies found for this URL.

Parameters:
url - The (not connected)url that may have cookies.
uc - The urlconnection to recieve the cookies.
See Also:
extractAllCookies(java.net.URL, java.net.URLConnection)

writeCookies

public void writeCookies(ObjectOutput out)
Writes all stored cookies to an object stream

Parameters:
out - The object stream to write to.

readCookies

public void readCookies(ObjectInput in)
Reads cookies from an object stream

Parameters:
in - The object stream to read from

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener vc)
Register a listener for Cookie events. Listeners can thow PropertyVetoException if they do not want a cookie to be added.