Class JSONObjectFormatter
java.lang.Object
org.apache.openjpa.persistence.jest.JSONObjectFormatter
- All Implemented Interfaces:
ObjectFormatter<JSON>
Marshals a root instance and its persistent closure as JSON object.
The closure is resolved against the persistence context that contains the root instance.
The JSON format introduces a $id and $ref to address reference that pure JSON does not.
- Author:
- Pinaki Poddar
-
Field Summary
Fields inherited from interface org.apache.openjpa.persistence.jest.ObjectFormatter
dateFormat
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionencode
(jakarta.persistence.metamodel.Metamodel model) Encode the given domain model in to a object.void
encode
(Object obj, JPAServletContext ctx) encode
(Collection<OpenJPAStateManager> sms, jakarta.persistence.metamodel.Metamodel model) Encode thepersistent closure
of the given collection of managed instances as a resource e.g a XML or HTML document or an interactive document with JavaScript or a JSON array.Gets the mime type produced by this formatter.writeOut
(jakarta.persistence.metamodel.Metamodel model, String title, String desc, String uri, OutputStream out) Encodes the given domain model, then write it into the given output stream.writeOut
(Collection<OpenJPAStateManager> sms, jakarta.persistence.metamodel.Metamodel model, String title, String desc, String uri, OutputStream out) Encodes thepersistent closure
of the given collection of objects, then write it into the given output stream.
-
Constructor Details
-
JSONObjectFormatter
public JSONObjectFormatter()
-
-
Method Details
-
getMimeType
Description copied from interface:ObjectFormatter
Gets the mime type produced by this formatter.- Specified by:
getMimeType
in interfaceObjectFormatter<JSON>
-
encode
-
writeOut
public JSON writeOut(Collection<OpenJPAStateManager> sms, jakarta.persistence.metamodel.Metamodel model, String title, String desc, String uri, OutputStream out) throws IOException Description copied from interface:ObjectFormatter
Encodes thepersistent closure
of the given collection of objects, then write it into the given output stream.- Specified by:
writeOut
in interfaceObjectFormatter<JSON>
- Parameters:
sms
- the collection of objects to be formatted.model
- a meta-model of managed types, provided for easier introspection if necessarytitle
- TODOdesc
- TODOuri
- TODO- Throws:
IOException
-
encode
public JSON encode(Collection<OpenJPAStateManager> sms, jakarta.persistence.metamodel.Metamodel model) Description copied from interface:ObjectFormatter
Encode thepersistent closure
of the given collection of managed instances as a resource e.g a XML or HTML document or an interactive document with JavaScript or a JSON array. Exact nature of the output type is the generic parameter of this interface.- Specified by:
encode
in interfaceObjectFormatter<JSON>
- Parameters:
sms
- a collection of managed instancesmodel
- domain model- Returns:
- an encoded object e.g. a XML or HTML Document or a JSON object.
-
encode
Description copied from interface:ObjectFormatter
Encode the given domain model in to a object.- Specified by:
encode
in interfaceObjectFormatter<JSON>
- Parameters:
model
- a meta-model of managed types- Returns:
- an encoded object e.g. a XML or HTML Document or a JSON object.
-
writeOut
public JSON writeOut(jakarta.persistence.metamodel.Metamodel model, String title, String desc, String uri, OutputStream out) throws IOException Description copied from interface:ObjectFormatter
Encodes the given domain model, then write it into the given output stream.- Specified by:
writeOut
in interfaceObjectFormatter<JSON>
- Parameters:
model
- a meta-model of managed types- Throws:
IOException
-