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

This page was automatically generated by Maven