org.apache.cactus
class Cookie

java.lang.Object
  |
  +--org.apache.cactus.Cookie
All Implemented Interfaces:
Serializable
Known Advisors:
LogAspect

public class Cookie
extends java.lang.Object
implements 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.1 2002/03/01 00:43:45 vmassol Exp $
Author:
Vincent Massol

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

Constructor Detail

Cookie

public Cookie(String theDomain,
              String theName,
              String theValue)
Create a cookie.
Parameters:
theDomain - the cookie domain
theName - the cookie name
theValue - the cookie value
Method Detail

equals

public boolean equals(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
Affected by:
around() in LogAspect.

getComment

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

getDomain

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

getExpiryDate

public Date getExpiryDate()
Return the expiry date.
Returns:
the expiry date of this cookie, or null if none set.

getName

public String getName()
Returns:
the cookie name

getPath

public String getPath()
Return the path this cookie is associated with.
Returns:
the cookie path

getValue

public String getValue()
Returns:
the cookie value

hashCode

public int hashCode()
Hash up name, value and domain into new hash.
Returns:
the hashcode of this class

isExpired

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

isSecure

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

isToBeDiscarded

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

setComment

public void setComment(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
Affected by:
around() in LogAspect.

setDomain

public void setDomain(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
Affected by:
around() in LogAspect.

setExpiryDate

public void setExpiryDate(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.
Affected by:
around() in LogAspect.

setName

public void setName(String theName)
Sets the cookie name
Parameters:
theName - the cookie name
Affected by:
around() in LogAspect.

setPath

public void setPath(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
Affected by:
around() in LogAspect.

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
Affected by:
around() in LogAspect.

setValue

public void setValue(String theValue)
Sets the cookie value
Parameters:
theValue - the cookie value
Affected by:
around() in LogAspect.

toString

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


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