View Javadoc

1   /***
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.cpd;
5   
6   import net.sourceforge.pmd.PMD;
7   
8   import java.util.Iterator;
9   
10  public class SimpleRenderer implements Renderer {
11  
12      public String render(Iterator matches) {
13          StringBuffer rpt = new StringBuffer();
14          while (matches.hasNext()) {
15              Match match = (Match) matches.next();
16              rpt.append("=====================================================================" + PMD.EOL);
17              rpt.append("Found a " + match.getLineCount() + " line (" + match.getTokenCount() + " tokens) duplication in the following files: " + PMD.EOL);
18              for (Iterator occurrences = match.iterator(); occurrences.hasNext();) {
19                  TokenEntry mark = (TokenEntry) occurrences.next();
20                  rpt.append("Starting at line " + mark.getBeginLine() + " of " + mark.getTokenSrcID() + PMD.EOL);
21              }
22              rpt.append(match.getSourceCodeSlice() + PMD.EOL);
23          }
24          return rpt.toString();
25      }
26  }