|
Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface RestContext
Context object that is supplied to RestCommands
when they
are dispatched. This provides access to the general environment in which
the RestCommand
is running, including access to the
HttpServletRequest
, HttpServletResponse
and
the ServletContext
. This context object also provides the
method, servlet path and command path that resulted in the dispatch
to the RestCommand
. Several convenience methods are included
in this interface, providing simple access to request parameters, locales,
including a means to compute a preferred locale, and utiltity methods to obtain
portions of the command path. Finally, the requested RestResult
FormatType
enum
is available from this context object.
Field Summary | |
---|---|
static String |
format
parameter literal for specifying the format in a REST command URL |
static String |
max
parameter literal for specifying the max number of results to return in a REST command URL |
static String |
start
parameter literal for specifying the start index in a REST command URL |
static String |
version
parameter literal for specifying the version in a REST command URL |
static String |
webapp
parameter literal for specifying the webapp in a REST command URL |
Method Summary | |
---|---|
String |
fourthPathInfo()
Return the 2nd identifier portion of the path. |
javax.servlet.ServletContext |
getContext()
Gets the ServletContext associated with the current RestCommand dispatch. |
RestResult.FormatType |
getFormatType()
Gets the requested RestResult FormatType enum for use in assembling the output
of the current RestCommand . |
Integer |
getIntegerParamValue(String key)
Gets the first value for the parameter identified by key as an Integer. |
ArrayList<Locale> |
getLocales()
Gets the list of acceptable client locales in decreasing order, starting with the preferred locale. |
String |
getMethod()
Gets the HTTP method that was used to invoke the current RestCommand . |
String[] |
getMultiParamValue(String key)
Gets all values for the parameter identified by key. |
Map<String,String[]> |
getParams()
Gets a collection of all the the request parameters associated with the current command request. |
String |
getPath()
Gets the command path portion of the request URI, which identifies a specific RestCommand . |
String |
getPathInfo(int index)
Return the nth identifier portion of the path. |
Locale |
getPreferredLocale()
Returns the preferred client locale, based on the first element in the underlying locale list. |
javax.servlet.http.HttpServletRequest |
getRequest()
Gets the HttpServletRequest associated with this RestCommand dispatch. |
javax.servlet.http.HttpServletResponse |
getResponse()
Gets the HttpServletResponse associated with this RestCommand dispatch. |
String |
getServletPath()
Gets the servlet path associated with the current RestCommand request. |
String |
getSingleParamValue(String key)
Gets a the first value for the parameter identified by key. |
String |
secondPathInfo()
Return the verb portion of the path. |
void |
setContext(javax.servlet.ServletContext context)
Sets the current ServletContext . |
void |
setLocales(ArrayList<Locale> locales)
Sets the preferred requesting client Locales into this RestContext . |
void |
setParams(Map<String,String[]> params)
Sets the Map of parameters into this RestContext . |
void |
setPath(String path)
Sets the current command path. |
void |
setRequest(javax.servlet.http.HttpServletRequest request)
Sets the current HttpServletRequest . |
void |
setResponse(javax.servlet.http.HttpServletResponse response)
Sets the current HttpServletResponse . |
String |
thirdPathInfo()
Return the identifier portion of the path. |
String |
toString()
Returns a String representation of this RestContext object. |
Field Detail |
---|
static final String webapp
static final String version
static final String format
static final String max
static final String start
Method Detail |
---|
javax.servlet.http.HttpServletRequest getRequest()
HttpServletRequest
associated with this RestCommand
dispatch.
void setRequest(javax.servlet.http.HttpServletRequest request)
HttpServletRequest
. This is intended for use by the REST framework.
request
- the request to set into this RestContext
javax.servlet.http.HttpServletResponse getResponse()
HttpServletResponse
associated with this RestCommand
dispatch.
void setResponse(javax.servlet.http.HttpServletResponse response)
HttpServletResponse
. This is intended for use by the REST framework.
response
- the response to set into this RestContext
javax.servlet.ServletContext getContext()
ServletContext
associated with the current RestCommand
dispatch.
void setContext(javax.servlet.ServletContext context)
ServletContext
. This is intended for use by the REST framework.
context
- the servlet context to set into this RestContext
String getMethod()
RestCommand
.
This is one of GET, POST, PUT or DELETE
String getServletPath()
RestCommand
request. This
will be either the direct path to the RestServlet
or one of the alternate
serlvet mappings that are used for any of the configured command namespaces.
String getPath()
RestCommand
.
void setPath(String path)
path
- the command path to setMap<String,String[]> getParams()
Map
keyed on parameter name with values derived from the actual request parametersString getSingleParamValue(String key)
key
- the parameter name to get a parameter value for
String[] getMultiParamValue(String key)
key
- the parameter name to get a parameter value for
Integer getIntegerParamValue(String key)
key
- the parameter name to get a parameter value for
void setParams(Map<String,String[]> params)
Map
of parameters into this RestContext
.
This is intended for use by the REST framework.
params
- a collection of parameters keyed by parameter nameArrayList<Locale> getLocales()
Locales
that the requesting client prefersvoid setLocales(ArrayList<Locale> locales)
Locales
into this RestContext
.
This is intended for use by the REST framework.
locales
- the preferred Locales
from the requesting client.Locale getPreferredLocale()
Locale
String secondPathInfo()
Return the verb portion of the path. Typically REST style API are in the format
http://someserver:80/webapp/rest/resthandler/verb/idenditifer
This would return the second parameter after the servlet context param. i.e. "verb"
Path information was supplied in the constructor of this class via request.getPathInfo();
String thirdPathInfo()
Return the identifier portion of the path. Typically REST style API are in the format
http://someserver:80/webapp/rest/resthandler/verb/idenditifer
This would return the third parameter after the servlet context param. i.e. "identifier"
Path information was supplied in the constructor of this class via request.getPathInfo();
String fourthPathInfo()
Return the 2nd identifier portion of the path. Typically REST style API are in the format
http://someserver:80/webapp/rest/resthandler/verb/{idenditifer}/{2nd idenditifer}
This would return the fourth paramater after the servlet context param. i.e. "2nd identifier"
Path information was supplied in the constructor of this class via request.getPathInfo();
String getPathInfo(int index)
Return the nth identifier portion of the path. Typically REST style API are in the format
http://someserver:80/webapp/restservetcontextparam/{path part[0])/{path part[1]}/{path part[2]}
This would return the nth paramater after the servlet context param. 0 == first, 1 == second, etc.
Path information was supplied in the constructor of this class via request.getPathInfo();
String toString()
String
representation of this RestContext
object.
toString
in class Object
String
RestResult.FormatType getFormatType()
RestResult
FormatType
enum for use in assembling the output
of the current RestCommand
.
|
Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |