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

This page was automatically generated by Maven