Class FileBuilder
Builds a VersionedFile with Revisions from logging data.
This class is responsible for deciding if a file or revisions will be
included in the report, for translating from CVS logfile data structures to
the data structures in the net.sf.statsvn.model package, and for
calculating the LOC history for the file.
A main goal of this class is to delay the creation of the VersionedFile object until all revisions of the file have been collected from the log. We could simply create VersionedFile and Revisions on the fly as we parse through the log, but this creates a problem if we decide not to include the file after reading several revisions. The creation of a VersionedFile or Revision can cause many more objects to be created (Author, Directory, Commit), and it would be very hard to get rid of them if we don't want the file. This problem is solved by first collecting all information about one file in this class, and then, with all information present, deciding if we want to create the model instances or not.
- Version:
- $Id: FileBuilder.java 351 2008-03-28 18:46:26Z benoitx $
- Author:
- Richard Cyganiak invalid input: '<'richard@cyganiak.de>, Tammo van Lessen, Jason Kealey invalid input: '<'jkealey@shade.ca>, Gunter Mussbacher invalid input: '<'gunterm@site.uottawa.ca>
-
Constructor Summary
ConstructorsConstructorDescriptionFileBuilder(Builder builder, String name, boolean isBinary, Map revBySymnames, Map dateBySymnames) Creates a new FileBuilder. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRevisionData(RevisionData data) Adds a revision to the file.net.sf.statcvs.model.VersionedFilecreateFile(Date beginOfLogDate) Creates and returns aVersionedFilerepresentation of the file.booleanReturns true if the file has revisions.protected booleanReturns true if the file's most recent revision is dead.getName()New in StatSVN: Gives the FileBuilder's filename.New in StatSVN: The list of revisions made on this file.booleanisBinary()New in StatSVN: Returns true if this file is known to be binary.voidsetBinary(boolean isBinary) New in StatSVN: Sets the file's binary flag.voidupdateRevision(String revisionNumber, int linesAdded, int linesRemoved) New in StatSVN: Updates a particular revision with new line count information.
-
Constructor Details
-
FileBuilder
public FileBuilder(Builder builder, String name, boolean isBinary, Map revBySymnames, Map dateBySymnames) Creates a new FileBuilder.- Parameters:
builder- a Builder that provides factory services for author and directory instances and line counts.name- the filenamebinary- Is this a binary file or not?
-
-
Method Details
-
addRevisionData
Adds a revision to the file. The revisions must be added in the same order as they appear in the CVS logfile, that is, most recent first.- Parameters:
data- the revision
-
createFile
Creates and returns aVersionedFilerepresentation of the file. null is returned if the file does not meet certain criteria, for example if its filename meets an exclude filter or if it was dead during the entire logging timespan.- Parameters:
beginOfLogDate- the date of the begin of the log- Returns:
- a VersionedFile representation of the file.
-
finalRevisionIsDead
protected boolean finalRevisionIsDead()Returns true if the file's most recent revision is dead.- Returns:
- true if the file is dead.
-
existRevision
public boolean existRevision()Returns true if the file has revisions.- Returns:
- Returns true if the file has revisions.
-
getName
-
getRevisions
New in StatSVN: The list of revisions made on this file.- Returns:
- the list of revisions on this file
-
isBinary
public boolean isBinary()New in StatSVN: Returns true if this file is known to be binary.- Returns:
- true if this file is known to be binary, false otherwise.
-
setBinary
public void setBinary(boolean isBinary) New in StatSVN: Sets the file's binary flag.- Parameters:
binary- is the file binary?
-
updateRevision
New in StatSVN: Updates a particular revision with new line count information. If the file or revision does not exist, action will do nothing. Necessary because line counts are not given in the log file and hence can only be added in a second pass.- Parameters:
revisionNumber- the revision number to be updatedlinesAdded- the lines that were addedlinesRemoved- the lines that were removed
-