1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.commons.pkg;
21
22 public abstract class AbstractToken implements Comparable
23 {
24
25 String token;
26
27 public AbstractToken(AbstractToken[] depends, String separator)
28 {
29
30 StringBuffer sb = new StringBuffer();
31 for (int i = 0; i < depends.length; i++) {
32 sb.append(depends[i].token);
33 if (i < depends.length - 1) {
34 sb.append(separator);
35 }
36 }
37
38 this.token = sb.toString();
39 }
40
41 public AbstractToken(String token)
42 {
43 this.token = token;
44 }
45
46 public AbstractToken()
47 {
48 }
49
50 public int compareTo(Object o)
51 {
52 AbstractToken t = (AbstractToken)o;
53 return token.compareTo(t.token);
54 }
55
56 public boolean equals(Object o)
57 {
58 if (o instanceof AbstractToken) {
59 return ((AbstractToken)o).token.equals(token);
60 }
61 return false;
62 }
63
64 public int hashCode()
65 {
66 return token.hashCode();
67 }
68
69 public String toString()
70 {
71 return token;
72 }
73
74 }
75