|
jCookie v0.8b | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sonalb.net.http.cookie.Cookie
The data structure representing a cookie. Supports both Netscape (Version 0) and RFC2965 (Version 1) cookies. The fields common to both these versions are listed below:
Constructor Summary | |
Cookie(String name,
String value,
String domain,
String path)
Creates cookie instance. |
|
Cookie(String name,
String value,
URL requestURL)
Creates cookie instance. |
Method Summary | |
Object |
clone()
|
int |
compareTo(Object o)
Compares one Cookie with another. |
boolean |
equals(Object obj)
Checks whether two cookies are equal. |
String |
getComment()
Gets the comment for this cookie. |
URL |
getCommentURL()
Gets the comment URL for this cookie. |
String |
getDomain()
Gets the domain in which this cookie is valid. |
Date |
getExpires()
Gets the date-time when this cookie expires. |
int |
getMaxAge()
Gets the amount of time this Cookie is valid, measured in seconds from the time the value was set. |
String |
getName()
Gets the name of this cookie. |
String |
getPath()
Gets the path for this cookie. |
String |
getPortList()
Gets the list of ports to which this cookie can be sent. |
String |
getValue()
Gets the value of this cookie. |
String |
getVersion()
Gets the version of this Cookie. |
boolean |
hasExpired()
Checks whether this cookie's lifetime has expired or not. |
boolean |
hasExpired(Date d)
Checks whether this cookie's lifetime has expired or not. |
boolean |
isDiscardable()
Checks whether this cookie can be discarded once the session is over. |
boolean |
isSecure()
Checks whether this cookie will be sent over secure channels only. |
void |
setComment(String comment)
Sets the comment for this cookie. |
void |
setCommentURL(URL url)
Sets the comment URL for this cookie. |
void |
setDiscard(boolean bDiscard)
Sets the discard status of this cookie. |
void |
setDomain(String domain)
Sets the domain for this Cookie. |
void |
setDomain(URL requestURL)
Sets the domain for this Cookie. |
void |
setExpires(Date expires)
Sets the date-time when this cookie expires. |
void |
setMaxAge(int maxage)
Sets the lifetime of this Cookie. |
void |
setMaxAge(int maxage,
Date base)
Sets the lifetime of this Cookie. |
void |
setName(String name)
Sets the Cookie name. |
void |
setPath(String path)
Sets the path for this Cookie. |
void |
setPath(URL requestURL)
Sets the path for this Cookie. |
void |
setPort(int p)
Sets the port to which this cookie can be sent. |
void |
setPort(URL url)
Sets the port to which this cookie can be sent. |
void |
setPortList(int[] ports)
Sets the list of ports to which this Cookie can be sent. |
void |
setSecure(boolean bSecure)
Sets whether this cookie should be sent only over secure channels. |
void |
setValue(String value)
Sets the Cookie value. |
void |
setVersion(String version)
Sets the Cookie version. |
String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Cookie(String name, String value, String domain, String path)
name
- the Cookie namevalue
- the Cookie valuedomain
- the domain in which this Cookie is validpath
- the path for this Cookiepublic Cookie(String name, String value, URL requestURL)
name
- the Cookie namevalue
- the Cookie valuerequestURL
- the request URL which resulted in this cookie being receivedMethod Detail |
public Object clone() throws CloneNotSupportedException
public int compareTo(Object o)
compareTo
in interface Comparable
java.lang.Comparable
o
- the Object to be compared.ClassCastException
- if the specified object's type prevents it
from being compared to this Object.public void setName(String name)
name
- the Cookie namepublic void setValue(String value)
value
- the Cookie valuepublic void setMaxAge(int maxage)
maxage
- the number of seconds from now that this Cookie is valid (delta-t)UnsupportedOperationException
- when called on a Version 0 cookiepublic void setMaxAge(int maxage, Date base)
maxage
- the number of seconds from base that this Cookie is valid (delta-t)base
- the Date from which the delta-t should be countedUnsupportedOperationException
- when called on a Version 0 cookiepublic int getMaxAge()
UnsupportedOperationException
- if this method is called on a Version 0 cookiepublic void setExpires(Date expires)
expires
- the Date when this cookie expiresUnsupportedOperationException
- when called on a Version 1 cookiepublic void setVersion(String version)
version
- the Cookie version. Either "0" or "1"public String getVersion()
public void setPath(String path)
path
- the Path for this Cookiepublic void setPath(URL requestURL)
requestURL
- the request URL which caused this Cookie to be sent.public void setDomain(String domain)
domain
- the Cookie domainpublic void setDomain(URL requestURL)
requestURL
- the request URL which caused this cookie to be sentpublic void setPortList(int[] ports)
ports
- the valid ports as array of int; non-positive values ignoredUnsupportedException
- when called on a Version 0 cookiepublic void setPort(int p)
p
- the PortUnsupportedOperationException
- when called on a Version 0 cookiepublic void setPort(URL url)
url
- the request URLUnsupportedOperationException
- when called on a Version 0 cookiepublic String getPortList()
UnsupportedOperationException
- when called on a Version 0 cookiepublic void setSecure(boolean bSecure)
bSecure
- secure or not ?public String getName()
public String getValue()
public String getComment()
public void setComment(String comment)
comment
- the commentpublic void setCommentURL(URL url)
url
- the URLpublic URL getCommentURL()
public Date getExpires()
public boolean isDiscardable()
public void setDiscard(boolean bDiscard)
bDiscard
- discardable or not ?UnsupportedOperationException
- when called on a Version 0 cookiepublic String getDomain()
public String getPath()
public boolean isSecure()
public boolean hasExpired()
public boolean hasExpired(Date d)
public boolean equals(Object obj)
equals
in class Object
java.lang.Object
obj
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.java.lang.Boolean#hashCode()
,
Hashtable
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString
in class Object
java.lang.Object
|
Copyright (c) 2001-2002 Sonal Bansal | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |