net.sf.statcvs.model
Class Directory

java.lang.Object
  extended bynet.sf.statcvs.model.Directory
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
DirectoryImpl, DirectoryRoot

public abstract class Directory
extends java.lang.Object
implements java.lang.Comparable

Represents a directory in the module. A container for CvsFiles.

Version:
$Id: Directory.java,v 1.3 2003/04/20 17:45:49 cyganiak Exp $
Author:
Richard Cyganiak

Constructor Summary
Directory()
           
 
Method Summary
 void addFile(CvsFile file)
          Adds a file to this directory
 void addSubdirectory(Directory dir)
          Adds a subdirectory to this directory.
 int compareTo(java.lang.Object o)
           
 int getCurrentFileCount()
          Returns the number of files in this directory.
 int getCurrentLOC()
          Returns the number of code lines in this directory.
abstract  int getDepth()
           
 java.util.Collection getFiles()
          Returns all CvsFile objects in this directory
abstract  java.lang.String getName()
          Returns the directory's name without full path or any slashes, e.g.
abstract  Directory getParent()
          Returns the directory's parent directory or null if it is the root
abstract  java.lang.String getPath()
          Returns the directory's full path with trailing slash, for example "src/net/sf/statcvs/"
 RevisionIterator getRevisionIterator()
          Returns a RevisionIterator of all revisions to files in this directory.
 java.util.Collection getSubdirectories()
          Returns a collection of all immediate subdirectories
 java.util.List getSubdirectoriesRecursive()
          Returns a list of all subdirectories, including their subdirectories and this directory itself.
 boolean isEmpty()
          Returns true if all files in this directory and its subdirectories are deleted, or if it doesn't have any files and subdirectories at all.
abstract  boolean isRoot()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Directory

public Directory()
Method Detail

getName

public abstract java.lang.String getName()
Returns the directory's name without full path or any slashes, e.g. "src"

Returns:
the directory's name

getPath

public abstract java.lang.String getPath()
Returns the directory's full path with trailing slash, for example "src/net/sf/statcvs/"

Returns:
the directory's path

getParent

public abstract Directory getParent()
Returns the directory's parent directory or null if it is the root

Returns:
the directory's parent

isRoot

public abstract boolean isRoot()
Returns:
true if this is the root of the directory tree

getDepth

public abstract int getDepth()
Returns:
the level of this directory in the directory tree. 0 for the root.

addFile

public void addFile(CvsFile file)
Adds a file to this directory

Parameters:
file - a file in this directory

getFiles

public java.util.Collection getFiles()
Returns all CvsFile objects in this directory

Returns:
the files in this directory, unordered

getRevisionIterator

public RevisionIterator getRevisionIterator()
Returns a RevisionIterator of all revisions to files in this directory. The revisions are in no particular order.

Returns:
RevisionIterator for this directory

addSubdirectory

public void addSubdirectory(Directory dir)
Adds a subdirectory to this directory.

Parameters:
dir - an immediate subdirectory

getSubdirectories

public java.util.Collection getSubdirectories()
Returns a collection of all immediate subdirectories

Returns:
collection of Directory objects

getSubdirectoriesRecursive

public java.util.List getSubdirectoriesRecursive()
Returns a list of all subdirectories, including their subdirectories and this directory itself. The list is preordered, beginning with this directory itself.

Returns:
list of Directory objects

getCurrentLOC

public int getCurrentLOC()
Returns the number of code lines in this directory. The returned number will be for the current revisions of all files. TODO: Write tests!

Returns:
LOC in this directory

getCurrentFileCount

public int getCurrentFileCount()
Returns the number of files in this directory. Deleted files are not counted. TODO: Write tests!

Returns:
number of files in this directory

isEmpty

public boolean isEmpty()
Returns true if all files in this directory and its subdirectories are deleted, or if it doesn't have any files and subdirectories at all. TODO: Write tests!

Returns:
true if the directory is currently empty

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(java.lang.Object)