| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
  |
  +--org.apache.commons.httpclient.NameValuePair
        |
        +--org.apache.commons.httpclient.Cookie
HTTP "magic-cookie" represents a piece of state information that the HTTP agent and the target server can exchange to maintain a session.
| Constructor Summary | |
Cookie()
Default constructor.  | 
|
Cookie(String domain,
       String name,
       String value)
Creates a cookie with the given name, value and domain attribute.  | 
|
Cookie(String domain,
       String name,
       String value,
       String path,
       Date expires,
       boolean secure)
Creates a cookie with the given name, value, domain attribute, path attribute, expiration attribute, and secure attribute  | 
|
Cookie(String domain,
       String name,
       String value,
       String path,
       int maxAge,
       boolean secure)
Creates a cookie with the given name, value, domain attribute, path attribute, maximum age attribute, and secure attribute  | 
|
| Method Summary | |
 int | 
compare(Object o1,
        Object o2)
Compares two cookies to determine order for cookie header.  | 
static Header | 
createCookieHeader(String domain,
                   int port,
                   String path,
                   boolean secure,
                   Cookie[] cookies)
Deprecated. use CookieSpec interface | 
static Header | 
createCookieHeader(String domain,
                   int port,
                   String path,
                   boolean secure,
                   Date now,
                   Cookie[] cookies)
Deprecated. use CookieSpec interface | 
static Header | 
createCookieHeader(String domain,
                   String path,
                   boolean secure,
                   Cookie[] cookies)
Deprecated. use CookieSpec interface | 
static Header | 
createCookieHeader(String domain,
                   String path,
                   Cookie[] cookies)
Deprecated. use CookieSpec interface | 
 boolean | 
equals(Object obj)
Two cookies are equal if the name, path and domain match.  | 
 String | 
getComment()
Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.  | 
 String | 
getDomain()
Returns domain attribute of the cookie.  | 
 Date | 
getExpiryDate()
Returns the expiration Date of the cookie, or null
 if none exists. | 
 String | 
getPath()
Returns the path attribute of the cookie  | 
 boolean | 
getSecure()
 | 
 int | 
getVersion()
Returns the version of the cookie specification to which this cookie conforms.  | 
 int | 
hashCode()
Returns a hash code in keeping with the Object.hashCode() general hashCode contract. | 
 boolean | 
isDomainAttributeSpecified()
Returns true if cookie's domain was set via a domain attribute in the Set-Cookie header.  | 
 boolean | 
isExpired()
Returns true if this cookie has expired.  | 
 boolean | 
isExpired(Date now)
Returns true if this cookie has expired according to the time passed in.  | 
 boolean | 
isPathAttributeSpecified()
Returns true if cookie's path was set via a path attribute in the Set-Cookie header.  | 
 boolean | 
isPersistent()
Returns false if the cookie should be discarded at the end of the "session"; true otherwise.  | 
 boolean | 
matches(String domain,
        int port,
        String path,
        boolean secure)
Deprecated. use CookieSpec interface | 
 boolean | 
matches(String domain,
        int port,
        String path,
        boolean secure,
        Date date)
Deprecated. use CookieSpec interface | 
static Cookie[] | 
parse(String domain,
      int port,
      String path,
      boolean secure,
      Header setCookie)
Deprecated. use CookieSpec interface | 
static Cookie[] | 
parse(String domain,
      int port,
      String path,
      Header setCookie)
Deprecated. use CookieSpec interface | 
static Cookie[] | 
parse(String domain,
      String path,
      boolean secure,
      Header setCookie)
Deprecated. use CookieSpec interface | 
static Cookie[] | 
parse(String domain,
      String path,
      Header setCookie)
Deprecated. use CookieSpec interface | 
 void | 
setComment(String comment)
If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment.  | 
 void | 
setDomain(String domain)
Sets the domain attribute.  | 
 void | 
setDomainAttributeSpecified(boolean value)
Indicates whether the cookie had a domain specified in a domain attribute of the Set-Cookie header.  | 
 void | 
setExpiryDate(Date expiryDate)
Sets expiration date.  | 
 void | 
setPath(String path)
Sets the path attribute.  | 
 void | 
