01: package org.acm.seguin.pmd.cpd;
02:
03: import org.acm.seguin.pmd.PMD;
04:
05: import java.io.Serializable;
06: import java.util.List;
07:
08: public class SourceCode implements Serializable {
09:
10: private String fileName;
11: private List code;
12:
13: public SourceCode(String fileName) {
14: this .fileName = fileName;
15: }
16:
17: public void setCode(List newCode) {
18: code = newCode;
19: }
20:
21: public String getSlice(int startLine, int endLine) {
22: StringBuffer sb = new StringBuffer();
23: for (int i = startLine; i <= endLine && i < code.size(); i++) {
24: if (sb.length() != 0) {
25: sb.append(PMD.EOL);
26: }
27: sb.append((String) code.get(i));
28: }
29: return sb.toString();
30: }
31:
32: public String getFileName() {
33: return fileName;
34: }
35:
36: public boolean equals(Object other) {
37: SourceCode o = (SourceCode) other;
38: return o.fileName.equals(fileName);
39: }
40:
41: public int hashCode() {
42: return fileName.hashCode();
43: }
44: }
|