net.sf.statcvs.input
Class Builder

java.lang.Object
  extended by net.sf.statcvs.input.Builder

public class Builder
extends java.lang.Object

Helps building the CvsContent from a CVS log. The Builder is fed by some CVS history data source, for example a CVS log parser. It creates and collects the CvsFile and CvsRevision objects. It calculates LOC values to the individual revisions.

It also takes care of the creation of Author and Directory objects and makes sure that there's only one of these for each author name and path.

Version:
$Id: Builder.java,v 1.10 2003/06/05 16:59:19 cyganiak Exp $
Author:
Richard Cyganiak

Constructor Summary
Builder(RepositoryFileManager repositoryFileManager)
          Creates a new Builder
 
Method Summary
 void buildFileBegin(java.lang.String filename, boolean isBinary, boolean isInAttic)
          Starts building a new file.
 void buildFileEnd()
          Finishes building a file.
 void buildRevisionAuthor(java.lang.String author)
          Sets the author's name for the current revision
 void buildRevisionBegin(java.lang.String revisionNumber)
          Starts building a new revision for the current file.
 void buildRevisionDate(java.util.Date date)
          Sets the date for the current revision
 void buildRevisionEnd(java.lang.String comment)
          Finishes building a revision
 void buildRevisionStateChange(int linesAdded, int linesRemoved)
          Makes the current revision a normal file-modifying revision.
 void buildRevisionStateDead()
          Makes the current revision a dead (deleted) revision
 void buildRevisionStateInitial()
          Makes the current revision an initial revision
 void finish()
          Called after all files and revisions have been added (built).
 Author getAuthor(java.lang.String name)
          returns the Author of the given name or creates it if it does not yet exist.
 CvsContent getCvsContent()
          Returns a CvsContent object of all files
 Directory getDirectory(java.lang.String filename)
          Returns the Directory of the given filename or creates it if it does not yet exist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Builder

public Builder(RepositoryFileManager repositoryFileManager)
Creates a new Builder

Parameters:
repositoryFileManager - the RepositoryFileManager that can be used to retrieve LOC counts for the files that this builder will create
Method Detail

finish

public void finish()
Called after all files and revisions have been added (built). Does stuff to make sure that the internals of the CvsContent are in a valid state.


getAuthor

public Author getAuthor(java.lang.String name)
returns the Author of the given name or creates it if it does not yet exist.

Parameters:
name - the author's name
Returns:
a corresponding Author object

getDirectory

public Directory getDirectory(java.lang.String filename)
Returns the Directory of the given filename or creates it if it does not yet exist.

Parameters:
filename - the name and path of a file, for example "src/Main.java"
Returns:
a corresponding Directory object

buildFileBegin

public void buildFileBegin(java.lang.String filename,
                           boolean isBinary,
                           boolean isInAttic)
Starts building a new file. The files are not expected to be created in any particular order.

Parameters:
filename - the file's name with path, for example "path/file.txt"
isBinary - true if it's a binary file
isInAttic - true if the file is dead on the main branch

buildFileEnd

public void buildFileEnd()
Finishes building a file.


buildRevisionBegin

public void buildRevisionBegin(java.lang.String revisionNumber)
Starts building a new revision for the current file. The revisions must be built in reverse chronological order, that is, build the latest revision first.

Parameters:
revisionNumber - the revision number, for example "1.12"

buildRevisionDate

public void buildRevisionDate(java.util.Date date)
Sets the date for the current revision

Parameters:
date - the date

buildRevisionAuthor

public void buildRevisionAuthor(java.lang.String author)
Sets the author's name for the current revision

Parameters:
author - the author's name

buildRevisionStateInitial

public void buildRevisionStateInitial()
Makes the current revision an initial revision


buildRevisionStateChange

public void buildRevisionStateChange(int linesAdded,
                                     int linesRemoved)
Makes the current revision a normal file-modifying revision.

Parameters:
linesAdded - number of lines added to this revision
linesRemoved - number of lines removed to this revision

buildRevisionStateDead

public void buildRevisionStateDead()
Makes the current revision a dead (deleted) revision


buildRevisionEnd

public void buildRevisionEnd(java.lang.String comment)
Finishes building a revision

Parameters:
comment - the revision comment

getCvsContent

public CvsContent getCvsContent()
Returns a CvsContent object of all files

Returns:
CvsContent a CvsContent object