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 PreloadedTree

java.lang.Object
  extended byjavafe.filespace.Tree
      extended byjavafe.filespace.HashTree
          extended byjavafe.filespace.PreloadedTree
Direct Known Subclasses:
FileTree, PkgTree, UnionTree

abstract class PreloadedTree
extends HashTree

A PreloadedTree is a HashTree whose edges map is loaded exactly once before any children-fetching queries complete; the loading is lazy, however, and occurs when the first children-fetching method is called.

If a subclass adds additional methods that refer to edges, it should make sure ensureEdgesLoaded is called before edges is used.


Field Summary
protected  java.util.Hashtable edges
          The mapping between our outgoing edge's labels and the subTrees they point to.
private  boolean loaded
          Have we loaded the edges map yet?
 
Fields inherited from class javafe.filespace.Tree
data
 
Constructor Summary
  PreloadedTree(java.lang.Object data)
          Create a root node:
protected PreloadedTree(Tree parent, java.lang.String label, java.lang.Object data)
          Create a non-root node:
 
Method Summary
 java.util.Enumeration children()
          * Fetching and counting children: * *
 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 abstract  void loadEdges()
          Load the edges map for use.
 
Methods inherited from class javafe.filespace.Tree
getChildrenCount, getLabel, getParent, getQualifiedChild, getQualifiedName, getRootNode, getSimpleName, isLeaf, print, printDetails
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loaded

private boolean loaded
Have we loaded the edges map yet?


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

PreloadedTree

public PreloadedTree(java.lang.Object data)
Create a root node:


PreloadedTree

protected PreloadedTree(Tree parent,
                        java.lang.String label,
                        java.lang.Object data)
Create a non-root node:

Method Detail

ensureEdgesLoaded

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


loadEdges

protected abstract void loadEdges()
Load the edges map 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