setPathAttributeSpecified(boolean value)
Indicates whether the cookie had a path specified in a path attribute of the Set-Cookie header.  | 
 void | 
setSecure(boolean secure)
Sets the secure attribute of the cookie.  | 
 void | 
setVersion(int version)
Sets the version of the cookie specification to which this cookie conforms.  | 
 String | 
toExternalForm()
Returns a textual representation of the cookie.  | 
 String | 
toString()
Return a textual representation of the cookie.  | 
| Methods inherited from class org.apache.commons.httpclient.NameValuePair | 
getName, getValue, setName, setValue | 
| Methods inherited from class java.lang.Object | 
 | 
| Constructor Detail | 
public Cookie()
public Cookie(String domain,
              String name,
              String value)
name - the cookie namevalue - the cookie valuedomain - the domain this cookie can be sent to
public Cookie(String domain,
              String name,
              String value,
              String path,
              Date expires,
              boolean secure)
name - the cookie namevalue - the cookie valuedomain - the domain this cookie can be sent topath - the path prefix for which this cookie can be sentexpires - the Date at which this cookie expires,
                or null if the cookie expires at the end
                of the sessionsecure - if true this cookie can only be sent over secure
 connectionsIllegalArgumentException - If cookie name is null or blank,
   cookie name contains a blank, or cookie name starts with character $
public Cookie(String domain,
              String name,
              String value,
              String path,
              int maxAge,
              boolean secure)
name - the cookie namevalue - the cookie valuedomain - the domain this cookie can be sent topath - the path prefix for which this cookie can be sentmaxAge - the number of seconds for which this cookie is valid.
               maxAge is expected to be a non-negative number. 
               -1 signifies that the cookie should never expire.secure - if true this cookie can only be sent over secure
 connections| Method Detail | 
public String getComment()
setComment(String)public void setComment(String comment)
comment -  getComment()public Date getExpiryDate()
Date of the cookie, or null
 if none exists.
 Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.
Date, or null.setExpiryDate(java.util.Date)public void setExpiryDate(Date expiryDate)
Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.
expiryDate - the Date after which this cookie is no longer valid.getExpiryDate()public boolean isPersistent()
public String getDomain()
setDomain(java.lang.String)public void setDomain(String domain)
domain - The value of the domain attributegetDomain()public String getPath()
setPath(java.lang.String)public void setPath(String path)
path - The value of the path attributegetPath()public boolean getSecure()
true if this cookie should only be sent over secure connections.setSecure(boolean)public void setSecure(boolean secure)
When true 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.
secure - The value of the secure attributegetSecure()public int getVersion()
setVersion(int)public void setVersion(int version)
version - the version of the cookie.getVersion()public boolean isExpired()
public boolean isExpired(Date now)
now - The current time.public void setPathAttributeSpecified(boolean value)
value - true if the cookie's path was explicitly 
 set, false otherwise.isPathAttributeSpecified()public boolean isPathAttributeSpecified()
setPathAttributeSpecified(boolean)public void setDomainAttributeSpecified(boolean value)
value - true if the cookie's domain was explicitly 
 set, false otherwise.isDomainAttributeSpecified()public boolean isDomainAttributeSpecified()
setDomainAttributeSpecified(boolean)public int hashCode()
Object.hashCode() general hashCode contract.hashCode in class NameValuePairpublic boolean equals(Object obj)
equals in interface Comparatorequals in class NameValuePairobj - The object to compare against.public String toExternalForm()
public boolean matches(String domain,
                       int port,
                       String path,
                       boolean secure,
                       Date date)
CookieSpec interface
domain - the host to which the request is being submittedport - the port to which the request is being submitted (currently
 ignored)path - the path to which the request is being submittedsecure - true if the request is using the HTTPS protocoldate - the time at which the request is submitted
public boolean matches(String domain,
                       int port,
                       String path,
                       boolean secure)
CookieSpec interface
domain - the host to which the request is being submittedport - the port to which the request is being submitted (currently
 ignored)path - the path to which the request is being submittedsecure - True if this cookie has the secure flag set
public static Header createCookieHeader(String domain,
                                        String path,
                                        Cookie[] cookies)
