Class JSONObjectFormatter

  • All Implemented Interfaces:
    ObjectFormatter<JSON>

    public class JSONObjectFormatter
    extends java.lang.Object
    implements 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      JSON encode​(jakarta.persistence.metamodel.Metamodel model)
      Encode the given domain model in to a object.
      void encode​(java.lang.Object obj, JPAServletContext ctx)  
      JSON encode​(java.util.Collection<OpenJPAStateManager> sms, jakarta.persistence.metamodel.Metamodel model)
      Encode the persistent 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.
      java.lang.String getMimeType()
      Gets the mime type produced by this formatter.
      JSON writeOut​(jakarta.persistence.metamodel.Metamodel model, java.lang.String title, java.lang.String desc, java.lang.String uri, java.io.OutputStream out)
      Encodes the given domain model, then write it into the given output stream.
      JSON writeOut​(java.util.Collection<OpenJPAStateManager> sms, jakarta.persistence.metamodel.Metamodel model, java.lang.String title, java.lang.String desc, java.lang.String uri, java.io.OutputStream out)
      Encodes the persistent closure of the given collection of objects, then write it into the given output stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JSONObjectFormatter

        public JSONObjectFormatter()
    • Method Detail

      • writeOut

        public JSON writeOut​(java.util.Collection<OpenJPAStateManager> sms,
                             jakarta.persistence.metamodel.Metamodel model,
                             java.lang.String title,
                             java.lang.String desc,
                             java.lang.String uri,
                             java.io.OutputStream out)
                      throws java.io.IOException
        Description copied from interface: ObjectFormatter
        Encodes the persistent closure of the given collection of objects, then write it into the given output stream.
        Specified by:
        writeOut in interface ObjectFormatter<JSON>
        Parameters:
        sms - the collection of objects to be formatted.
        model - a meta-model of managed types, provided for easier introspection if necessary
        title - TODO
        desc - TODO
        uri - TODO
        Throws:
        java.io.IOException
      • encode

        public JSON encode​(java.util.Collection<OpenJPAStateManager> sms,
                           jakarta.persistence.metamodel.Metamodel model)
        Description copied from interface: ObjectFormatter
        Encode the persistent 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 interface ObjectFormatter<JSON>
        Parameters:
        sms - a collection of managed instances
        model - domain model
        Returns:
        an encoded object e.g. a XML or HTML Document or a JSON object.
      • encode

        public JSON encode​(jakarta.persistence.metamodel.Metamodel model)
        Description copied from interface: ObjectFormatter
        Encode the given domain model in to a object.
        Specified by:
        encode in interface ObjectFormatter<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,
                             java.lang.String title,
                             java.lang.String desc,
                             java.lang.String uri,
                             java.io.OutputStream out)
                      throws java.io.IOException
        Description copied from interface: ObjectFormatter
        Encodes the given domain model, then write it into the given output stream.
        Specified by:
        writeOut in interface ObjectFormatter<JSON>
        Parameters:
        model - a meta-model of managed types
        Throws:
        java.io.IOException