Interface Cookie
- All Superinterfaces:
Comparable<Cookie>
- All Known Subinterfaces:
Cookie
- All Known Implementing Classes:
DefaultCookie
,DefaultCookie
An interface defining an
HTTP cookie.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
Constant for undefined MaxAge attribute value. -
Method Summary
Modifier and TypeMethodDescriptiondomain()
Returns the domain of thisCookie
.boolean
Checks to see if thisCookie
can only be accessed via HTTP.boolean
isSecure()
Checks to see if thisCookie
is securelong
maxAge()
Returns the maximum age of thisCookie
in seconds orUNDEFINED_MAX_AGE
if unspecifiedname()
Returns the name of thisCookie
.path()
Returns the path of thisCookie
.void
Sets the domain of thisCookie
.void
setHttpOnly
(boolean httpOnly) Determines if thisCookie
is HTTP only.void
setMaxAge
(long maxAge) Sets the maximum age of thisCookie
in seconds.void
Sets the path of thisCookie
.void
setSecure
(boolean secure) Sets the security getStatus of thisCookie
void
Sets the value of thisCookie
.void
setWrap
(boolean wrap) Sets true if the value of thisCookie
is to be wrapped with double quotes.value()
Returns the value of thisCookie
.boolean
wrap()
Returns true if the raw value of thisCookie
, was wrapped with double quotes in original Set-Cookie header.Methods inherited from interface java.lang.Comparable
compareTo
-
Field Details
-
UNDEFINED_MAX_AGE
static final long UNDEFINED_MAX_AGEConstant for undefined MaxAge attribute value.- See Also:
-
-
Method Details
-
name
String name()Returns the name of thisCookie
.- Returns:
- The name of this
Cookie
-
value
String value()Returns the value of thisCookie
.- Returns:
- The value of this
Cookie
-
setValue
Sets the value of thisCookie
.- Parameters:
value
- The value to set
-
wrap
boolean wrap()Returns true if the raw value of thisCookie
, was wrapped with double quotes in original Set-Cookie header.- Returns:
- If the value of this
Cookie
is to be wrapped
-
setWrap
void setWrap(boolean wrap) Sets true if the value of thisCookie
is to be wrapped with double quotes.- Parameters:
wrap
- true if wrap
-
domain
String domain()Returns the domain of thisCookie
.- Returns:
- The domain of this
Cookie
-
setDomain
Sets the domain of thisCookie
.- Parameters:
domain
- The domain to use
-
path
String path()Returns the path of thisCookie
.- Returns:
- The
Cookie
's path
-
setPath
Sets the path of thisCookie
.- Parameters:
path
- The path to use for thisCookie
-
maxAge
long maxAge()Returns the maximum age of thisCookie
in seconds orUNDEFINED_MAX_AGE
if unspecified- Returns:
- The maximum age of this
Cookie
-
setMaxAge
void setMaxAge(long maxAge) Sets the maximum age of thisCookie
in seconds. If an age of0
is specified, thisCookie
will be automatically removed by browser because it will expire immediately. IfUNDEFINED_MAX_AGE
is specified, thisCookie
will be removed when the browser is closed.- Parameters:
maxAge
- The maximum age of thisCookie
in seconds
-
isSecure
boolean isSecure()Checks to see if thisCookie
is secure- Returns:
- True if this
Cookie
is secure, otherwise false
-
setSecure
void setSecure(boolean secure) Sets the security getStatus of thisCookie
- Parameters:
secure
- True if thisCookie
is to be secure, otherwise false
-
isHttpOnly
boolean isHttpOnly()Checks to see if thisCookie
can only be accessed via HTTP. If this returns true, theCookie
cannot be accessed through client side script - But only if the browser supports it. For more information, please look here- Returns:
- True if this
Cookie
is HTTP-only or false if it isn't
-
setHttpOnly
void setHttpOnly(boolean httpOnly) Determines if thisCookie
is HTTP only. If set to true, thisCookie
cannot be accessed by a client side script. However, this works only if the browser supports it. For information, please look here.- Parameters:
httpOnly
- True if theCookie
is HTTP only, otherwise false.
-