proper.database
Class JoinTreeNode

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by proper.database.JoinTreeNode
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class JoinTreeNode
extends javax.swing.tree.DefaultMutableTreeNode

A specialized TreeNode class that handles Join-Objects and provides some methods for conveniencs.
Note: the root node is just a table, since it doesn't join with any other table to the left.

Version:
$Revision: 1.1 $
Author:
FracPete
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
EMPTY_ENUMERATION
 
Constructor Summary
JoinTreeNode()
          initializes the node with no Join
JoinTreeNode(Join j)
          initializes the node with the given Join
JoinTreeNode(java.lang.String s)
          initializes the node with the given string (can be either a Table or a Join-Definition)
JoinTreeNode(Table t)
          initializes the node with the given Table (only for the root element!)
 
Method Summary
 java.util.Vector getAllJoins()
          returns a vector with all the Joins in the subtree, including this node (depth-first)
 java.util.Vector getAllNodes()
          returns all the nodes in the subtree including this node (depth-first)
 java.util.Vector getAllTables()
          returns a vector with all the Tables in the subtree, including this node (depth-first)
 Join getChildJoinAt(int index)
          returns the Join of the specified child
 Join getJoin()
          returns the Join object of this node, null if not a Join object stored
 java.util.Vector getJoinsAlongPath()
          returns all the Joins (as string representations) that are along the path to the root.
Note: the root is a Table element!
 Table getTable()
          returns the Table object of this node, null if not a Table object stored
 java.util.Vector getTablesAlongPath()
          returns all the Tables that are along the path to the root
 boolean isInPath(Join j)
          checks whether the given Join is somewhere on the path to the root
 boolean isJoin()
          checks whether we have a Join object as userobject
 boolean isTable()
          checks whether we have a Table object as userobject (as root element)
static void main(java.lang.String[] args)
          for testing only
static JoinTreeNode parseTreeString(java.lang.String tree)
          parses the given tree in string representation and returns it in a TreeNode Structure, e.g.:
 void setJoin(Join j)
          sets the Join
 void setTable(Table t)
          sets the Table
 java.lang.String toString()
          returns the name of the table
 java.lang.String toString(boolean all)
          returns either the whole subtree (including itself) as a string representation (= TRUE) or only the table (= FALSE)
 java.lang.String toTreeString()
          returns itself and the subtree underneath in a string representation that can be parsed with the parseTree(String) method
 java.lang.String toTreeString(boolean full)
          returns itself and the subtree underneath in a string representation that can be parsed with the parseTree(String) method
static java.lang.String toTreeString(JoinTreeNode node)
          returns the node and the subtree underneath in a string representation that can be parsed with the parseTree(String) method
static java.lang.String toTreeString(JoinTreeNode node, boolean full)
          returns the node and the subtree underneath in a string representation that can be parsed with the parseTree(String) method
 void updateChildren()
          in case the name of the table changed, all the children Joins will be updated.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JoinTreeNode

public JoinTreeNode()
initializes the node with no Join


JoinTreeNode

public JoinTreeNode(Join j)
initializes the node with the given Join


JoinTreeNode

public JoinTreeNode(Table t)
initializes the node with the given Table (only for the root element!)


JoinTreeNode

public JoinTreeNode(java.lang.String s)
initializes the node with the given string (can be either a Table or a Join-Definition)

See Also:
Join.parseString(String)
Method Detail

setJoin

public void setJoin(Join j)
sets the Join


setTable

public void setTable(Table t)
sets the Table


isJoin

public boolean isJoin()
checks whether we have a Join object as userobject


isTable

public boolean isTable()
checks whether we have a Table object as userobject (as root element)


getJoin

public Join getJoin()
returns the Join object of this node, null if not a Join object stored


getTable

public Table getTable()
returns the Table object of this node, null if not a Table object stored


getChildJoinAt

public Join getChildJoinAt(int index)
returns the Join of the specified child


isInPath

public boolean isInPath(Join j)
checks whether the given Join is somewhere on the path to the root


getJoinsAlongPath

public java.util.Vector getJoinsAlongPath()
returns all the Joins (as string representations) that are along the path to the root.
Note: the root is a Table element!

See Also:
Join.parseString(String)

getTablesAlongPath

public java.util.Vector getTablesAlongPath()
returns all the Tables that are along the path to the root


getAllNodes

public java.util.Vector getAllNodes()
returns all the nodes in the subtree including this node (depth-first)


getAllJoins

public java.util.Vector getAllJoins()
returns a vector with all the Joins in the subtree, including this node (depth-first)


getAllTables

public java.util.Vector getAllTables()
returns a vector with all the Tables in the subtree, including this node (depth-first)


updateChildren

public void updateChildren()
in case the name of the table changed, all the children Joins will be updated.


parseTreeString

public static JoinTreeNode parseTreeString(java.lang.String tree)
parses the given tree in string representation and returns it in a TreeNode Structure, e.g.:
   a[b,c[d,e]]
 
represents the following tree:
   a
   |-b
   |-c
   | |-d
   | |-e
 

See Also:
toTreeString(), toTreeString(boolean)

toTreeString

public java.lang.String toTreeString()
returns itself and the subtree underneath in a string representation that can be parsed with the parseTree(String) method

See Also:
parseTreeString(String)

toTreeString

public java.lang.String toTreeString(boolean full)
returns itself and the subtree underneath in a string representation that can be parsed with the parseTree(String) method

Parameters:
full - whether to print columns, sizes, etc in parentheses
See Also:
parseTreeString(String)

toTreeString

public static java.lang.String toTreeString(JoinTreeNode node)
returns the node and the subtree underneath in a string representation that can be parsed with the parseTree(String) method

Parameters:
node - the node to represent in String notation
See Also:
parseTreeString(String)

toTreeString

public static java.lang.String toTreeString(JoinTreeNode node,
                                            boolean full)
returns the node and the subtree underneath in a string representation that can be parsed with the parseTree(String) method

Parameters:
node - the node to get the string notation from
full - whether to print columns, sizes, etc in parentheses
See Also:
parseTreeString(String)

toString

public java.lang.String toString()
returns the name of the table

Overrides:
toString in class javax.swing.tree.DefaultMutableTreeNode

toString

public java.lang.String toString(boolean all)
returns either the whole subtree (including itself) as a string representation (= TRUE) or only the table (= FALSE)


main

public static void main(java.lang.String[] args)
for testing only