net.sf.statcvs.model
Class CvsRevision

java.lang.Object
  extended by net.sf.statcvs.model.CvsRevision

public class CvsRevision
extends java.lang.Object

Object which contains information about one revision of a file.

Everytime an author checks his code into a repository the revision number he was working on, is incremented. Revision numbers have an odd number of periods. And on each forked revision an even integer is appended to the original revision (e.g. Rev 1.3 forks to 1.3.2.1 :-). The 0 is not used for revision numbering. It has a special meaning in the cvs branching mechanism. These are the so called "magic branches".

TODO: Make this class immutable (no setters, fat constructor) and give linesAdded, linesRemoved and linesOfCode intuitive semantics (and not the strange semantics of cvs log)

Version:
$Id: CvsRevision.java,v 1.42 2003/06/05 16:59:19 cyganiak Exp $
Author:
Manuel Schulze, Richard Cyganiak

Field Summary
static int STATE_DEAD
          state constant for dead (deleted) revisions
static int STATE_INITIAL_REVISION
          state constant which marks an initial release of a file
static int STATE_NORMAL
          state constant for normal revisions
static int STATE_RE_ADDED
          state constant which marks a re-add of a previously deleted file
 
Constructor Summary
CvsRevision(java.lang.String revision)
          Creates a new revision of a file with the specified revision number.
 
Method Summary
 Author getAuthor()
          Returns the author
 java.lang.String getComment()
          Returns the comment.
 java.util.Date getDate()
          Returns the date.
 int getEffectiveLinesOfCode()
          Returns the lines of code value for this revision.
 CvsFile getFile()
          Returns the CvsFile object of this revision.
 int getFileCountChange()
          Returns the change of the file count caused by this revision.
 int getLinesAdded()
          Returns the number of added lines.
 int getLinesOfCode()
          Returns the lines of code value for this revision.
 int getLinesOfCodeChange()
          Returns by how many lines the line count changed with this revision.
 int getLinesRemoved()
          Returns the number of removed lines.
 int getLineValue()
          Returns the lines of code value of this revision.
 CvsRevision getPreviousRevision()
          Returns the predecessor of this revision or null if it is the first revision.
 int getRemovingValue()
          Returns the lines of code removing value of this revision.
 java.lang.String getRevision()
          Returns the revision number.
 boolean isDead()
           
 boolean isInitialRevision()
          Returns true if this is the first revision for
 boolean isReAdd()
          Returns TRUE if Revision is re-added, FALSE otherwise
 void setAuthor(Author author)
          Sets the author.
 void setComment(java.lang.String comment)
          Sets the comment.
protected  void setCvsFile(CvsFile file)
          Sets the CvsFile which the revision belongs to.
 void setDate(java.util.Date date)
          Sets the date.
 void setLinesAdded(int linesadded)
          Sets the number of added lines.
 void setLinesOfCode(int linesOfCode)
          Sets the lines of code value for this revision.
 void setLinesRemoved(int linesremoved)
          Sets the number of removed lines.
 void setState(int state)
          Sets the state flag of this revision.
 java.lang.String toString()
          Returns a string representation of this objects content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATE_INITIAL_REVISION

public static final int STATE_INITIAL_REVISION
state constant which marks an initial release of a file

See Also:
Constant Field Values

STATE_NORMAL

public static final int STATE_NORMAL
state constant for normal revisions

See Also:
Constant Field Values

STATE_DEAD

public static final int STATE_DEAD
state constant for dead (deleted) revisions

See Also:
Constant Field Values

STATE_RE_ADDED

public static final int STATE_RE_ADDED
state constant which marks a re-add of a previously deleted file

See Also:
Constant Field Values
Constructor Detail

CvsRevision

public CvsRevision(java.lang.String revision)
Creates a new revision of a file with the specified revision number.

Parameters:
revision - revision number, for example "1.1"
Method Detail

setCvsFile

