1
2
3
4 package net.sourceforge.pmd.renderers;
5
6 import java.io.IOException;
7 import java.util.Iterator;
8 import java.util.LinkedList;
9 import java.util.List;
10
11 import net.sourceforge.pmd.Report;
12 import net.sourceforge.pmd.RuleViolation;
13 import net.sourceforge.pmd.util.datasource.DataSource;
14
15
16
17
18
19
20
21
22
23
24
25
26 public abstract class AbstractIncrementingRenderer extends AbstractRenderer {
27
28
29
30
31 protected List<Report.ProcessingError> errors = new LinkedList<Report.ProcessingError>();
32
33
34
35
36 protected List<Report.SuppressedViolation> suppressed = new LinkedList<Report.SuppressedViolation>();
37
38 public AbstractIncrementingRenderer(String name, String description) {
39 super(name, description);
40 }
41
42
43
44
45 public void start() throws IOException {
46 }
47
48
49
50
51 public void startFileAnalysis(DataSource dataSource) {
52 }
53
54
55
56
57 public void renderFileReport(Report report) throws IOException {
58 Iterator<RuleViolation> violations = report.iterator();
59 if (violations.hasNext()) {
60 renderFileViolations(violations);
61 getWriter().flush();
62 }
63
64 for (Iterator<Report.ProcessingError> i = report.errors(); i.hasNext();) {
65 errors.add(i.next());
66 }
67
68 if (showSuppressedViolations) {
69 suppressed.addAll(report.getSuppressedRuleViolations());
70 }
71 }
72
73
74
75
76
77
78 public abstract void renderFileViolations(Iterator<RuleViolation> violations) throws IOException;
79
80
81
82
83 public void end() throws IOException {
84 }
85 }