Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.wlp.rest.command
Interface RestContext

All Superinterfaces
  Serializable

    public interface RestContext

extends Serializable

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

### webapp

    static final String webapp

  parameter literal for specifying the webapp in a REST command URL

  See Also
    Constants Summary

### version

    static final String version

  parameter literal for specifying the version in a REST command URL

  See Also
    Constants Summary

### format

    static final String format

  parameter literal for specifying the format in a REST command URL

  See Also
    Constants Summary

### max

    static final String max

  parameter literal for specifying the max number of results to return in a REST command URL

  See Also
    Constants Summary

### start

    static final String start

  parameter literal for specifying the start index in a REST command URL

  See Also
    Constants Summary

Method Detail

### getRequest

    javax.servlet.http.HttpServletRequest getRequest()

  Gets the `HttpServletRequest` associated with this `RestCommand` dispatch.

  Returns
    the current request

### setRequest

    void setRequest(javax.servlet.http.HttpServletRequest request)

  Sets the current `HttpServletRequest`. This is intended for use by the REST framework.

  Parameters
    `request` - the request to set into this `RestContext`

### getResponse

    javax.servlet.http.HttpServletResponse getResponse()

  Gets the `HttpServletResponse` associated with this `RestCommand` dispatch.

  Returns
    the current response

### setResponse

    void setResponse(javax.servlet.http.HttpServletResponse response)

  Sets the current `HttpServletResponse`. This is intended for use by the REST framework.

  Parameters
    `response` - the response to set into this `RestContext`

### getContext

    javax.servlet.ServletContext getContext()

  Gets the `ServletContext` associated with the current `RestCommand` dispatch.

  Returns
    the current servlet context

### setContext

    void setContext(javax.servlet.ServletContext context)

  Sets the current `ServletContext`. This is intended for use by the REST framework.

  Parameters
    `context` - the servlet context to set into this `RestContext`

### getMethod

    String getMethod()

  Gets the HTTP method that was used to invoke the current `RestCommand`. This is one of GET, POST, PUT or DELETE

  Returns
    the current HTTP method

### getServletPath

    String getServletPath()

  Gets the servlet path associated with the current `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.

  Returns
    the servlet path for the current request

### getPath

    String getPath()

  Gets the command path portion of the request URI, which identifies a specific `RestCommand`.

  Returns
    the current command path

### setPath

    void setPath(String path)

  Sets the current command path. This is intended for use by the REST framework.

  Parameters
    `path` - the command path to set

### getParams

    Map<String,String[]> getParams()

  Gets a collection of all the the request parameters associated with the current command request.

  Returns
    a `Map` keyed on parameter name with values derived from the actual request parameters

### getSingleParamValue

    String getSingleParamValue(String key)

  Gets a the first value for the parameter identified by key.

  Parameters
    `key` - the parameter name to get a parameter value for
  Returns
    the value of the parameter, if it exists. If the parameter is multivalued, this returns the first occurence of the parameter.

### getMultiParamValue

    String[] getMultiParamValue(String key)

  Gets all values for the parameter identified by key.

  Parameters
    `key` - the parameter name to get a parameter value for
  Returns
    a collection of String values for the requested paramter. If the parameter does not exists, this is an empty array.

### getIntegerParamValue

    Integer getIntegerParamValue(String key)

  Gets the first value for the parameter identified by key as an Integer.

  Parameters
    `key` - the parameter name to get a parameter value for
  Returns
    the value of the parameter as an Integer

### setParams

    void setParams(Map<String,String[]> params)

  Sets the `Map` of parameters into this `RestContext`. This is intended for use by the REST framework.

  Parameters
    `params` - a collection of parameters keyed by parameter name

### getLocales

    ArrayList<Locale> getLocales()

  Gets the list of acceptable client locales in decreasing order, starting with the preferred locale.

  Returns
    a list of `Locales` that the requesting client prefers

### setLocales

    void setLocales(ArrayList<Locale> locales)

  Sets the preferred requesting client `Locales` into this `RestContext`. This is intended for use by the REST framework.

  Parameters
    `locales` - the preferred `Locales` from the requesting client.

### getPreferredLocale

    Locale getPreferredLocale()

  Returns the preferred client locale, based on the first element in the underlying locale list.

  Returns
    the computed preferred `Locale`

### secondPathInfo

    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();

  Returns
    Return the second path element after the servlet context

### thirdPathInfo

    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();

  Returns
    Return the third path element after the servlet context. If there is not third path element return null.

### fourthPathInfo

    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();

  Returns
    Return the fourth path element after the servlet context. If there is no fourth path element return null.

### 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();

  Returns
    Return the nth path element after the servlet context. If there is no nth path element return null.

### toString

    String toString()

  Returns a `String` representation of this `RestContext` object.

  Overrides:
    `toString` in class `Object`
  Returns
    this context as a `String`

### getFormatType

    RestResult.FormatType getFormatType()

  Gets the requested `RestResult` `FormatType` enum for use in assembling the output of the current `RestCommand`.

  Returns
    the format type the user requested or the default type

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.