01: package org.acm.seguin.pmd.cpd;
02:
03: import org.acm.seguin.pmd.PMD;
04:
05: import java.util.Iterator;
06:
07: public class SimpleRenderer implements Renderer {
08:
09: public String render(Iterator matches) {
10: StringBuffer rpt = new StringBuffer();
11: while (matches.hasNext()) {
12: Match match = (Match) matches.next();
13: rpt
14: .append("====================================================================="
15: + PMD.EOL);
16: rpt.append("Found a " + match.getLineCount() + " line ("
17: + match.getTokenCount()
18: + " tokens) duplication in the following files: "
19: + PMD.EOL);
20: for (Iterator occurrences = match.iterator(); occurrences
21: .hasNext();) {
22: Mark mark = (Mark) occurrences.next();
23: rpt.append("Starting at line " + mark.getBeginLine()
24: + " of " + mark.getTokenSrcID() + PMD.EOL);
25: }
26: rpt.append(match.getSourceCodeSlice() + PMD.EOL);
27: }
28: return rpt.toString();
29: }
30: }
|