ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

javafe.filespace
Class UnionTree

java.lang.Object
  extended byjavafe.filespace.Tree
      extended byjavafe.filespace.HashTree
          extended byjavafe.filespace.PreloadedTree
              extended byjavafe.filespace.UnionTree

public class UnionTree
extends PreloadedTree

A UnionTree is a Tree which represents the union of a series of Tree's.

A node exists in a UnionTree iff a corresponding node (i.e., same fully qualified name) exists in any of the underlying Trees. Its data field is copied at creation time from the first such corresponding node (i.e., the one whose Tree is first in the list of underlying Trees).

Exception: if the underlying list contains 0 Trees, then the UnionTree contains exactly 1 node, the root node, which will have data equal to null.

The other corresponding nodes of a node X can be accessed by calling X.duplicates(), which returns a list of all the corresponding nodes (including the first one) in the same order as the original input list of Trees.

The behavior of a UnionTree is undefined if the underlying Trees it depends on are altered after it has been created.


Field Summary
protected  java.util.Hashtable edges
          The mapping between our outgoing edge's labels and the subTrees they point to.
protected  Tree[] roots
          The list of Trees we represent the union of: Invariant: contains no nulls and is non-null.
 
Fields inherited from class javafe.filespace.Tree
data
 
Constructor Summary
  UnionTree(Tree[] roots)
          Create a new Tree that represents the union of the Trees in roots.
protected UnionTree(Tree parent, java.lang.String label, Tree[] roots)
          Create a non-root node: roots must be non-null and contain no nulls.
 
Method Summary
 java.util.Enumeration children()
          * Fetching and counting children: * *
 int countDuplicates()
          Return the number of nodes corresponding to this one there are in the underlying Trees.
 Tree[] duplicates()
          Return a list of all the nodes that correspond to this one in the underlying Trees in the same order as the original list of Trees.
 void ensureEdgesLoaded()
          Ensure that the edges map is ready for use
 Tree getChild(java.lang.String label)
          Fetch our direct child along the edge labelled label.
protected  void loadEdge(java.lang.String label)
           
protected  void loadEdges()
          Load the edges map for use.
static void main(java.lang.String[] args)
          A simple test driver
 void printDetails(java.lang.String prefix)
          * Debugging functions: * *
 
Methods inherited from class javafe.filespace.Tree
getChildrenCount, getLabel, getParent, getQualifiedChild, getQualifiedName, getRootNode, getSimpleName, isLeaf, print
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

roots

protected Tree[] roots
The list of Trees we represent the union of:

Invariant: contains no nulls and is non-null.


edges

protected java.util.Hashtable edges
The mapping between our outgoing edge's labels and the subTrees they point to. No entry for a label means no edge with that label exists.

Invariant: all elements of edges are Trees and all keys are Strings.

Constructor Detail

UnionTree

public UnionTree(Tree[] roots)
Create a new Tree that represents the union of the Trees in roots.

roots must be non-null and contain no nulls.


UnionTree

protected UnionTree(Tree parent,
                    java.lang.String label,
                    Tree[] roots)
Create a non-root node:

roots must be non-null and contain no nulls.

Method Detail

duplicates

public Tree[] duplicates()
Return a list of all the nodes that correspond to this one in the underlying Trees in the same order as the original list of Trees. This ist is never null and never contains any nulls.


countDuplicates

public int countDuplicates()
Return the number of nodes corresponding to this one there are in the underlying Trees.


loadEdges

protected void loadEdges()
Load the edges map for use.

Specified by:
loadEdges in class PreloadedTree

loadEdge

protected void loadEdge(java.lang.String label)

printDetails

public void printDetails(java.lang.String prefix)
* Debugging functions: * *

Overrides:
printDetails in class Tree

main

public static void main(java.lang.String[] args)
A simple test driver


ensureEdgesLoaded

public final void ensureEdgesLoaded()
Ensure that the edges map is ready for use


children

public final java.util.Enumeration children()
* Fetching and counting children: * *

Overrides:
children in class HashTree

getChild

public final Tree getChild(java.lang.String label)
Description copied from class: HashTree
Fetch our direct child along the edge labelled label. Iff there is no such child, return null.

Overrides:
getChild in class HashTree

ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

The ESC/Java2 Project Homepage