org.xlattice.corexml.bind
Class Ordering

java.lang.Object
  extended by org.xlattice.corexml.bind.Ordering
Direct Known Subclasses:
AttrBag, Bag, Seq

public abstract class Ordering
extends java.lang.Object

The set or sequence of Joins which bind XML element or attribute values with fields in an object which is an instance of a bound class. The Ordering may be sequential, in which case joined elements or attributes are matched in turn, or a set, in which case attributes or elements may appear in any order in the XML. Joins added to the Ordering may be either Bindings or SubMappings. Bindings either associate an attribute with a field in an object or associate the presence or value of a subelement. SubMappings map a child object to a parent. A Collector is used to map any number of child objects to a parent. XXX Set Orderings (Bags) are not supported in the current XXX implementation.

Author:
Jim Dixon

Constructor Summary
protected Ordering()
          No-arg constructor.
 
Method Summary
protected abstract  void add(Join j)
          Add a Join to the Ordering.
protected abstract  void apply(Element elm, java.lang.Object o)
          Apply the ordering to an XML element, using values of XML attributes and other Nodes to set fields in the object, create child objects, and so forth, recursively.
protected abstract  void generate(Element elm, java.lang.Object o)
          Use the Ordering to generate XML from a subtree of Java objects.
protected  java.lang.Class getClazz()
           
protected abstract  void join(java.lang.Class clazz)
          Set the joined class for all descendents.
protected  void setClazz(java.lang.Class clazz)
          Set the Java class associated with the Ordering.
protected abstract  int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ordering

protected Ordering()
No-arg constructor.

Method Detail

getClazz

protected java.lang.Class getClazz()
Returns:
the Java Class associated with the Ordering

setClazz

protected void setClazz(java.lang.Class clazz)
Set the Java class associated with the Ordering. Must be called by subclasses. XXX Must NOT be called by other classes!


add

protected abstract void add(Join j)
                     throws CoreXmlException
Add a Join to the Ordering.

Parameters:
j - Join to be added
Throws:
CoreXmlException

join

protected abstract void join(java.lang.Class clazz)
                      throws CoreXmlException
Set the joined class for all descendents. Subclasses must call Ordering.setClazz() and iterate over all descendents, calling their join(clazz) methods.

Parameters:
clazz - Class that descendents are to be joined to.
Throws:
CoreXmlException

size

protected abstract int size()
Returns:
a count of Joins in the Ordering

apply

protected abstract void apply(Element elm,
                              java.lang.Object o)
                       throws CoreXmlException
Apply the ordering to an XML element, using values of XML attributes and other Nodes to set fields in the object, create child objects, and so forth, recursively.

Parameters:
elm - Element from which values will be drawn
o - object to which values will be assigned
Throws:
CoreXmlException

generate

protected abstract void generate(Element elm,
                                 java.lang.Object o)
                          throws CoreXmlException
Use the Ordering to generate XML from a subtree of Java objects. The Joins in the Ordering are applied in turn, but in no predictable order.

Parameters:
elm - XML Element to which child Nodes will be attached
o - Java object from which values will be drawn
Throws:
CoreXmlException