public abstract class

JsonFormatWriter

extends Object
implements FormatWriter<T>
java.lang.Object
   ↳ org.odata4j.format.json.JsonFormatWriter<T>
Known Direct Subclasses

Class Overview

Write content to an output stream in JSON format.

This class is abstract because it delegates the strategy pattern of writing actual content elements to its (various) subclasses.

Each element in the array to be written can be wrapped in a function call on the JavaScript side by specifying the name of a function to call to the constructor.

Summary

Fields
private final String jsonpCallback
private ODataVersion version
Public Constructors
JsonFormatWriter(String jsonpCallback, ODataVersion version)
Creates a new JSON writer.
Public Methods
String getContentType()
Recover the MIME content type for the stream
void write(UriInfo uriInfo, Writer w, T target)
Write an object to the formatted version of the stream
Protected Methods
String getJsonpCallback()
ODataVersion getVersion()
boolean isV2OrGreater()
void maybeWriteResultsProperty(JsonWriter jw)
void writeCollection(JsonWriter jw, EdmCollectionType type, OCollection<? extends OObject> coll)
void writeComplexObject(JsonWriter jw, String fullyQualifiedTypeName, List<OProperty<?>> props)
abstract void writeContent(UriInfo uriInfo, JsonWriter jw, T target)
A strategy method to actually write content objects
void writeLinks(JsonWriter jw, OEntity oe, UriInfo uriInfo, boolean isResponse)
void writeOEntity(UriInfo uriInfo, JsonWriter jw, OEntity oe, EdmEntitySet ees, boolean isResponse)
void writeOProperties(JsonWriter jw, List<OProperty<?>> properties)
void writeProperty(JsonWriter jw, OProperty<?> prop)
void writeRequestLink(JsonWriter jw, OLink link, OEntity oe, UriInfo uriInfo)
void writeResponseLink(JsonWriter jw, OLink link, OEntity oe, UriInfo uriInfo)
void writeValue(JsonWriter jw, EdmType type, Object pvalue)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.odata4j.format.FormatWriter

Fields

private final String jsonpCallback

private ODataVersion version

Public Constructors

public JsonFormatWriter (String jsonpCallback, ODataVersion version)

Creates a new JSON writer.

Parameters
jsonpCallback A function to call on the javascript side to act on the data provided in the content.
version

Public Methods

public String getContentType ()

Recover the MIME content type for the stream

Returns
  • the MIME content type to be used for the content of this stream

public void write (UriInfo uriInfo, Writer w, T target)

Write an object to the formatted version of the stream

Parameters
uriInfo The base uri of the entity documents
w The underlying "stream" to write to
target The object to be written

Protected Methods

protected String getJsonpCallback ()

protected ODataVersion getVersion ()

protected boolean isV2OrGreater ()

protected void maybeWriteResultsProperty (JsonWriter jw)

Parameters
jw

protected void writeCollection (JsonWriter jw, EdmCollectionType type, OCollection<? extends OObject> coll)

Parameters
jw
type
coll

protected void writeComplexObject (JsonWriter jw, String fullyQualifiedTypeName, List<OProperty<?>> props)

Parameters
jw
fullyQualifiedTypeName
props

protected abstract void writeContent (UriInfo uriInfo, JsonWriter jw, T target)

A strategy method to actually write content objects

Parameters
uriInfo The base URI that indicates where in the schema we are
jw The JSON writer object
target The content value to be written

protected void writeLinks (JsonWriter jw, OEntity oe, UriInfo uriInfo, boolean isResponse)

Parameters
jw
oe
uriInfo
isResponse

protected void writeOEntity (UriInfo uriInfo, JsonWriter jw, OEntity oe, EdmEntitySet ees, boolean isResponse)

Parameters
uriInfo
jw
oe
ees
isResponse

protected void writeOProperties (JsonWriter jw, List<OProperty<?>> properties)

Parameters
jw
properties

protected void writeProperty (JsonWriter jw, OProperty<?> prop)

Parameters
jw
prop

protected void writeRequestLink (JsonWriter jw, OLink link, OEntity oe, UriInfo uriInfo)

Parameters
jw
link
oe
uriInfo

protected void writeResponseLink (JsonWriter jw, OLink link, OEntity oe, UriInfo uriInfo)

Parameters
jw
link
oe
uriInfo

protected void writeValue (JsonWriter jw, EdmType type, Object pvalue)

Parameters
jw
type
pvalue