diff options
author | Elliott Hughes <enh@google.com> | 2010-04-23 18:06:45 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2010-04-23 18:06:45 -0700 |
commit | 633d446a21eaceecc0948893769f82163f1cb1e5 (patch) | |
tree | e08da4ecf7f51e3a3d0eee7b679546c91bed0b99 /src/com/android/providers/contacts/NameNormalizer.java | |
parent | 80d7871ca31d604cbfd857661d5300bb090076db (diff) | |
download | packages_providers_ContactsProvider-633d446a21eaceecc0948893769f82163f1cb1e5.zip packages_providers_ContactsProvider-633d446a21eaceecc0948893769f82163f1cb1e5.tar.gz packages_providers_ContactsProvider-633d446a21eaceecc0948893769f82163f1cb1e5.tar.bz2 |
Start weaning NameNormalizer off icu4jni implementation details.
Minor reshuffling necessary to keep building with the Java 6 API changes
post-froyo. This is compatible with the Java 5 API, and needs only an import
change to be compatible with the Java 6 API.
Ideally, this class should only be using public API, but I don't think
anyone has time for that right now.
Bug: 2417080
Change-Id: I40ac70a62ccf0a096a5635cc0499699b8bb69498
Diffstat (limited to 'src/com/android/providers/contacts/NameNormalizer.java')
-rw-r--r-- | src/com/android/providers/contacts/NameNormalizer.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/com/android/providers/contacts/NameNormalizer.java b/src/com/android/providers/contacts/NameNormalizer.java index f40a632..6dfe8bd 100644 --- a/src/com/android/providers/contacts/NameNormalizer.java +++ b/src/com/android/providers/contacts/NameNormalizer.java @@ -16,8 +16,10 @@ package com.android.providers.contacts; import com.ibm.icu4jni.text.CollationAttribute; +import com.ibm.icu4jni.text.CollationKey; // TODO: java.text.CollationKey post-froyo import com.ibm.icu4jni.text.Collator; import com.ibm.icu4jni.text.RuleBasedCollator; +import java.util.Locale; /** * Converts a name to a normalized form by removing all non-letter characters and normalizing @@ -27,14 +29,14 @@ public class NameNormalizer { private static final RuleBasedCollator sCompressingCollator; static { - sCompressingCollator = (RuleBasedCollator)Collator.getInstance(null); + sCompressingCollator = (RuleBasedCollator)Collator.getInstance(Locale.getDefault()); sCompressingCollator.setStrength(Collator.PRIMARY); sCompressingCollator.setDecomposition(Collator.CANONICAL_DECOMPOSITION); } private static final RuleBasedCollator sComplexityCollator; static { - sComplexityCollator = (RuleBasedCollator)Collator.getInstance(null); + sComplexityCollator = (RuleBasedCollator)Collator.getInstance(Locale.getDefault()); sComplexityCollator.setStrength(Collator.TERTIARY); sComplexityCollator.setAttribute(CollationAttribute.CASE_FIRST, CollationAttribute.VALUE_LOWER_FIRST); @@ -45,7 +47,8 @@ public class NameNormalizer { * of names. It ignores non-letter characters and removes accents. */ public static String normalize(String name) { - return Hex.encodeHex(sCompressingCollator.getSortKey(lettersAndDigitsOnly(name)), true); + CollationKey key = sCompressingCollator.getCollationKey(lettersAndDigitsOnly(name)); + return Hex.encodeHex(key.toByteArray(), true); } /** |