Coverage Report - net.sf.statcvs.reports.ModuleTableReport
 
Classes in this File Line Coverage Branch Coverage Complexity
ModuleTableReport
0%
0/40
0%
0/8
2.333
 
 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: ModuleTableReport.java,v $
 21  
         $Date: 2009/08/22 10:30:42 $
 22  
 */
 23  
 package net.sf.statcvs.reports;
 24  
 
 25  
 import java.util.Iterator;
 26  
 
 27  
 import net.sf.statcvs.Messages;
 28  
 import net.sf.statcvs.model.Module;
 29  
 import net.sf.statcvs.model.Repository;
 30  
 import net.sf.statcvs.model.VersionedFile;
 31  
 import net.sf.statcvs.reportmodel.IntegerColumn;
 32  
 import net.sf.statcvs.reportmodel.SimpleTextColumn;
 33  
 import net.sf.statcvs.reportmodel.Table;
 34  
 import net.sf.statcvs.util.IntegerMap;
 35  
 
 36  
 /**
 37  
  * Table report which creates a table containing the names of
 38  
  * all modules and the number of changes and LOC in them.
 39  
  * 
 40  
  * @author Benoit Xhenseval
 41  
  * @version $Id: ModuleTableReport.java,v 1.2 2009/08/22 10:30:42 benoitx Exp $
 42  
  */
 43  
 public class ModuleTableReport implements TableReport {
 44  
     private final Repository content;
 45  0
     private Table table = null;
 46  0
     private final IntegerMap filesMap = new IntegerMap();
 47  0
     private final IntegerMap changesMap = new IntegerMap();
 48  0
     private final IntegerMap linesMap = new IntegerMap();
 49  
 
 50  
     /**
 51  
      * Creates a table report containing all modules and their
 52  
      * respective number of changes and LOC.
 53  
      * @param content the version control source data
 54  
      */
 55  0
     public ModuleTableReport(final Repository content) {
 56  0
         this.content = content;
 57  0
     }
 58  
 
 59  
     public void calculate() {
 60  0
         Iterator it = this.content.getModules().values().iterator();
 61  0
         while (it.hasNext()) {
 62  0
             final Module mod = (Module) it.next();
 63  
             //            final Directory dir = rev.getFile().getDirectory();
 64  0
             final Iterator files = mod.getFiles().iterator();
 65  0
             while (files.hasNext()) {
 66  0
                 final VersionedFile vf = (VersionedFile) files.next();
 67  0
                 filesMap.addInt(mod.getName(), 1);
 68  0
                 changesMap.addInt(mod.getName(), vf.getRevisions().size());
 69  
             }
 70  0
             linesMap.addInt(mod.getName(), mod.getCurrentLinesOfCode());
 71  
         }
 72  0
         this.table = new Table(Messages.getString("MODULES_TABLE_SUMMARY"));
 73  0
         final IntegerColumn changes = new IntegerColumn(Messages.getString("COLUMN_CHANGES"));
 74  0
         final IntegerColumn linesOfCode = new IntegerColumn(Messages.getString("COLUMN_LOC"));
 75  0
         final IntegerColumn filesCol = new IntegerColumn(Messages.getString("FILES"));
 76  0
         final SimpleTextColumn keys = new SimpleTextColumn(Messages.getString("COLUMN_MODULES"));
 77  0
         keys.setTotal(Messages.getString("TOTALS"));
 78  0
         changes.setShowPercentages(true);
 79  0
         linesOfCode.setShowPercentages(true);
 80  0
         this.table.addColumn(keys);
 81  0
         this.table.addColumn(filesCol);
 82  0
         this.table.addColumn(changes);
 83  0
         this.table.addColumn(linesOfCode);
 84  0
         this.table.setKeysInFirstColumn(true);
 85  
 
 86  0
         it = linesMap.iteratorSortedByValueReverse();
 87  0
         while (it.hasNext()) {
 88  0
             final Object key = it.next();
 89  0
             keys.addValue(key);
 90  0
             changes.addValue(changesMap.get(key));
 91  0
             linesOfCode.addValue(linesMap.get(key));
 92  0
             filesCol.addValue(filesMap.get(key));
 93  
         }
 94  0
         if (this.table.getRowCount() > 1) {
 95  0
             this.table.setShowTotals(true);
 96  
         }
 97  0
     }
 98  
 
 99  
     public Table getTable() {
 100  0
         return table;
 101  
     }
 102  
 }