javax.ws.rs.core
Class NewCookie

java.lang.Object
  extended by javax.ws.rs.core.Cookie
      extended by javax.ws.rs.core.NewCookie

public class NewCookie
extends Cookie

Used to create a new HTTP cookie, transferred in a response.

See Also:
IETF RFC 2109

Field Summary
static int DEFAULT_MAX_AGE
          Specifies that the cookie expires with the current application/browser session.
 
Fields inherited from class javax.ws.rs.core.Cookie
DEFAULT_VERSION
 
Constructor Summary
NewCookie(Cookie cookie)
          Create a new instance copying the information in the supplied cookie.
NewCookie(Cookie cookie, java.lang.String comment, int maxAge, boolean secure)
          Create a new instance supplementing the information in the supplied cookie.
NewCookie(java.lang.String name, java.lang.String value)
          Create a new instance.
NewCookie(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain, int version, java.lang.String comment, int maxAge, boolean secure)
          Create a new instance.
NewCookie(java.lang.String name, java.lang.String value, java.lang.String path, java.lang.String domain, java.lang.String comment, int maxAge, boolean secure)
          Create a new instance.
 
Method Summary
 java.lang.String getComment()
          Get the comment associated with the cookie.
 int getMaxAge()
          Get the maximum age of the the cookie in seconds.
 boolean isSecure()
          Whether the cookie will only be sent over a secure connection.
 java.lang.String toString()
          Convert the cookie to a string suitable for use as the value of the corresponding HTTP header.
static NewCookie valueOf(java.lang.String value)
          Creates a new instance of NewCookie by parsing the supplied string.
 
Methods inherited from class javax.ws.rs.core.Cookie
getDomain, getName, getPath, getValue, getVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MAX_AGE

public static final int DEFAULT_MAX_AGE
Specifies that the cookie expires with the current application/browser session.

See Also:
Constant Field Values
Constructor Detail

NewCookie

public NewCookie(java.lang.String name,
                 java.lang.String value)
Create a new instance.

Parameters:
name - the name of the cookie
value - the value of the cookie

NewCookie

public NewCookie(java.lang.String name,
                 java.lang.String value,
                 java.lang.String path,
                 java.lang.String domain,
                 java.lang.String comment,
                 int maxAge,
                 boolean secure)
Create a new instance.

Parameters:
name - the name of the cookie
value - the value of the cookie
path - the URI path for which the cookie is valid
domain - the host domain for which the cookie is valid
comment - the comment
maxAge - the maximum age of the cookie in seconds
secure - specifies whether the cookie will only be sent over a secure connection

NewCookie

public NewCookie(java.lang.String name,
                 java.lang.String value,
                 java.lang.String path,
                 java.lang.String domain,
                 int version,
                 java.lang.String comment,
                 int maxAge,
                 boolean secure)
Create a new instance.

Parameters:
name - the name of the cookie
value - the value of the cookie
path - the URI path for which the cookie is valid
domain - the host domain for which the cookie is valid
version - the version of the specification to which the cookie complies
comment - the comment
maxAge - the maximum age of the cookie in seconds
secure - specifies whether the cookie will only be sent over a secure connection

NewCookie

public NewCookie(Cookie cookie)
Create a new instance copying the information in the supplied cookie.

Parameters:
cookie - the cookie to clone

NewCookie

public NewCookie(Cookie cookie,
                 java.lang.String comment,
                 int maxAge,
                 boolean secure)
Create a new instance supplementing the information in the supplied cookie.

Parameters:
cookie - the cookie to clone
comment - the comment
maxAge - the maximum age of the cookie in seconds
secure - specifies whether the cookie will only be sent over a secure connection
Method Detail

valueOf

public static NewCookie valueOf(java.lang.String value)
                         throws java.lang.IllegalArgumentException
Creates a new instance of NewCookie by parsing the supplied string.

Parameters:
value - the cookie string
Returns:
the newly created NewCookie
Throws:
java.lang.IllegalArgumentException - if the supplied string cannot be parsed

getComment

public java.lang.String getComment()
Get the comment associated with the cookie.

Returns:
the comment or null if none set

getMaxAge

public int getMaxAge()
Get the maximum age of the the cookie in seconds. Cookies older than the maximum age are discarded. A cookie can be unset by sending a new cookie with maximum age of 0 since it will overwrite any existing cookie and then be immediately discarded. The default value of -1 indicates that the cookie will be discarded at the end of the browser/application session.

Returns:
the maximum age in seconds

isSecure

public boolean isSecure()
Whether the cookie will only be sent over a secure connection. Defaults to false.

Returns:
true if the cookie will only be sent over a secure connection, false otherwise.

toString

public java.lang.String toString()
Convert the cookie to a string suitable for use as the value of the corresponding HTTP header.

Overrides:
toString in class Cookie
Returns:
a stringified cookie


Copyright © 2008. All Rights Reserved.