org.apache.openjpa.persistence.jest
Class XMLFormatter

java.lang.Object
  extended by 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 Summary
protected static Localizer _loc
           
static Schema _xsd
           
 
Fields inherited from interface org.apache.openjpa.persistence.jest.ObjectFormatter
dateFormat
 
Constructor Summary
XMLFormatter()
           
 
Method Summary
 Document encode(Collection<OpenJPAStateManager> sms, Metamodel model)
          Encodes the closure of given collection of managed instance into a new XML document according to JEST Instance XML Schema.
 Document encode(Metamodel model)
          Encodes the given meta-model into a new XML document according to JEST Domain XML Schema.
 String getMimeType()
          Gets the mime type produced by this formatter.
 Element newDocument(String rootTag)
          Create a new document with the given tag as the root element.
 void write(Document doc, OutputStream out)
           
 void write(Document doc, Writer writer)
           
 Document writeOut(Collection<OpenJPAStateManager> objs, Metamodel model, String title, String desc, String uri, OutputStream out)
          Encodes the persistent closure of the given collection of objects, then write it into the given output stream.
 Document writeOut(Metamodel model, String title, String desc, String uri, OutputStream out)
          Encodes the given domain model, 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
 

Field Detail

_xsd

public static final Schema _xsd

_loc

protected static Localizer _loc
Constructor Detail

XMLFormatter

public XMLFormatter()
Method Detail

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,
                       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(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,
                         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(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


Copyright © 2006–2013 Apache Software Foundation. All rights reserved.