protected void setCvsFile(CvsFile file)
Sets the CvsFile which the revision belongs to. Called by CvsFile.CvsFile(java.lang.String, net.sf.statcvs.model.Directory, java.util.List, boolean, boolean).

Parameters:
file - CvsFile that belongs to this revision

getRevision

public java.lang.String getRevision()
Returns the revision number.

Returns:
String

getAuthor

public Author getAuthor()
Returns the author

Returns:
the author of this revision

getComment

public java.lang.String getComment()
Returns the comment.

Returns:
String

getDate

public java.util.Date getDate()
Returns the date.

Returns:
Date

getLinesAdded

public int getLinesAdded()
Returns the number of added lines.

Returns:
int

getLinesRemoved

public int getLinesRemoved()
Returns the number of removed lines.

Returns:
int

setState

public void setState(int state)
Sets the state flag of this revision. May be one of the STATE_XXX constants.

Parameters:
state - the state of this revision

setAuthor

public void setAuthor(Author author)
Sets the author.

Parameters:
author - The author to set

setComment

public void setComment(java.lang.String comment)
Sets the comment.

Parameters:
comment - The comment to set

setDate

public void setDate(java.util.Date date)
Sets the date.

Parameters:
date - The date to set

setLinesAdded

public void setLinesAdded(int linesadded)
Sets the number of added lines.

Parameters:
linesadded - The linesadded to set

setLinesRemoved

public void setLinesRemoved(int linesremoved)
Sets the number of removed lines.

Parameters:
linesremoved - The linesremoved to set

setLinesOfCode

public void setLinesOfCode(int linesOfCode)
Sets the lines of code value for this revision. This is the number of code lines the file contained in this revision, or 0 for binary files. Deleted files still keep their lines of code value.

Parameters:
linesOfCode - the number of code lines

getLinesOfCode

public int getLinesOfCode()
Returns the lines of code value for this revision. This is the number of code lines the file contained in this revision, or 0 for binary files. Deleted files still keep their lines of code value.

Returns:
the number of code lines

getEffectiveLinesOfCode

public int getEffectiveLinesOfCode()
Returns the lines of code value for this revision. This is the number of code lines the file contained in this revision, or 0 for binary files and dead files.

Returns:
the number of code lines

getLinesOfCodeChange

public int getLinesOfCodeChange()
Returns by how many lines the line count changed with this revision. Deletions return -getLinesOfCode(), re-adds and initial revisions return getLinesOfCode().

Returns:
the line count change of this revision

getFileCountChange

public int getFileCountChange()
Returns the change of the file count caused by this revision. This is 1 for initial revisions and re-adds, -1 for deletions, and 0 for normal revisions.

Returns:
the file count change of this revision

isInitialRevision

public boolean isInitialRevision()
Returns true if this is the first revision for

Returns:
true if this is the first revision for this file.

isReAdd

public boolean isReAdd()
Returns TRUE if Revision is re-added, FALSE otherwise

Returns:
boolean TRUE if Revision is re-added, FALSE otherwise

isDead

public boolean isDead()
Returns:
true if the file is deleted in this revision

toString

public java.lang.String toString()
Returns a string representation of this objects content.

Overrides:
toString in class java.lang.Object
Returns:
String representation

getFile

public CvsFile getFile()
Returns the CvsFile object of this revision.

Returns:
the CvsFile object of this revision.

getLineValue

public int getLineValue()
Returns the lines of code value of this revision. This is the sum of lines changed and added in this revision.

Returns:
lines changed or added

getRemovingValue

public int getRemovingValue()
Returns the lines of code removing value of this revision. This is the sum of lines changed and deleted in this revision. TODO: Write test case for this and getLineValue() for the case that a file is deleted and re-added

Returns:
lines changed or deleted

getPreviousRevision

public CvsRevision getPreviousRevision()
Returns the predecessor of this revision or null if it is the first revision.

Returns:
the predecessor of this revision