org.rimudb
Class DataObjectNode

java.lang.Object
  extended by org.rimudb.DataObjectNode
All Implemented Interfaces:
java.lang.Comparable

public class DataObjectNode
extends java.lang.Object
implements java.lang.Comparable

This class is an object representation of the structure of the database to be persisted to or loaded from XML. This is an object representation of the structure.xml file contents that control loading and saving of dataObject trees. This is created and used internally by the DBStructure object, and should not be used directly by any other class.


Field Summary
static int ACTION_INSERT
           
static int ACTION_PURGE
           
static int ACTION_REPLACE
           
 
Constructor Summary
DataObjectNode(CompoundDatabase cdb, DataObjectNode parentNode, java.lang.String name, Table table)
           
 
Method Summary
 void addDataObjectNode(DataObjectNode node)
           
 void addProperty(org.w3c.dom.Element element)
           
 void addProperty(org.w3c.dom.Element element, int keySequence)
           
 void addPropertyNode(PropertyNode node)
           
 void commit(Session session)
           
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 DataObject createDataObject()
           
 boolean equals(java.lang.Object o)
           
 void error(java.lang.String s)
           
 int getAction()
           
 DataObject[] getAllByStructure(java.util.Properties constants)
          This method returns an array of DataObject's for some or all records in the table.
 DataObject[] getAllByStructureIteratively(java.util.Properties constants, int batchSize)
          This method returns an array of DataObject's for some or all records in the table.
 DataObjectNode getChild(java.lang.String name)
           
 java.util.Collection getChildren()
           
 DataObject getCurrentDataObject()
           
 java.lang.String getName()
           
 DataObject[] getNextIterativeBatch(int batchSize)
          This method should be used on after getAllByStructureIteratively() has been called.
 java.util.Collection getProperties()
           
 PropertyNode getProperty(java.lang.String name)
           
 java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.String name)
           
 boolean getPurgedFlag()
          Getter method for purgedFlag.
 WhereList getWhereList(java.util.Properties constants)
          Returns the WhereList that represents any "constant" or "parent" Property tags in the KeyList element in the "structure.xml" document.
 void purge()
          Purge all the records in the table before inserting any new records.
 DataObject[] selectAll(WhereList wherelist)
          Return all the data objects that match the WhereList.
 void setAction(int newAction)
           
 void setCurrentDataObject(DataObject dobj)
           
 void setParentProperties()
          Loads any properties configured as from the parent object with the data from the parent object.
 void setPurgedFlag(boolean purgedFlag)
          Setter method for purgedFlag.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_INSERT

public static final int ACTION_INSERT
See Also:
Constant Field Values

ACTION_REPLACE

public static final int ACTION_REPLACE
See Also:
Constant Field Values

ACTION_PURGE

public static final int ACTION_PURGE
See Also:
Constant Field Values
Constructor Detail

DataObjectNode

public DataObjectNode(CompoundDatabase cdb,
                      DataObjectNode parentNode,
                      java.lang.String name,
                      Table table)
Method Detail

addDataObjectNode

public void addDataObjectNode(DataObjectNode node)

addProperty

public void addProperty(org.w3c.dom.Element element)

addProperty

public void addProperty(org.w3c.dom.Element element,
                        int keySequence)

addPropertyNode

public void addPropertyNode(PropertyNode node)

commit

public void commit(Session session)
            throws RimuDBException
Throws:
RimuDBException

compareTo

public int compareTo(java.lang.Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.

Finally, the implementer must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.

It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals."

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this Object.

createDataObject

public DataObject createDataObject()
                            throws java.lang.reflect.InvocationTargetException,
                                   java.lang.InstantiationException,
                                   java.lang.IllegalAccessException
Throws:
java.lang.reflect.InvocationTargetException
java.lang.InstantiationException
java.lang.IllegalAccessException

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getAction

public int getAction()

selectAll

public DataObject[] selectAll(WhereList wherelist)
                       throws RimuDBException
Return all the data objects that match the WhereList.

Parameters:
wherelist - WhereList
Returns:
DataObject[]
Throws:
RimuDBException

getWhereList

public WhereList getWhereList(java.util.Properties constants)
                       throws RimuDBException
Returns the WhereList that represents any "constant" or "parent" Property tags in the KeyList element in the "structure.xml" document. If there are no "constant" or "parent" properties, it returns an empty WhereList. Any "constant" values need to be passed as an argument.

Throws:
RimuDBException

getAllByStructure

public DataObject[] getAllByStructure(java.util.Properties constants)
                               throws RimuDBException
This method returns an array of DataObject's for some or all records in the table.

Returns:
com.amo.data.access.KeyList[]
Throws:
RimuDBException

getAllByStructureIteratively

public DataObject[] getAllByStructureIteratively(java.util.Properties constants,
                                                 int batchSize)
                                          throws RimuDBException
This method returns an array of DataObject's for some or all records in the table.

This method returns the DataObjects in batches. The batchSize is passed in as an argument. If the batchSize is greater than or equal to the total number of records, it will return all the records available. If the batchSize is less than the total number of records, use getNextKeysByStructureIteratively() to get the rest of the records.

Throws:
RimuDBException

getNextIterativeBatch

public DataObject[] getNextIterativeBatch(int batchSize)
                                   throws RimuDBException
This method should be used on after getAllByStructureIteratively() has been called. Call this method to return in batches any DataObjects that haven't already been retrieved. The batchSize is passed in as an argument. If the batchSize is greater than or equal to the total number of records, it will return all the records available. If the batchSize is less than the total number of records, use getAllByStructureIteratively() getNextIterativeBatch() to get the rest of the records. If there are no more records to retrieve, it returns an empty array.

Throws:
RimuDBException

getChild

public DataObjectNode getChild(java.lang.String name)

getChildren

public java.util.Collection getChildren()

getCurrentDataObject

public DataObject getCurrentDataObject()

getName

public java.lang.String getName()

getProperty

public PropertyNode getProperty(java.lang.String name)

getPropertyDescriptor

public java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.String name)

getProperties

public java.util.Collection getProperties()

error

public void error(java.lang.String s)

setAction

public void setAction(int newAction)

setParentProperties

public void setParentProperties()
Loads any properties configured as from the parent object with the data from the parent object.


purge

public void purge()
Purge all the records in the table before inserting any new records. Note: This calls a purge() method in the DO, so if you haven't implemented it yet, you must do so. See CSIItemDO for an example.


getPurgedFlag

public boolean getPurgedFlag()
Getter method for purgedFlag.

If we are persisting to the database, and the action tells us to purge the table before inserting the records, the table should only be purged once. Use this method to check this flag to see if we have already purged the table.

Returns:
true if we've already purged the table, false otherwise.

setPurgedFlag

public void setPurgedFlag(boolean purgedFlag)
Setter method for purgedFlag.

If we are persisting to the database, and the action tells us to purge the table before inserting the records, the table should only be purged once. Use this method to set this flag to true after we have purged the table.

Parameters:
purgedFlag -

setCurrentDataObject

public void setCurrentDataObject(DataObject dobj)
Parameters:
dobj -


Copyright © 2008-2011 Simon Ritchie. All Rights Reserved.