CollationKey.java
2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.agl.text;
import com.adobe.agl.text.RawCollationKey;
public final class CollationKey
implements Comparable {
private byte[] m_key_;
private String m_source_;
private int m_hashCode_;
private int m_length_;
public CollationKey(String source, RawCollationKey key) {
this.m_source_ = source;
this.m_key_ = key.releaseBytes();
this.m_hashCode_ = 0;
this.m_length_ = -1;
}
public String getSourceString() {
return this.m_source_;
}
public int compareTo(CollationKey target) {
int i = 0;
int r;
int l;
while ((l = this.m_key_[i] & 255) >= (r = target.m_key_[i] & 255)) {
if (l > r) {
return 1;
}
if (l == 0) {
return 0;
}
++i;
}
return -1;
}
public int compareTo(Object obj) {
return this.compareTo((CollationKey)obj);
}
public boolean equals(Object target) {
if (!(target instanceof CollationKey)) {
return false;
}
return this.equals((CollationKey)target);
}
public boolean equals(CollationKey target) {
if (this == target) {
return true;
}
if (target == null) {
return false;
}
CollationKey other = target;
int i = 0;
do {
if (this.m_key_[i] != other.m_key_[i]) {
return false;
}
if (this.m_key_[i] == 0) break;
++i;
} while (true);
return true;
}
public int hashCode() {
if (this.m_hashCode_ == 0) {
if (this.m_key_ == null) {
this.m_hashCode_ = 1;
} else {
int size = this.m_key_.length >> 1;
StringBuffer key = new StringBuffer(size);
int i = 0;
while (this.m_key_[i] != 0 && this.m_key_[i + 1] != 0) {
key.append((char)(this.m_key_[i] << 8 | this.m_key_[i + 1]));
i += 2;
}
if (this.m_key_[i] != 0) {
key.append((char)(this.m_key_[i] << 8));
}
this.m_hashCode_ = key.toString().hashCode();
}
}
return this.m_hashCode_;
}
}