use of android.icu.impl.coll.CollationTailoring in project j2objc by google.
the class CollatorServiceShim method makeInstance.
// Ported from C++ Collator::makeInstance().
private static final Collator makeInstance(ULocale desiredLocale) {
Output<ULocale> validLocale = new Output<ULocale>(ULocale.ROOT);
CollationTailoring t = CollationLoader.loadTailoring(desiredLocale, validLocale);
return new RuleBasedCollator(t, validLocale.value);
}
use of android.icu.impl.coll.CollationTailoring in project j2objc by google.
the class RuleBasedCollator method internalBuildTailoring.
/**
* Implements from-rule constructors.
* @param rules rule string
* @throws Exception
*/
private final void internalBuildTailoring(String rules) throws Exception {
CollationTailoring base = CollationRoot.getRoot();
// Most code using Collator does not need to build a Collator from rules.
// By using reflection, most code will not have a static dependency on the builder code.
// CollationBuilder builder = new CollationBuilder(base);
ClassLoader classLoader = ClassLoaderUtil.getClassLoader(getClass());
CollationTailoring t;
try {
Class<?> builderClass = classLoader.loadClass("android.icu.impl.coll.CollationBuilder");
Object builder = builderClass.getConstructor(CollationTailoring.class).newInstance(base);
// builder.parseAndBuild(rules);
Method parseAndBuild = builderClass.getMethod("parseAndBuild", String.class);
t = (CollationTailoring) parseAndBuild.invoke(builder, rules);
} catch (InvocationTargetException e) {
throw (Exception) e.getTargetException();
}
t.actualLocale = null;
adoptTailoring(t);
}
Aggregations