to top
Android APIs
public class

BasicClientCookie

extends Object
implements Cloneable ClientCookie SetCookie
java.lang.Object
   ↳ org.apache.http.impl.cookie.BasicClientCookie
Known Direct Subclasses

Class Overview

HTTP "magic-cookie" represents a piece of state information that the HTTP agent and the target server can exchange to maintain a session.

Summary

[Expand]
Inherited Constants
From interface org.apache.http.cookie.ClientCookie
Public Constructors
BasicClientCookie(String name, String value)
Default Constructor taking a name and a value.
Public Methods
Object clone()
Creates and returns a copy of this Object.
boolean containsAttribute(String name)
String getAttribute(String name)
String getComment()
Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.
String getCommentURL()
Returns null.
String getDomain()
Returns domain attribute of the cookie.
Date getExpiryDate()
Returns the expiration Date of the cookie, or null if none exists.
String getName()
Returns the name.
String getPath()
Returns the path attribute of the cookie
int[] getPorts()
Returns null.
String getValue()
Returns the value.
int getVersion()
Returns the version of the cookie specification to which this cookie conforms.
boolean isExpired(Date date)
Returns true if this cookie has expired.
boolean isPersistent()
Returns false if the cookie should be discarded at the end of the "session"; true otherwise.
boolean isSecure()
Indicates whether this cookie requires a secure connection.
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 setDomain(String domain)
Sets the domain attribute.
void setExpiryDate(Date expiryDate)
Sets expiration date.
void setPath(String path)
Sets the path attribute.
void setSecure(boolean secure)
Sets the secure attribute of the cookie.
void setValue(String value)
Sets the value
void setVersion(int version)
Sets the version of the cookie specification to which this cookie conforms.
String toString()
Returns a string containing a concise, human-readable description of this object.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.cookie.ClientCookie
From interface org.apache.http.cookie.Cookie
From interface org.apache.http.cookie.SetCookie

Public Constructors

public BasicClientCookie (String name, String value)

Added in API level 1

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

Parameters
name The name.
value The value.

Public Methods

public Object clone ()

Added in API level 1

Creates and returns a copy of this Object. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should call super.clone() to create the new instance and then create deep copies of the nested, mutable objects.

Returns
  • a copy of this object.

public boolean containsAttribute (String name)

Added in API level 1

public String getAttribute (String name)

Added in API level 1

public String getComment ()

Added in API level 1

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

Returns
  • comment

public String getCommentURL ()

Added in API level 1

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

public String getDomain ()

Added in API level 1

Returns domain attribute of the cookie.

Returns
  • the value of the domain attribute

public Date getExpiryDate ()

Added in API level 1

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
  • Expiration Date, or null.

public String getName ()

Added in API level 1

Returns the name.

Returns
  • String name The name

public String getPath ()

Added in API level 1

Returns the path attribute of the cookie

Returns
  • The value of the path attribute.

public int[] getPorts ()

Added in API level 1

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

public String getValue ()

Added in API level 1

Returns the value.

Returns
  • String value The current value.

public int getVersion ()

Added in API level 1

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

Returns
  • the version of the cookie.
See Also

public boolean isExpired (Date date)

Added in API level 1

Returns true if this cookie has expired.

Parameters
date Current time
Returns
  • true if the cookie has expired.

public boolean isPersistent ()

Added in API level 1

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

public boolean isSecure ()

Added in API level 1

Indicates whether this cookie requires a secure connection.

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

public void setAttribute (String name, String value)

Added in API level 1

public void setComment (String comment)

Added in API level 1

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

See Also

public void setDomain (String domain)

Added in API level 1

Sets the domain attribute.

Parameters
domain The value of the domain attribute
See Also

public void setExpiryDate (Date expiryDate)

Added in API level 1

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 the Date after which this cookie is no longer valid.
See Also

public void setPath (String path)

Added in API level 1

Sets the path attribute.

Parameters
path The value of the path attribute
See Also

public void setSecure (boolean secure)

Added in API level 1

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

public void setValue (String value)

Added in API level 1

Sets the value

public void setVersion (int version)

Added in API level 1

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

Parameters
version the version of the cookie.
See Also

public String toString ()

Added in API level 1

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.