org.apache.cactus
Class Cookie

java.lang.Object
  extended byorg.apache.cactus.Cookie
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
HttpSessionCookie

public class Cookie
extends java.lang.Object
implements java.io.Serializable

Client cookie. Used for manipulating client cookies either in beginXXX() (to send cookies) or in endXXX() methods (to assert returned cookies).

Version:
$Id: Cookie.java,v 1.9 2003/06/22 15:03:54 vmassol Exp $
Author:
Vincent Massol
See Also:
Serialized Form

Constructor Summary
Cookie(java.lang.String theDomain, java.lang.String theName, java.lang.String theValue)
          Create a cookie.
 
Method Summary
 boolean equals(java.lang.Object theObject)
          Two cookies match if the name, path and domain match.
 java.lang.String getComment()
          Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.
static java.lang.String getCookieDomain(WebRequest theRequest, java.lang.String theRealHost)
          Deprecated. use CookieUtil.getCookieDomain(WebRequest, String)
static java.lang.String getCookiePath(WebRequest theRequest, java.lang.String theRealPath)
          Deprecated. use CookieUtil.getCookiePath(WebRequest, String)
static int getCookiePort(WebRequest theRequest, int theRealPort)
          Deprecated. use CookieUtil.getCookiePort(WebRequest, int)
 java.lang.String getDomain()
          Returns the domain of this cookie.
 java.util.Date getExpiryDate()
          Return the expiry date.
 java.lang.String getName()
           
 java.lang.String getPath()
          Return the path this cookie is associated with.
 java.lang.String getValue()
           
 int hashCode()
          Hash up name, value and domain into new hash.
 boolean isExpired()
           
 boolean isSecure()
           
 boolean isToBeDiscarded()
           
 void setComment(java.lang.String theComment)
          If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment.
 void setDomain(java.lang.String theDomain)
          Sets the cookie domain.
 void setExpiryDate(java.util.Date theExpiryDate)
          Set the cookie expires date.
 void setName(java.lang.String theName)
          Sets the cookie name
 void setPath(java.lang.String thePath)
          Sets the cookie path.
 void setSecure(boolean isSecure)
          Indicates to the user agent that the cookie should only be sent using a secure protocol (https).
 void setValue(java.lang.String theValue)
          Sets the cookie value
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cookie

public Cookie(java.lang.String theDomain,
              java.lang.String theName,
              java.lang.String theValue)
Create a cookie.

Parameters:
theDomain - the cookie domain
theName - the cookie name
theValue - the cookie value
Method Detail

setName

public void setName(java.lang.String theName)
Sets the cookie name

Parameters:
theName - the cookie name

getName

public java.lang.String getName()
Returns:
the cookie name

setValue

public void setValue(java.lang.String theValue)
Sets the cookie value

Parameters:
theValue - the cookie value

getValue

public java.lang.String getValue()
Returns:
the cookie value

getComment

public java.lang.String getComment()
Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.

Returns:
the cookie comment

setComment

public void setComment(java.lang.String theComment)
If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment.

Parameters:
theComment - the cookie's text comment

getExpiryDate

public java.util.Date getExpiryDate()
Return the expiry date.

Returns:
the expiry date of this cookie, or null if none set.

setExpiryDate

public void setExpiryDate(java.util.Date theExpiryDate)
Set the cookie expires date.

Netscape's original proposal defined an Expires header that took a date value in a fixed-length variant format in place of Max-Age: Wdy, DD-Mon-YY HH:MM:SS GMT Note that the Expires date format contains embedded spaces, and that "old" cookies did not have quotes around values. Clients that implement to this specification should be aware of "old" cookies and Expires.

Parameters:
theExpiryDate - the expires date.

isToBeDiscarded

public boolean isToBeDiscarded()
Returns:
true if the cookie should be discarded at the end of the session; false otherwise

getDomain

public java.lang.String getDomain()
Returns the domain of this cookie.

Returns:
the cookie domain

setDomain

public void setDomain(java.lang.String theDomain)
Sets the cookie domain. This cookie should be presented only to hosts satisfying this domain name pattern. Read RFC 2109 for specific details of the syntax. Briefly, a domain name name begins with a dot (".foo.com") and means that hosts in that DNS zone ("www.foo.com", but not "a.b.foo.com") should see the cookie. By default, cookies are only returned to the host which saved them.

Parameters:
theDomain - the cookie domain

getPath

public java.lang.String getPath()
Return the path this cookie is associated with.

Returns:
the cookie path

setPath

public void setPath(java.lang.String thePath)
Sets the cookie path. This cookie should be presented only with requests beginning with this URL. Read RFC 2109 for a specification of the default behaviour. Basically, URLs in the same "directory" as the one which set the cookie, and in subdirectories, can all see the cookie unless a different path is set.

Parameters:
thePath - the cookie path

isSecure

public boolean isSecure()
Returns:
true if the cookie should only be sent over secure connections.

setSecure

public void setSecure(boolean isSecure)
Indicates to the user agent that the cookie should only be sent using a secure protocol (https). This should only be set when the cookie's originating server used a secure protocol to set the cookie's value.

Parameters:
isSecure - true if the cookie should be sent over secure connections only

isExpired

public boolean isExpired()
Returns:
true if this cookie has expired

hashCode

public int hashCode()
Hash up name, value and domain into new hash.

Returns:
the hashcode of this class

equals

public boolean equals(java.lang.Object theObject)
Two cookies match if the name, path and domain match.

Parameters:
theObject - the cookie object to match
Returns:
true of the object passed as paramater is equal to this coookie instance

toString

public java.lang.String toString()
Returns:
a string representation of the cookie

getCookieDomain

public static java.lang.String getCookieDomain(WebRequest theRequest,
                                               java.lang.String theRealHost)
Deprecated. use CookieUtil.getCookieDomain(WebRequest, String)

See Also:
CookieUtil.getCookieDomain(WebRequest, String)

getCookiePort

public static int getCookiePort(WebRequest theRequest,
                                int theRealPort)
Deprecated. use CookieUtil.getCookiePort(WebRequest, int)

See Also:
CookieUtil.getCookiePort(WebRequest, int)

getCookiePath

public static java.lang.String getCookiePath(WebRequest theRequest,
                                             java.lang.String theRealPath)
Deprecated. use CookieUtil.getCookiePath(WebRequest, String)

See Also:
CookieUtil.getCookiePath(WebRequest, String)


Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.