org.odata4j.format.json
Class JsonFormatWriter<T>

java.lang.Object
  extended by org.odata4j.format.json.JsonFormatWriter<T>
Type Parameters:
T - the type of the content elements to be written to the stream.
All Implemented Interfaces:
FormatWriter<T>
Direct Known Subclasses:
JsonEntryFormatWriter, JsonFeedFormatWriter, JsonPropertyFormatWriter, JsonRequestEntryFormatWriter, JsonServiceDocumentFormatWriter

public abstract class JsonFormatWriter<T>
extends Object
implements FormatWriter<T>

Write content to an HTTP 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.


Constructor Summary
JsonFormatWriter(String jsonpCallback)
          Create a new JSON writer.
 
Method Summary
 String getContentType()
          Recover the MIME content type for the stream
protected  String getJsonpCallback()
           
 void write(ExtendedUriInfo uriInfo, Writer w, T target)
          Write an object to the formatted version of the stream
protected abstract  void writeContent(ExtendedUriInfo uriInfo, JsonWriter jw, T target)
          A strategy method to actually write content objects
protected  void writeOEntity(ExtendedUriInfo uriInfo, JsonWriter jw, OEntity oe, EdmEntitySet ees, boolean isResponse)
           
protected  void writeOProperties(JsonWriter jw, List<OProperty<?>> properties)
           
protected  void writeProperty(JsonWriter jw, OProperty<?> prop)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonFormatWriter

public JsonFormatWriter(String jsonpCallback)
Create a new JSON writer.

Parameters:
jsonpCallback - a function to call on the javascript side to act on the data provided in the content.
Method Detail

getContentType

public String getContentType()
Description copied from interface: FormatWriter
Recover the MIME content type for the stream

Specified by:
getContentType in interface FormatWriter<T>
Returns:
the MIME content type to be used for the content of this stream

getJsonpCallback

protected String getJsonpCallback()

write

public void write(ExtendedUriInfo uriInfo,
                  Writer w,
                  T target)
Description copied from interface: FormatWriter
Write an object to the formatted version of the stream

Specified by:
write in interface FormatWriter<T>
Parameters:
uriInfo - the base uri of the entity documents
w - the underlying "stream" to write to
target - the object to be written

writeContent

protected abstract void writeContent(ExtendedUriInfo 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

writeOEntity

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

writeOProperties

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

writeProperty

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


http://odata4j.org