CollatorServiceShim.java
3.9 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.agl.text;
import com.adobe.agl.impl.ICULocaleService;
import com.adobe.agl.impl.ICUResourceBundle;
import com.adobe.agl.impl.ICUService;
import com.adobe.agl.text.Collator;
import com.adobe.agl.text.RuleBasedCollator;
import com.adobe.agl.util.ULocale;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.Set;
final class CollatorServiceShim
extends Collator.ServiceShim {
private static ICULocaleService service = new CService();
CollatorServiceShim() {
}
Collator getInstance(ULocale locale) {
try {
ULocale[] actualLoc = new ULocale[1];
Collator coll = (Collator)service.get(locale, actualLoc);
if (coll == null) {
throw new MissingResourceException("Could not locate Collator data", "", "");
}
coll = (Collator)coll.clone();
coll.setLocale(actualLoc[0], actualLoc[0]);
return coll;
}
catch (CloneNotSupportedException e) {
throw new IllegalStateException(e.getMessage());
}
}
Object registerInstance(Collator collator, ULocale locale) {
return service.registerObject(collator, locale);
}
Object registerFactory(Collator.CollatorFactory f) {
class CFactory
extends ICULocaleService.LocaleKeyFactory {
Collator.CollatorFactory delegate;
CFactory(Collator.CollatorFactory fctry) {
super(fctry.visible());
this.delegate = fctry;
}
public Object handleCreate(ULocale loc, int kind, ICUService srvc) {
Collator coll = this.delegate.createCollator(loc);
return coll;
}
public String getDisplayName(String id, ULocale displayLocale) {
ULocale objectLocale = new ULocale(id);
return this.delegate.getDisplayName(objectLocale, displayLocale);
}
public Set getSupportedIDs() {
return this.delegate.getSupportedLocaleIDs();
}
}
return service.registerFactory(new CFactory(f));
}
boolean unregister(Object registryKey) {
return service.unregisterFactory((ICUService.Factory)registryKey);
}
Locale[] getAvailableLocales() {
if (service.isDefault()) {
return ICUResourceBundle.getAvailableLocales("com/adobe/agl/impl/data/icudt40b/coll");
}
return service.getAvailableLocales();
}
ULocale[] getAvailableULocales() {
if (service.isDefault()) {
return ICUResourceBundle.getAvailableULocales("com/adobe/agl/impl/data/icudt40b/coll");
}
return service.getAvailableULocales();
}
String getDisplayName(ULocale objectLocale, ULocale displayLocale) {
String id = objectLocale.getName();
return service.getDisplayName(id, displayLocale);
}
private static class CService
extends ICULocaleService {
CService() {
class CollatorFactory
extends ICULocaleService.ICUResourceBundleFactory {
CollatorFactory() {
super("com/adobe/agl/impl/data/icudt40b/coll");
}
protected Object handleCreate(ULocale uloc, int kind, ICUService srvc) {
return new RuleBasedCollator(uloc);
}
}
super("Collator");
this.registerFactory(new CollatorFactory());
this.markDefault();
}
protected Object handleDefault(ICUService.Key key, String[] actualIDReturn) {
if (actualIDReturn != null) {
actualIDReturn[0] = "root";
}
try {
return new RuleBasedCollator(ULocale.ROOT);
}
catch (MissingResourceException e) {
return null;
}
}
}
}