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 CSVRenderer implements Renderer { 11 public String render(Report report) { 12 StringBuffer buf = new StringBuffer(quoteAndCommify("Problem")); 13 buf.append(quoteAndCommify("File")); 14 buf.append(quoteAndCommify("Line")); 15 buf.append(quote("Description")); 16 buf.append(PMD.EOL); 17 18 int violationCount = 1; 19 for (Iterator i = report.iterator(); i.hasNext();) { 20 RuleViolation rv = (RuleViolation) i.next(); 21 buf.append(quoteAndCommify(Integer.toString(violationCount))); 22 buf.append(quoteAndCommify(rv.getFilename())); 23 buf.append(quoteAndCommify(Integer.toString(rv.getLine()))); 24 buf.append(quote(StringUtil.replaceString(rv.getDescription(), '\"', "'"))); 25 buf.append(PMD.EOL); 26 violationCount++; 27 } 28 return buf.toString(); 29 } 30 31 private String quote(String d) { 32 return "\"" + d + "\""; 33 } 34 35 private String quoteAndCommify(String d) { 36 return quote(d) + ","; 37 } 38 39 }

This page was automatically generated by Maven