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 import net.sourceforge.pmd.util.StringUtil; 10 11 import java.util.Iterator; 12 13 public class HTMLRenderer implements Renderer { 14 15 public String render(Report report) { 16 StringBuffer buf = new StringBuffer("<html><head><title>PMD</title></head><body>" + PMD.EOL + "<table align=\"center\" cellspacing=\"0\" cellpadding=\"3\"><tr>" + PMD.EOL + "<th>#</th><th>File</th><th>Line</th><th>Problem</th></tr>" + PMD.EOL); 17 boolean colorize = true; 18 int violationCount = 1; 19 for (Iterator i = report.iterator(); i.hasNext();) { 20 RuleViolation rv = (RuleViolation) i.next(); 21 buf.append("<tr"); 22 if (colorize) { 23 buf.append(" bgcolor=\"lightgrey\""); 24 colorize = false; 25 } else { 26 colorize = true; 27 } 28 buf.append("> " + PMD.EOL); 29 buf.append("<td align=\"center\">" + violationCount + "</td>" + PMD.EOL); 30 buf.append("<td width=\"*%\">" + rv.getFilename() + "</td>" + PMD.EOL); 31 buf.append("<td align=\"center\" width=\"5%\">" + Integer.toString(rv.getLine()) + "</td>" + PMD.EOL); 32 33 String d = rv.getDescription(); 34 d = StringUtil.replaceString(d, '&', "&"); 35 d = StringUtil.replaceString(d, '<', "<"); 36 d = StringUtil.replaceString(d, '>', ">"); 37 buf.append("<td width=\"*\">" + d + "</td>" + PMD.EOL); 38 39 buf.append("</tr>" + PMD.EOL); 40 41 violationCount++; 42 } 43 buf.append("</table></body></html>"); 44 return buf.toString(); 45 } 46 }

This page was automatically generated by Maven