Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 85 |  | Methods: | 12
| NCLOC: | 64 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
TokenEntry.java | 75% | 96.2% | 100% | 95.2% |

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.HashMap;
7 |  | import java.util.Map;
8 |  |
9 |  | public class TokenEntry implements Comparable {
10 |  |
11 |  | public static final TokenEntry EOF = new TokenEntry();
12 |  |
13 |  | private String tokenSrcID;
14 |  | private int beginLine;
15 |  | private int index;
16 |  | private int identifier;
17 |  | private int hashCode;
18 |  |
19 |  | private final static Map Tokens = new HashMap();
20 |  | private static int TokenCount = 0;
21 |  |
22 | 8 | private TokenEntry() {
23 | 8 | this.identifier = 0;
24 | 8 | this.tokenSrcID = "EOFMarker";
25 |  | }
26 |  |
27 | 243 | public TokenEntry(String image, String tokenSrcID, int beginLine) {
28 | 243 | Integer i = (Integer) Tokens.get(image);
29 | 243 | if (i == null) {
30 | 109 | i = new Integer(Tokens.size() + 1);
31 | 109 | Tokens.put(image, i);
32 |  | }
33 | 243 | this.identifier = i.intValue();
34 | 243 | this.tokenSrcID = tokenSrcID;
35 | 243 | this.beginLine = beginLine;
36 | 243 | this.index = TokenCount++;
37 |  | }
38 |  |
39 | 13 | public static TokenEntry getEOF() {
40 | 13 | TokenCount++;
41 | 13 | return EOF;
42 |  | }
43 |  |
44 | 3 | public static void clearImages() {
45 | 3 | Tokens.clear();
46 | 3 | TokenCount = 0;
47 |  | }
48 |  |
49 | 19 | public String getTokenSrcID() {
50 | 19 | return tokenSrcID;
51 |  | }
52 |  |
53 | 21 | public int getBeginLine() {
54 | 21 | return beginLine;
55 |  | }
56 |  |
57 | 292 | public int getIdentifier() {
58 | 292 | return this.identifier;
59 |  | }
60 |  |
61 | 332 | public int getIndex() {
62 | 332 | return this.index;
63 |  | }
64 |  |
65 | 200 | public int hashCode() {
66 | 200 | return hashCode;
67 |  | }
68 |  |
69 | 72 | public void setHashCode(int hashCode) {
70 | 72 | this.hashCode = hashCode;
71 |  | }
72 |  |
73 | 22 | public boolean equals(Object o) {
74 | 22 | if (!(o instanceof TokenEntry)) {
75 | 0 | return false;
76 |  | }
77 | 22 | TokenEntry other = (TokenEntry) o;
78 | 22 | return other.hashCode == hashCode;
79 |  | }
80 |  |
81 | 18 | public int compareTo(Object o) {
82 | 18 | TokenEntry other = (TokenEntry) o;
83 | 18 | return getIndex() - other.getIndex();
84 |  | }
85 |  | }