From: Yoshito Umaoka Date: Fri, 16 Nov 2012 23:16:12 +0000 (+0000) Subject: ICU-9668 Updated the spec of ULocale#equals. The modified implementation never return... X-Git-Tag: milestone-59-0-1~3314 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63b30dc4c1e612e04701b88922e512006f8a397d;p=icu ICU-9668 Updated the spec of ULocale#equals. The modified implementation never returns true when the argument is String. X-SVN-Rev: 32859 --- diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundle.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundle.java index 748ec3966ba..8a681404f7c 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundle.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundle.java @@ -882,7 +882,7 @@ public class ICUResourceBundle extends UResourceBundle { if (i != -1) { String temp = localeName.substring(0, i); b = (ICUResourceBundle)instantiateBundle(baseName, temp, root, disableFallback); - if(b!=null && b.getULocale().equals(temp)){ + if(b!=null && b.getULocale().getName().equals(temp)){ b.setLoadingStatus(ICUResourceBundle.FROM_FALLBACK); } }else{ diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java index f9346fcc904..505ae400011 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java @@ -758,7 +758,7 @@ public final class ULocale implements Serializable { /** * Returns true if the other object is another ULocale with the - * same full name, or is a String localeID that matches the full name. + * same full name. * Note that since names are not canonicalized, two ULocales that * function identically might not compare equal. * @@ -769,9 +769,6 @@ public final class ULocale implements Serializable { if (this == obj) { return true; } - if (obj instanceof String) { - return localeID.equals((String)obj); - } if (obj instanceof ULocale) { return localeID.equals(((ULocale)obj).localeID); } diff --git a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java index 1d1d319a74b..fee425993e3 100644 --- a/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java +++ b/icu4j/main/tests/collate/src/com/ibm/icu/dev/test/util/ICUResourceBundleCollationTest.java @@ -92,7 +92,7 @@ public final class ICUResourceBundleCollationTest extends TestFmwk { try{ bundle = (ICUResourceBundle) UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_COLLATION_BASE_NAME,ULocale.canonicalize("de__PHONEBOOK")); - if(!bundle.getULocale().equals("de")){ + if(!bundle.getULocale().getName().equals("de")){ errln("did not get the expected bundle"); } key = bundle.getStringWithFallback("collations/collation/default"); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java index 530fc04182b..3c1f843ee39 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ICUResourceBundleTest.java @@ -92,7 +92,7 @@ public final class ICUResourceBundleTest extends TestFmwk { } bundle = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, "bogus"); - if(bundle instanceof UResourceBundle && bundle.getULocale().equals("en_US")){ + if(bundle instanceof UResourceBundle && bundle.getULocale().getName().equals("en_US")){ logln("wrapper mechanism works for bogus locale"); }else{ errln("wrapper mechanism failed for bogus locale."); diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java index 01e8633cc4e..93fb166da73 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java @@ -960,7 +960,7 @@ public class ULocaleTest extends TestFmwk { if(locales.length<10){ errln("Did not get the correct result from getAvailableLocales"); } - if(!locales[locales.length-1].equals("zu_ZA")){ + if(!locales[locales.length-1].getName().equals("zu_ZA")){ errln("Did not get the expected result"); } }