Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 108 |  | Methods: | 3
| NCLOC: | 85 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
VBHTMLRenderer.java | 88.9% | 95% | 100% | 93.8% |

1 |  | /**
2 |  | * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 |  | */
4 |  | package net.sourceforge.pmd.renderers;
5 |  |
6 |  | import net.sourceforge.pmd.IRuleViolation;
7 |  | import net.sourceforge.pmd.PMD;
8 |  | import net.sourceforge.pmd.Report;
9 |  |
10 |  | import java.io.IOException;
11 |  | import java.io.Writer;
12 |  | import java.util.Iterator;
13 |  |
14 |  | /**
15 |  | * @author Vladimir
16 |  | * @version $Revision: 1.15 $ $Date: 2006/11/19 02:01:35 $
17 |  | */
18 |  | public class VBHTMLRenderer extends AbstractRenderer {
19 |  |
20 | 5 | public void render(Writer writer, Report report) throws IOException {
21 | 5 | if (report.isEmpty()) {
22 | 1 | return;
23 |  | }
24 |  |
25 | 3 | StringBuffer sb = new StringBuffer();
26 | 3 | String filename = null;
27 | 3 | String lineSep = PMD.EOL;
28 |  |
29 | 3 | boolean colorize = false;
30 |  |
31 | 3 | writer.write(header());
32 | 3 | for (Iterator iter = report.iterator(); iter.hasNext();) {
33 | 3 | sb.setLength(0);
34 | 3 | IRuleViolation rv = (IRuleViolation) iter.next();
35 | 3 | if (!rv.getFilename().equals(filename)) { // New File
36 | 2 | if (filename != null) {
37 | 0 | sb.append("</table></br>");
38 | 0 | colorize = false;
39 |  | }
40 | 2 | filename = rv.getFilename();
41 | 2 | sb.append("<table border=\"0\" width=\"80%\">");
42 | 2 | sb.append("<tr id=TableHeader><td colspan=\"2\"><font class=title>&nbsp;").append(filename).append("</font></tr>");
43 | 2 | sb.append(lineSep);
44 |  | }
45 |  |
46 | 3 | if (colorize) {
47 | 1 | sb.append("<tr id=RowColor1>");
48 |  | } else {
49 | 2 | sb.append("<tr id=RowColor2>");
50 |  | }
51 |  |
52 | 3 | colorize = !colorize;
53 | 3 | sb.append("<td width=\"50\" align=\"right\"><font class=body>" + rv.getBeginLine() + "&nbsp;&nbsp;&nbsp;</font></td>");
54 | 3 | sb.append("<td><font class=body>" + rv.getDescription() + "</font></td>");
55 | 3 | sb.append("</tr>");
56 | 3 | sb.append(lineSep);
57 | 3 | writer.write(sb.toString());
58 |  | }
59 | 3 | if (filename != null) {
60 | 2 | writer.write("</table>");
61 |  | }
62 | 3 | writer.write("<br>");
63 |  |
64 |  | // output the problems
65 | 3 | Iterator iter = report.errors();
66 | 3 | if (iter.hasNext()) {
67 | 1 | sb.setLength(0);
68 | 1 | sb.append("<table border=\"0\" width=\"80%\">");
69 | 1 | sb.append("<tr id=TableHeader><td><font class=title>&nbsp;Problems found</font></td></tr>");
70 | 1 | colorize = false;
71 | 1 | while (iter.hasNext()) {
72 | 1 | if (colorize) {
73 | 0 | sb.append("<tr id=RowColor1>");
74 |  | } else {
75 | 1 | sb.append("<tr id=RowColor2>");
76 |  | }
77 | 1 | colorize = !colorize;
78 | 1 | sb.append("<td><font class=body>").append(iter.next()).append("\"</font></td></tr>");
79 |  | }
80 | 1 | sb.append("</table>");
81 | 1 | writer.write(sb.toString());
82 |  | }
83 |  |
84 | 3 | writer.write(footer());
85 |  | }
86 |  |
87 | 3 | private String header() {
88 | 3 | StringBuffer sb = new StringBuffer();
89 | 3 | sb.append("<html><head><title>PMD</title></head>");
90 | 3 | sb.append("<style type=\"text/css\">");
91 | 3 | sb.append("<!--" + PMD.EOL);
92 | 3 | sb.append("body { background-color: white; font-family:verdana, arial, helvetica, geneva; font-size: 16px; font-style: italic; color: black; }" + PMD.EOL);
93 | 3 | sb.append(".title { font-family: verdana, arial, helvetica,geneva; font-size: 12px; font-weight:bold; color: white; }" + PMD.EOL);
94 | 3 | sb.append(".body { font-family: verdana, arial, helvetica, geneva; font-size: 12px; font-weight:plain; color: black; }" + PMD.EOL);
95 | 3 | sb.append("#TableHeader { background-color: #003366; }" + PMD.EOL);
96 | 3 | sb.append("#RowColor1 { background-color: #eeeeee; }" + PMD.EOL);
97 | 3 | sb.append("#RowColor2 { background-color: white; }" + PMD.EOL);
98 | 3 | sb.append("-->");
99 | 3 | sb.append("</style>");
100 | 3 | sb.append("<body><center>");
101 | 3 | return sb.toString();
102 |  | }
103 |  |
104 | 3 | private String footer() {
105 | 3 | return "</center></body></html>";
106 |  | }
107 |  |
108 |  | }