Clover coverage report - PMD - 3.7
Coverage timestamp: Wed May 31 2006 09:25:59 EDT

file stats: | LOC: | 82 |  | Methods: | 12
| NCLOC: | 61 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL

TokenEntry.java

100%

100%

100%

100%

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 | TokenEntry other = (TokenEntry) o;
75 | 22 | return other.hashCode == hashCode;
76 |  | }
77 |  |
78 | 18 | public int compareTo(Object o) {
79 | 18 | TokenEntry other = (TokenEntry) o;
80 | 18 | return getIndex() - other.getIndex();
81 |  | }
82 |  | }