com.jayway.restassured.response
Class Cookie

java.lang.Object
  extended by com.jayway.restassured.response.Cookie
All Implemented Interfaces:
NameAndValue

public class Cookie
extends Object
implements NameAndValue

Cookie class represents a token or short packet of state information (also referred to as "magic-cookie") that the HTTP agent and the target server can exchange to maintain a session. In its simples form an HTTP cookie is merely a name / value pair. To construct a new new Cookie use the Builder like this:

  Cookie cookie = new Cookie.Builder("name", "value").setComment("some comment").setExpiryDate(someDate).build();
 
Credits: Some of the javadoc in this class is copied from the org.apache.http.cookie.Cookie class in Apache HTTP Client. and some (version and secured) from Scalatra.


Nested Class Summary
static class Cookie.Builder
           
 
Field Summary
static String COMMENT
           
static String DOMAIN
           
static String EXPIRES
           
static String MAX_AGE
           
static String PATH
           
static String SECURE
           
static String VERSION
           
 
Method Summary
 boolean equals(Object o)
           
 String getComment()
          Returns the comment describing the purpose of this cookie, or null if no such comment has been defined.
 String getDomain()
          Returns domain attribute of the cookie.
 Date getExpiryDate()
          Returns the expiration Date of the cookie, or null if none exists.
 int getMaxAge()
          Returns the maximum age of the cookie, specified in seconds, By default, -1 indicating the cookie will persist until browser shutdown.
 String getName()
          Returns the name.
 String getPath()
          Returns the path attribute of the cookie.
 String getValue()
          Returns the value.
 int getVersion()
          Gets the version of the cookie protocol this cookie complies with.
 boolean hasComment()
           
 boolean hasDomain()
           
 boolean hasExpiryDate()
           
 int hashCode()
           
 boolean hasMaxAge()
           
 boolean hasPath()
           
 boolean hasValue()
           
 boolean hasVersion()
           
 boolean isSecured()
          Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMENT

public static final String COMMENT
See Also:
Constant Field Values

PATH

public static final String PATH
See Also:
Constant Field Values

DOMAIN

public static final String DOMAIN
See Also:
Constant Field Values

MAX_AGE

public static final String MAX_AGE
See Also:
Constant Field Values

SECURE

public static final String SECURE
See Also:
Constant Field Values

EXPIRES

public static final String EXPIRES
See Also:
Constant Field Values

VERSION

public static final String VERSION
See Also:
Constant Field Values
Method Detail

getName

public String getName()
Returns the name.

Specified by:
getName in interface NameAndValue
Returns:
String name The name

getValue

public String getValue()
Returns the value.

Specified by:
getValue in interface NameAndValue
Returns:
The current value.

hasValue

public boolean hasValue()
Returns:
true if this cookie has a value defined, false otherwise.

getComment

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

Returns:
comment

hasComment

public boolean hasComment()
Returns:
true if this cookie has a comment defined, false otherwise.

getExpiryDate

public Date getExpiryDate()
Returns the expiration Date of the cookie, or null if none exists.

Returns:
Expiration Date, or null.

hasExpiryDate

public boolean hasExpiryDate()
Returns:
true if this cookie has an expiry defined, false otherwise.

getDomain

public String getDomain()
Returns domain attribute of the cookie. The value of the Domain attribute specifies the domain for which the cookie is valid.

Returns:
the value of the domain attribute.

hasDomain

public boolean hasDomain()
Returns:
true if this cookie has a domain defined, false otherwise.

getPath

public String getPath()
Returns the path attribute of the cookie. The value of the Path attribute specifies the subset of URLs on the origin server to which this cookie applies.

Returns:
The value of the path attribute.

hasPath

public boolean hasPath()
Returns:
true if this cookie has a path defined, false otherwise.

isSecured

public boolean isSecured()
Indicates to the browser whether the cookie should only be sent using a secure protocol, such as HTTPS or SSL.

Returns:
true if this cookies is secured.

getVersion

public int getVersion()
Gets the version of the cookie protocol this cookie complies with. Version 0 complies with the original Netscape cookie specification. Version 1 complies with RFC 2109.

Returns:
The version of this cookie or -1 if version is undefined.

hasVersion

public boolean hasVersion()
Returns:
true if this cookie has a version defined, false otherwise.

getMaxAge

public int getMaxAge()
Returns the maximum age of the cookie, specified in seconds, By default, -1 indicating the cookie will persist until browser shutdown.

Returns:
an integer specifying the maximum age of the cookie in seconds; if negative, means the cookie persists until browser shutdown

hasMaxAge

public boolean hasMaxAge()
Returns:
true if this cookie has a Max-Age defined, false otherwise.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010-2012. All Rights Reserved.