Package org.apache.http.impl.cookie
Class BasicClientCookie
java.lang.Object
org.apache.http.impl.cookie.BasicClientCookie
- All Implemented Interfaces:
Serializable
,Cloneable
,ClientCookie
,Cookie
,SetCookie
- Direct Known Subclasses:
BasicClientCookie2
public class BasicClientCookie
extends Object
implements SetCookie, ClientCookie, Cloneable, Serializable
Default implementation of
SetCookie
.- Since:
- 4.0
- See Also:
-
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
ConstructorsConstructorDescriptionBasicClientCookie
(String name, String value) Default Constructor taking a name and a value. -
Method Summary
Modifier and TypeMethodDescriptionclone()
boolean
containsAttribute
(String name) getAttribute
(String name) Returns the comment describing the purpose of this cookie, ornull
if no such comment has been defined.Returns null.Returns domain attribute of the cookie.Returns the expirationDate
of the cookie, ornull
if none exists.getName()
Returns the name.getPath()
Returns the path attribute of the cookieint[]
getPorts()
Returns null.getValue()
Returns the value.int
Returns the version of the cookie specification to which this cookie conforms.boolean
Returns true if this cookie has expired.boolean
Returnsfalse
if the cookie should be discarded at the end of the "session";true
otherwise.boolean
isSecure()
Indicates whether this cookie requires a secure connection.boolean
removeAttribute
(String name) void
setAttribute
(String name, String value) 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
setCreationDate
(Date creationDate) void
Sets the domain attribute.void
setExpiryDate
(Date expiryDate) Sets expiration date.void
Sets the path attribute.void
setSecure
(boolean secure) Sets the secure attribute of the cookie.void
Sets the valuevoid
setVersion
(int version) Sets the version of the cookie specification to which this cookie conforms.toString()
-
Constructor Details
-
BasicClientCookie
Default Constructor taking a name and a value. The value may be null.- Parameters:
name
- The name.value
- The value.
-
-
Method Details
-
getName
Returns the name. -
getValue
Returns the value. -
setValue
Sets the value -
getComment
Returns the comment describing the purpose of this cookie, ornull
if no such comment has been defined.- Specified by:
getComment
in interfaceCookie
- Returns:
- comment
- See Also:
-
setComment
If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment.- Specified by:
setComment
in interfaceSetCookie
- Parameters:
comment
-- See Also:
-
getCommentURL
Returns null. Cookies prior to RFC2965 do not set this attribute- Specified by:
getCommentURL
in interfaceCookie
-
getExpiryDate
Returns the expirationDate
of the cookie, ornull
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.
- Specified by:
getExpiryDate
in interfaceCookie
- Returns:
- Expiration
Date
, ornull
. - See Also:
-
setExpiryDate
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:
setExpiryDate
in interfaceSetCookie
- Parameters:
expiryDate
- theDate
after which this cookie is no longer valid.- See Also:
-
isPersistent
public boolean isPersistent()Returnsfalse
if the cookie should be discarded at the end of the "session";true
otherwise.- Specified by:
isPersistent
in interfaceCookie
- Returns:
false
if the cookie should be discarded at the end of the "session";true
otherwise
-
getDomain
Returns domain attribute of the cookie. -
setDomain
Sets the domain attribute. -
getPath
Returns the path attribute of the cookie -
setPath
Sets the path attribute. -
isSecure
public boolean isSecure()Description copied from interface:Cookie
Indicates whether this cookie requires a secure connection. -
setSecure
public void setSecure(boolean secure) 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. -
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:
getVersion
in interfaceCookie
- Returns:
- the version of the cookie.
- See Also:
-
setVersion
public void setVersion(int version) Sets the version of the cookie specification to which this cookie conforms.- Specified by:
setVersion
in interfaceSetCookie
- Parameters:
version
- the version of the cookie.- See Also:
-
isExpired
Returns true if this cookie has expired. -
getCreationDate
- Since:
- 4.4
-
setCreationDate
- Since:
- 4.4
-
setAttribute
-
getAttribute
- Specified by:
getAttribute
in interfaceClientCookie
-
containsAttribute
- Specified by:
containsAttribute
in interfaceClientCookie
-
removeAttribute
- Since:
- 4.4
-
clone
- Throws:
CloneNotSupportedException
-
toString
-