org.nakedobjects.runtime.snapshot
Class XmlSnapshot

java.lang.Object
  extended by org.nakedobjects.runtime.snapshot.XmlSnapshot

public final class XmlSnapshot
extends java.lang.Object

Traverses object graph from specified root, so that an XML representation of the graph can be returned.

Initially designed to allow snapshots to be easily created.

Typical use:

 XmlSnapshot snapshot = new XmlSnapshot(customer); // where customer is a reference to an ANO
 Element customerAsXml = snapshot.toXml(); // returns customer's fields, titles of simple references, number of items in collections
 snapshot.include("placeOfBirth"); // navigates to ANO represented by simple reference "placeOfBirth"
 snapshot.include("orders/product"); // navigates to all Orders of Customer, and from them for their products 
 

Alternative fluent use:

 XmlSnapshot snapshot = 
     XmlSnapshot.create(customer)
                .includePath("placeOfBirth")
                .include("orders/product")
                .build();
 Element customerAsXml = snapshot.toXml();
 


Nested Class Summary
static class XmlSnapshot.Builder
           
 
Constructor Summary
XmlSnapshot(NakedObject rootObject)
          Start a snapshot at the root object, using own namespace manager.
XmlSnapshot(NakedObject rootObject, boolean addOids)
          Start a snapshot at the root object, using own namespace manager.
XmlSnapshot(NakedObject rootObject, XmlSchema schema, boolean addOids)
          Start a snapshot at the root object, using supplied namespace manager.
 
Method Summary
static XmlSnapshot.Builder create(Snapshottable snapshottable)
           
 NakedObject getObject()
           
 XmlSchema getSchema()
           
 java.lang.String getSchemaLocationFileName()
          The name of the xsi:schemaLocation in the XML document.
 org.w3c.dom.Document getXmlDocument()
           
 org.w3c.dom.Element getXmlElement()
          The root element of getXmlDocument().
 org.w3c.dom.Document getXsdDocument()
           
 org.w3c.dom.Element getXsdElement()
          The root element of getXsdDocument().
 void include(java.lang.String path)
           
 void include(java.lang.String path, java.lang.String annotation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlSnapshot

public XmlSnapshot(NakedObject rootObject)
Start a snapshot at the root object, using own namespace manager.


XmlSnapshot

public XmlSnapshot(NakedObject rootObject,
                   boolean addOids)
Start a snapshot at the root object, using own namespace manager.


XmlSnapshot

public XmlSnapshot(NakedObject rootObject,
                   XmlSchema schema,
                   boolean addOids)
Start a snapshot at the root object, using supplied namespace manager.

Method Detail

create

public static XmlSnapshot.Builder create(Snapshottable snapshottable)

getObject

public NakedObject getObject()

getSchema

public XmlSchema getSchema()

getSchemaLocationFileName

public java.lang.String getSchemaLocationFileName()
The name of the xsi:schemaLocation in the XML document. Taken from the fullyQualifiedClassName (which also is used as the basis for the targetNamespace. Populated in appendXml(NakedObject).


getXmlDocument

public org.w3c.dom.Document getXmlDocument()

getXmlElement

public org.w3c.dom.Element getXmlElement()
The root element of getXmlDocument(). Returns null until the snapshot has actually been built.


getXsdDocument

public org.w3c.dom.Document getXsdDocument()

getXsdElement

public org.w3c.dom.Element getXsdElement()
The root element of getXsdDocument(). Returns null until the snapshot has actually been built.


include

public void include(java.lang.String path)

include

public void include(java.lang.String path,
                    java.lang.String annotation)


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.