Top Description Fields Constructors Methods
org.apache.http.impl.cookie

public Class BasicClientCookie

extends Object
implements SetCookie, ClientCookie, Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable, org.apache.http.cookie.ClientCookie, org.apache.http.cookie.Cookie, org.apache.http.cookie.SetCookie
Known Direct Subclasses
org.apache.http.impl.cookie.BasicClientCookie2
Imports
java.io.Serializable, java.util.Date, .HashMap, .Locale, .Map, org.apache.http.cookie.ClientCookie, .SetCookie, org.apache.http.util.Args

Default implementation of SetCookie.
Since
4.0

Field Summary

Modifier and TypeField and Description
private Map<String, String>
attribs

Cookie attributes as specified by the origin server

private String
cookieComment

Comment attribute.

private String
cookieDomain

Domain attribute.

private Date
private String
cookiePath

Path attribute.

private int
cookieVersion

The version of the cookie specification I was created from.

private Date
private boolean
isSecure

My secure flag.

private final String
name

Cookie name

private static final long
private String
value

Cookie value

Constructor Summary

AccessConstructor and Description
public
BasicClientCookie(final String
The name.
name
,
final String
The value.
value
)

Default Constructor taking a name and a value.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public boolean
public String
public String

Returns:

comment
getComment
()

Implements org.apache.http.cookie.Cookie.getComment.

Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.
public String
public Date
public String

Returns:

the value of the domain attribute
getDomain
()

Implements org.apache.http.cookie.Cookie.getDomain.

Returns domain attribute of the cookie.
public Date

Returns:

Expiration Date, or null.
getExpiryDate
()

Implements org.apache.http.cookie.Cookie.getExpiryDate.

Returns the expiration Date of the cookie, or null if none exists.
public String

Returns:

String name The name
getName
()

Implements org.apache.http.cookie.Cookie.getName.

Returns the name.
public String

Returns:

The value of the path attribute.
getPath
()

Implements org.apache.http.cookie.Cookie.getPath.

Returns the path attribute of the cookie
public int[]
public String

Returns:

String value The current value.
getValue
()

Implements org.apache.http.cookie.Cookie.getValue.

Returns the value.
public int

Returns:

the version of the cookie.
getVersion
()

Implements org.apache.http.cookie.Cookie.getVersion.

Returns the version of the cookie specification to which this cookie conforms.
public boolean

Returns:

true if the cookie has expired.
isExpired
(final Date
Current time
date
)

Implements org.apache.http.cookie.Cookie.isExpired.

Returns true if this cookie has expired.
public boolean

Returns:

false if the cookie should be discarded at the end of the "session"; true otherwise
isPersistent
()

Implements org.apache.http.cookie.Cookie.isPersistent.

Returns false if the cookie should be discarded at the end of the "session"; true otherwise.
public boolean

Returns:

true if this cookie should only be sent over secure connections.
isSecure
()

Implements org.apache.http.cookie.Cookie.isSecure.

Indicates whether this cookie requires a secure connection.
public boolean
removeAttribute(final String name)

public void
setAttribute(final String name, final String value)

public void
setComment(final String comment)

Implements org.apache.http.cookie.SetCookie.setComment.

If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment.
public void
setCreationDate(final Date creationDate)

public void
setDomain(final String
The value of the domain attribute
domain
)

Implements org.apache.http.cookie.SetCookie.setDomain.

Sets the domain attribute.
public void
setExpiryDate(final Date
the Date after which this cookie is no longer valid.
expiryDate
)

Implements org.apache.http.cookie.SetCookie.setExpiryDate.

Sets expiration date.
public void
setPath(final String
The value of the path attribute
path
)

Implements org.apache.http.cookie.SetCookie.setPath.

Sets the path attribute.
public void
setSecure(final boolean
The value of the secure attribute
secure
)

Implements org.apache.http.cookie.SetCookie.setSecure.

Sets the secure attribute of the cookie.
public void
setValue(final String value)

Implements org.apache.http.cookie.SetCookie.setValue.

Sets the value
public void
setVersion(final int
the version of the cookie.
version
)

Implements org.apache.http.cookie.SetCookie.setVersion.

Sets the version of the cookie specification to which this cookie conforms.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attribsback to summary
private Map<String, String> attribs

Cookie attributes as specified by the origin server

cookieCommentback to summary
private String cookieComment

Comment attribute.

cookieDomainback to summary
private String cookieDomain

Domain attribute.

cookieExpiryDateback to summary
private Date cookieExpiryDate

Expiration Date.

cookiePathback to summary
private String cookiePath

Path attribute.

cookieVersionback to summary
private int cookieVersion

The version of the cookie specification I was created from.

creationDateback to summary
private Date creationDate
isSecureback to summary
private boolean isSecure

My secure flag.

nameback to summary
private final String name

Cookie name

serialVersionUIDback to summary
private static final long serialVersionUID
valueback to summary
private String value

Cookie value

Constructor Detail

BasicClientCookieback to summary
public BasicClientCookie(final String name, final String value)

Default Constructor taking a name and a value. The value may be null.

Parameters
name:String

The name.

value:String

The value.

