Coverage Report - net.sf.statcvs.reports.TopDevelopersTableReport
 
Classes in this File Line Coverage Branch Coverage Complexity
TopDevelopersTableReport
0%
0/29
0%
0/8
2.667
 
 1  
 package net.sf.statcvs.reports;
 2  
 
 3  
 import java.util.Iterator;
 4  
 
 5  
 import net.sf.statcvs.Messages;
 6  
 import net.sf.statcvs.model.Author;
 7  
 import net.sf.statcvs.output.ReportConfig;
 8  
 import net.sf.statcvs.reportmodel.AuthorColumn;
 9  
 import net.sf.statcvs.reportmodel.IntegerColumn;
 10  
 import net.sf.statcvs.reportmodel.Table;
 11  
 
 12  
 /**
 13  
  * Table report which creates a table containing the names of the
 14  
  * top 10 developers and their LOC contributions.
 15  
  * 
 16  
  * @author Richard Cyganiak <rcyg@gmx.de>
 17  
  * @version $Id: TopDevelopersTableReport.java,v 1.2 2008/04/02 11:22:15 benoitx Exp $
 18  
  */
 19  
 public class TopDevelopersTableReport extends AbstractLocTableReport implements TableReport {
 20  0
     private Table table = null;
 21  
 
 22  
     /**
 23  
      * Creates a table report containing the top 10 authors and their
 24  
      * LOC contributions
 25  
      * @param content the version control source data
 26  
      */
 27  
     public TopDevelopersTableReport(final ReportConfig config) {
 28  0
         super(config);
 29  0
     }
 30  
 
 31  
     /**
 32  
      * @see net.sf.statcvs.reports.TableReport#calculate()
 33  
      */
 34  
     public void calculate() {
 35  0
         if (this.table != null) {
 36  0
             return;
 37  
         }
 38  
         String summary;
 39  0
         if (getDeveloperCount() > 10) {
 40  0
             summary = Messages.getString("TOP_AUTHORS_TABLE_SUMMARY1");
 41  
         } else {
 42  0
             summary = Messages.getString("TOP_AUTHORS_TABLE_SUMMARY2");
 43  
         }
 44  0
         table = new Table(summary);
 45  0
         final AuthorColumn authors = new AuthorColumn();
 46  0
         final IntegerColumn linesOfCode = new IntegerColumn(Messages.getString("COLUMN_LOC"));
 47  0
         linesOfCode.setShowPercentages(true);
 48  0
         table.addColumn(authors);
 49  0
         table.addColumn(linesOfCode);
 50  0
         table.setKeysInFirstColumn(true);
 51  
 
 52  0
         calculateChangesAndLinesPerDeveloper(getContent().getRevisions());
 53  0
         int lines = 0;
 54  0
         final Iterator it = getLinesMap().iteratorSortedByValueReverse();
 55  0
         while (it.hasNext()) {
 56  0
             final Author author = (Author) it.next();
 57  0
             authors.addValue(author);
 58  0
             linesOfCode.addValue(getLinesMap().get(author));
 59  0
             lines++;
 60  0
             if (lines == 10) {
 61  0
                 break;
 62  
             }
 63  0
         }
 64  0
         linesOfCode.setSum(getLinesMap().sum());
 65  0
     }
 66  
 
 67  
     /**
 68  
      * @see net.sf.statcvs.reports.TableReport#getTable()
 69  
      */
 70  
     public Table getTable() {
 71  0
         return table;
 72  
     }
 73  
 }