Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 51 |  | Methods: | 4
| NCLOC: | 45 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
SummaryHTMLRenderer.java | 100% | 100% | 100% | 100% |

1 |  | package net.sourceforge.pmd.renderers;
2 |  |
3 |  | import net.sourceforge.pmd.PMD;
4 |  | import net.sourceforge.pmd.Report;
5 |  |
6 |  | import java.io.IOException;
7 |  | import java.io.Writer;
8 |  | import java.util.Iterator;
9 |  | import java.util.Map;
10 |  |
11 |  | public class SummaryHTMLRenderer extends AbstractRenderer {
12 |  | private String linePrefix,linkPrefix;
13 | 5 | public SummaryHTMLRenderer(String linkPrefix, String linePrefix) {
14 | 5 | this.linePrefix = linePrefix;
15 | 5 | this.linkPrefix = linkPrefix;
16 |  | }
17 |  |
18 | 5 | public SummaryHTMLRenderer(){
19 | 5 | this(null,null);
20 |  | }
21 |  |
22 | 5 | public void render(Writer writer, Report report) throws IOException {
23 | 5 | writer.write("<html><head><title>PMD</title></head><body>" + PMD.EOL);
24 | 5 | renderSummary(writer, report);
25 | 4 | writer.write("<h2><center>Detail</h2></center>");
26 | 4 | writer.write("<table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL + "<th>#</th><th>File</th><th>Line</th><th>Problem</th></tr>" + PMD.EOL);
27 | 4 | new HTMLRenderer(linkPrefix,linePrefix).renderBody(writer, report);
28 | 4 | writer.write("</table></body></html>");
29 |  | }
30 |  |
31 | 5 | public void renderSummary(Writer writer, Report report) throws IOException {
32 | 5 | StringBuffer buf = new StringBuffer();
33 | 5 | buf.append("<h2><center>Summary</h2></center>");
34 | 5 | buf.append("<table align=\"center\" cellspacing=\"0\" cellpadding=\"3\">");
35 | 5 | buf.append("<th>Rule name</th>");
36 | 5 | buf.append("<th>Number of violations</th>");
37 | 5 | writer.write(buf.toString());
38 | 5 | Map summary = report.getSummary();
39 | 4 | for (Iterator i = summary.entrySet().iterator(); i.hasNext();) {
40 | 2 | Map.Entry entry = (Map.Entry) i.next();
41 | 2 | String ruleName = (String) entry.getKey();
42 | 2 | buf.setLength(0);
43 | 2 | buf.append("<tr>");
44 | 2 | buf.append("<td>" + ruleName + "</td>");
45 | 2 | buf.append("<td align=center>" + ((Integer) entry.getValue()).intValue() + "</td>");
46 | 2 | buf.append("</tr>");
47 | 2 | writer.write(buf.toString());
48 |  | }
49 | 4 | writer.write("</table>");
50 |  | }
51 |  | }