01: package org.acm.seguin.pmd.renderers;
02:
03: import org.acm.seguin.pmd.PMD;
04: import org.acm.seguin.pmd.Report;
05: import org.acm.seguin.pmd.RuleViolation;
06:
07: import java.util.Iterator;
08:
09: public class TextRenderer implements Renderer {
10: public String render(Report report) {
11: if (report.isEmpty()) {
12: return "No problems found!";
13: }
14: StringBuffer buf = new StringBuffer();
15: for (Iterator i = report.iterator(); i.hasNext();) {
16: RuleViolation rv = (RuleViolation) i.next();
17: buf.append(PMD.EOL + rv.getFilename());
18: buf.append("\t" + Integer.toString(rv.getLine()));
19: buf.append("\t" + rv.getDescription());
20: }
21: for (Iterator i = report.errors(); i.hasNext();) {
22: Report.ProcessingError error = (Report.ProcessingError) i
23: .next();
24: buf.append(PMD.EOL + error.getFile());
25: buf.append("\t-");
26: buf.append("\t" + error.getMsg());
27: }
28: return buf.toString();
29: }
30: }
|