|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface State
The State
is used by the Request
to
examine the cookies that have been issued with the HTTP request.
The purpose of this interface is to provide implementations of
the ProtocolHandler
with a simple HTTP state control
mechanism. This provides access to the cookies issued using the
simple.http.net.Cookie
object.
The HTTP State Management Mechanism, RFC 2109, specifies Cookie
and Set-Cookie headers that can be used by HTTP servers to manage
state across multiple requests. The State
object
abstracts this by setting up a context between the
Request
and Response
. The various
setCookie
methods enable the State
to be used to add Set-Cookie headers to the HTTP response header
once it commits and cookie objects can be examined using the
getCookie
and getValue
methods.
Method Summary | |
---|---|
void |
clear()
Removes all cookies from the state. |
boolean |
contains(java.lang.String name)
Checks to see if the cookie of the specified name exists in the State . |
Cookie |
getCookie(java.lang.String name)
This returns the Cookie object stored under the
specified name. |
Cookie[] |
getCookies()
The getCookies method returns all cookies that
exist within the state. |
Cookie[] |
getSetCookies()
The getSetCookies method is used to retrieve the
cookies that have been added to the state. |
java.lang.String |
getValue(java.lang.String name)
This is used to retreive the value of the Cookie
stored under the specified name. |
boolean |
isEmpty()
Checks to see if the State is empty. |
Cookie |
remove(java.lang.String name)
This method removes and returns the removed cookie object from the State . |
void |
setCookie(Cookie cookie)
The setCookie method is used to set a cookie value
with the cookie name. |
void |
setCookie(java.lang.String name,
java.lang.String value)
The setCookie method is used to set a cookie value
for a specified name. |
void |
setCookie(java.lang.String name,
java.lang.String value,
java.lang.String path)
The setCookie method is used to set a cookie value
for a specified name. |
int |
size()
Returns the number of cookies that exist within the state. |
Method Detail |
---|
void setCookie(Cookie cookie)
setCookie
method is used to set a cookie value
with the cookie name. This will add a cookie to the state
stored under the Cookie.getName
value. Once the
Response
object commits then the header will be
given to the client with the Set-Cookie header.
cookie
- this is the simple.util.net.Cookie
that is to be used in a Set-Cookie response headervoid setCookie(java.lang.String name, java.lang.String value)
setCookie
method is used to set a cookie value
for a specified name. This will add a cookie to the state
stored under the specified name as a Cookie
object.
Once the Response
object commits then the header
will be given to the client with the Set-Cookie header. This is
a convienience method that avoids having to create a cookie.
name
- the name of the cookie to be given to the clientvalue
- the value that the cookie is to be givenvoid setCookie(java.lang.String name, java.lang.String value, java.lang.String path)
setCookie
method is used to set a cookie value
for a specified name. This will add a cookie to the state
stored under the specified name as a Cookie
object.
Once the Response
object commits then the header
will be given to the client with the Set-Cookie header. This is
a convienience method that avoids having to create a cookie.
name
- the name of the cookie to be given to the clientvalue
- the value that the cookie is to be givenpath
- specifies the path the cookie object is to haveCookie getCookie(java.lang.String name)
Cookie
object stored under the
specified name. This is used to retieve cookies that have
been issued with the HTTP request and set using the
setCookie
methods.
name
- this is the name of the cookie to be retreived
Cookie
by the given nameCookie[] getSetCookies()
getSetCookies
method is used to retrieve the
cookies that have been added to the state. This is useful
so that the ProtocolHandler
can determine the
cookies add using the setCookie
methods. The
cookies returned from this method are the only cookies sent
to the HTTP client using the Set-Cookie header.
Cookie
with
the cookies set with this instanceCookie[] getCookies()
getCookies
method returns all cookies that
exist within the state. The cookies returned include all
cookies retreived from the HTTP request header and all
cookies set using the current State
instance.
Cookie
of all
cookies within the current statejava.lang.String getValue(java.lang.String name)
Cookie
stored under the specified name. This is a convienience
method that avoids having to deal with the cookie object
directly. If the cookis does not exist ths returns null.
name
- this is the name of the cookie to be retreived
Cookie
Cookie remove(java.lang.String name)
State
. If the a Cookie
by the specified name does not exist then null is returned.
name
- this name of the cookie that is to be removed
Cookie
instance removed from this
state or null is it did not exist.boolean contains(java.lang.String name)
State
.
name
- the name of the Cookie
object
boolean isEmpty()
State
is empty. If empty
this represents a new client or a browser that does not
accept Set-Cookie headers for privacy.
int size()
size
is zero this isEmpty
.
void clear()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |