1
2
3
4
5
6
7
8
9
10
11 package psiprobe.tokenizer;
12
13 import java.util.Objects;
14
15
16
17
18 public class TokenizerSymbol implements Comparable<Object> {
19
20
21 final String name;
22
23
24 final String startText;
25
26
27 final String tailText;
28
29
30 final boolean hidden;
31
32
33 final boolean decodePaired;
34
35
36 final boolean enabled;
37
38
39 final boolean canBeNested;
40
41
42
43
44
45
46
47
48
49
50
51
52 public TokenizerSymbol(String name, String startText, String tailText, boolean hidden,
53 boolean decodePaired, boolean enabled, boolean canBeNested) {
54
55 this.name = name;
56 this.startText = startText;
57 this.tailText = tailText;
58 this.hidden = hidden;
59 this.decodePaired = decodePaired;
60 this.enabled = enabled;
61 this.canBeNested = canBeNested;
62 }
63
64 @Override
65 public int compareTo(Object obj) {
66 if (obj instanceof Character) {
67 return compareTo((Character) obj);
68 }
69 return compareTo((TokenizerSymbol) obj);
70 }
71
72
73
74
75
76
77
78
79 public int compareTo(Character chr) {
80 return chr - startText.charAt(0);
81 }
82
83
84
85
86
87
88
89
90 public int compareTo(TokenizerSymbol symbol) {
91 return symbol.startText.compareTo(startText);
92 }
93
94 @Override
95 public int hashCode() {
96 return Objects.hash(this.name, this.startText, this.tailText, this.hidden, this.decodePaired,
97 this.enabled, this.canBeNested);
98 }
99
100 @Override
101 public boolean equals(Object obj) {
102 if (obj == null || getClass() != obj.getClass()) {
103 return false;
104 }
105 final TokenizerSymbol other = (TokenizerSymbol) obj;
106 return Objects.equals(this.name, other.name) && Objects.equals(this.startText, other.startText)
107 && Objects.equals(this.tailText, other.tailText) && this.hidden == other.hidden
108 && this.decodePaired == other.decodePaired && this.enabled == other.enabled
109 && this.canBeNested == other.canBeNested;
110 }
111
112 }