Class Cookie
- java.lang.Object
-
- org.apache.commons.httpclient.NameValuePair
-
- org.apache.commons.httpclient.Cookie
-
- All Implemented Interfaces:
java.io.Serializable,java.util.Comparator
- Direct Known Subclasses:
Cookie2
@Deprecated public class Cookie extends NameValuePair implements java.io.Serializable, java.util.Comparator
Deprecated.HTTP "magic-cookie" represents a piece of state information that the HTTP agent and the target server can exchange to maintain a session.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Cookie()Deprecated.Default constructor.Cookie(java.lang.String domain, java.lang.String name, java.lang.String value)Deprecated.Creates a cookie with the given name, value and domain attribute.Cookie(java.lang.String domain, java.lang.String name, java.lang.String value, java.lang.String path, int maxAge, boolean secure)Deprecated.Creates a cookie with the given name, value, domain attribute, path attribute, maximum age attribute, and secure attributeCookie(java.lang.String domain, java.lang.String name, java.lang.String value, java.lang.String path, java.util.Date expires, boolean secure)Deprecated.Creates a cookie with the given name, value, domain attribute, path attribute, expiration attribute, and secure attribute
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intcompare(java.lang.Object o1, java.lang.Object o2)Deprecated.Compares two cookies to determine order for cookie header.booleanequals(java.lang.Object obj)Deprecated.Two cookies are equal if the name, path and domain match.java.lang.StringgetComment()Deprecated.Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.java.lang.StringgetDomain()Deprecated.Returns domain attribute of the cookie.java.util.DategetExpiryDate()Deprecated.Returns the expirationDateof the cookie, or null if none exists.java.lang.StringgetPath()Deprecated.Returns the path attribute of the cookiebooleangetSecure()Deprecated.intgetVersion()Deprecated.Returns the version of the cookie specification to which this cookie conforms.inthashCode()Deprecated.Returns a hash code in keeping with theObject.hashCode()general hashCode contract.booleanisDomainAttributeSpecified()Deprecated.Returns true if cookie's domain was set via a domain attribute in the Set-Cookie header.booleanisExpired()Deprecated.Returns true if this cookie has expired.booleanisExpired(java.util.Date now)Deprecated.Returns true if this cookie has expired according to the time passed in.booleanisPathAttributeSpecified()Deprecated.Returns true if cookie's path was set via a path attribute in the Set-Cookie header.booleanisPersistent()Deprecated.Returns false if the cookie should be discarded at the end of the "session"; true otherwise.voidsetComment(java.lang.String comment)Deprecated.If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment.voidsetDomain(java.lang.String domain)Deprecated.Sets the domain attribute.voidsetDomainAttributeSpecified(boolean value)Deprecated.Indicates whether the cookie had a domain specified in a domain attribute of the Set-Cookie header.voidsetExpiryDate(java.util.Date expiryDate)Deprecated.Sets expiration date.voidsetPath(java.lang.String path)Deprecated.Sets the path attribute.voidsetPathAttributeSpecified(boolean value)Deprecated.Indicates whether the cookie had a path specified in a path attribute of the Set-Cookie header.voidsetSecure(boolean secure)Deprecated.Sets the secure attribute of the cookie.voidsetVersion(int version)Deprecated.Sets the version of the cookie specification to which this cookie conforms.java.lang.StringtoExternalForm()Deprecated.Return a textual representation of the cookie.java.lang.StringtoString()Deprecated.Return a textual representation of the cookie.-
Methods inherited from class org.apache.commons.httpclient.NameValuePair
getName, getValue, setName, setValue
-
-
-
-
Constructor Detail
-
Cookie
public Cookie()
Deprecated.Default constructor. Creates a blank cookie
-
Cookie
public Cookie(java.lang.String domain, java.lang.String name, java.lang.String value)Deprecated.Creates a cookie with the given name, value and domain attribute.- Parameters:
name- the cookie namevalue- the cookie valuedomain- the domain this cookie can be sent to
-
Cookie
public Cookie(java.lang.String domain, java.lang.String name, java.lang.String value, java.lang.String path, java.util.Date expires, boolean secure)Deprecated.Creates a cookie with the given name, value, domain attribute, path attribute, expiration attribute, and secure attribute- Parameters:
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- theDateat 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 connections- Throws:
java.lang.IllegalArgumentException- If cookie name is null or blank, cookie name contains a blank, or cookie name starts with character $
-
Cookie
public Cookie(java.lang.String domain, java.lang.String name, java.lang.String value, java.lang.String path, int maxAge, boolean secure)Deprecated.Creates a cookie with the given name, value, domain attribute, path attribute, maximum age attribute, and secure attribute- Parameters:
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
-
getComment
public java.lang.String getComment()
Deprecated.Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.- Returns:
- comment
- See Also:
setComment(String)
-
setComment
public void setComment(java.lang.String comment)
Deprecated.If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment.- Parameters:
comment-- See Also:
getComment()
-
getExpiryDate
public java.util.Date getExpiryDate()
Deprecated.Returns the expirationDateof 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.
- Returns:
- Expiration
Date, or null. - See Also:
setExpiryDate(java.util.Date)
-
setExpiryDate
public void setExpiryDate(java.util.Date expiryDate)
Deprecated.Sets expiration date.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.
- Parameters:
expiryDate- theDateafter which this cookie is no longer valid.- See Also:
getExpiryDate()
-
isPersistent
public boolean isPersistent()
Deprecated.Returns false if the cookie should be discarded at the end of the "session"; true otherwise.- Returns:
- false if the cookie should be discarded at the end of the "session"; true otherwise
-
getDomain
public java.lang.String getDomain()
Deprecated.Returns domain attribute of the cookie.- Returns:
- the value of the domain attribute
- See Also:
setDomain(java.lang.String)
-
setDomain
public void setDomain(java.lang.String domain)
Deprecated.Sets the domain attribute.- Parameters:
domain- The value of the domain attribute- See Also:
getDomain()
-
getPath
public java.lang.String getPath()
Deprecated.Returns the path attribute of the cookie- Returns:
- The value of the path attribute.
- See Also:
setPath(java.lang.String)
-
setPath
public void setPath(java.lang.String path)
Deprecated.Sets the path attribute.- Parameters:
path- The value of the path attribute- See Also:
getPath()
-
getSecure
public boolean getSecure()
Deprecated.- Returns:
trueif this cookie should only be sent over secure connections.- See Also:
setSecure(boolean)
-
setSecure
public void setSecure(boolean secure)
Deprecated.Sets the secure attribute of the cookie.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.
- Parameters:
secure- The value of the secure attribute- See Also:
getSecure()
-
getVersion
public int getVersion()
Deprecated.Returns the version of the cookie specification to which this cookie conforms.- Returns:
- the version of the cookie.
- See Also:
setVersion(int)
-
setVersion
public void setVersion(int version)
Deprecated.Sets the version of the cookie specification to which this cookie conforms.- Parameters:
version- the version of the cookie.- See Also:
getVersion()
-
isExpired
public boolean isExpired()
Deprecated.Returns true if this cookie has expired.- Returns:
- true if the cookie has expired.
-
isExpired
public boolean isExpired(java.util.Date now)
Deprecated.Returns true if this cookie has expired according to the time passed in.- Parameters:
now- The current time.- Returns:
- true if the cookie expired.
-
setPathAttributeSpecified
public void setPathAttributeSpecified(boolean value)
Deprecated.Indicates whether the cookie had a path specified in a path attribute of the Set-Cookie header. This value is important for generating the Cookie header because some cookie specifications require that the Cookie header should only include a path attribute if the cookie's path was specified in the Set-Cookie header.- Parameters:
value- true if the cookie's path was explicitly set, false otherwise.- See Also:
isPathAttributeSpecified()
-
isPathAttributeSpecified
public boolean isPathAttributeSpecified()
Deprecated.Returns true if cookie's path was set via a path attribute in the Set-Cookie header.- Returns:
- value true if the cookie's path was explicitly set, false otherwise.
- See Also:
setPathAttributeSpecified(boolean)
-
setDomainAttributeSpecified
public void setDomainAttributeSpecified(boolean value)
Deprecated.Indicates whether the cookie had a domain specified in a domain attribute of the Set-Cookie header. This value is important for generating the Cookie header because some cookie specifications require that the Cookie header should only include a domain attribute if the cookie's domain was specified in the Set-Cookie header.- Parameters:
value- true if the cookie's domain was explicitly set, false otherwise.- See Also:
isDomainAttributeSpecified()
-
isDomainAttributeSpecified
public boolean isDomainAttributeSpecified()
Deprecated.Returns true if cookie's domain was set via a domain attribute in the Set-Cookie header.- Returns:
- value true if the cookie's domain was explicitly set, false otherwise.
- See Also:
setDomainAttributeSpecified(boolean)
-
hashCode
public int hashCode()
Deprecated.Returns a hash code in keeping with theObject.hashCode()general hashCode contract.- Overrides:
hashCodein classNameValuePair- Returns:
- A hash code
-
equals
public boolean equals(java.lang.Object obj)
Deprecated.Two cookies are equal if the name, path and domain match.- Specified by:
equalsin interfacejava.util.Comparator- Overrides:
equalsin classNameValuePair- Parameters:
obj- The object to compare against.- Returns:
- true if the two objects are equal.
-
toExternalForm
public java.lang.String toExternalForm()
Deprecated.Return a textual representation of the cookie.- Returns:
- string.
-
compare
public int compare(java.lang.Object o1, java.lang.Object o2)Deprecated.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.
- Specified by:
comparein interfacejava.util.Comparator- Parameters:
o1- The first object to be comparedo2- The second object to be compared- Returns:
- See
Comparator.compare(Object,Object)
-
toString
public java.lang.String toString()
Deprecated.Return a textual representation of the cookie.- Overrides:
toStringin classNameValuePair- Returns:
- string.
- See Also:
toExternalForm()
-
-