net.sf.statcvs.model
Class CvsRevision

java.lang.Object
  extended bynet.sf.statcvs.model.CvsRevision

public class CvsRevision
extends java.lang.Object

Object which contains information about one revision of a file.

Everytime a developer 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".

Version:
$Id: CvsRevision.java,v 1.29 2003/03/18 10:33:55 lukasz Exp $
Author:
Manuel Schulze

Field Summary
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 String.
 
Method Summary
 java.lang.String getAuthor()
          Returns the author.
 java.lang.String getBranchName()
          Returns the branch name of the file.
 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 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 if this is the head revision it returns the lines of code otherwise it returns the number of added lines in this revision
 java.lang.String getRevision()
          Returns the revision.
 boolean isDead()
           
 boolean isInitialRevision()
          Returns true if this is the first revision for
 boolean isOnMainBranch()
          Returns true if this revision is part of the main branch, and false if it is part of a side branch.
 boolean isReAdd()
          Returns TRUE if Revision is re-added, FALSE otherwise
 void setAuthor(java.lang.String author)
          Sets the author.
 void setBranchName(java.lang.String branch)
          Sets the branch of the revision.
 void setComment(java.lang.String comment)
          Sets the comment.
protected  void setCvsFile(CvsFile file)
          Sets the CvsFile for the revision.
 void setDate(java.util.Date date)
          Sets the date.
 void setIsDead(boolean isDead)
          Mark a dead file (which is currently deleted).
 void setLines(int added, int removed)
          Convenience method for setting both added and removed lines.
 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_NORMAL

public static final int STATE_NORMAL
state constant for normal revisions

See Also:
Constant Field Values

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_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 String.

Parameters:
revision - revision number
Method Detail

setCvsFile

protected void setCvsFile(CvsFile file)
Sets the CvsFile for the revision. Called by CvsFile.

Parameters:
file - CvsFile that belongs to this revision

getAuthor

public java.lang.String getAuthor()
Returns the author.

Returns:
String

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

getRevision

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

Returns:
String

getBranchName

public java.lang.String getBranchName()
Returns the branch name of the file.

Returns:
the branch name, or null for the main branch

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

setIsDead

public void setIsDead(boolean isDead)
Mark a dead file (which is currently deleted).

Parameters:
isDead - the live status of the revision

setAuthor

public void setAuthor(java.lang.String 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

setBranchName

public void setBranchName(java.lang.String branch)
Sets the branch of the revision. null is the main branch.

Parameters:
branch - the name of a branch

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

setLines

public void setLines(int added,
                     int removed)
Convenience method for setting both added and removed lines.

Parameters:
added - the number of added lines
removed - the number of removed lines

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

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.

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 if this is the head revision it returns the lines of code otherwise it returns the number of added lines in this revision

Returns:
int the lines of code value of this revision if this is the head revision it returns the lines of code otherwise it returns the number of added lines in this revision

isOnMainBranch

public boolean isOnMainBranch()
Returns true if this revision is part of the main branch, and false if it is part of a side branch. This information is extracted from the revision number. Revisions like 1.1 and 5.212 are on the main branch, 1.1.1.1 and 1.4.2.13 and 1.4.2.13.4.1 are on side branches.

Returns:
true if this revision is part of the main branch.