Package org.apache.http.impl.cookie
Class BasicClientCookie
- java.lang.Object
-
- org.apache.http.impl.cookie.BasicClientCookie
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,ClientCookie,Cookie,SetCookie
- Direct Known Subclasses:
BasicClientCookie2
public class BasicClientCookie extends java.lang.Object implements SetCookie, ClientCookie, java.lang.Cloneable, java.io.Serializable
Default implementation ofSetCookie.- Since:
- 4.0
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.apache.http.cookie.ClientCookie
COMMENT_ATTR, COMMENTURL_ATTR, DISCARD_ATTR, DOMAIN_ATTR, EXPIRES_ATTR, MAX_AGE_ATTR, PATH_ATTR, PORT_ATTR, SECURE_ATTR, VERSION_ATTR
-
-
Constructor Summary
Constructors Constructor Description BasicClientCookie(java.lang.String name, java.lang.String value)Default Constructor taking a name and a value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()booleancontainsAttribute(java.lang.String name)java.lang.StringgetAttribute(java.lang.String name)java.lang.StringgetComment()Returns the comment describing the purpose of this cookie, ornullif no such comment has been defined.java.lang.StringgetCommentURL()Returns null.java.util.DategetCreationDate()java.lang.StringgetDomain()Returns domain attribute of the cookie.java.util.DategetExpiryDate()Returns the expirationDateof the cookie, ornullif none exists.java.lang.StringgetName()Returns the name.java.lang.StringgetPath()Returns the path attribute of the cookieint[]getPorts()Returns null.java.lang.StringgetValue()Returns the value.intgetVersion()Returns the version of the cookie specification to which this cookie conforms.booleanisExpired(java.util.Date date)Returns true if this cookie has expired.booleanisPersistent()Returnsfalseif the cookie should be discarded at the end of the "session";trueotherwise.booleanisSecure()Indicates whether this cookie requires a secure connection.booleanremoveAttribute(java.lang.String name)voidsetAttribute(java.lang.String name, java.lang.String value)voidsetComment(java.lang.String comment)If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment.voidsetCreationDate(java.util.Date creationDate)voidsetDomain(java.lang.String domain)Sets the domain attribute.voidsetExpiryDate(java.util.Date expiryDate)Sets expiration date.voidsetPath(java.lang.String path)Sets the path attribute.voidsetSecure(boolean secure)Sets the secure attribute of the cookie.voidsetValue(java.lang.String value)Sets the valuevoidsetVersion(int version)Sets the version of the cookie specification to which this cookie conforms.java.lang.StringtoString()
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name.
-
getValue
public java.lang.String getValue()
Returns the value.
-
setValue
public void setValue(java.lang.String value)
Sets the value
-
getComment
public java.lang.String getComment()
Returns the comment describing the purpose of this cookie, ornullif no such comment has been defined.- Specified by:
getCommentin interfaceCookie- Returns:
- comment
- See Also:
setComment(String)
-
setComment
public void setComment(java.lang.String comment)
If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment.- Specified by:
setCommentin interfaceSetCookie- Parameters:
comment-- See Also:
getComment()
-
getCommentURL
public java.lang.String getCommentURL()
Returns null. Cookies prior to RFC2965 do not set this attribute- Specified by:
getCommentURLin interfaceCookie
-
getExpiryDate
public java.util.Date getExpiryDate()
Returns the expirationDateof the cookie, ornullif 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.
- Specified by:
getExpiryDatein interfaceCookie- Returns:
- Expiration
Date, ornull. - See Also:
setExpiryDate(java.util.Date)
-
setExpiryDate
public void setExpiryDate(java.util.Date expiryDate)
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.
- Specified by:
setExpiryDatein interfaceSetCookie- Parameters:
expiryDate- theDateafter which this cookie is no longer valid.- See Also:
getExpiryDate()
-
isPersistent
public boolean isPersistent()
Returnsfalseif the cookie should be discarded at the end of the "session";trueotherwise.- Specified by:
isPersistentin interfaceCookie- Returns:
falseif the cookie should be discarded at the end of the "session";trueotherwise
-
getDomain
public java.lang.String getDomain()
Returns domain attribute of the cookie.- Specified by:
getDomainin interfaceCookie- Returns:
- the value of the domain attribute
- See Also:
setDomain(java.lang.String)
-
setDomain
public void setDomain(java.lang.String domain)
Sets the domain attribute.- Specified by:
setDomainin interfaceSetCookie- Parameters:
domain- The value of the domain attribute- See Also:
getDomain()
-
getPath
public java.lang.String getPath()
Returns the path attribute of the cookie- Specified by:
getPathin interfaceCookie- Returns:
- The value of the path attribute.
- See Also:
setPath(java.lang.String)
-
setPath
public void setPath(java.lang.String path)
Sets the path attribute.
-
isSecure
public boolean isSecure()
Description copied from interface:CookieIndicates whether this cookie requires a secure connection.- Specified by:
isSecurein interfaceCookie- Returns:
trueif this cookie should only be sent over secure connections.- See Also:
setSecure(boolean)
-
setSecure
public void setSecure(boolean secure)
Sets the secure attribute of the cookie.When
truethe 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.- Specified by:
setSecurein interfaceSetCookie- Parameters:
secure- The value of the secure attribute- See Also:
isSecure()
-
getPorts
public int[] getPorts()
Returns null. Cookies prior to RFC2965 do not set this attribute
-
getVersion
public int getVersion()
Returns the version of the cookie specification to which this cookie conforms.- Specified by:
getVersionin interfaceCookie- Returns:
- the version of the cookie.
- See Also:
setVersion(int)
-
setVersion
public void setVersion(int version)
Sets the version of the cookie specification to which this cookie conforms.- Specified by:
setVersionin interfaceSetCookie- Parameters:
version- the version of the cookie.- See Also:
getVersion()
-
isExpired
public boolean isExpired(java.util.Date date)
Returns true if this cookie has expired.
-
getCreationDate
public java.util.Date getCreationDate()
- Since:
- 4.4
-
setCreationDate
public void setCreationDate(java.util.Date creationDate)
- Since:
- 4.4
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.String value)
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
- Specified by:
getAttributein interfaceClientCookie
-
containsAttribute
public boolean containsAttribute(java.lang.String name)
- Specified by:
containsAttributein interfaceClientCookie
-
removeAttribute
public boolean removeAttribute(java.lang.String name)
- Since:
- 4.4
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Throws:
java.lang.CloneNotSupportedException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-