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 FileTree

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

class FileTree
extends PreloadedTree

A FileTree is a Tree that mirrors the contents of a disk filesystem; the constructor takes in a directory and returns a tree representing the filesystem rooted at that directory.

FileTree works by scanning directories the first time clients ask for information about that part of the tree. If the filesystem is changed afterwards, the changes will not be visible in the FileTree.

The data field of every (sub)node in a FileTree contains a non-null NormalGenericFile representing the file it mirrors on disk.


Field Summary
protected  java.io.File dir
          The directory we are a snapshot of
protected  java.util.Hashtable edges
          The mapping between our outgoing edge's labels and the subTrees they point to.
 
Fields inherited from class javafe.filespace.Tree
data
 
Constructor Summary
  FileTree(java.io.File dir)
          Create a root node:
protected FileTree(Tree parent, java.lang.String label, java.io.File dir)
          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  void loadEdges()
          Load the edges map for use.
static void main(java.lang.String[] args)
          A simple test driver
 
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

dir

protected java.io.File dir
The directory we are a snapshot of


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

FileTree

public FileTree(java.io.File dir)
Create a root node:


FileTree

protected FileTree(Tree parent,
                   java.lang.String label,
                   java.io.File dir)
Create a non-root node:

Method Detail

loadEdges

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

Specified by:
loadEdges in class PreloadedTree

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