Class XMLFormatter
- java.lang.Object
-
- org.apache.openjpa.persistence.jest.XMLFormatter
-
- All Implemented Interfaces:
ObjectFormatter<org.w3c.dom.Document>
public class XMLFormatter extends java.lang.Object implements ObjectFormatter<org.w3c.dom.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 thejest-instance.xsd
schema.- Author:
- Pinaki Poddar
-
-
Field Summary
Fields Modifier and Type Field Description protected static Localizer
_loc
static javax.xml.validation.Schema
_xsd
-
Fields inherited from interface org.apache.openjpa.persistence.jest.ObjectFormatter
dateFormat
-
-
Constructor Summary
Constructors Constructor Description XMLFormatter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.w3c.dom.Document
encode(jakarta.persistence.metamodel.Metamodel model)
Encodes the given meta-model into a new XML document according to JEST Domain XML Schema.org.w3c.dom.Document
encode(java.util.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.java.lang.String
getMimeType()
Gets the mime type produced by this formatter.org.w3c.dom.Element
newDocument(java.lang.String rootTag)
Create a new document with the given tag as the root element.void
write(org.w3c.dom.Document doc, java.io.OutputStream out)
void
write(org.w3c.dom.Document doc, java.io.Writer writer)
org.w3c.dom.Document
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.org.w3c.dom.Document
writeOut(java.util.Collection<OpenJPAStateManager> objs, jakarta.persistence.metamodel.Metamodel model, java.lang.String title, java.lang.String desc, java.lang.String uri, java.io.OutputStream out)
Encodes thepersistent closure
of the given collection of objects, then write it into the given output stream.
-
-
-
Field Detail
-
_xsd
public static final javax.xml.validation.Schema _xsd
-
_loc
protected static Localizer _loc
-
-
Method Detail
-
getMimeType
public java.lang.String getMimeType()
Description copied from interface:ObjectFormatter
Gets the mime type produced by this formatter.- Specified by:
getMimeType
in interfaceObjectFormatter<org.w3c.dom.Document>
-
encode
public org.w3c.dom.Document encode(java.util.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 interfaceObjectFormatter<org.w3c.dom.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 org.w3c.dom.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 interfaceObjectFormatter<org.w3c.dom.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 org.w3c.dom.Element newDocument(java.lang.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 org.w3c.dom.Document writeOut(java.util.Collection<OpenJPAStateManager> objs, 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 thepersistent closure
of the given collection of objects, then write it into the given output stream.- Specified by:
writeOut
in interfaceObjectFormatter<org.w3c.dom.Document>
- Parameters:
objs
- the collection of objects to be formatted.model
- a meta-model of managed types, provided for easier introspection if necessarytitle
- TODOdesc
- TODOuri
- TODO- Throws:
java.io.IOException
-
writeOut
public org.w3c.dom.Document 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 interfaceObjectFormatter<org.w3c.dom.Document>
- Parameters:
model
- a meta-model of managed types- Throws:
java.io.IOException
-
write
public void write(org.w3c.dom.Document doc, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
write
public void write(org.w3c.dom.Document doc, java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
-