summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--JavaLibrary.mk11
-rw-r--r--icu/src/main/java/com/ibm/icu4jni/text/Collator.java1
-rw-r--r--icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java1
-rw-r--r--icu/src/main/java/com/ibm/icu4jni/util/ICU.java (renamed from icu/src/main/java/com/ibm/icu4jni/util/Resources.java)100
-rw-r--r--icu/src/main/java/com/ibm/icu4jni/util/LocaleData.java104
-rw-r--r--icu/src/main/native/BidiWrapper.cpp1
-rw-r--r--icu/src/main/native/ICU.cpp (renamed from icu/src/main/native/Resources.cpp)60
-rw-r--r--icu/src/main/native/NativeBreakIterator.cpp2
-rw-r--r--icu/src/main/native/NativeCollation.cpp2
-rw-r--r--icu/src/main/native/NativeConverter.cpp2
-rw-r--r--icu/src/main/native/NativeDecimalFormat.cpp1
-rw-r--r--icu/src/main/native/NativeIDN.cpp2
-rw-r--r--icu/src/main/native/NativeNormalizer.cpp2
-rw-r--r--icu/src/main/native/NativeRegEx.cpp2
-rw-r--r--icu/src/main/native/UCharacter.cpp1
-rw-r--r--icu/src/main/native/sub.mk2
-rw-r--r--icu/src/test/java/com/ibm/icu4jni/util/ResourcesTest.java74
-rw-r--r--luni/src/main/java/java/util/Calendar.java8
-rw-r--r--luni/src/main/java/java/util/Currency.java21
-rw-r--r--luni/src/main/java/java/util/Formatter.java3
-rw-r--r--luni/src/main/java/java/util/Locale.java164
-rw-r--r--luni/src/main/java/java/util/ResourceBundle.java4
-rw-r--r--luni/src/main/java/java/util/TimeZone.java7
-rw-r--r--luni/src/test/java/com/ibm/icu4jni/util/AllTests.java (renamed from icu/src/test/java/com/ibm/icu4jni/util/AllTests.java)2
-rw-r--r--luni/src/test/java/com/ibm/icu4jni/util/ICUTest.java74
-rwxr-xr-xrun-core-tests2
-rw-r--r--text/src/main/java/java/text/BreakIterator.java4
-rw-r--r--text/src/main/java/java/text/Collator.java4
-rw-r--r--text/src/main/java/java/text/DateFormat.java21
-rw-r--r--text/src/main/java/java/text/DateFormatSymbols.java16
-rw-r--r--text/src/main/java/java/text/DecimalFormat.java25
-rw-r--r--text/src/main/java/java/text/DecimalFormatSymbols.java8
-rw-r--r--text/src/main/java/java/text/NumberFormat.java24
-rw-r--r--text/src/main/java/java/text/SimpleDateFormat.java6
34 files changed, 332 insertions, 429 deletions
diff --git a/JavaLibrary.mk b/JavaLibrary.mk
index f9468a8..23f866a 100644
--- a/JavaLibrary.mk
+++ b/JavaLibrary.mk
@@ -149,16 +149,6 @@ LOCAL_MODULE := core-tests-dom
include $(BUILD_JAVA_LIBRARY)
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(call all-test-java-files-under,icu)
-LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
-LOCAL_NO_STANDARD_LIBRARIES := true
-LOCAL_JAVA_LIBRARIES := core core-tests-support
-LOCAL_DX_FLAGS := --core-library
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE := core-tests-icu
-include $(BUILD_JAVA_LIBRARY)
-
-include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-test-java-files-under,json)
LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
LOCAL_NO_STANDARD_LIBRARIES := true
@@ -204,7 +194,6 @@ LOCAL_JAVA_LIBRARIES := \
core-tests-concurrent \
core-tests-crypto \
core-tests-dom \
- core-tests-icu \
core-tests-json \
core-tests-logging \
core-tests-luni-kernel \
diff --git a/icu/src/main/java/com/ibm/icu4jni/text/Collator.java b/icu/src/main/java/com/ibm/icu4jni/text/Collator.java
index 3673d32..7883d30 100644
--- a/icu/src/main/java/com/ibm/icu4jni/text/Collator.java
+++ b/icu/src/main/java/com/ibm/icu4jni/text/Collator.java
@@ -11,7 +11,6 @@
package com.ibm.icu4jni.text;
import com.ibm.icu4jni.text.RuleBasedCollator;
-import com.ibm.icu4jni.util.Resources;
import java.util.Locale;
/**
diff --git a/icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java b/icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java
index 91f2beb..272d525 100644
--- a/icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java
+++ b/icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java
@@ -16,7 +16,6 @@
package com.ibm.icu4jni.text;
-import com.ibm.icu4jni.util.Resources;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.Locale;
diff --git a/icu/src/main/java/com/ibm/icu4jni/util/Resources.java b/icu/src/main/java/com/ibm/icu4jni/util/ICU.java
index 874d9be..b684068 100644
--- a/icu/src/main/java/com/ibm/icu4jni/util/Resources.java
+++ b/icu/src/main/java/com/ibm/icu4jni/util/ICU.java
@@ -16,26 +16,14 @@
package com.ibm.icu4jni.util;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.ListResourceBundle;
import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
import java.util.TimeZone;
import java.util.logging.Logger;
/**
* Makes ICU data accessible to Java.
- *
- * TODO: move the LocaleData stuff into LocaleData and rename this class.
*/
-public final class Resources {
- // A cache for the locale-specific data.
- private static final HashMap<String, LocaleData> localeDataCache =
- new HashMap<String, LocaleData>();
-
+public final class ICU {
/**
* Cache for ISO language names.
*/
@@ -52,49 +40,6 @@ public final class Resources {
private static String[] availableTimezones;
/**
- * Returns a shared LocaleData for the given locale.
- */
- public static LocaleData getLocaleData(Locale locale) {
- if (locale == null) {
- locale = Locale.getDefault();
- }
- String localeName = locale.toString();
- synchronized (localeDataCache) {
- LocaleData localeData = localeDataCache.get(localeName);
- if (localeData != null) {
- return localeData;
- }
- }
- LocaleData newLocaleData = makeLocaleData(locale);
- synchronized (localeDataCache) {
- LocaleData localeData = localeDataCache.get(localeName);
- if (localeData != null) {
- return localeData;
- }
- localeDataCache.put(localeName, newLocaleData);
- return newLocaleData;
- }
- }
-
- private static LocaleData makeLocaleData(Locale locale) {
- String language = locale.getLanguage();
- String country = locale.getCountry();
- String variant = locale.getVariant();
- // Start with data from the parent (next-most-specific) locale...
- LocaleData result = new LocaleData();
- if (variant.length() > 0) {
- result.overrideWithDataFrom(getLocaleData(new Locale(language, country, "")));
- } else if (country.length() > 0) {
- result.overrideWithDataFrom(getLocaleData(new Locale(language, "", "")));
- } else if (language.length() > 0) {
- result.overrideWithDataFrom(getLocaleData(Locale.ROOT));
- }
- // Override with data from this locale.
- result.overrideWithDataFrom(initLocaleData(locale));
- return result;
- }
-
- /**
* Returns an array of ISO language names (two-letter codes), fetched either
* from ICU's database or from our memory cache.
*
@@ -104,7 +49,6 @@ public final class Resources {
if (isoLanguages == null) {
isoLanguages = getISOLanguagesNative();
}
-
return isoLanguages.clone();
}
@@ -118,7 +62,6 @@ public final class Resources {
if (isoCountries == null) {
isoCountries = getISOCountriesNative();
}
-
return isoCountries.clone();
}
@@ -129,11 +72,9 @@ public final class Resources {
* @return The array.
*/
public static String[] getKnownTimezones() {
- // TODO Drop the Linux ZoneInfo stuff in favor of ICU.
if (availableTimezones == null) {
availableTimezones = TimeZone.getAvailableIDs();
}
-
return availableTimezones.clone();
}
@@ -233,8 +174,7 @@ public final class Resources {
result[i][4] = arrayToFill[4][i];
}
- Logger.getLogger(Resources.class.getSimpleName()).info(
- "Loaded time zone names for " + locale + " in "
+ Logger.global.info("Loaded time zone names for " + locale + " in "
+ (System.currentTimeMillis() - start) + "ms.");
return result;
@@ -348,6 +288,10 @@ public final class Resources {
private static native String[] getAvailableLocalesNative();
private static native String[] getAvailableNumberFormatLocalesNative();
+ public static native String getCurrencyCodeNative(String locale);
+ public static native int getCurrencyFractionDigitsNative(String currencyCode);
+ public static native String getCurrencySymbolNative(String locale, String currencyCode);
+
public static native String getDisplayCountryNative(String countryCode, String locale);
public static native String getDisplayLanguageNative(String languageCode, String locale);
public static native String getDisplayVariantNative(String variantCode, String locale);
@@ -355,11 +299,6 @@ public final class Resources {
public static native String getISO3CountryNative(String locale);
public static native String getISO3LanguageNative(String locale);
- public static native String getCurrencyCodeNative(String locale);
- public static native String getCurrencySymbolNative(String locale, String currencyCode);
-
- public static native int getCurrencyFractionDigitsNative(String currencyCode);
-
private static native String[] getISOLanguagesNative();
private static native String[] getISOCountriesNative();
@@ -368,30 +307,5 @@ public final class Resources {
private static native String getDisplayTimeZoneNative(String id, boolean isDST, int style,
String locale);
- private static LocaleData initLocaleData(Locale locale) {
- LocaleData localeData = new LocaleData();
- if (!initLocaleDataImpl(locale.toString(), localeData)) {
- throw new AssertionError("couldn't initialize LocaleData for locale " + locale);
- }
- if (localeData.fullTimeFormat != null) {
- // There are some full time format patterns in ICU that use the pattern character 'v'.
- // Java doesn't accept this, so we replace it with 'z' which has about the same result
- // as 'v', the timezone name.
- // 'v' -> "PT", 'z' -> "PST", v is the generic timezone and z the standard tz
- // "vvvv" -> "Pacific Time", "zzzz" -> "Pacific Standard Time"
- localeData.fullTimeFormat = localeData.fullTimeFormat.replace('v', 'z');
- }
- if (localeData.numberPattern != null) {
- // The number pattern might contain positive and negative subpatterns. Arabic, for
- // example, might look like "#,##0.###;#,##0.###-" because the minus sign should be
- // written last. Macedonian supposedly looks something like "#,##0.###;(#,##0.###)".
- // (The negative subpattern is optional, though, and not present in most locales.)
- // By only swallowing '#'es and ','s after the '.', we ensure that we don't
- // accidentally eat too much.
- localeData.integerPattern = localeData.numberPattern.replaceAll("\\.[#,]*", "");
- }
- return localeData;
- }
-
- private static native boolean initLocaleDataImpl(String locale, LocaleData result);
+ static native boolean initLocaleDataImpl(String locale, LocaleData result);
}
diff --git a/icu/src/main/java/com/ibm/icu4jni/util/LocaleData.java b/icu/src/main/java/com/ibm/icu4jni/util/LocaleData.java
index 0ba18d1..e27bd54 100644
--- a/icu/src/main/java/com/ibm/icu4jni/util/LocaleData.java
+++ b/icu/src/main/java/com/ibm/icu4jni/util/LocaleData.java
@@ -18,6 +18,8 @@ package com.ibm.icu4jni.util;
import java.text.DateFormat;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Locale;
/**
* Passes locale-specific from ICU native code to Java.
@@ -27,29 +29,32 @@ import java.util.Arrays;
* them a clone rather than the original.
*/
public final class LocaleData {
+ // A cache for the locale-specific data.
+ private static final HashMap<String, LocaleData> localeDataCache = new HashMap<String, LocaleData>();
+
public Integer firstDayOfWeek;
public Integer minimalDaysInFirstWeek;
-
+
public String[] amPm;
-
+
public String[] eras;
-
+
public String[] longMonthNames;
public String[] shortMonthNames;
-
+
public String[] longWeekdayNames;
public String[] shortWeekdayNames;
-
+
public String fullTimeFormat;
public String longTimeFormat;
public String mediumTimeFormat;
public String shortTimeFormat;
-
+
public String fullDateFormat;
public String longDateFormat;
public String mediumDateFormat;
public String shortDateFormat;
-
+
// DecimalFormatSymbols.
public char zeroDigit;
public char digit;
@@ -63,15 +68,61 @@ public final class LocaleData {
public String exponentSeparator;
public String infinity;
public String NaN;
-
+
public String currencySymbol;
public String internationalCurrencySymbol;
-
+
public String numberPattern;
public String integerPattern;
public String currencyPattern;
public String percentPattern;
-
+
+ private LocaleData() {
+ }
+
+ /**
+ * Returns a shared LocaleData for the given locale.
+ */
+ public static LocaleData get(Locale locale) {
+ if (locale == null) {
+ locale = Locale.getDefault();
+ }
+ String localeName = locale.toString();
+ synchronized (localeDataCache) {
+ LocaleData localeData = localeDataCache.get(localeName);
+ if (localeData != null) {
+ return localeData;
+ }
+ }
+ LocaleData newLocaleData = makeLocaleData(locale);
+ synchronized (localeDataCache) {
+ LocaleData localeData = localeDataCache.get(localeName);
+ if (localeData != null) {
+ return localeData;
+ }
+ localeDataCache.put(localeName, newLocaleData);
+ return newLocaleData;
+ }
+ }
+
+ private static LocaleData makeLocaleData(Locale locale) {
+ String language = locale.getLanguage();
+ String country = locale.getCountry();
+ String variant = locale.getVariant();
+ // Start with data from the parent (next-most-specific) locale...
+ LocaleData result = new LocaleData();
+ if (!variant.isEmpty()) {
+ result.overrideWithDataFrom(get(new Locale(language, country, "")));
+ } else if (!country.isEmpty()) {
+ result.overrideWithDataFrom(get(new Locale(language, "", "")));
+ } else if (!language.isEmpty()) {
+ result.overrideWithDataFrom(get(Locale.ROOT));
+ }
+ // Override with data from this locale.
+ result.overrideWithDataFrom(initLocaleData(locale));
+ return result;
+ }
+
@Override public String toString() {
return "LocaleData[" +
"firstDayOfWeek=" + firstDayOfWeek + "," +
@@ -109,8 +160,8 @@ public final class LocaleData {
"currencyPattern=" + currencyPattern + "," +
"percentPattern=" + percentPattern + "]";
}
-
- public void overrideWithDataFrom(LocaleData overrides) {
+
+ private void overrideWithDataFrom(LocaleData overrides) {
if (overrides.firstDayOfWeek != null) {
firstDayOfWeek = overrides.firstDayOfWeek;
}
@@ -214,7 +265,7 @@ public final class LocaleData {
percentPattern = overrides.percentPattern;
}
}
-
+
public String getDateFormat(int style) {
switch (style) {
case DateFormat.SHORT:
@@ -228,7 +279,7 @@ public final class LocaleData {
}
throw new AssertionError();
}
-
+
public String getTimeFormat(int style) {
switch (style) {
case DateFormat.SHORT:
@@ -242,4 +293,29 @@ public final class LocaleData {
}
throw new AssertionError();
}
+
+ private static LocaleData initLocaleData(Locale locale) {
+ LocaleData localeData = new LocaleData();
+ if (!ICU.initLocaleDataImpl(locale.toString(), localeData)) {
+ throw new AssertionError("couldn't initialize LocaleData for locale " + locale);
+ }
+ if (localeData.fullTimeFormat != null) {
+ // There are some full time format patterns in ICU that use the pattern character 'v'.
+ // Java doesn't accept this, so we replace it with 'z' which has about the same result
+ // as 'v', the timezone name.
+ // 'v' -> "PT", 'z' -> "PST", v is the generic timezone and z the standard tz
+ // "vvvv" -> "Pacific Time", "zzzz" -> "Pacific Standard Time"
+ localeData.fullTimeFormat = localeData.fullTimeFormat.replace('v', 'z');
+ }
+ if (localeData.numberPattern != null) {
+ // The number pattern might contain positive and negative subpatterns. Arabic, for
+ // example, might look like "#,##0.###;#,##0.###-" because the minus sign should be
+ // written last. Macedonian supposedly looks something like "#,##0.###;(#,##0.###)".
+ // (The negative subpattern is optional, though, and not present in most locales.)
+ // By only swallowing '#'es and ','s after the '.', we ensure that we don't
+ // accidentally eat too much.
+ localeData.integerPattern = localeData.numberPattern.replaceAll("\\.[#,]*", "");
+ }
+ return localeData;
+ }
}
diff --git a/icu/src/main/native/BidiWrapper.cpp b/icu/src/main/native/BidiWrapper.cpp
index 68419c0..7a25ff1 100644
--- a/icu/src/main/native/BidiWrapper.cpp
+++ b/icu/src/main/native/BidiWrapper.cpp
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#define LOG_TAG "BidiWrapper"
#include "AndroidSystemNatives.h"
#include <JNIHelp.h>
#include "ErrorCode.h"
diff --git a/icu/src/main/native/Resources.cpp b/icu/src/main/native/ICU.cpp
index fb53f87..3066edb 100644
--- a/icu/src/main/native/Resources.cpp
+++ b/icu/src/main/native/ICU.cpp
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-#define LOG_TAG "Resources"
+#define LOG_TAG "ICU"
#include "JNIHelp.h"
#include "AndroidSystemNatives.h"
#include "ScopedUtfChars.h"
+#include "UniquePtr.h"
#include "cutils/log.h"
#include "unicode/numfmt.h"
#include "unicode/locid.h"
@@ -72,28 +73,23 @@ static Locale getLocale(JNIEnv* env, jstring localeName) {
return Locale::createFromName(ScopedUtfChars(env, localeName).data());
}
-static jint getCurrencyFractionDigitsNative(JNIEnv* env, jclass clazz, jstring currencyCode) {
+static jint getCurrencyFractionDigitsNative(JNIEnv* env, jclass, jstring currencyCode) {
UErrorCode status = U_ZERO_ERROR;
-
- NumberFormat* fmt = NumberFormat::createCurrencyInstance(status);
+ UniquePtr<NumberFormat> fmt(NumberFormat::createCurrencyInstance(status));
if (U_FAILURE(status)) {
return -1;
}
-
const jchar* cCode = env->GetStringChars(currencyCode, NULL);
fmt->setCurrency(cCode, status);
env->ReleaseStringChars(currencyCode, cCode);
if (U_FAILURE(status)) {
return -1;
}
-
// for CurrencyFormats the minimum and maximum fraction digits are the same.
- int result = fmt->getMinimumFractionDigits();
- delete fmt;
- return result;
+ return fmt->getMinimumFractionDigits();
}
-static jstring getCurrencyCodeNative(JNIEnv* env, jclass clazz, jstring key) {
+static jstring getCurrencyCodeNative(JNIEnv* env, jclass, jstring key) {
UErrorCode status = U_ZERO_ERROR;
ScopedResourceBundle supplData(ures_openDirect(NULL, "supplementalData", &status));
if (U_FAILURE(status)) {
@@ -142,8 +138,7 @@ static jstring getCurrencyCodeNative(JNIEnv* env, jclass clazz, jstring key) {
return env->NewString(id, length);
}
-static jstring getCurrencySymbolNative(JNIEnv* env, jclass clazz,
- jstring locale, jstring currencyCode) {
+static jstring getCurrencySymbolNative(JNIEnv* env, jclass, jstring locale, jstring currencyCode) {
// LOGI("ENTER getCurrencySymbolNative");
const char* locName = env->GetStringUTFChars(locale, NULL);
@@ -175,8 +170,7 @@ static jstring getCurrencySymbolNative(JNIEnv* env, jclass clazz,
return (currSymbL == 0) ? NULL : env->NewString(currSymbU, currSymbL);
}
-static jstring getDisplayCountryNative(JNIEnv* env, jclass clazz,
- jstring targetLocale, jstring locale) {
+static jstring getDisplayCountryNative(JNIEnv* env, jclass, jstring targetLocale, jstring locale) {
Locale loc = getLocale(env, locale);
Locale targetLoc = getLocale(env, targetLocale);
@@ -186,8 +180,7 @@ static jstring getDisplayCountryNative(JNIEnv* env, jclass clazz,
return env->NewString(str.getBuffer(), str.length());
}
-static jstring getDisplayLanguageNative(JNIEnv* env, jclass clazz,
- jstring targetLocale, jstring locale) {
+static jstring getDisplayLanguageNative(JNIEnv* env, jclass, jstring targetLocale, jstring locale) {
Locale loc = getLocale(env, locale);
Locale targetLoc = getLocale(env, targetLocale);
@@ -197,23 +190,20 @@ static jstring getDisplayLanguageNative(JNIEnv* env, jclass clazz,
return env->NewString(str.getBuffer(), str.length());
}
-static jstring getDisplayVariantNative(JNIEnv* env, jclass clazz,
- jstring targetLocale, jstring locale) {
-
+static jstring getDisplayVariantNative(JNIEnv* env, jclass, jstring targetLocale, jstring locale) {
Locale loc = getLocale(env, locale);
Locale targetLoc = getLocale(env, targetLocale);
-
UnicodeString str;
targetLoc.getDisplayVariant(loc, str);
return env->NewString(str.getBuffer(), str.length());
}
-static jstring getISO3CountryNative(JNIEnv* env, jclass clazz, jstring locale) {
+static jstring getISO3CountryNative(JNIEnv* env, jclass, jstring locale) {
Locale loc = getLocale(env, locale);
return env->NewStringUTF(loc.getISO3Country());
}
-static jstring getISO3LanguageNative(JNIEnv* env, jclass clazz, jstring locale) {
+static jstring getISO3LanguageNative(JNIEnv* env, jclass, jstring locale) {
Locale loc = getLocale(env, locale);
return env->NewStringUTF(loc.getISO3Language());
}
@@ -232,11 +222,11 @@ static jobjectArray toStringArray(JNIEnv* env, const char* const* strings) {
return result;
}
-static jobjectArray getISOCountriesNative(JNIEnv* env, jclass clazz) {
+static jobjectArray getISOCountriesNative(JNIEnv* env, jclass) {
return toStringArray(env, Locale::getISOCountries());
}
-static jobjectArray getISOLanguagesNative(JNIEnv* env, jclass clazz) {
+static jobjectArray getISOLanguagesNative(JNIEnv* env, jclass) {
return toStringArray(env, Locale::getISOLanguages());
}
@@ -289,9 +279,7 @@ static jstring formatDate(JNIEnv* env, const SimpleDateFormat& fmt, const UDate&
return env->NewString(str.getBuffer(), str.length());
}
-static void getTimeZonesNative(JNIEnv* env, jclass clazz,
- jobjectArray outerArray, jstring locale) {
-
+static void getTimeZonesNative(JNIEnv* env, jclass, jobjectArray outerArray, jstring locale) {
// get all timezone objects
jobjectArray zoneIdArray = (jobjectArray) env->GetObjectArrayElement(outerArray, 0);
int count = env->GetArrayLength(zoneIdArray);
@@ -361,18 +349,13 @@ static void getTimeZonesNative(JNIEnv* env, jclass clazz,
}
}
-static jstring getDisplayTimeZoneNative(JNIEnv* env, jclass clazz,
- jstring zoneId, jboolean isDST, jint style, jstring localeId) {
-
- TimeZone* zone = timeZoneFromId(env, zoneId);
+static jstring getDisplayTimeZoneNative(JNIEnv* env, jclass, jstring zoneId, jboolean isDST, jint style, jstring localeId) {
+ UniquePtr<TimeZone> zone(timeZoneFromId(env, zoneId));
Locale locale = getLocale(env, localeId);
-
// Try to get the display name of the TimeZone according to the Locale
UnicodeString displayName;
zone->getDisplayName((UBool)isDST, (style == 0 ? TimeZone::SHORT : TimeZone::LONG), locale, displayName);
- jstring result = env->NewString(displayName.getBuffer(), displayName.length());
- delete zone;
- return result;
+ return env->NewString(displayName.getBuffer(), displayName.length());
}
static bool getDayIntVector(JNIEnv* env, UResourceBundle* gregorian, int* values) {
@@ -604,7 +587,7 @@ static void setCharField(JNIEnv* env, jobject obj, const char* fieldName, UResou
}
}
-static jboolean initLocaleDataImpl(JNIEnv* env, jclass clazz, jstring locale, jobject localeData) {
+static jboolean initLocaleDataImpl(JNIEnv* env, jclass, jstring locale, jobject localeData) {
const char* loc = env->GetStringUTFChars(locale, NULL);
UErrorCode status = U_ZERO_ERROR;
ScopedResourceBundle root(ures_openU(NULL, loc, &status));
@@ -674,7 +657,7 @@ static jboolean initLocaleDataImpl(JNIEnv* env, jclass clazz, jstring locale, jo
jstring internationalCurrencySymbol = getIntCurrencyCode(env, locale);
jstring currencySymbol = NULL;
if (internationalCurrencySymbol != NULL) {
- currencySymbol = getCurrencySymbolNative(env, clazz, locale, internationalCurrencySymbol);
+ currencySymbol = getCurrencySymbolNative(env, NULL, locale, internationalCurrencySymbol);
} else {
internationalCurrencySymbol = env->NewStringUTF("XXX");
}
@@ -725,6 +708,5 @@ int register_com_ibm_icu4jni_util_Resources(JNIEnv* env) {
}
string_class = (jclass) env->NewGlobalRef(stringclass);
- return jniRegisterNativeMethods(env, "com/ibm/icu4jni/util/Resources",
- gMethods, NELEM(gMethods));
+ return jniRegisterNativeMethods(env, "com/ibm/icu4jni/util/ICU", gMethods, NELEM(gMethods));
}
diff --git a/icu/src/main/native/NativeBreakIterator.cpp b/icu/src/main/native/NativeBreakIterator.cpp
index 6cc774b..5b12ba3 100644
--- a/icu/src/main/native/NativeBreakIterator.cpp
+++ b/icu/src/main/native/NativeBreakIterator.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define LOG_TAG "NativeBreakIterator"
+
#include "JNIHelp.h"
#include "AndroidSystemNatives.h"
#include "ErrorCode.h"
diff --git a/icu/src/main/native/NativeCollation.cpp b/icu/src/main/native/NativeCollation.cpp
index 148c16e..5bc7749 100644
--- a/icu/src/main/native/NativeCollation.cpp
+++ b/icu/src/main/native/NativeCollation.cpp
@@ -7,6 +7,8 @@
*******************************************************************************
*/
+#define LOG_TAG "NativeCollation"
+
#include "JNIHelp.h"
#include "AndroidSystemNatives.h"
#include "ErrorCode.h"
diff --git a/icu/src/main/native/NativeConverter.cpp b/icu/src/main/native/NativeConverter.cpp
index 1bb9ac8..f227f3d 100644
--- a/icu/src/main/native/NativeConverter.cpp
+++ b/icu/src/main/native/NativeConverter.cpp
@@ -15,6 +15,8 @@
* @author: Ram Viswanadha
*/
+#define LOG_TAG "NativeConverter"
+
#include "AndroidSystemNatives.h"
#include "ErrorCode.h"
#include "JNIHelp.h"
diff --git a/icu/src/main/native/NativeDecimalFormat.cpp b/icu/src/main/native/NativeDecimalFormat.cpp
index b62e5b1..6909553 100644
--- a/icu/src/main/native/NativeDecimalFormat.cpp
+++ b/icu/src/main/native/NativeDecimalFormat.cpp
@@ -15,6 +15,7 @@
*/
#define LOG_TAG "NativeDecimalFormat"
+
#include "JNIHelp.h"
#include "AndroidSystemNatives.h"
#include "cutils/log.h"
diff --git a/icu/src/main/native/NativeIDN.cpp b/icu/src/main/native/NativeIDN.cpp
index 72afc74..2b45dbe 100644
--- a/icu/src/main/native/NativeIDN.cpp
+++ b/icu/src/main/native/NativeIDN.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define LOG_TAG "NativeIDN"
+
#include "ErrorCode.h"
#include "JNIHelp.h"
#include "ScopedJavaUnicodeString.h"
diff --git a/icu/src/main/native/NativeNormalizer.cpp b/icu/src/main/native/NativeNormalizer.cpp
index 0aa7d29..663a7c1 100644
--- a/icu/src/main/native/NativeNormalizer.cpp
+++ b/icu/src/main/native/NativeNormalizer.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define LOG_TAG "NativeNormalizer"
+
#include "ErrorCode.h"
#include "JNIHelp.h"
#include "ScopedJavaUnicodeString.h"
diff --git a/icu/src/main/native/NativeRegEx.cpp b/icu/src/main/native/NativeRegEx.cpp
index 7b3cafc..f8be4ee 100644
--- a/icu/src/main/native/NativeRegEx.cpp
+++ b/icu/src/main/native/NativeRegEx.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define LOG_TAG "NativeRegEx"
+
#include "AndroidSystemNatives.h"
#include <stdlib.h>
diff --git a/icu/src/main/native/UCharacter.cpp b/icu/src/main/native/UCharacter.cpp
index 9856a1a..4186b75 100644
--- a/icu/src/main/native/UCharacter.cpp
+++ b/icu/src/main/native/UCharacter.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#define LOG_TAG "UCharacter"
#include "JNIHelp.h"
#include "AndroidSystemNatives.h"
#include "ScopedJavaUnicodeString.h"
diff --git a/icu/src/main/native/sub.mk b/icu/src/main/native/sub.mk
index f72db1b..599c102 100644
--- a/icu/src/main/native/sub.mk
+++ b/icu/src/main/native/sub.mk
@@ -5,6 +5,7 @@
LOCAL_SRC_FILES := \
BidiWrapper.cpp \
ErrorCode.cpp \
+ ICU.cpp \
NativeBreakIterator.cpp \
NativeCollation.cpp \
NativeConverter.cpp \
@@ -12,7 +13,6 @@ LOCAL_SRC_FILES := \
NativeIDN.cpp \
NativeNormalizer.cpp \
NativeRegEx.cpp \
- Resources.cpp \
UCharacter.cpp
LOCAL_C_INCLUDES += \
diff --git a/icu/src/test/java/com/ibm/icu4jni/util/ResourcesTest.java b/icu/src/test/java/com/ibm/icu4jni/util/ResourcesTest.java
deleted file mode 100644
index 7dcaa9c..0000000
--- a/icu/src/test/java/com/ibm/icu4jni/util/ResourcesTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.ibm.icu4jni.util;
-
-import java.util.Locale;
-
-public class ResourcesTest extends junit.framework.TestCase {
- public void test_getISOLanguages() throws Exception {
- // Check that corrupting our array doesn't affect other callers.
- assertNotNull(Resources.getISOLanguages()[0]);
- Resources.getISOLanguages()[0] = null;
- assertNotNull(Resources.getISOLanguages()[0]);
- }
-
- public void test_getISOCountries() throws Exception {
- // Check that corrupting our array doesn't affect other callers.
- assertNotNull(Resources.getISOCountries()[0]);
- Resources.getISOCountries()[0] = null;
- assertNotNull(Resources.getISOCountries()[0]);
- }
-
- public void test_getAvailableLocales() throws Exception {
- // Check that corrupting our array doesn't affect other callers.
- assertNotNull(Resources.getAvailableLocales()[0]);
- Resources.getAvailableLocales()[0] = null;
- assertNotNull(Resources.getAvailableLocales()[0]);
- }
-
- public void test_getKnownTimezones() throws Exception {
- // Check that corrupting our array doesn't affect other callers.
- assertNotNull(Resources.getKnownTimezones()[0]);
- Resources.getKnownTimezones()[0] = null;
- assertNotNull(Resources.getKnownTimezones()[0]);
- }
-
- public void test_getDisplayTimeZones() throws Exception {
- // Check that corrupting our array doesn't affect other callers.
- assertNotNull(Resources.getDisplayTimeZones(null)[0]);
- Resources.getDisplayTimeZones(null)[0] = null;
- assertNotNull(Resources.getDisplayTimeZones(null)[0]);
- // getDisplayTimezones actually returns a String[][] rather than a String[].
- assertNotNull(Resources.getDisplayTimeZones(null)[0][0]);
- Resources.getDisplayTimeZones(null)[0][0] = null;
- assertNotNull(Resources.getDisplayTimeZones(null)[0][0]);
- }
-
- public void test_localeFromString() throws Exception {
- // localeFromString is pretty lenient. Some of these can't be round-tripped
- // through Locale.toString.
- assertEquals(Locale.ENGLISH, Resources.localeFromString("en"));
- assertEquals(Locale.ENGLISH, Resources.localeFromString("en_"));
- assertEquals(Locale.ENGLISH, Resources.localeFromString("en__"));
- assertEquals(Locale.US, Resources.localeFromString("en_US"));
- assertEquals(Locale.US, Resources.localeFromString("en_US_"));
- assertEquals(new Locale("", "US", ""), Resources.localeFromString("_US"));
- assertEquals(new Locale("", "US", ""), Resources.localeFromString("_US_"));
- assertEquals(new Locale("", "", "POSIX"), Resources.localeFromString("__POSIX"));
- assertEquals(new Locale("aa", "BB", "CC"), Resources.localeFromString("aa_BB_CC"));
- }
-}
diff --git a/luni/src/main/java/java/util/Calendar.java b/luni/src/main/java/java/util/Calendar.java
index 6cb3ec7..3e5e43d 100644
--- a/luni/src/main/java/java/util/Calendar.java
+++ b/luni/src/main/java/java/util/Calendar.java
@@ -18,7 +18,7 @@
package java.util;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -724,11 +724,9 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
*/
protected Calendar(TimeZone timezone, Locale locale) {
this(timezone);
- // BEGIN android-changed
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
+ LocaleData localeData = LocaleData.get(locale);
setFirstDayOfWeek(localeData.firstDayOfWeek.intValue());
setMinimalDaysInFirstWeek(localeData.minimalDaysInFirstWeek.intValue());
- // END android-changed
}
@@ -962,7 +960,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
* are available.
*/
public static synchronized Locale[] getAvailableLocales() {
- return Resources.getAvailableCalendarLocales();
+ return ICU.getAvailableCalendarLocales();
}
/**
diff --git a/luni/src/main/java/java/util/Currency.java b/luni/src/main/java/java/util/Currency.java
index a3ab15c..83d7f80 100644
--- a/luni/src/main/java/java/util/Currency.java
+++ b/luni/src/main/java/java/util/Currency.java
@@ -17,16 +17,13 @@
package java.util;
-// BEGIN android-added
+import com.ibm.icu4jni.util.ICU;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
-import java.util.logging.Logger;
-import org.apache.harmony.luni.util.Msg;
-// END android-added
-
-import java.security.AccessController;
import java.io.Serializable;
+import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.logging.Logger;
+import org.apache.harmony.luni.util.Msg;
/**
* This class represents a currency as identified in the ISO 4217 currency
@@ -59,12 +56,12 @@ public final class Currency implements Serializable {
}
// Ensure that we throw if the our currency code isn't an ISO currency code.
- String symbol = Resources.getCurrencySymbolNative(Locale.US.toString(), currencyCode);
+ String symbol = ICU.getCurrencySymbolNative(Locale.US.toString(), currencyCode);
if (symbol == null) {
throw new IllegalArgumentException(Msg.getString("K0322", currencyCode));
}
- this.defaultFractionDigits = Resources.getCurrencyFractionDigitsNative(currencyCode);
+ this.defaultFractionDigits = ICU.getCurrencyFractionDigitsNative(currencyCode);
if (defaultFractionDigits < 0) {
// In practice, I don't think this can fail because ICU doesn't care whether you give
// it a valid country code, and will just return a sensible default for the default
@@ -120,7 +117,7 @@ public final class Currency implements Serializable {
country = country + "_" + variant;
}
- String currencyCode = Resources.getCurrencyCodeNative(country);
+ String currencyCode = ICU.getCurrencyCodeNative(country);
if (currencyCode == null) {
throw new IllegalArgumentException(Msg.getString("K0323", locale.toString()));
} else if (currencyCode.equals("None")) {
@@ -164,13 +161,13 @@ public final class Currency implements Serializable {
}
// Check the locale first, in case the locale has the same currency.
- LocaleData localeData = Resources.getLocaleData(locale);
+ LocaleData localeData = LocaleData.get(locale);
if (localeData.internationalCurrencySymbol.equals(currencyCode)) {
return localeData.currencySymbol;
}
// Try ICU, and fall back to the currency code if ICU has nothing.
- String symbol = Resources.getCurrencySymbolNative(locale.toString(), currencyCode);
+ String symbol = ICU.getCurrencySymbolNative(locale.toString(), currencyCode);
return symbol != null ? symbol : currencyCode;
}
diff --git a/luni/src/main/java/java/util/Formatter.java b/luni/src/main/java/java/util/Formatter.java
index f79fde9..db35ef1 100644
--- a/luni/src/main/java/java/util/Formatter.java
+++ b/luni/src/main/java/java/util/Formatter.java
@@ -16,7 +16,6 @@
package java.util;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File;
@@ -1414,7 +1413,7 @@ public final class Formatter implements Closeable, Flushable {
Transformer(Formatter formatter, Locale locale) {
this.formatter = formatter;
this.locale = (locale == null ? Locale.US : locale);
- this.localeData = Resources.getLocaleData(locale);
+ this.localeData = LocaleData.get(locale);
}
private NumberFormat getNumberFormat() {
diff --git a/luni/src/main/java/java/util/Locale.java b/luni/src/main/java/java/util/Locale.java
index 702c5ff..ce1992c 100644
--- a/luni/src/main/java/java/util/Locale.java
+++ b/luni/src/main/java/java/util/Locale.java
@@ -17,7 +17,7 @@
package java.util;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -84,82 +84,82 @@ public final class Locale implements Cloneable, Serializable {
/**
* Locale constant for en_CA.
*/
- public static final Locale CANADA = new Locale("en", "CA"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale CANADA = new Locale("en", "CA");
/**
* Locale constant for fr_CA.
*/
- public static final Locale CANADA_FRENCH = new Locale("fr", "CA"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale CANADA_FRENCH = new Locale("fr", "CA");
/**
* Locale constant for zh_CN.
*/
- public static final Locale CHINA = new Locale("zh", "CN"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale CHINA = new Locale("zh", "CN");
/**
* Locale constant for zh.
*/
- public static final Locale CHINESE = new Locale("zh", ""); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale CHINESE = new Locale("zh", "");
/**
* Locale constant for en.
*/
- public static final Locale ENGLISH = new Locale("en", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale ENGLISH = new Locale("en", "");
/**
* Locale constant for fr_FR.
*/
- public static final Locale FRANCE = new Locale("fr", "FR"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale FRANCE = new Locale("fr", "FR");
/**
* Locale constant for fr.
*/
- public static final Locale FRENCH = new Locale("fr", ""); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale FRENCH = new Locale("fr", "");
/**
* Locale constant for de.
*/
- public static final Locale GERMAN = new Locale("de", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale GERMAN = new Locale("de", "");
/**
* Locale constant for de_DE.
*/
- public static final Locale GERMANY = new Locale("de", "DE"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale GERMANY = new Locale("de", "DE");
/**
* Locale constant for it.
*/
- public static final Locale ITALIAN = new Locale("it", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale ITALIAN = new Locale("it", "");
/**
* Locale constant for it_IT.
*/
- public static final Locale ITALY = new Locale("it", "IT"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale ITALY = new Locale("it", "IT");
/**
* Locale constant for ja_JP.
*/
- public static final Locale JAPAN = new Locale("ja", "JP"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale JAPAN = new Locale("ja", "JP");
/**
* Locale constant for ja.
*/
- public static final Locale JAPANESE = new Locale("ja", ""); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale JAPANESE = new Locale("ja", "");
/**
* Locale constant for ko_KR.
*/
- public static final Locale KOREA = new Locale("ko", "KR"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale KOREA = new Locale("ko", "KR");
/**
* Locale constant for ko.
*/
- public static final Locale KOREAN = new Locale("ko", ""); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale KOREAN = new Locale("ko", "");
/**
* Locale constant for zh_CN.
*/
- public static final Locale PRC = new Locale("zh", "CN"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale PRC = new Locale("zh", "CN");
/**
* Locale constant for the root locale. The root locale has an empty language,
@@ -173,40 +173,35 @@ public final class Locale implements Cloneable, Serializable {
/**
* Locale constant for zh_CN.
*/
- public static final Locale SIMPLIFIED_CHINESE = new Locale("zh", "CN"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale SIMPLIFIED_CHINESE = new Locale("zh", "CN");
/**
* Locale constant for zh_TW.
*/
- public static final Locale TAIWAN = new Locale("zh", "TW"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale TAIWAN = new Locale("zh", "TW");
/**
* Locale constant for zh_TW.
*/
- public static final Locale TRADITIONAL_CHINESE = new Locale("zh", "TW"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale TRADITIONAL_CHINESE = new Locale("zh", "TW");
/**
* Locale constant for en_GB.
*/
- public static final Locale UK = new Locale("en", "GB"); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final Locale UK = new Locale("en", "GB");
/**
* Locale constant for en_US.
*/
- public static final Locale US = new Locale("en", "US"); //$NON-NLS-1$//$NON-NLS-2$
+ public static final Locale US = new Locale("en", "US");
private static final PropertyPermission setLocalePermission = new PropertyPermission(
- "user.language", "write"); //$NON-NLS-1$//$NON-NLS-2$
+ "user.language", "write");
static {
- String language = AccessController
- .doPrivileged(new PriviAction<String>("user.language", "en")); //$NON-NLS-1$ //$NON-NLS-2$
- // BEGIN android-changed
- String region = AccessController.doPrivileged(new PriviAction<String>(
- "user.region", "US")); //$NON-NLS-1$ //$NON-NLS-2$
- // END android-changed
- String variant = AccessController.doPrivileged(new PriviAction<String>(
- "user.variant", "")); //$NON-NLS-1$ //$NON-NLS-2$
+ String language = AccessController.doPrivileged(new PriviAction<String>("user.language", "en"));
+ String region = AccessController.doPrivileged(new PriviAction<String>("user.region", "US"));
+ String variant = AccessController.doPrivileged(new PriviAction<String>("user.variant", ""));
defaultLocale = new Locale(language, region, variant);
}
@@ -215,19 +210,15 @@ public final class Locale implements Cloneable, Serializable {
private transient String variantCode;
private transient String cachedToStringResult;
- // BEGIN android-removed
- // private transient ULocale uLocale;
- // END android-removed
-
- /**
- * Constructs a default which is used during static initialization of the
- * default for the platform.
- */
- private Locale() {
- languageCode = "en"; //$NON-NLS-1$
- countryCode = "US"; //$NON-NLS-1$
- variantCode = ""; //$NON-NLS-1$
- }
+ /**
+ * Constructs a default which is used during static initialization of the
+ * default for the platform.
+ */
+ private Locale() {
+ languageCode = "en";
+ countryCode = "US";
+ variantCode = "";
+ }
/**
* Constructs a new {@code Locale} using the specified language.
@@ -236,7 +227,7 @@ public final class Locale implements Cloneable, Serializable {
* the language this {@code Locale} represents.
*/
public Locale(String language) {
- this(language, "", ""); //$NON-NLS-1$//$NON-NLS-2$
+ this(language, "", "");
}
/**
@@ -248,7 +239,7 @@ public final class Locale implements Cloneable, Serializable {
* the country this {@code Locale} represents.
*/
public Locale(String language, String country) {
- this(language, country, ""); //$NON-NLS-1$
+ this(language, country, "");
}
/**
@@ -282,12 +273,12 @@ public final class Locale implements Cloneable, Serializable {
// END android-changed
// Map new language codes to the obsolete language
// codes so the correct resource bundles will be used.
- if (languageCode.equals("he")) {//$NON-NLS-1$
- languageCode = "iw"; //$NON-NLS-1$
- } else if (languageCode.equals("id")) {//$NON-NLS-1$
- languageCode = "in"; //$NON-NLS-1$
- } else if (languageCode.equals("yi")) {//$NON-NLS-1$
- languageCode = "ji"; //$NON-NLS-1$
+ if (languageCode.equals("he")) {
+ languageCode = "iw";
+ } else if (languageCode.equals("id")) {
+ languageCode = "in";
+ } else if (languageCode.equals("yi")) {
+ languageCode = "ji";
}
// countryCode is defined in ASCII character set
@@ -348,7 +339,7 @@ public final class Locale implements Cloneable, Serializable {
* @return an array of {@code Locale}s.
*/
public static Locale[] getAvailableLocales() {
- return Resources.getAvailableLocales();
+ return ICU.getAvailableLocales();
}
/**
@@ -391,16 +382,14 @@ public final class Locale implements Cloneable, Serializable {
* @return a country name.
*/
public String getDisplayCountry(Locale locale) {
- // BEGIN android-changed
if (countryCode.length() == 0) {
return countryCode;
}
- String result = Resources.getDisplayCountryNative(toString(), locale.toString());
+ String result = ICU.getDisplayCountryNative(toString(), locale.toString());
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = Resources.getDisplayCountryNative(toString(), Locale.getDefault().toString());
+ result = ICU.getDisplayCountryNative(toString(), Locale.getDefault().toString());
}
return result;
- // END android-changed
}
/**
@@ -424,16 +413,14 @@ public final class Locale implements Cloneable, Serializable {
* @return a language name.
*/
public String getDisplayLanguage(Locale locale) {
- // BEGIN android-changed
if (languageCode.length() == 0) {
return languageCode;
}
- String result = Resources.getDisplayLanguageNative(toString(), locale.toString());
+ String result = ICU.getDisplayLanguageNative(toString(), locale.toString());
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = Resources.getDisplayLanguageNative(toString(), Locale.getDefault().toString());
+ result = ICU.getDisplayLanguageNative(toString(), Locale.getDefault().toString());
}
return result;
- // END android-changed
}
/**
@@ -463,22 +450,22 @@ public final class Locale implements Cloneable, Serializable {
}
if (countryCode.length() > 0) {
if (count == 1) {
- buffer.append(" ("); //$NON-NLS-1$
+ buffer.append(" (");
}
buffer.append(getDisplayCountry(locale));
count++;
}
if (variantCode.length() > 0) {
if (count == 1) {
- buffer.append(" ("); //$NON-NLS-1$
+ buffer.append(" (");
} else if (count == 2) {
- buffer.append(","); //$NON-NLS-1$
+ buffer.append(",");
}
buffer.append(getDisplayVariant(locale));
count++;
}
if (count > 1) {
- buffer.append(")"); //$NON-NLS-1$
+ buffer.append(")");
}
return buffer.toString();
}
@@ -504,16 +491,14 @@ public final class Locale implements Cloneable, Serializable {
* @return a variant name.
*/
public String getDisplayVariant(Locale locale) {
- // BEGIN android-changed
if (variantCode.length() == 0) {
return variantCode;
}
- String result = Resources.getDisplayVariantNative(toString(), locale.toString());
+ String result = ICU.getDisplayVariantNative(toString(), locale.toString());
if (result == null) { // TODO: do we need to do this, or does ICU do it for us?
- result = Resources.getDisplayVariantNative(toString(), Locale.getDefault().toString());
+ result = ICU.getDisplayVariantNative(toString(), Locale.getDefault().toString());
}
return result;
- // END android-changed
}
/**
@@ -525,12 +510,10 @@ public final class Locale implements Cloneable, Serializable {
* if there is no matching three letter ISO country code.
*/
public String getISO3Country() throws MissingResourceException {
- // BEGIN android-changed
if (countryCode.length() == 0) {
return countryCode;
}
- return Resources.getISO3CountryNative(toString());
- // END android-changed
+ return ICU.getISO3CountryNative(toString());
}
/**
@@ -542,12 +525,10 @@ public final class Locale implements Cloneable, Serializable {
* if there is no matching three letter ISO language code.
*/
public String getISO3Language() throws MissingResourceException {
- // BEGIN android-changed
if (languageCode.length() == 0) {
return languageCode;
}
- return Resources.getISO3LanguageNative(toString());
- // END android-changed
+ return ICU.getISO3LanguageNative(toString());
}
/**
@@ -557,9 +538,7 @@ public final class Locale implements Cloneable, Serializable {
* @return an array of strings.
*/
public static String[] getISOCountries() {
- // BEGIN android-changed
- return Resources.getISOCountries();
- // END android-changed
+ return ICU.getISOCountries();
}
/**
@@ -569,9 +548,7 @@ public final class Locale implements Cloneable, Serializable {
* @return an array of strings.
*/
public static String[] getISOLanguages() {
- // BEGIN android-changed
- return Resources.getISOLanguages();
- // END android-changed
+ return ICU.getISOLanguages();
}
/**
@@ -670,25 +647,24 @@ public final class Locale implements Cloneable, Serializable {
}
private static final ObjectStreamField[] serialPersistentFields = {
- new ObjectStreamField("country", String.class), //$NON-NLS-1$
- new ObjectStreamField("hashcode", Integer.TYPE), //$NON-NLS-1$
- new ObjectStreamField("language", String.class), //$NON-NLS-1$
- new ObjectStreamField("variant", String.class) }; //$NON-NLS-1$
+ new ObjectStreamField("country", String.class),
+ new ObjectStreamField("hashcode", Integer.TYPE),
+ new ObjectStreamField("language", String.class),
+ new ObjectStreamField("variant", String.class) };
private void writeObject(ObjectOutputStream stream) throws IOException {
ObjectOutputStream.PutField fields = stream.putFields();
- fields.put("country", countryCode); //$NON-NLS-1$
- fields.put("hashcode", -1); //$NON-NLS-1$
- fields.put("language", languageCode); //$NON-NLS-1$
- fields.put("variant", variantCode); //$NON-NLS-1$
+ fields.put("country", countryCode);
+ fields.put("hashcode", -1);
+ fields.put("language", languageCode);
+ fields.put("variant", variantCode);
stream.writeFields();
}
- private void readObject(ObjectInputStream stream) throws IOException,
- ClassNotFoundException {
+ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = stream.readFields();
- countryCode = (String) fields.get("country", ""); //$NON-NLS-1$//$NON-NLS-2$
- languageCode = (String) fields.get("language", ""); //$NON-NLS-1$//$NON-NLS-2$
- variantCode = (String) fields.get("variant", ""); //$NON-NLS-1$//$NON-NLS-2$
+ countryCode = (String) fields.get("country", "");
+ languageCode = (String) fields.get("language", "");
+ variantCode = (String) fields.get("variant", "");
}
}
diff --git a/luni/src/main/java/java/util/ResourceBundle.java b/luni/src/main/java/java/util/ResourceBundle.java
index 8901e45..dda89b9 100644
--- a/luni/src/main/java/java/util/ResourceBundle.java
+++ b/luni/src/main/java/java/util/ResourceBundle.java
@@ -17,7 +17,7 @@
package java.util;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import dalvik.system.VMStack;
import java.io.File;
import java.io.IOException;
@@ -632,7 +632,7 @@ public abstract class ResourceBundle {
}
private void setLocale(String name) {
- setLocale(Resources.localeFromString(name));
+ setLocale(ICU.localeFromString(name));
}
public static final void clearCache() {
diff --git a/luni/src/main/java/java/util/TimeZone.java b/luni/src/main/java/java/util/TimeZone.java
index dd320b8..a195045 100644
--- a/luni/src/main/java/java/util/TimeZone.java
+++ b/luni/src/main/java/java/util/TimeZone.java
@@ -17,13 +17,10 @@
package java.util;
+import com.ibm.icu4jni.util.ICU;
import java.io.Serializable;
-
-// BEGIN android-added
import org.apache.harmony.luni.internal.util.ZoneInfo;
import org.apache.harmony.luni.internal.util.ZoneInfoDB;
-import com.ibm.icu4jni.util.Resources;
-// END android-added
/**
* {@code TimeZone} represents a time zone offset, taking into account
@@ -276,7 +273,7 @@ public abstract class TimeZone implements Serializable, Cloneable {
if (style == SHORT || style == LONG) {
boolean useDaylight = daylightTime && useDaylightTime();
- String result = Resources.getDisplayTimeZone(getID(), daylightTime, style, locale.toString());
+ String result = ICU.getDisplayTimeZone(getID(), daylightTime, style, locale.toString());
if (result != null) {
return result;
}
diff --git a/icu/src/test/java/com/ibm/icu4jni/util/AllTests.java b/luni/src/test/java/com/ibm/icu4jni/util/AllTests.java
index 92df6fc..2db1dcc 100644
--- a/icu/src/test/java/com/ibm/icu4jni/util/AllTests.java
+++ b/luni/src/test/java/com/ibm/icu4jni/util/AllTests.java
@@ -22,7 +22,7 @@ import junit.framework.TestSuite;
public class AllTests {
public static final Test suite() {
TestSuite suite = new TestSuite();
- suite.addTestSuite(com.ibm.icu4jni.util.ResourcesTest.class);
+ suite.addTestSuite(ICUTest.class);
return suite;
}
}
diff --git a/luni/src/test/java/com/ibm/icu4jni/util/ICUTest.java b/luni/src/test/java/com/ibm/icu4jni/util/ICUTest.java
new file mode 100644
index 0000000..f8797b3
--- /dev/null
+++ b/luni/src/test/java/com/ibm/icu4jni/util/ICUTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.ibm.icu4jni.util;
+
+import java.util.Locale;
+
+public class ICUTest extends junit.framework.TestCase {
+ public void test_getISOLanguages() throws Exception {
+ // Check that corrupting our array doesn't affect other callers.
+ assertNotNull(ICU.getISOLanguages()[0]);
+ ICU.getISOLanguages()[0] = null;
+ assertNotNull(ICU.getISOLanguages()[0]);
+ }
+
+ public void test_getISOCountries() throws Exception {
+ // Check that corrupting our array doesn't affect other callers.
+ assertNotNull(ICU.getISOCountries()[0]);
+ ICU.getISOCountries()[0] = null;
+ assertNotNull(ICU.getISOCountries()[0]);
+ }
+
+ public void test_getAvailableLocales() throws Exception {
+ // Check that corrupting our array doesn't affect other callers.
+ assertNotNull(ICU.getAvailableLocales()[0]);
+ ICU.getAvailableLocales()[0] = null;
+ assertNotNull(ICU.getAvailableLocales()[0]);
+ }
+
+ public void test_getKnownTimezones() throws Exception {
+ // Check that corrupting our array doesn't affect other callers.
+ assertNotNull(ICU.getKnownTimezones()[0]);
+ ICU.getKnownTimezones()[0] = null;
+ assertNotNull(ICU.getKnownTimezones()[0]);
+ }
+
+ public void test_getDisplayTimeZones() throws Exception {
+ // Check that corrupting our array doesn't affect other callers.
+ assertNotNull(ICU.getDisplayTimeZones(null)[0]);
+ ICU.getDisplayTimeZones(null)[0] = null;
+ assertNotNull(ICU.getDisplayTimeZones(null)[0]);
+ // getDisplayTimezones actually returns a String[][] rather than a String[].
+ assertNotNull(ICU.getDisplayTimeZones(null)[0][0]);
+ ICU.getDisplayTimeZones(null)[0][0] = null;
+ assertNotNull(ICU.getDisplayTimeZones(null)[0][0]);
+ }
+
+ public void test_localeFromString() throws Exception {
+ // localeFromString is pretty lenient. Some of these can't be round-tripped
+ // through Locale.toString.
+ assertEquals(Locale.ENGLISH, ICU.localeFromString("en"));
+ assertEquals(Locale.ENGLISH, ICU.localeFromString("en_"));
+ assertEquals(Locale.ENGLISH, ICU.localeFromString("en__"));
+ assertEquals(Locale.US, ICU.localeFromString("en_US"));
+ assertEquals(Locale.US, ICU.localeFromString("en_US_"));
+ assertEquals(new Locale("", "US", ""), ICU.localeFromString("_US"));
+ assertEquals(new Locale("", "US", ""), ICU.localeFromString("_US_"));
+ assertEquals(new Locale("", "", "POSIX"), ICU.localeFromString("__POSIX"));
+ assertEquals(new Locale("aa", "BB", "CC"), ICU.localeFromString("aa_BB_CC"));
+ }
+}
diff --git a/run-core-tests b/run-core-tests
index 57120c5..345f23b 100755
--- a/run-core-tests
+++ b/run-core-tests
@@ -25,7 +25,7 @@ chmod 777 $tmp
# Build the classpath by putting together the jar file for each module.
classpath="/system/framework/sqlite-jdbc.jar" # Bonus item for jdbc testing.
-modules="annotation archive concurrent crypto dom icu json \
+modules="annotation archive concurrent crypto dom json \
logging luni-kernel luni math nio nio_char prefs regex security sql \
suncompat support text x-net xml"
for module in $modules; do
diff --git a/text/src/main/java/java/text/BreakIterator.java b/text/src/main/java/java/text/BreakIterator.java
index 6031046..a858b46 100644
--- a/text/src/main/java/java/text/BreakIterator.java
+++ b/text/src/main/java/java/text/BreakIterator.java
@@ -18,7 +18,7 @@
package java.text;
import com.ibm.icu4jni.text.NativeBreakIterator;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.util.Locale;
/**
@@ -252,7 +252,7 @@ public abstract class BreakIterator implements Cloneable {
* are available.
*/
public static Locale[] getAvailableLocales() {
- return Resources.getAvailableBreakIteratorLocales();
+ return ICU.getAvailableBreakIteratorLocales();
}
/**
diff --git a/text/src/main/java/java/text/Collator.java b/text/src/main/java/java/text/Collator.java
index 902eecc..dba931c 100644
--- a/text/src/main/java/java/text/Collator.java
+++ b/text/src/main/java/java/text/Collator.java
@@ -17,7 +17,7 @@
package java.text;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Comparator;
@@ -254,7 +254,7 @@ public abstract class Collator implements Comparator<Object>, Cloneable {
* are available.
*/
public static Locale[] getAvailableLocales() {
- return Resources.getAvailableCollatorLocales();
+ return ICU.getAvailableCollatorLocales();
}
/**
diff --git a/text/src/main/java/java/text/DateFormat.java b/text/src/main/java/java/text/DateFormat.java
index 84c544e..0b44aad 100644
--- a/text/src/main/java/java/text/DateFormat.java
+++ b/text/src/main/java/java/text/DateFormat.java
@@ -18,7 +18,7 @@
package java.text;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.io.InvalidObjectException;
import java.util.Calendar;
import java.util.Date;
@@ -406,7 +406,7 @@ public abstract class DateFormat extends Format {
* are available.
*/
public static Locale[] getAvailableLocales() {
- return Resources.getAvailableDateFormatLocales();
+ return ICU.getAvailableDateFormatLocales();
}
/**
@@ -461,10 +461,7 @@ public abstract class DateFormat extends Format {
*/
public final static DateFormat getDateInstance(int style, Locale locale) {
checkDateStyle(style);
- // BEGIN android-changed
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
- return new SimpleDateFormat(localeData.getDateFormat(style), locale);
- // END android-changed
+ return new SimpleDateFormat(LocaleData.get(locale).getDateFormat(style), locale);
}
/**
@@ -513,15 +510,12 @@ public abstract class DateFormat extends Format {
* if {@code dateStyle} or {@code timeStyle} is not one of
* SHORT, MEDIUM, LONG, FULL, or DEFAULT.
*/
- public final static DateFormat getDateTimeInstance(int dateStyle,
- int timeStyle, Locale locale) {
+ public final static DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) {
checkTimeStyle(timeStyle);
checkDateStyle(dateStyle);
- // BEGIN android-changed
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
+ LocaleData localeData = LocaleData.get(locale);
String pattern = localeData.getDateFormat(dateStyle) + " " + localeData.getTimeFormat(timeStyle);
return new SimpleDateFormat(pattern, locale);
- // END android-changed
}
/**
@@ -587,10 +581,7 @@ public abstract class DateFormat extends Format {
*/
public final static DateFormat getTimeInstance(int style, Locale locale) {
checkTimeStyle(style);
- // BEGIN android-changed
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
- return new SimpleDateFormat(localeData.getTimeFormat(style), locale);
- // END android-changed
+ return new SimpleDateFormat(LocaleData.get(locale).getTimeFormat(style), locale);
}
/**
diff --git a/text/src/main/java/java/text/DateFormatSymbols.java b/text/src/main/java/java/text/DateFormatSymbols.java
index 73e89e0..d586ae1 100644
--- a/text/src/main/java/java/text/DateFormatSymbols.java
+++ b/text/src/main/java/java/text/DateFormatSymbols.java
@@ -18,7 +18,7 @@
package java.text;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
@@ -94,7 +94,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
synchronized String[][] internalZoneStrings() {
if (zoneStrings == null) {
- zoneStrings = Resources.getDisplayTimeZones(locale.toString());
+ zoneStrings = ICU.getDisplayTimeZones(locale.toString());
}
return zoneStrings;
}
@@ -118,16 +118,14 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/
public DateFormatSymbols(Locale locale) {
this.locale = locale;
- // BEGIN android-changed
this.localPatternChars = SimpleDateFormat.patternChars;
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
+ LocaleData localeData = LocaleData.get(locale);
this.ampms = localeData.amPm;
this.eras = localeData.eras;
this.months = localeData.longMonthNames;
this.shortMonths = localeData.shortMonthNames;
this.weekdays = localeData.longWeekdayNames;
this.shortWeekdays = localeData.shortWeekdayNames;
- // END android-changed
}
/**
@@ -165,7 +163,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @hide
*/
public static Locale[] getAvailableLocales() {
- return Resources.getAvailableDateFormatSymbolsLocales();
+ return ICU.getAvailableDateFormatSymbolsLocales();
}
private void writeObject(ObjectOutputStream oos) throws IOException {
@@ -344,9 +342,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @return a two-dimensional array of strings.
*/
public String[][] getZoneStrings() {
- // BEGIN android-changed
- return Resources.clone2dStringArray(internalZoneStrings());
- // END android-changed
+ return ICU.clone2dStringArray(internalZoneStrings());
}
@Override
@@ -483,7 +479,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* the two-dimensional array of strings.
*/
public void setZoneStrings(String[][] data) {
- zoneStrings = Resources.clone2dStringArray(data);
+ zoneStrings = ICU.clone2dStringArray(data);
customZoneStrings = true;
}
}
diff --git a/text/src/main/java/java/text/DecimalFormat.java b/text/src/main/java/java/text/DecimalFormat.java
index 2776575..d7ac012 100644
--- a/text/src/main/java/java/text/DecimalFormat.java
+++ b/text/src/main/java/java/text/DecimalFormat.java
@@ -17,6 +17,8 @@
package java.text;
+import com.ibm.icu4jni.text.NativeDecimalFormat;
+import com.ibm.icu4jni.util.LocaleData;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -29,9 +31,6 @@ import java.security.PrivilegedAction;
import java.util.Currency;
import java.util.Locale;
-import com.ibm.icu4jni.text.NativeDecimalFormat;
-import com.ibm.icu4jni.util.LocaleData;
-
/**
* A concrete subclass of {@link NumberFormat} that formats decimal numbers. It
* has a variety of features designed to make it possible to parse and format
@@ -238,7 +237,7 @@ import com.ibm.icu4jni.util.LocaleData;
* </tr>
* </table> </blockquote>
* <p>
- * A {@code DecimalFormat} pattern contains a postive and negative subpattern,
+ * A {@code DecimalFormat} pattern contains a positive and negative subpattern,
* for example, "#,##0.00;(#,##0.00)". Each subpattern has a prefix, a numeric
* part and a suffix. If there is no explicit negative subpattern, the negative
* subpattern is the localized minus sign prefixed to the positive subpattern.
@@ -353,7 +352,7 @@ import com.ibm.icu4jni.util.LocaleData;
* example, 0.125 is formatted as "0.12" if the maximum fraction digits is 2.
* <li>If the number of actual fraction digits is less than the
* <em>minimum fraction digits</em>, then trailing zeros are added. For
- * example, 0.125 is formatted as "0.1250" if the mimimum fraction digits is set
+ * example, 0.125 is formatted as "0.1250" if the minimum fraction digits is set
* to 4.
* <li>Trailing fractional zeros are not displayed if they occur <em>j</em>
* positions after the decimal, where <em>j</em> is less than the maximum
@@ -499,7 +498,7 @@ import com.ibm.icu4jni.util.LocaleData;
* number of '@' characters in the pattern - 1, and a maximum fraction digit
* count of the number of '@' and '#' characters in the pattern - 1. For
* example, the pattern {@code "@@###E0"} is equivalent to {@code "0.0###E0"}.
- * <li>If signficant digits are in use then the integer and fraction digit
+ * <li>If significant digits are in use then the integer and fraction digit
* counts, as set via the API, are ignored.
* </ul>
* <h4> <strong><font color="red">NEW</font>&nbsp;</strong> Padding</h4>
@@ -558,12 +557,9 @@ public class DecimalFormat extends NumberFormat {
* See "<a href="../util/Locale.html#default_locale">Be wary of the default locale</a>".
*/
public DecimalFormat() {
- // BEGIN android-changed: reduce duplication.
Locale locale = Locale.getDefault();
this.symbols = new DecimalFormatSymbols(locale);
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
- initNative(localeData.numberPattern);
- // END android-changed
+ initNative(LocaleData.get(locale).numberPattern);
}
/**
@@ -576,9 +572,7 @@ public class DecimalFormat extends NumberFormat {
* if the pattern cannot be parsed.
*/
public DecimalFormat(String pattern) {
- // BEGIN android-changed: reduce duplication.
this(pattern, Locale.getDefault());
- // END android-changed
}
/**
@@ -593,20 +587,16 @@ public class DecimalFormat extends NumberFormat {
* if the pattern cannot be parsed.
*/
public DecimalFormat(String pattern, DecimalFormatSymbols value) {
- // BEGIN android-changed: reduce duplication.
this.symbols = (DecimalFormatSymbols) value.clone();
initNative(pattern);
- // END android-changed
}
- // BEGIN android-added: used by NumberFormat.getInstance because cloning DecimalFormatSymbols is slow.
+ // Used by NumberFormat.getInstance because cloning DecimalFormatSymbols is slow.
DecimalFormat(String pattern, Locale locale) {
this.symbols = new DecimalFormatSymbols(locale);
initNative(pattern);
}
- // END android-added
- // BEGIN android-changed: reduce duplication.
private void initNative(String pattern) {
try {
this.dform = new NativeDecimalFormat(pattern, symbols);
@@ -618,7 +608,6 @@ public class DecimalFormat extends NumberFormat {
super.setMinimumFractionDigits(dform.getMinimumFractionDigits());
super.setMinimumIntegerDigits(dform.getMinimumIntegerDigits());
}
- // END android-added
/**
* Changes the pattern of this decimal format to the specified pattern which
diff --git a/text/src/main/java/java/text/DecimalFormatSymbols.java b/text/src/main/java/java/text/DecimalFormatSymbols.java
index b1144a8..a32f6cf 100644
--- a/text/src/main/java/java/text/DecimalFormatSymbols.java
+++ b/text/src/main/java/java/text/DecimalFormatSymbols.java
@@ -18,7 +18,7 @@
package java.text;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -82,8 +82,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* the locale.
*/
public DecimalFormatSymbols(Locale locale) {
- // BEGIN android-changed
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
+ LocaleData localeData = LocaleData.get(locale);
this.zeroDigit = localeData.zeroDigit;
this.digit = localeData.digit;
this.decimalSeparator = localeData.decimalSeparator;
@@ -106,7 +105,6 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
currencySymbol = localeData.currencySymbol;
intlCurrencySymbol = localeData.internationalCurrencySymbol;
}
- // END android-changed
}
/**
@@ -144,7 +142,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable {
* @hide
*/
public static Locale[] getAvailableLocales() {
- return Resources.getAvailableDecimalFormatSymbolsLocales();
+ return ICU.getAvailableDecimalFormatSymbolsLocales();
}
@Override
diff --git a/text/src/main/java/java/text/NumberFormat.java b/text/src/main/java/java/text/NumberFormat.java
index ace2697..a4cccc0 100644
--- a/text/src/main/java/java/text/NumberFormat.java
+++ b/text/src/main/java/java/text/NumberFormat.java
@@ -18,7 +18,7 @@
package java.text;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
@@ -314,7 +314,7 @@ public abstract class NumberFormat extends Format {
* are available.
*/
public static Locale[] getAvailableLocales() {
- return Resources.getAvailableNumberFormatLocales();
+ return ICU.getAvailableNumberFormatLocales();
}
/**
@@ -353,10 +353,7 @@ public abstract class NumberFormat extends Format {
* @return a {@code NumberFormat} for handling currency values.
*/
public static NumberFormat getCurrencyInstance(Locale locale) {
- // BEGIN android-changed
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
- return getInstance(localeData.currencyPattern, locale);
- // END android-changed
+ return getInstance(LocaleData.get(locale).currencyPattern, locale);
}
/**
@@ -379,12 +376,9 @@ public abstract class NumberFormat extends Format {
* @return a {@code NumberFormat} for handling integers.
*/
public static NumberFormat getIntegerInstance(Locale locale) {
- // BEGIN android-changed
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
- NumberFormat result = getInstance(localeData.integerPattern, locale);
+ NumberFormat result = getInstance(LocaleData.get(locale).integerPattern, locale);
result.setParseIntegerOnly(true);
return result;
- // END android-changed
}
/**
@@ -477,10 +471,7 @@ public abstract class NumberFormat extends Format {
* @return a {@code NumberFormat} for handling {@code Number} objects.
*/
public static NumberFormat getNumberInstance(Locale locale) {
- // BEGIN android-changed
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
- return getInstance(localeData.numberPattern, locale);
- // END android-changed
+ return getInstance(LocaleData.get(locale).numberPattern, locale);
}
/**
@@ -503,10 +494,7 @@ public abstract class NumberFormat extends Format {
* @return a {@code NumberFormat} for handling percentage values.
*/
public static NumberFormat getPercentInstance(Locale locale) {
- // BEGIN android-changed
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(locale);
- return getInstance(localeData.percentPattern, locale);
- // END android-changed
+ return getInstance(LocaleData.get(locale).percentPattern, locale);
}
@Override
diff --git a/text/src/main/java/java/text/SimpleDateFormat.java b/text/src/main/java/java/text/SimpleDateFormat.java
index e3669ad..cb114a3 100644
--- a/text/src/main/java/java/text/SimpleDateFormat.java
+++ b/text/src/main/java/java/text/SimpleDateFormat.java
@@ -18,7 +18,7 @@
package java.text;
import com.ibm.icu4jni.util.LocaleData;
-import com.ibm.icu4jni.util.Resources;
+import com.ibm.icu4jni.util.ICU;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -569,7 +569,7 @@ public class SimpleDateFormat extends DateFormat {
}
private static String defaultPattern() {
- LocaleData localeData = com.ibm.icu4jni.util.Resources.getLocaleData(Locale.getDefault());
+ LocaleData localeData = LocaleData.get(Locale.getDefault());
return localeData.getDateFormat(SHORT) + " " + localeData.getTimeFormat(SHORT);
}
@@ -886,7 +886,7 @@ public class SimpleDateFormat extends DateFormat {
}
// We can't call TimeZone.getDisplayName() because it would not use
// the custom DateFormatSymbols of this SimpleDateFormat.
- String custom = Resources.lookupDisplayTimeZone(formatData.zoneStrings, tz.getID(), daylight, style);
+ String custom = ICU.lookupDisplayTimeZone(formatData.zoneStrings, tz.getID(), daylight, style);
if (custom != null) {
buffer.append(custom);
return;