summaryrefslogtreecommitdiffstats
path: root/text/src
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-04-22 13:38:42 -0700
committerElliott Hughes <enh@google.com>2010-04-22 14:00:53 -0700
commita7d4139bed693bf6037bf5f7f49a24b077102adc (patch)
treedb9d78c4a6cc9478a88996acd08f7b19be0cba48 /text/src
parent5779f05dd67ea322017c4ceb45270f5c6969d6b5 (diff)
downloadlibcore-a7d4139bed693bf6037bf5f7f49a24b077102adc.zip
libcore-a7d4139bed693bf6037bf5f7f49a24b077102adc.tar.gz
libcore-a7d4139bed693bf6037bf5f7f49a24b077102adc.tar.bz2
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
Diffstat (limited to 'text/src')
-rw-r--r--text/src/main/java/java/text/RuleBasedCollator.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/text/src/main/java/java/text/RuleBasedCollator.java b/text/src/main/java/java/text/RuleBasedCollator.java
index 77492b5..0955f89 100644
--- a/text/src/main/java/java/text/RuleBasedCollator.java
+++ b/text/src/main/java/java/text/RuleBasedCollator.java
@@ -269,15 +269,14 @@ public class RuleBasedCollator extends Collator {
* the result of a former {@link #getRules()} call.
* <p>
* Note that the {@code rules} are actually interpreted as a delta to the
- * standard Unicode Collation Algorithm (UCA). Hence, an empty {@code rules}
- * string results in the default UCA rules being applied. This differs
+ * standard Unicode Collation Algorithm (UCA). This differs
* slightly from other implementations which work with full {@code rules}
* specifications and may result in different behavior.
*
* @param rules
* the collation rules.
* @throws NullPointerException
- * if {@code rules} is {@code null}.
+ * if {@code rules == null}.
* @throws ParseException
* if {@code rules} contains rules with invalid collation rule
* syntax.
@@ -286,6 +285,9 @@ public class RuleBasedCollator extends Collator {
if (rules == null) {
throw new NullPointerException();
}
+ if (rules.isEmpty()) {
+ throw new ParseException("empty rules", 0);
+ }
try {
this.icuColl = new com.ibm.icu4jni.text.RuleBasedCollator(rules);
this.icuColl.setDecomposition(com.ibm.icu4jni.text.Collator.CANONICAL_DECOMPOSITION);
@@ -310,8 +312,7 @@ public class RuleBasedCollator extends Collator {
* the source character iterator.
* @return a {@code CollationElementIterator} for {@code source}.
*/
- public CollationElementIterator getCollationElementIterator(
- CharacterIterator source) {
+ public CollationElementIterator getCollationElementIterator(CharacterIterator source) {
if (source == null) {
throw new NullPointerException();
}