1 package org.codehaus.mojo.javancss;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.List;
23 import java.util.Locale;
24 import java.util.ResourceBundle;
25
26 import org.apache.maven.plugin.logging.Log;
27 import org.apache.maven.doxia.sink.Sink;
28 import org.dom4j.Document;
29 import org.dom4j.Node;
30
31
32
33
34
35
36
37 public class NcssAggregateReportGenerator
38 extends AbstractNcssReportGenerator
39 {
40
41
42
43
44
45
46 public NcssAggregateReportGenerator( Sink sink, ResourceBundle bundle, Log log )
47 {
48 super( sink, bundle, log );
49 }
50
51
52
53
54
55
56
57
58 public void doReport( Locale locale, List<ModuleReport> moduleReports, int lineThreshold )
59 {
60
61 getSink().head();
62 getSink().title();
63 getSink().text( getString( "report.javancss.title" ) );
64 getSink().title_();
65 getSink().head_();
66
67 getSink().body();
68 doIntro( false );
69
70 startSection( "report.javancss.module.link", "report.javancss.module.title" );
71 doModuleAnalysis( moduleReports );
72 endSection();
73 getSink().body_();
74 getSink().close();
75 }
76
77 private void doModuleAnalysis( List<ModuleReport> reports )
78 {
79 getSink().table();
80 getSink().tableRow();
81 headerCellHelper( getString( "report.javancss.header.module" ) );
82 headerCellHelper( getString( "report.javancss.header.packages" ) );
83 headerCellHelper( getString( "report.javancss.header.classetotal" ) );
84 headerCellHelper( getString( "report.javancss.header.functiontotal" ) );
85 headerCellHelper( getString( "report.javancss.header.ncsstotal" ) );
86 headerCellHelper( getString( "report.javancss.header.javadoc" ) );
87 headerCellHelper( getString( "report.javancss.header.javadoc_line" ) );
88 headerCellHelper( getString( "report.javancss.header.single_comment" ) );
89 headerCellHelper( getString( "report.javancss.header.multi_comment" ) );
90 getSink().tableRow_();
91
92 int packages = 0;
93 int classes = 0;
94 int methods = 0;
95 int ncss = 0;
96 int javadocs = 0;
97 int jdlines = 0;
98 int single = 0;
99 int multi = 0;
100 for ( ModuleReport report : reports )
101 {
102 Document document = report.getJavancssDocument();
103 getSink().tableRow();
104 getLog().debug( "Aggregating " + report.getModule().getArtifactId() );
105 tableCellHelper( report.getModule().getArtifactId() );
106 int packageSize = document.selectNodes( "//javancss/packages/package" ).size();
107 packages += packageSize;
108 tableCellHelper( String.valueOf( packageSize ) );
109
110 Node node = document.selectSingleNode( "//javancss/packages/total" );
111
112 String classSize = node.valueOf( "classes" );
113 tableCellHelper( classSize );
114 classes += Integer.parseInt( classSize );
115
116 String methodSize = node.valueOf( "functions" );
117 tableCellHelper( methodSize );
118 methods += Integer.parseInt( methodSize );
119
120 String ncssSize = node.valueOf( "ncss" );
121 tableCellHelper( ncssSize );
122 ncss += Integer.parseInt( ncssSize );
123
124 String javadocSize = node.valueOf( "javadocs" );
125 tableCellHelper( javadocSize );
126 javadocs += Integer.parseInt( javadocSize );
127
128 String jdlineSize = node.valueOf( "javadoc_lines" );
129 tableCellHelper( jdlineSize );
130 jdlines += Integer.parseInt( jdlineSize );
131
132 String singleSize = node.valueOf( "single_comment_lines" );
133 tableCellHelper( singleSize );
134 single += Integer.parseInt( singleSize );
135
136 String multiSize = node.valueOf( "multi_comment_lines" );
137 tableCellHelper( multiSize );
138 multi += Integer.parseInt( multiSize );
139
140 getSink().tableRow_();
141 }
142
143
144 getSink().tableRow();
145 tableCellHelper( getString( "report.javancss.header.totals" ) );
146 tableCellHelper( String.valueOf( packages ) );
147 tableCellHelper( String.valueOf( classes ) );
148 tableCellHelper( String.valueOf( methods ) );
149 tableCellHelper( String.valueOf( ncss ) );
150 tableCellHelper( String.valueOf( javadocs ) );
151 tableCellHelper( String.valueOf( jdlines ) );
152 tableCellHelper( String.valueOf( single ) );
153 tableCellHelper( String.valueOf( multi ) );
154 getSink().tableRow_();
155
156 getSink().table_();
157 }
158
159 }