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

This page was automatically generated by Maven