1 package net.sourceforge.pmd.cpd;
2
3 import java.util.ArrayList;
4 import java.util.Iterator;
5 import java.util.List;
6
7 public class Match implements Comparable {
8
9 private int tokenCount;
10 private int lineCount;
11 private List marks = new ArrayList();
12 private String code;
13
14 public Match(int tokenCount) {
15 this.tokenCount = tokenCount;
16 }
17
18 public Match(int tokenCount, Mark first, Mark second) {
19 marks.add(first);
20 marks.add(second);
21 this.tokenCount = tokenCount;
22 }
23
24 public void add(Mark mark) {
25 marks.add(mark);
26 }
27
28 public int getMarkCount() {
29 return this.marks.size();
30 }
31
32 public void setLineCount(int lineCount) {
33 this.lineCount = lineCount;
34 }
35
36 public int getLineCount() {
37 return this.lineCount;
38 }
39
40 public int getTokenCount() {
41 return this.tokenCount;
42 }
43
44 public String getSourceCodeSlice() {
45 return this.code;
46 }
47
48 public void setSourceCodeSlice(String code) {
49 this.code = code;
50 }
51
52 public Iterator iterator() {
53 return marks.iterator();
54 }
55
56 public int compareTo(Object o) {
57 Match other = (Match)o;
58 return other.getTokenCount() - this.getTokenCount();
59 }
60
61 public String toString() {
62 return "Match:\r\ntokenCount = " + tokenCount + "\r\nmark1 = " + marks.get(0) + "\r\nmark2 =" + marks.get(1);
63 }
64 }
This page was automatically generated by Maven