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.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
`protected String` | `contentType`
`protected static Debug` | `debug`
`protected static HashMap<RestResult.FormatType,Formatter>` | `formatters`
`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` | `getCharacterEncoding()` Get character encoding
`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`.
`static HashMap<RestResult.FormatType,Formatter>` | `getFormatters()`
`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` | `setCharacterEncoding(String characterEncoding)`
`static void` | `setFormatters(HashMap<RestResult.FormatType,Formatter> formatters)`
`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

### debug

    protected static final Debug debug

### contentType

    protected String contentType

### formatters

    protected static HashMap<RestResult.FormatType,Formatter> formatters

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`

### getCharacterEncoding

    public String getCharacterEncoding()

  Description copied from interface: `RestResult`
  Get character encoding

  Specified by:
    `getCharacterEncoding` in interface `RestResult`

### setCharacterEncoding

    public void setCharacterEncoding(String characterEncoding)

### getFormatters

    public static HashMap<RestResult.FormatType,Formatter> getFormatters()

### setFormatters

    public static void setFormatters(HashMap<RestResult.FormatType,Formatter> formatters)

### 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 © 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.