ice.net
Class Cookie

java.lang.Object
  extended byice.net.Cookie
All Implemented Interfaces:
Serializable

public class Cookie
extends Object
implements Serializable

This class represents one cookie. A cookie is essentially an id tag sent to the browser in order to ID the user. Used for "shopping carts", etc

See Also:
CookieManager, Serialized Form

Constructor Summary
Cookie()
          Construct an empty cookie.
Cookie(String nameIn, String valueIn, String commentIn, String domainIn, int maxAgeIn, String pathIn, boolean secureIn, Date expiresIn, String versionIn)
          Construct a cookie with the specified parameters
 
Method Summary
 Date expirationDate()
          Returns expiration date.
 String getComment()
          Get the comment field of the cookie, if any.
 String getDomain()
          Returns the cookie domain
 int getMaxAge()
          Get the max age field of the cookie.
 String getName()
          Returns the cookie name
 String getPath()
          Returns the cookie path
 boolean getSecure()
          Returns true if cookie is marked secure.
 String getValue()
          Returns the cookie value
 String getVersion()
          Get the version field of the cookie.
 boolean isExpired()
          Returns true if the cookie has expired.
 boolean isPrivate()
          Returns true if this is a private cookie
 boolean isSessionCookie()
          Returns true if cookie is a session cookie.
 long lastUsed()
          Returns the date this cookie was last used.
static Cookie parseFromString(URL url, String str)
          Create a cookie from the supplied String.
 void setComment(String commentIn)
          Set the comment field of the cookie.
 void setDomain(String domainIn)
          Set the domain.
 void setExpirationDate(Date expiresIn)
          Set the expiration date of the cookie.
 void setMaxAge(int maxAgeIn)
          Set the max age field of the cookie.
 void setName(String nameIn)
          Set the name
 void setPath(String pathIn)
          Set the path
 void setPrivate(boolean isPrivateIn)
          Set cookie as private or public
 void setSecure(boolean secureIn)
          Set the secure flag on the cookie.
 void setValue(String valueIn)
           
 void setVersion(String versionIn)
          Set the version field of the cookie.
 int size()
          Returns the size of the cookie in bytes.
 String toString()
          Return a string representation of the cookie.
 String use()
          Returns the string to apply to an http header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cookie

public Cookie()
Construct an empty cookie.


Cookie

public Cookie(String nameIn,
              String valueIn,
              String commentIn,
              String domainIn,
              int maxAgeIn,
              String pathIn,
              boolean secureIn,
              Date expiresIn,
              String versionIn)
Construct a cookie with the specified parameters

Method Detail

toString

public String toString()
Return a string representation of the cookie.


parseFromString

public static Cookie parseFromString(URL url,
                                     String str)
Create a cookie from the supplied String.

Parameters:
url - The cookie was recieved from this URL.
str - String containing the header containing the string.

isExpired

public boolean isExpired()
Returns true if the cookie has expired. Returns false if cookie is a session cookie.


isSessionCookie

public boolean isSessionCookie()
Returns true if cookie is a session cookie.


use

public String use()
Returns the string to apply to an http header.


lastUsed

public long lastUsed()
Returns the date this cookie was last used.


size

public int size()
Returns the size of the cookie in bytes.


expirationDate

public Date expirationDate()
Returns expiration date.


setExpirationDate

public void setExpirationDate(Date expiresIn)
Set the expiration date of the cookie.


getName

public String getName()
Returns the cookie name


setName

public void setName(String nameIn)
Set the name


getValue

public String getValue()
Returns the cookie value


setValue

public void setValue(String valueIn)

getPath

public String getPath()
Returns the cookie path


setPath

public void setPath(String pathIn)
Set the path


getDomain

public String getDomain()
Returns the cookie domain


setDomain

public void setDomain(String domainIn)
Set the domain.


getSecure

public boolean getSecure()
Returns true if cookie is marked secure.


setSecure

public void setSecure(boolean secureIn)
Set the secure flag on the cookie.


getComment

public String getComment()
Get the comment field of the cookie, if any.


setComment

public void setComment(String commentIn)
Set the comment field of the cookie.


getVersion

public String getVersion()
Get the version field of the cookie.


setVersion

public void setVersion(String versionIn)
Set the version field of the cookie.


getMaxAge

public int getMaxAge()
Get the max age field of the cookie.


setMaxAge

public void setMaxAge(int maxAgeIn)
Set the max age field of the cookie.


setPrivate

public void setPrivate(boolean isPrivateIn)
Set cookie as private or public


isPrivate

public boolean isPrivate()
Returns true if this is a private cookie