diff --git a/icu4j/src/com/ibm/icu/impl/ICULocaleService.java b/icu4j/src/com/ibm/icu/impl/ICULocaleService.java index 87e55bd1f2..e1c61806b0 100644 --- a/icu4j/src/com/ibm/icu/impl/ICULocaleService.java +++ b/icu4j/src/com/ibm/icu/impl/ICULocaleService.java @@ -72,7 +72,11 @@ public class ICULocaleService extends ICUService { * getKey (stripping any prefix) into a ULocale. */ public Object get(ULocale locale, int kind, ULocale[] actualReturn) { - Key key = createKey(locale.toString(), kind); + String name = locale.getName(); + if (name.length() > 0) { // arrgh, canonicalize turns "" into en_US_POSIX + name = ULocale.canonicalize(name); + } + Key key = createKey(name, kind); if (actualReturn == null) { return getKey(key); } @@ -186,6 +190,7 @@ public class ICULocaleService extends ICUService { */ public static class LocaleKey extends ICUService.Key { private int kind; + private int varstart; private String primaryID; private String fallbackID; private String currentID; @@ -198,7 +203,7 @@ public class ICULocaleService extends ICUService { public static LocaleKey createWithCanonicalFallback(String primaryID, String canonicalFallbackID) { return createWithCanonicalFallback(primaryID, canonicalFallbackID, KIND_ANY); } - + /** * Create a LocaleKey with canonical primary and fallback IDs. */ @@ -209,7 +214,7 @@ public class ICULocaleService extends ICUService { String canonicalPrimaryID = LocaleUtility.canonicalLocaleString(primaryID); return new LocaleKey(primaryID, canonicalPrimaryID, canonicalFallbackID, kind); } - + /** * PrimaryID is the user's requested locale string, * canonicalPrimaryID is this string in canonical form, @@ -220,11 +225,11 @@ public class ICULocaleService extends ICUService { super(primaryID); this.kind = kind; - if (canonicalPrimaryID == null) { this.primaryID = ""; } else { this.primaryID = canonicalPrimaryID; + this.varstart = this.primaryID.indexOf('@'); } if (this.primaryID == "") { this.fallbackID = null; @@ -236,7 +241,7 @@ public class ICULocaleService extends ICUService { } } - this.currentID = this.primaryID; + this.currentID = varstart == -1 ? this.primaryID : this.primaryID.substring(0, varstart); } /** @@ -295,6 +300,17 @@ public class ICULocaleService extends ICUService { return LocaleUtility.getLocaleFromName(currentID); } + /** + * Convenience method to return the ulocale corresponding to the (canonical) currentID. + */ + public ULocale currentULocale() { + if (varstart == -1) { + return new ULocale(currentID); + } else { + return new ULocale(currentID + primaryID.substring(varstart)); + } + } + /** * If the key has a fallback, modify the key and return true, * otherwise return false.

@@ -414,7 +430,7 @@ public class ICULocaleService extends ICUService { int kind = lkey.kind(); if (supportsULocale()) { - ULocale uloc = new ULocale(lkey.currentID()); + ULocale uloc = lkey.currentULocale(); return handleCreate(uloc, kind, service); } else { Locale loc = lkey.currentLocale(); @@ -511,7 +527,7 @@ public class ICULocaleService extends ICUService { } Locale loc = LocaleUtility.getLocaleFromName(id); return loc.getDisplayName(locale); - // } + // } // return null; } diff --git a/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java b/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java index 6dd3493c86..1b6059de0b 100644 --- a/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java +++ b/icu4j/src/com/ibm/icu/impl/ICUResourceBundle.java @@ -784,6 +784,11 @@ public abstract class ICUResourceBundle extends UResourceBundle{ HashSet set = new HashSet(); set.addAll(Arrays.asList(locales)); + // add the obsolete ids, we really do support them + set.add("iw"); + set.add("iw_IL"); + set.add("in"); + set.add("in_ID"); return Collections.unmodifiableSet(set); } catch (MissingResourceException e) { diff --git a/icu4j/src/com/ibm/icu/text/DecimalFormat.java b/icu4j/src/com/ibm/icu/text/DecimalFormat.java index 09217e2dd9..7640516596 100755 --- a/icu4j/src/com/ibm/icu/text/DecimalFormat.java +++ b/icu4j/src/com/ibm/icu/text/DecimalFormat.java @@ -1457,26 +1457,26 @@ public class DecimalFormat extends NumberFormat { // Handle integral values if (mult == 1 && digitList.isIntegral()) { - // hack quick long + // hack quick long if (digitList.decimalAt < 12) { // quick check for long long l = 0; if (digitList.count > 0) { int nx = 0; - while (nx < digitList.count) { - l = l * 10 + (char)digitList.digits[nx++] - '0'; - } - while (nx++ < digitList.decimalAt) { - l *= 10; - } - if (!status[STATUS_POSITIVE]) { - l = -l; - } - } - n = new Long(l); + while (nx < digitList.count) { + l = l * 10 + (char)digitList.digits[nx++] - '0'; + } + while (nx++ < digitList.decimalAt) { + l *= 10; + } + if (!status[STATUS_POSITIVE]) { + l = -l; + } + } + n = new Long(l); } else { - BigInteger big = digitList.getBigInteger(status[STATUS_POSITIVE]); - n = (big.bitLength() < 64) ? - (Number) new Long(big.longValue()) : (Number) big; + BigInteger big = digitList.getBigInteger(status[STATUS_POSITIVE]); + n = (big.bitLength() < 64) ? + (Number) new Long(big.longValue()) : (Number) big; } } @@ -2654,12 +2654,13 @@ public class DecimalFormat extends NumberFormat { { if (obj == null) return false; if (!super.equals(obj)) return false; // super does class check + DecimalFormat other = (DecimalFormat) obj; /* Add the comparison of the four new added fields ,they are * posPrefixPattern, posSuffixPattern, negPrefixPattern, negSuffixPattern. * [Richard/GCL] */ - return (((posPrefixPattern == other.posPrefixPattern && + return ((posPrefixPattern == other.posPrefixPattern && positivePrefix.equals(other.positivePrefix)) || (posPrefixPattern != null && posPrefixPattern.equals(other.posPrefixPattern))) @@ -2686,7 +2687,7 @@ public class DecimalFormat extends NumberFormat { && (!useSignificantDigits || minSignificantDigits == other.minSignificantDigits && maxSignificantDigits == other.maxSignificantDigits) - && symbols.equals(other.symbols)); + && symbols.equals(other.symbols); } // protected void handleToString(StringBuffer buf) { @@ -2695,8 +2696,8 @@ public class DecimalFormat extends NumberFormat { // buf.append("positivePrefix: '" + positivePrefix + "'\n"); // buf.append("posSuffixPattern: '" + posSuffixPattern + "'\n"); // buf.append("positiveSuffix: '" + positiveSuffix + "'\n"); -// buf.append("negPrefixPattern: '" + Utility.format1ForSource(negPrefixPattern) + "'\n"); -// buf.append("negativePrefix: '" + Utility.format1ForSource(negativePrefix) + "'\n"); +// buf.append("negPrefixPattern: '" + com.ibm.icu.impl.Utility.format1ForSource(negPrefixPattern) + "'\n"); +// buf.append("negativePrefix: '" + com.ibm.icu.impl.Utility.format1ForSource(negativePrefix) + "'\n"); // buf.append("negSuffixPattern: '" + negSuffixPattern + "'\n"); // buf.append("negativeSuffix: '" + negativeSuffix + "'\n"); // buf.append("multiplier: '" + multiplier + "'\n"); @@ -2705,6 +2706,9 @@ public class DecimalFormat extends NumberFormat { // buf.append("decimalSeparatorAlwaysShown: '" + decimalSeparatorAlwaysShown + "'\n"); // buf.append("useExponentialNotation: '" + useExponentialNotation + "'\n"); // buf.append("minExponentDigits: '" + minExponentDigits + "'\n"); +// buf.append("useSignificantDigits: '" + useSignificantDigits + "'\n"); +// buf.append("minSignificantDigits: '" + minSignificantDigits + "'\n"); +// buf.append("maxSignificantDigits: '" + maxSignificantDigits + "'\n"); // buf.append("symbols: '" + symbols + "'"); // }