Coverage Report - net.sf.statcvs.input.RevisionData
 
Classes in this File Line Coverage Branch Coverage Complexity
RevisionData
0%
0/35
0%
0/16
1
 
 1  
 /*
 2  
         StatCvs - CVS statistics generation 
 3  
         Copyright (C) 2002  Lukasz Pekacki <lukasz@pekacki.de>
 4  
         http://statcvs.sf.net/
 5  
     
 6  
         This library is free software; you can redistribute it and/or
 7  
         modify it under the terms of the GNU Lesser General Public
 8  
         License as published by the Free Software Foundation; either
 9  
         version 2.1 of the License, or (at your option) any later version.
 10  
 
 11  
         This library is distributed in the hope that it will be useful,
 12  
         but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  
         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  
         Lesser General Public License for more details.
 15  
 
 16  
         You should have received a copy of the GNU Lesser General Public
 17  
         License along with this library; if not, write to the Free Software
 18  
         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 19  
     
 20  
         $RCSfile: RevisionData.java,v $
 21  
         $Date: 2008/04/02 11:22:15 $
 22  
 */
 23  
 package net.sf.statcvs.input;
 24  
 
 25  
 import java.util.Date;
 26  
 
 27  
 import net.sf.statcvs.util.CvsLogUtils;
 28  
 
 29  
 /**
 30  
  * Container for all information contained in one CVS revisionNumber
 31  
  * 
 32  
  * @author Richard Cyganiak <richard@cyganiak.de>
 33  
  * @version $Id: RevisionData.java,v 1.7 2008/04/02 11:22:15 benoitx Exp $
 34  
  */
 35  0
 public class RevisionData {
 36  
     private String revisionNumber;
 37  
     private Date date;
 38  
     private String loginName;
 39  0
     private boolean stateExp = false;
 40  0
     private boolean stateDead = false;
 41  0
     private boolean hasNoLines = true;
 42  
     private int linesAdded;
 43  
     private int linesRemoved;
 44  
     private String comment;
 45  
 
 46  
     /**
 47  
      * @return Returns the loginName.
 48  
      */
 49  
     public String getLoginName() {
 50  0
         return loginName;
 51  
     }
 52  
 
 53  
     /**
 54  
      * @param authorName The loginName to set.
 55  
      */
 56  
     public void setLoginName(final String authorName) {
 57  0
         this.loginName = authorName;
 58  0
     }
 59  
 
 60  
     /**
 61  
      * @return Returns the date.
 62  
      */
 63  
     public Date getDate() {
 64  0
         return date;
 65  
     }
 66  
 
 67  
     /**
 68  
      * @param date The date to set.
 69  
      */
 70  
     public void setDate(final Date date) {
 71  0
         this.date = date;
 72  0
     }
 73  
 
 74  
     /**
 75  
      * @return Returns the linesAdded.
 76  
      */
 77  
     public int getLinesAdded() {
 78  0
         return linesAdded;
 79  
     }
 80  
 
 81  
     /**
 82  
      * @return Returns the linesRemoved.
 83  
      */
 84  
     public int getLinesRemoved() {
 85  0
         return linesRemoved;
 86  
     }
 87  
 
 88  
     /**
 89  
      * Checks if the revision contains numbers for the added
 90  
      * and removed lines.
 91  
      * @return true if the revision contains numbers for the
 92  
      *                 added and removed lines
 93  
      */
 94  
     public boolean hasNoLines() {
 95  0
         return hasNoLines;
 96  
     }
 97  
 
 98  
     /**
 99  
      * Sets the number of added and removed lines.
 100  
      * @param added The number of added lines
 101  
      * @param removed The number of removed lines
 102  
      */
 103  
     public void setLines(final int added, final int removed) {
 104  0
         this.linesAdded = added;
 105  0
         this.linesRemoved = removed;
 106  0
         hasNoLines = false;
 107  0
     }
 108  
 
 109  
     /**
 110  
      * @return Returns the revisionNumber.
 111  
      */
 112  
     public String getRevisionNumber() {
 113  0
         return revisionNumber;
 114  
     }
 115  
 
 116  
     /**
 117  
      * Sets the revision number.
 118  
      * @param revision The revision number
 119  
      */
 120  
     public void setRevisionNumber(final String revision) {
 121  0
         this.revisionNumber = revision;
 122  0
     }
 123  
 
 124  
     public void setStateDead() {
 125  0
         stateDead = true;
 126  0
     }
 127  
 
 128  
     public void setStateExp() {
 129  0
         stateExp = true;
 130  0
     }
 131  
 
 132  
     /**
 133  
      * @return Returns the comment.
 134  
      */
 135  
     public String getComment() {
 136  0
         return comment;
 137  
     }
 138  
 
 139  
     /**
 140  
      * @param comment The comment to set.
 141  
      */
 142  
     public void setComment(final String comment) {
 143  0
         this.comment = comment;
 144  0
     }
 145  
 
 146  
     /**
 147  
      * Returns <tt>true</tt> if this revisionNumber marks the adding of a new file
 148  
      * on a subbranch. CVS creates a dead 1.1 revisionNumber on the trunk even if
 149  
      * the file never gets merged into the trunk. If we evaluate the trunk,
 150  
      * and the file doesn't have any other revisions on the trunk, then we
 151  
      * ignore this revisionNumber.
 152  
      *  
 153  
      * @return <tt>true</tt> if this is the adding of a new file on a subbranch
 154  
      */
 155  
     public boolean isAddOnSubbranch() {
 156  0
         return stateDead && revisionNumber.equals("1.1");
 157  
     }
 158  
 
 159  
     /**
 160  
      * Returns <tt>true</tt> if this revisionNumber is the removal of a file.
 161  
      * Any dead revisionNumber means that the file was removed. The only exception
 162  
      * is a dead 1.1 revisionNumber, which is an add on a subbranch.
 163  
      * 
 164  
      * @return <tt>true</tt> if this revisionNumber deletes the file.
 165  
      * @see #isAddOnSubbranch
 166  
      */
 167  
     public boolean isDeletion() {
 168  0
         return stateDead && !revisionNumber.equals("1.1");
 169  
     }
 170  
 
 171  
     /**
 172  
      * Returns <tt>true</tt> if this revisionNumber is a normal change, or if it
 173  
      * restores a removed file. The distinction between these two cases
 174  
      * can be made by looking at the previous (in time, not log order) revisionNumber.
 175  
      * If it was a deletion, then this revisionNumber is a restore.
 176  
      * 
 177  
      * @return <tt>true</tt> if this is a normal change or a restore.
 178  
      */
 179  
     public boolean isChangeOrRestore() {
 180  0
         return stateExp && !hasNoLines;
 181  
     }
 182  
 
 183  
     /**
 184  
      * Returns <tt>true</tt> if this revisionNumber is the creation of a new file.
 185  
      * 
 186  
      * @return <tt>true</tt> if this is the creation of a new file.
 187  
      */
 188  
     public boolean isCreation() {
 189  0
         return stateExp && hasNoLines;
 190  
     }
 191  
 
 192  
     /**
 193  
      * Returns <tt>true</tt> if this revisionNumber is on the main branch.
 194  
      * 
 195  
      * @return <tt>true</tt> if this revisionNumber is on the main branch.
 196  
      */
 197  
     public boolean isOnTrunk() {
 198  0
         return CvsLogUtils.isOnMainBranch(revisionNumber);
 199  
     }
 200  
 
 201  
     /**
 202  
      * Returns <tt>true</tt> if this is an Exp revisionNumber.
 203  
      * This is CVS speak for any "live" revisionNumber, that is, if this is
 204  
      * the current revisionNumber, then a file exists in the working copy.
 205  
      * 
 206  
      * @return <tt>true</tt> if this is an Exp revisionNumber
 207  
      */
 208  
     public boolean isStateExp() {
 209  0
         return stateExp;
 210  
     }
 211  
 
 212  
     /**
 213  
      * Returns <tt>true</tt> if this is a dead revisionNumber. If this is the
 214  
      * current revisionNumber, then the file does not exist in the working copy.
 215  
      * 
 216  
      * @return <tt>true</tt> if this is a dead revisionNumber
 217  
      */
 218  
     public boolean isStateDead() {
 219  0
         return stateDead;
 220  
     }
 221  
 
 222  
     public String toString() {
 223  0
         return "RevisionData " + revisionNumber;
 224  
     }
 225  
 }