CookieSpec interface
If no cookies match, returns null.
domain - The domainpath - The pathcookies - The cookies to use
public static Header createCookieHeader(String domain,
                                        String path,
                                        boolean secure,
                                        Cookie[] cookies)
                                 throws IllegalArgumentException
CookieSpec interface
If no cookies match, returns null.
domain - The domainpath - The pathsecure - True if this cookie has the secure flag setcookies - The cookies to use.IllegalArgumentException - if domain or path is null
public static Header createCookieHeader(String domain,
                                        int port,
                                        String path,
                                        boolean secure,
                                        Cookie[] cookies)
                                 throws IllegalArgumentException
CookieSpec interface
If no cookies match, returns null.
domain - The domainport - The portpath - The pathsecure - True if this cookie has the secure flag setcookies - The cookies to use.IllegalArgumentException - if domain or path is null
public static Header createCookieHeader(String domain,
                                        int port,
                                        String path,
                                        boolean secure,
                                        Date now,
                                        Cookie[] cookies)
                                 throws IllegalArgumentException
CookieSpec interface
If no cookies match, returns null.
domain - The domainport - The portpath - The pathsecure - True if this cookie has the secure flag setnow - The date to check for expirycookies - The cookies to use.IllegalArgumentException - if domain or path is null
public int compare(Object o1,
                   Object o2)
Compares two cookies to determine order for cookie header.
Most specific should be first.
This method is implemented so a cookie can be used as a comparator for a SortedSet of cookies. Specifically it's used above in the createCookieHeader method.
compare in interface Comparatoro1 - The first object to be comparedo2 - The second object to be comparedComparator.compare(Object,Object)public String toString()
toString in class NameValuePairtoExternalForm()
public static Cookie[] parse(String domain,
                             int port,
                             String path,
                             Header setCookie)
                      throws HttpException,
                             IllegalArgumentException
CookieSpec interface
Header into an array of
 Cookies, assuming that the cookies were recieved
 on an insecure channel.domain - the domain from which the Header was receivedport - the port from which the Header was received
 (currently ignored)path - the path from which the Header was receivedsetCookie - the Set-Cookie Header received from the
 serverHeaderHttpException - if an exception occurs during parsingIllegalArgumentException - if domain or path are null
public static Cookie[] parse(String domain,
                             String path,
                             Header setCookie)
                      throws HttpException,
                             IllegalArgumentException
CookieSpec interface
Header into an array of
 Cookies, assuming that the cookies were recieved
 on an insecure channel.domain - the domain from which the Header was receivedpath - the path from which the Header was receivedsetCookie - the Set-Cookie Header received from the
 serverHeaderHttpException - if an exception occurs during parsingIllegalArgumentException - if domain or path are null
public static Cookie[] parse(String domain,
                             String path,
                             boolean secure,
                             Header setCookie)
                      throws HttpException,
                             IllegalArgumentException
CookieSpec interface
Header into an array of
 Cookies.domain - the domain from which the Header was receivedpath - the path from which the Header was receivedsecure - true when the header was recieved over a secure
 channelsetCookie - the Set-Cookie Header received from the
 serverHeaderHttpException - if an exception occurs during parsingIllegalArgumentException - if domain or path are null
public static Cookie[] parse(String domain,
                             int port,
                             String path,
                             boolean secure,
                             Header setCookie)
                      throws HttpException
CookieSpec interface
Header into an array of
 Cookies.
 The syntax for the Set-Cookie response header is:
 set-cookie      =    "Set-Cookie:" cookies
 cookies         =    1#cookie
 cookie          =    NAME "=" VALUE * (";" cookie-av)
 NAME            =    attr
 VALUE           =    value
 cookie-av       =    "Comment" "=" value
                 |    "Domain" "=" value
                 |    "Max-Age" "=" value
                 |    "Path" "=" value
                 |    "Secure"
                 |    "Version" "=" 1*DIGIT
 domain - the domain from which the Header was receivedport - The port from which the Header was received.path - the path from which the Header was receivedsecure - true when the Header was received over
 HTTPSsetCookie - the Set-Cookie Header received from
 the serverHeaderHttpException - if an exception occurs during parsing
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||