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

## com.sun.jersey.api.json
Class JSONWithPadding

    java.lang.Object
      com.sun.jersey.api.json.JSONWithPadding

All Implemented Interfaces:
  org.codehaus.jackson.map.JsonSerializable, org.codehaus.jackson.map.JsonSerializableWithType

    public class JSONWithPadding

extends java.lang.Object
implements org.codehaus.jackson.map.JsonSerializableWithType

An entity supporting JSON with Padding (JSONP).

If an instance is returned by a resource method and the most acceptable media type is one of application/javascript, application/x-javascript, text/ecmascript, application/ecmascript or text/jscript then the object that is contained by the instance is serialized as JSON (if supported, using the application/json media type) and the result is wrapped around a JavaScript callback function, whose name by default is "callback". Otherwise, the object is serialized directly according to the most acceptable media type. This means that an instance can be used to produce the media types application/json, application/xml in addition to application/x-javascript.

Author:
  Jakub.Podlesak@Sun.COM

Field Summary
`static java.lang.String` | `DEFAULT_CALLBACK_NAME`

Constructor Summary
`JSONWithPadding(java.lang.Object jsonSource)` Pad JSON using the default function name "callback".
`JSONWithPadding(java.lang.Object jsonSource, java.lang.String callbackName)` Pad JSON using a declared callback function name.

Method Summary
`java.lang.String` | `getCallbackName()` Get the callback function name.
`java.lang.Object` | `getJsonSource()` Get the JSON source.
`void` | `serialize(org.codehaus.jackson.JsonGenerator jgen, org.codehaus.jackson.map.SerializerProvider provider)`
`void` | `serializeWithType(org.codehaus.jackson.JsonGenerator jgen, org.codehaus.jackson.map.SerializerProvider provider, org.codehaus.jackson.map.TypeSerializer typeSer)`

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

Field Detail

### DEFAULT_CALLBACK_NAME

    public static final java.lang.String DEFAULT_CALLBACK_NAME

See Also:
  Constant Field Values

Constructor Detail

### JSONWithPadding

    public JSONWithPadding(java.lang.Object jsonSource)

  Pad JSON using the default function name "callback".

  Parameters:
    `jsonSource` - the JSON to pad.

### JSONWithPadding

    public JSONWithPadding(java.lang.Object jsonSource,
                           java.lang.String callbackName)

  Pad JSON using a declared callback function name.

  Parameters:
    `jsonSource` - the JSON to pad.
    `callbackName` - the callback function name.

Method Detail

### getCallbackName

    public java.lang.String getCallbackName()

  Get the callback function name.

  Returns:
    the callback function name.

### getJsonSource

    public java.lang.Object getJsonSource()

  Get the JSON source.

  Returns:
    the JSON source.

### serialize

    public void serialize(org.codehaus.jackson.JsonGenerator jgen,
                          org.codehaus.jackson.map.SerializerProvider provider)
                   throws java.io.IOException,
                          org.codehaus.jackson.JsonProcessingException

  Specified by:
    `serialize` in interface `org.codehaus.jackson.map.JsonSerializable`
  Throws:
    `java.io.IOException`
    `org.codehaus.jackson.JsonProcessingException`

### serializeWithType

    public void serializeWithType(org.codehaus.jackson.JsonGenerator jgen,
                                  org.codehaus.jackson.map.SerializerProvider provider,
                                  org.codehaus.jackson.map.TypeSerializer typeSer)
                           throws java.io.IOException,
                                  org.codehaus.jackson.JsonProcessingException

  Specified by:
    `serializeWithType` in interface `org.codehaus.jackson.map.JsonSerializableWithType`
  Throws:
    `java.io.IOException`
    `org.codehaus.jackson.JsonProcessingException`

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

Copyright © 2013 Oracle Corporation. All Rights Reserved.