org.opengts.dbtools
Class DBFactoryTree

java.lang.Object
  extended by org.opengts.dbtools.DBFactoryTree

public class DBFactoryTree
extends java.lang.Object

DBFactoryTree provides an SQL table dependency tree. Instances of DBFactoryTree are nodes in this tree.


Method Summary
 void addChild(DBFactoryTree dbFactNode)
          Adds the specified node as a child of this node
 DBFactoryTree[] getChildren()
          Gets an array of children for this node
 DBFactory<? extends DBRecord> getDBFactory()
          Gets the defined DBFactory for this node
static DBFactoryTree[] getDBFactoryTree(DBFactory<? extends DBRecord> initialFactory)
          Returns an array of root DBFactoryTree nodes based on the specified top-level DBFactory.
static DBFactoryTree[] getDBFactoryTree(DBFactory<? extends DBRecord>[] initialFactories)
          Returns an array of root DBFactoryTree nodes based on the specified top-level DBFactory.
 DBRecord getDBRecord()
          Gets the DBRecord for this node
 DBField getField(java.lang.String name)
          Gets the DBField for the specified field name
 DBField[] getFields()
          Gets the fields for the DBFactory of this node
 DBField[] getKeyFields()
          Gets the primary key fields for the DBFactory of this node
 java.util.Map<DBField,java.lang.Object> getKeyMap()
          Returns an OrderedMap of defined primary keys
 java.lang.String[] getKeyNames()
          Returns the primary key field names for the DBFactory of this node
 int getLevel()
          Gets the tree level
 java.lang.String getName()
          Gets the table name for the DBFactory (if defined)
 DBFactoryTree getParentNode()
          Gets the parent DBFactoryTree node
 java.lang.String getUntranslatedTableName()
          Gets the table name for the defined DBFactory
 boolean hasChildren()
          Returns true if this node has children
 boolean hasDBFactory()
          Returns true if this node has a defined DBFactory
 boolean hasDBRecord()
          Returns true if a DBRecord is defined for this node
 boolean hasParentDBRecord()
          Returns true if the parent of this node has a defined DBRecord
 boolean isEditable()
          Returns true if the DBFactory table is editable
 boolean setDBRecord(DBRecord<?> record)
          Sets the DBRecord for this node
 void setParentNode(DBFactoryTree parent)
          Sets the parent DBFactoryTree node
 java.lang.String toString()
          Gets the String representation of this class (typically the DBFactory table name)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getLevel

public int getLevel()
Gets the tree level

Returns:
The tree level

setParentNode

public void setParentNode(DBFactoryTree parent)
Sets the parent DBFactoryTree node

Parameters:
parent - The parent node

getParentNode

public DBFactoryTree getParentNode()
Gets the parent DBFactoryTree node

Returns:
The parent DBFactory node

hasParentDBRecord

public boolean hasParentDBRecord()
Returns true if the parent of this node has a defined DBRecord

Returns:
True if the parent node has a defined DBRecord

hasDBFactory

public boolean hasDBFactory()
Returns true if this node has a defined DBFactory

Returns:
True if this node has a defined DBFactory

getDBFactory

public DBFactory<? extends DBRecord> getDBFactory()
Gets the defined DBFactory for this node

Returns:
The DBFactory for this node

isEditable

public boolean isEditable()
Returns true if the DBFactory table is editable

Returns:
True if the DBFactory table is editable

getFields

public DBField[] getFields()
Gets the fields for the DBFactory of this node

Returns:
The DBFields for this node

getKeyFields

public DBField[] getKeyFields()
Gets the primary key fields for the DBFactory of this node

Returns:
The primary key fields for this node

getKeyNames

public java.lang.String[] getKeyNames()
Returns the primary key field names for the DBFactory of this node

Returns:
The primary key field names for this node

getField

public DBField getField(java.lang.String name)
Gets the DBField for the specified field name

Parameters:
name - The name of the field to retrieve
Returns:
The DBField for the specified name

hasDBRecord

public boolean hasDBRecord()
Returns true if a DBRecord is defined for this node

Returns:
True is a DBRecord is defined for this node

getDBRecord

public DBRecord getDBRecord()
Gets the DBRecord for this node

Returns:
The DBRecord for this node

setDBRecord

public boolean setDBRecord(DBRecord<?> record)
Sets the DBRecord for this node

Parameters:
record - The DBRecord to set
Returns:
True if the DBRecord was successfully set, false otherwise

getUntranslatedTableName

public java.lang.String getUntranslatedTableName()
Gets the table name for the defined DBFactory

Returns:
The table name

getName

public java.lang.String getName()
Gets the table name for the DBFactory (if defined)

Returns:
The DBFactory table name, or "root" if the DBFactory is not defined, and the tree level is '0'

toString

public java.lang.String toString()
Gets the String representation of this class (typically the DBFactory table name)

Overrides:
toString in class java.lang.Object
Returns:
The String representation of this class

addChild

public void addChild(DBFactoryTree dbFactNode)
Adds the specified node as a child of this node

Parameters:
dbFactNode - The node to add

hasChildren

public boolean hasChildren()
Returns true if this node has children

Returns:
True if this node has children

getChildren

public DBFactoryTree[] getChildren()
Gets an array of children for this node

Returns:
An array of children for this node, or null if this node has no children

getKeyMap

public java.util.Map<DBField,java.lang.Object> getKeyMap()
Returns an OrderedMap of defined primary keys

Returns:
map of defined primary keys

getDBFactoryTree

public static DBFactoryTree[] getDBFactoryTree(DBFactory<? extends DBRecord> initialFactory)
Returns an array of root DBFactoryTree nodes based on the specified top-level DBFactory.

Parameters:
initialFactory - The root DBFactory which is traversed to create the DBFactoryTree. If null all root DBFactories will be traversed.
Returns:
An array of rot DBFactoryTree nodes. If the 'initialFactory' is null, the returned DBFactoryTree array will have at most 1 element.

getDBFactoryTree

public static DBFactoryTree[] getDBFactoryTree(DBFactory<? extends DBRecord>[] initialFactories)
Returns an array of root DBFactoryTree nodes based on the specified top-level DBFactory.

Parameters:
initialFactories - The root DBFactories which are traversed to create the DBFactoryTree. If null all root DBFactories will be traversed.
Returns:
An array of rot DBFactoryTree nodes.