Collator.java
8.16 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.agl.text;
import com.adobe.agl.impl.ICUDebug;
import com.adobe.agl.impl.ICUResourceBundle;
import com.adobe.agl.text.CollationKey;
import com.adobe.agl.text.RawCollationKey;
import com.adobe.agl.text.UnicodeSet;
import com.adobe.agl.util.ULocale;
import com.adobe.agl.util.VersionInfo;
import java.util.Comparator;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.Set;
public abstract class Collator
implements Cloneable,
Comparator {
public static final int PRIMARY = 0;
public static final int SECONDARY = 1;
public static final int TERTIARY = 2;
public static final int QUATERNARY = 3;
public static final int IDENTICAL = 15;
public static final int FULL_DECOMPOSITION = 15;
public static final int NO_DECOMPOSITION = 16;
public static final int CANONICAL_DECOMPOSITION = 17;
private static ServiceShim shim;
private static final String[] KEYWORDS;
private static final String RESOURCE = "collations";
private static final String BASE = "com/adobe/agl/impl/data/icudt40b/coll";
private int m_strength_ = 2;
private int m_decomposition_ = 17;
private static final boolean DEBUG;
private ULocale validLocale;
private ULocale actualLocale;
public void setStrength(int newStrength) {
if (newStrength != 0 && newStrength != 1 && newStrength != 2 && newStrength != 3 && newStrength != 15) {
throw new IllegalArgumentException("Incorrect comparison level.");
}
this.m_strength_ = newStrength;
}
public void setDecomposition(int decomposition) {
if (decomposition != 16 && decomposition != 17) {
throw new IllegalArgumentException("Wrong decomposition mode.");
}
this.m_decomposition_ = decomposition;
}
public static final Collator getInstance() {
return Collator.getInstance(ULocale.getDefault());
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
private static ServiceShim getShim() {
if (shim == null) {
try {
Class cls = Class.forName("com.adobe.agl.text.CollatorServiceShim");
shim = (ServiceShim)cls.newInstance();
}
catch (MissingResourceException e) {
throw e;
}
catch (Exception e) {
if (DEBUG) {
e.printStackTrace();
}
throw new RuntimeException(e.getMessage());
}
}
return shim;
}
public static final Collator getInstance(ULocale locale) {
return Collator.getShim().getInstance(locale);
}
public static final Collator getInstance(Locale locale) {
return Collator.getInstance(ULocale.forLocale(locale));
}
public static final Object registerInstance(Collator collator, ULocale locale) {
return Collator.getShim().registerInstance(collator, locale);
}
public static final Object registerFactory(CollatorFactory factory) {
return Collator.getShim().registerFactory(factory);
}
public static final boolean unregister(Object registryKey) {
if (shim == null) {
return false;
}
return shim.unregister(registryKey);
}
public static Locale[] getAvailableLocales() {
if (shim == null) {
return ICUResourceBundle.getAvailableLocales("com/adobe/agl/impl/data/icudt40b/coll");
}
return shim.getAvailableLocales();
}
public static final ULocale[] getAvailableULocales() {
if (shim == null) {
return ICUResourceBundle.getAvailableULocales("com/adobe/agl/impl/data/icudt40b/coll");
}
return shim.getAvailableULocales();
}
public static final String[] getKeywords() {
return KEYWORDS;
}
public static final String[] getKeywordValues(String keyword) {
if (!keyword.equals(KEYWORDS[0])) {
throw new IllegalArgumentException("Invalid keyword: " + keyword);
}
return ICUResourceBundle.getKeywordValues("com/adobe/agl/impl/data/icudt40b/coll", "collations");
}
public static final ULocale getFunctionalEquivalent(String keyword, ULocale locID, boolean[] isAvailable) {
return ICUResourceBundle.getFunctionalEquivalent("com/adobe/agl/impl/data/icudt40b/coll", "collations", keyword, locID, isAvailable, true);
}
public static final ULocale getFunctionalEquivalent(String keyword, ULocale locID) {
return Collator.getFunctionalEquivalent(keyword, locID, null);
}
public static String getDisplayName(Locale objectLocale, Locale displayLocale) {
return Collator.getShim().getDisplayName(ULocale.forLocale(objectLocale), ULocale.forLocale(displayLocale));
}
public static String getDisplayName(ULocale objectLocale, ULocale displayLocale) {
return Collator.getShim().getDisplayName(objectLocale, displayLocale);
}
public static String getDisplayName(Locale objectLocale) {
return Collator.getShim().getDisplayName(ULocale.forLocale(objectLocale), ULocale.getDefault());
}
public static String getDisplayName(ULocale objectLocale) {
return Collator.getShim().getDisplayName(objectLocale, ULocale.getDefault());
}
public int getStrength() {
return this.m_strength_;
}
public int getDecomposition() {
return this.m_decomposition_;
}
public int compare(Object source, Object target) {
if (!(source instanceof String) || !(target instanceof String)) {
throw new IllegalArgumentException("Arguments have to be of type String");
}
return this.compare((String)source, (String)target);
}
public boolean equals(String source, String target) {
return this.compare(source, target) == 0;
}
public UnicodeSet getTailoredSet() {
return new UnicodeSet(0, 1114111);
}
public abstract int compare(String var1, String var2);
public abstract CollationKey getCollationKey(String var1);
public abstract RawCollationKey getRawCollationKey(String var1, RawCollationKey var2);
public abstract int setVariableTop(String var1);
public abstract int getVariableTop();
public abstract void setVariableTop(int var1);
public abstract VersionInfo getVersion();
public abstract VersionInfo getUCAVersion();
protected Collator() {
}
public final ULocale getLocale(ULocale.Type type) {
return type == ULocale.ACTUAL_LOCALE ? this.actualLocale : this.validLocale;
}
final void setLocale(ULocale valid, ULocale actual) {
if (valid == null != (actual == null)) {
throw new IllegalArgumentException();
}
this.validLocale = valid;
this.actualLocale = actual;
}
static {
KEYWORDS = new String[]{"collation"};
DEBUG = ICUDebug.enabled("collator");
}
static abstract class ServiceShim {
ServiceShim() {
}
abstract Collator getInstance(ULocale var1);
abstract Object registerInstance(Collator var1, ULocale var2);
abstract Object registerFactory(CollatorFactory var1);
abstract boolean unregister(Object var1);
abstract Locale[] getAvailableLocales();
abstract ULocale[] getAvailableULocales();
abstract String getDisplayName(ULocale var1, ULocale var2);
}
public static abstract class CollatorFactory {
public boolean visible() {
return true;
}
public Collator createCollator(ULocale loc) {
return this.createCollator(loc.toLocale());
}
public Collator createCollator(Locale loc) {
return this.createCollator(ULocale.forLocale(loc));
}
public String getDisplayName(ULocale objectLocale, ULocale displayLocale) {
Set supported;
String name;
if (this.visible() && (supported = this.getSupportedLocaleIDs()).contains(name = objectLocale.getBaseName())) {
return objectLocale.getDisplayName(displayLocale);
}
return null;
}
public abstract Set getSupportedLocaleIDs();
}
}