Clover coverage report - PMD - 3.7
Coverage timestamp: Wed May 31 2006 09:25:59 EDT

file stats: | LOC: | 48 |  | Methods: | 1
| NCLOC: | 38 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL

XMLRenderer.java

83.3%

100%

100%

97.1%

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 |  | import net.sourceforge.pmd.util.StringUtil;
8 |  |
9 |  | import java.util.Iterator;
10 |  |
11 |  | /**
12 |  | * @author Philippe T'Seyen
13 |  | */
14 |  | public class XMLRenderer implements Renderer {
15 | 3 | public String render(Iterator matches) {
16 | 3 | StringBuffer buffer = new StringBuffer();
17 | 3 | buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
18 | 3 | buffer.append("<pmd-cpd>" + PMD.EOL);
19 | 3 | for (; matches.hasNext();) {
20 | 3 | Match match = (Match) matches.next();
21 | 3 | buffer.append("<duplication");
22 | 3 | buffer.append(" lines=\"");
23 | 3 | buffer.append(match.getLineCount());
24 | 3 | buffer.append("\"");
25 | 3 | buffer.append(" tokens=\"");
26 | 3 | buffer.append(match.getTokenCount());
27 | 3 | buffer.append("\">" + PMD.EOL);
28 |  |
29 | 3 | for (Iterator iterator = match.iterator(); iterator.hasNext();) {
30 | 6 | TokenEntry mark = (TokenEntry) iterator.next();
31 | 6 | buffer.append("<file");
32 | 6 | buffer.append(" line=\"");
33 | 6 | buffer.append(mark.getBeginLine());
34 | 6 | buffer.append("\"");
35 | 6 | buffer.append(" path=\"");
36 | 6 | buffer.append(mark.getTokenSrcID());
37 | 6 | buffer.append("\"/>" + PMD.EOL);
38 |  | }
39 | 3 | String codeFragment = match.getSourceCodeSlice();
40 | 3 | if (codeFragment != null) {
41 | 3 | buffer.append("<codefragment>" + PMD.EOL + "<![CDATA[" + PMD.EOL + StringUtil.replaceString(codeFragment, "]]>", "]]&gt;") + PMD.EOL + "]]>" + PMD.EOL + "</codefragment>" + PMD.EOL);
42 |  | }
43 | 3 | buffer.append("</duplication>" + PMD.EOL);
44 |  | }
45 | 3 | buffer.append("</pmd-cpd>");
46 | 3 | return buffer.toString();
47 |  | }
48 |  | }