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