org.apache.openjpa.persistence.jest
Class XMLFormatter

java.lang.Object
  extended by org.apache.openjpa.persistence.jest.XMLFormatter
All Implemented Interfaces:
ObjectFormatter<Document>
Direct Known Subclasses:
ExceptionFormatter, PropertiesFormatter

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
(package private)  Document decorate(Document doc, String title, String desc, String uri)
           
 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.
(package private)  String ior(OpenJPAStateManager sm)
           
 Element newDocument(String rootTag)
          Create a new document with the given tag as the root element.
(package private)  String typeOf(Class<?> cls)
           
(package private)  String typeOf(ClassMetaData meta)
           
(package private)  String typeOf(FieldMetaData fmd)
           
(package private)  String typeOf(OpenJPAStateManager sm)
           
(package private)  String typeOf(ValueMetaData vm)
           
(package private)  void validate(Document doc)
           
 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

decorate

Document decorate(Document doc,
                  String title,
                  String desc,
                  String uri)

write

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

write

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

validate

void validate(Document doc)
        throws Exception
Throws:
Exception

ior

String ior(OpenJPAStateManager sm)

typeOf

String typeOf(OpenJPAStateManager sm)

typeOf

String typeOf(Class<?> cls)

typeOf

String typeOf(ClassMetaData meta)

typeOf

String typeOf(ValueMetaData vm)

typeOf

String typeOf(FieldMetaData fmd)


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.