From a7d4139bed693bf6037bf5f7f49a24b077102adc Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 22 Apr 2010 13:38:42 -0700 Subject: java.text.RuleBasedCollator fixes. Add expectations for broken harmony tests, add our own equivalent (but correct) tets, and fix the bug turned up by the correct tests: the icu4jni RuleBasedCollator was using toString to convert a CharacterIterator to a String, resulting in iteration over the result of Object.toString (the class name and identity hash code) rather than the characters of interest. Also shut javac up about non-ASCII characters in Locale.java. Bug: 2608742 Bug: 2608750 Change-Id: I2171789058c8116eacd7e5815bd483f0bc07c69b --- .../main/java/com/ibm/icu4jni/text/RuleBasedCollator.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'icu/src') diff --git a/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedCollator.java b/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedCollator.java index a87c978..3135daa 100644 --- a/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedCollator.java +++ b/icu/src/main/java/com/ibm/icu4jni/text/RuleBasedCollator.java @@ -516,8 +516,17 @@ public final class RuleBasedCollator extends Collator { return result; } - public CollationElementIterator getCollationElementIterator(CharacterIterator source) { - return getCollationElementIterator(source.toString()); + public CollationElementIterator getCollationElementIterator(CharacterIterator it) { + // We only implement the String-based API, so build a string from the iterator. + return getCollationElementIterator(characterIteratorToString(it)); + } + + private String characterIteratorToString(CharacterIterator it) { + StringBuilder result = new StringBuilder(); + for (char ch = it.current(); ch != CharacterIterator.DONE; ch = it.next()) { + result.append(ch); + } + return result.toString(); } /** -- cgit v1.1