Class XMLFormatter

java.lang.Object
org.apache.openjpa.persistence.jest.XMLFormatter
All Implemented Interfaces:
ObjectFormatter<Document>

public class XMLFormatter extends Object implements ObjectFormatter<Document>
Marshals a root instance and its persistent closure as an XML element. The closure is resolved against the persistence context that contains the root instance. The XML document adheres to the jest-instance.xsd schema.
Author:
Pinaki Poddar
  • Field Details

    • _xsd

      public static final Schema _xsd
    • _loc

      protected static Localizer _loc
  • Constructor Details

    • XMLFormatter

      public XMLFormatter()
  • Method Details

    • getMimeType

      public String getMimeType()
      Description copied from interface: ObjectFormatter
      Gets the mime type produced by this formatter.
      Specified by:
      getMimeType in interface ObjectFormatter<Document>
    • encode

      public Document encode(Collection<OpenJPAStateManager> sms, jakarta.persistence.metamodel.Metamodel model)
      Encodes the closure of given collection of managed instance into a new XML document according to JEST Instance XML Schema.
      Specified by:
      encode in interface ObjectFormatter<Document>
      Parameters:
      sm - a collection of managed instances.
      parent - the parent node to which the new node be attached.
      Returns:
      an encoded object e.g. a XML or HTML Document or a JSON object.
    • encode

      public Document encode(jakarta.persistence.metamodel.Metamodel model)
      Encodes the given meta-model into a new XML document according to JEST Domain XML Schema.
      Specified by:
      encode in interface ObjectFormatter<Document>
      Parameters:
      model - a persistent domain model. Must not be null.
      Returns:
      an encoded object e.g. a XML or HTML Document or a JSON object.
    • newDocument

      public Element newDocument(String rootTag)
      Create a new document with the given tag as the root element.
      Parameters:
      rootTag - the tag of the root element
      Returns:
      the document element of a new document
    • writeOut

      public Document writeOut(Collection<OpenJPAStateManager> objs, jakarta.persistence.metamodel.Metamodel model, String title, String desc, String uri, OutputStream out) throws 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<Document>
      Parameters:
      objs - 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:
      IOException
    • writeOut

      public Document 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 interface ObjectFormatter<Document>
      Parameters:
      model - a meta-model of managed types
      Throws:
      IOException
    • write

      public void write(Document doc, OutputStream out) throws IOException
      Throws:
      IOException
    • write

      public void write(Document doc, Writer writer) throws IOException
      Throws:
      IOException