Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2008 BEA Systems, Inc. All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.wlp.rest.results
Class GenericRestResult

    java.lang.Object
      com.bea.wlp.rest.results.GenericRestResult

All Implemented Interfaces
  RestResult

Direct Known Subclasses:
  ErrorResult, ForwardResult

    public class GenericRestResult

extends Object
implements RestResult

A basic implementation of a `RestResult` that can be used to easily associate a JavaBean result object with a result that can be returned from a `RestCommand`. In most cases, custom implementations of `RestResult` are not necessary, and this class can be used as the result of a command.

This implementation handles formating for both XML and JSON, including providing an appropriate content type string for each. Overall command status of "ok" is always returned by this class, as it is generally used either empty by itself when a command is successful, or after a successful invokation of a `RestCommand` where a JavaBean is supplied as the result.

Nested Class Summary

Nested classes/interfaces inherited from interface com.bea.wlp.rest.results.RestResult
`RestResult.FormatType`

Field Summary
`static String` | `JSON_CONTENT_TYPE` content type string form the JSON content type
`static String` | `XML_CONTENT_TYPE` content type string for the XML content type

Constructor Summary
`GenericRestResult()`

Method Summary
`String` | `getContentType(RestResult.FormatType formatType)` Gets the content type of your response, which can be used to set the content type of the response from the `RestServlet`.
`String` | `getMessage()` For `GenericRestResult`, there is no message to return.
`String` | `getResponse(RestResult.FormatType formatType)` Return the response in the specified format.
`Object` | `getResponseBean()` Gets this `RestResult` as a JavaBean `Object`.
`int` | `getStatus()` Gets the overall status of the `RestResult`.
`boolean` | `isError()` Returns whether or not this `RestResult` is an error type result.
`void` | `setResponseBean(Object responseBean)` Sets the JavaBean `Object` to be used as the result data for this `RestResult`.
`protected String` | `toJSON()` Formats this result using the JSON formatter type.
`protected String` | `toXML()` Formats this result using the XML formatter type.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### XML_CONTENT_TYPE

    public static final String XML_CONTENT_TYPE

  content type string for the XML content type

  See Also
    Constants Summary

### JSON_CONTENT_TYPE

    public static final String JSON_CONTENT_TYPE

  content type string form the JSON content type

  See Also
    Constants Summary

Constructor Detail

### GenericRestResult

    public GenericRestResult()

Method Detail

### getResponse

    public String getResponse(RestResult.FormatType formatType)

  Return the response in the specified format.

  Specified by:
    `getResponse` in interface `RestResult`
  Parameters
    `formatType` - the desired `FormatType` to encode the result as
  Returns
    the formatted version of this `RestResult`

### getResponseBean

    public Object getResponseBean()

  Gets this `RestResult` as a JavaBean `Object`.

  Specified by:
    `getResponseBean` in interface `RestResult`
  Returns
    the JavaBean object that composes this result

### setResponseBean

    public void setResponseBean(Object responseBean)

  Sets the JavaBean `Object` to be used as the result data for this `RestResult`.

  Parameters
    `responseBean` - the JavaBean result

### getContentType

    public String getContentType(RestResult.FormatType formatType)

  Gets the content type of your response, which can be used to set the content type of the response from the `RestServlet`. This implementation can return content type strings for either XML or JSON.

  Specified by:
    `getContentType` in interface `RestResult`
  Parameters
    `formatType` - the desired `FormatType` for the response.
  Returns
    the content type `String`

### getStatus

    public int getStatus()

  Gets the overall status of the `RestResult`.

  Specified by:
    `getStatus` in interface `RestResult`
  Returns
    the status code for the `RestResult`.

### getMessage

    public String getMessage()

  For `GenericRestResult`, there is no message to return.

  Specified by:
    `getMessage` in interface `RestResult`
  Returns
    null

### isError

    public boolean isError()

  Returns whether or not this `RestResult` is an error type result.

  Specified by:
    `isError` in interface `RestResult`
  Returns
    false for the basic `GenericRestResult`

### toXML

    protected String toXML()

  Formats this result using the XML formatter type.

  Returns
    this `RestResult` formatted as XML.

### toJSON

    protected String toJSON()

  Formats this result using the JSON formatter type.

  Returns
    this `RestResult` formatted as JSON.

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

Copyright © 2008 BEA Systems, Inc. All Rights Reserved