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   public class Mark implements Comparable<Mark> {
7       private TokenEntry token;
8       private int lineCount;
9       private String code;
10  
11      public Mark(TokenEntry token) {
12          this.token = token;
13      }
14  
15      public TokenEntry getToken() {
16          return this.token;
17      }
18  
19      public String getFilename () {
20          return this.token.getTokenSrcID();
21      }
22  
23      public int getBeginLine () {
24          return this.token.getBeginLine();
25      }
26  
27  	public int getEndLine() {
28          return getBeginLine() + getLineCount() - 1;
29      }
30  
31      public int getLineCount() {
32          return this.lineCount;
33      }
34  
35      public void setLineCount(int lineCount) {
36          this.lineCount = lineCount;
37      }
38  
39      public String getSourceCodeSlice() {
40          return this.code;
41      }
42  
43      public void setSoureCodeSlice(String code) {
44          this.code = code;
45      }
46  
47      @Override
48      public int hashCode() {
49          final int prime = 31;
50          int result = 1;
51          result = prime * result + ((token == null) ? 0 : token.hashCode());
52          return result;
53      }
54  
55      @Override
56      public boolean equals(Object obj) {
57          if (this == obj) {
58              return true;
59          }
60          if (obj == null) {
61              return false;
62          }
63          if (getClass() != obj.getClass()) {
64              return false;
65          }
66          Mark other = (Mark) obj;
67          if (token == null) {
68              if (other.token != null) {
69                  return false;
70              }
71          } else if (!token.equals(other.token)) {
72              return false;
73          }
74          return true;
75      }
76  
77      @Override
78      public int compareTo(Mark other) {
79         return getToken().compareTo(other.getToken());
80      }
81  }