public class Cookie
extends java.lang.Object
Supported attributes:
All other attributes are currently not supported.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
HEADER_COOKIE |
static java.lang.String |
HEADER_SET_COOKIE |
static java.lang.String |
HEADER_SET_COOKIE2 |
Constructor and Description |
---|
Cookie(java.lang.String name,
java.lang.String value)
Creates a new Cookie with the given name and value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object object) |
static java.util.Vector |
getCookiesFromHeader(java.lang.String header)
Parses all
Cookie s from the given HTTP header field. |
java.lang.String |
getDomain()
Returns the domain of the
Cookie . |
java.lang.String |
getName()
Returns the name of the
Cookie . |
java.lang.String |
getPath()
Returns the path of the
Cookie . |
java.lang.String |
getPortlist()
Returns the port list attribute of the
Cookie . |
long |
getTimeCreated()
Returns the time the
Cookie was created. |
java.lang.String |
getValue()
Returns the value of the
Cookie . |
boolean |
isDomainFromURL()
Returns a flag to indicate if the domain of the
Cookie was
parsed from an URL using setDomainFromURL(String) . |
boolean |
isSecure()
Returns the secure attribute of the
Cookie . |
boolean |
matchesURL(java.lang.String url)
Checks if the
Cookie matches the given URL using the domain,
path and secure attributes. |
void |
setDomain(java.lang.String domain)
Sets the domain of the
Cookie . |
void |
setDomainFromURL(java.lang.String url)
Sets the domain of the
Cookie from a given URL. |
void |
setName(java.lang.String name)
Sets the name of the
Cookie . |
void |
setPath(java.lang.String path)
Sets the path of the
Cookie . |
void |
setPathFromURL(java.lang.String url)
Sets the path of the
Cookie from a given URL. |
void |
setPortlist(java.lang.String portlist)
Sets the port list of the
Cookie . |
void |
setSecure(boolean secure)
Sets the secure attribute of the
Cookie . |
void |
setTimeCreated(long created)
Sets the time the
Cookie was created |
void |
setValue(java.lang.String value)
Sets the value of the
Cookie . |
java.lang.String |
toString()
Returns a String representation of the Cookies name and value that can be
used in the HTTP Cookie header.
|
java.lang.String |
toVersion2String()
Returns an extended String representation of the Cookie that can be used
in the HTTP Cookie header.
|
public static final java.lang.String HEADER_COOKIE
public static final java.lang.String HEADER_SET_COOKIE
public static final java.lang.String HEADER_SET_COOKIE2
public Cookie(java.lang.String name, java.lang.String value)
IllegalArgumentException
will be
thrown. Typically this will be caused by illegal characters or the use of
reserverd words in the name of the Cookie.name
- the name of the Cookievalue
- the value of the Cookiepublic static java.util.Vector getCookiesFromHeader(java.lang.String header)
Cookie
s from the given HTTP header field. There
might be more than one Cookie set by the HTTP backend server. Both,
Set-Cookie and Set-Cookie2 headers are supported.header
- the header Stringpublic boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toVersion2String()
public boolean matchesURL(java.lang.String url)
Cookie
matches the given URL using the domain,
path and secure attributes.url
- the URL as Stringtrue
if the Cookie matches the URL and might be used
in a request using the given URL, false
if notpublic java.lang.String getName()
Cookie
.public void setName(java.lang.String name)
Cookie
.name
- as Stringpublic java.lang.String getValue()
Cookie
.public void setValue(java.lang.String value)
Cookie
.value
- as Stringpublic java.lang.String getDomain()
Cookie
.public void setDomain(java.lang.String domain)
Cookie
.domain
- as Stringpublic void setDomainFromURL(java.lang.String url)
Cookie
from a given URL.url
- as String to parse the domain frompublic java.lang.String getPath()
Cookie
.public void setPath(java.lang.String path)
Cookie
.path
- as Stringpublic void setPathFromURL(java.lang.String url)
Cookie
from a given URL.url
- as String to parse the path frompublic java.lang.String getPortlist()
Cookie
.public void setPortlist(java.lang.String portlist)
Cookie
.portList
- as Stringpublic boolean isSecure()
Cookie
.true
if the Cookie
requires secure
connections, false
if not.public void setSecure(boolean secure)
Cookie
.secure
- value as booleanpublic long getTimeCreated()
Cookie
was created. This enables to
calculate the age of the Cookie
.public void setTimeCreated(long created)
Cookie
was createdcreated
- value as long.public boolean isDomainFromURL()
Cookie
was
parsed from an URL using setDomainFromURL(String)
.true
if the domain and path were parsed from an URL,
false
if not.