Method Detail

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
Exceptions
CloneNotSupportedException:
if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
containsAttributeback to summary
public boolean containsAttribute(final String name)

Implements org.apache.http.cookie.ClientCookie.containsAttribute.

Annotations
@Override
getAttributeback to summary
public String getAttribute(final String name)

Implements org.apache.http.cookie.ClientCookie.getAttribute.

Annotations
@Override
getCommentback to summary
public String getComment()

Implements org.apache.http.cookie.Cookie.getComment.

Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.

Returns:String

comment

Annotations
@Override
See Also
setComment(String)
getCommentURLback to summary
public String getCommentURL()

Implements org.apache.http.cookie.Cookie.getCommentURL.

Returns null. Cookies prior to RFC2965 do not set this attribute

Annotations
@Override
getCreationDateback to summary
public Date getCreationDate()
Since
4.4
getDomainback to summary
public String getDomain()

Implements org.apache.http.cookie.Cookie.getDomain.

Returns domain attribute of the cookie.

Returns:String

the value of the domain attribute

Annotations
@Override
See Also
setDomain(java.lang.String)
getExpiryDateback to summary
public Date getExpiryDate()

Implements org.apache.http.cookie.Cookie.getExpiryDate.

Returns the expiration 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.

Returns:Date

Expiration Date, or null.

Annotations
@Override
See Also
setExpiryDate(java.util.Date)
getNameback to summary
public String getName()

Implements org.apache.http.cookie.Cookie.getName.

Returns the name.

Returns:String

String name The name

Annotations
@Override
getPathback to summary
public String getPath()

Implements org.apache.http.cookie.Cookie.getPath.

Returns the path attribute of the cookie

Returns:String

The value of the path attribute.

Annotations
@Override
See Also
setPath(java.lang.String)
getPortsback to summary
public int[] getPorts()

Implements org.apache.http.cookie.Cookie.getPorts.

Returns null. Cookies prior to RFC2965 do not set this attribute

Annotations
@Override
getValueback to summary
public String getValue()

Implements org.apache.http.cookie.Cookie.getValue.

Returns the value.

Returns:String

String value The current value.

Annotations
@Override
getVersionback to summary
public int getVersion()

Implements org.apache.http.cookie.Cookie.getVersion.

Returns the version of the cookie specification to which this cookie conforms.

Returns:int

the version of the cookie.

Annotations
@Override
See Also
setVersion(int)
isExpiredback to summary
public boolean isExpired(final Date date)

Implements org.apache.http.cookie.Cookie.isExpired.

Returns true if this cookie has expired.

Parameters
date:Date

Current time

Returns:boolean

true if the cookie has expired.

Annotations
@Override
isPersistentback to summary
public boolean isPersistent()

Implements org.apache.http.cookie.Cookie.isPersistent.

Returns false if the cookie should be discarded at the end of the "session"; true otherwise.

Returns:boolean

false if the cookie should be discarded at the end of the "session"; true otherwise

Annotations
@Override
isSecureback to summary
public boolean isSecure()

Implements org.apache.http.cookie.Cookie.isSecure.

Doc from org.apache.http.cookie.Cookie.isSecure.

Indicates whether this cookie requires a secure connection.

Returns:boolean

true if this cookie should only be sent over secure connections.

Annotations
@Override
See Also
setSecure(boolean)
removeAttributeback to summary
public boolean removeAttribute(final String name)
Since
4.4
setAttributeback to summary
public void setAttribute(final String name, final String value)
setCommentback to summary
public void setComment(final String comment)

Implements org.apache.http.cookie.SetCookie.setComment.

If a user agent (web browser) presents this cookie to a user, the cookie's purpose will be described using this comment.

Annotations
@Override
See Also
getComment()
setCreationDateback to summary
public void setCreationDate(final Date creationDate)
Since
4.4
setDomainback to summary
public void setDomain(final String domain)

Implements org.apache.http.cookie.SetCookie.setDomain.

Sets the domain attribute.

Parameters
domain:String

The value of the domain attribute

Annotations
@Override
See Also
getDomain
setExpiryDateback to summary
public void setExpiryDate(final Date expiryDate)

Implements org.apache.http.cookie.SetCookie.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.

Parameters
expiryDate:Date

the Date after which this cookie is no longer valid.

Annotations
@Override
See Also
getExpiryDate
setPathback to summary
public void setPath(final String path)

Implements org.apache.http.cookie.SetCookie.setPath.

Sets the path attribute.

Parameters
path:String

The value of the path attribute

Annotations
@Override
See Also
getPath
setSecureback to summary
public void setSecure(final boolean secure)

Implements org.apache.http.cookie.SetCookie.setSecure.

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:boolean

The value of the secure attribute

Annotations
@Override
See Also
isSecure()
setValueback to summary
public void setValue(final String value)

Implements org.apache.http.cookie.SetCookie.setValue.

Sets the value

Annotations
@Override
setVersionback to summary
public void setVersion(final int version)

Implements org.apache.http.cookie.SetCookie.setVersion.

Sets the version of the cookie specification to which this cookie conforms.

Parameters
version:int

the version of the cookie.

Annotations
@Override
See Also
getVersion
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override