de.unihalle.informatik.MiToBo.io.dirs
Class DirectoryTree

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBTree
      extended by de.unihalle.informatik.MiToBo.io.dirs.DirectoryTree

public class DirectoryTree
extends MTBTree

This class implements a data structure for representing directory trees. It is based on a conventional tree data structure, but provides methods for directly parsing a directory structure into the tree. Additionally, the class provides methods for getting a list of all files in all directories below the given root directory.

Author:
moeller
See Also:
MTBTree

Field Summary
private  java.lang.String mainpath
          Root directory of the tree.
 
Fields inherited from class de.unihalle.informatik.MiToBo.core.datatypes.MTBTree
root
 
Constructor Summary
DirectoryTree(java.lang.String dir)
          Standard constructor.
 
Method Summary
 java.util.Vector<java.lang.String> getFileList()
          Collect all files in the directory tree including their complete paths.
private  void initFromDirectory()
          Builds the directory tree by initiating the recursive parse procedure
private static MTBTreeNode traverseSubdir(java.lang.String path, java.lang.String subdir)
          Recursive traversal of subdirectories.
 
Methods inherited from class de.unihalle.informatik.MiToBo.core.datatypes.MTBTree
getRoot, printTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainpath

private java.lang.String mainpath
Root directory of the tree.

Constructor Detail

DirectoryTree

public DirectoryTree(java.lang.String dir)
Standard constructor.

Parameters:
dir - root directory where to begin the parsing
Method Detail

getFileList

public java.util.Vector<java.lang.String> getFileList()
Collect all files in the directory tree including their complete paths.

Returns:
vector containing all files with absolute path

initFromDirectory

private void initFromDirectory()
Builds the directory tree by initiating the recursive parse procedure


traverseSubdir

private static MTBTreeNode traverseSubdir(java.lang.String path,
                                          java.lang.String subdir)
Recursive traversal of subdirectories.

Parameters:
path - absolute path to parent directory
subdir - the subdirectory to be analyzed
Returns:
tree node for the subdirectory