summaryrefslogtreecommitdiffstats
path: root/icu/src/main/java
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-04-01 13:56:32 -0700
committerElliott Hughes <enh@google.com>2010-04-01 13:56:32 -0700
commitf9157eaea53923d3dbe6a521b29427819052f176 (patch)
tree23d24f5bad0fdaed99ee5e81de7d2f488d4edd19 /icu/src/main/java
parentf072c0384c0b12f081fb99bc365d284ae6381379 (diff)
downloadlibcore-f9157eaea53923d3dbe6a521b29427819052f176.zip
libcore-f9157eaea53923d3dbe6a521b29427819052f176.tar.gz
libcore-f9157eaea53923d3dbe6a521b29427819052f176.tar.bz2
Tidy up our getAvailableLocales methods to actually ask ICU4C.
These specialized methods are little used, and in several cases ICU itself just returns the list of locales, but that's ICU's business, not ours. As long as ICU is in charge of our locale-specific data, it should be responsible for answering questions about what locale-specific data is available... Change-Id: Idc8a66bbf7fcbc6b06e30929e6a7af3fe30ab7d1
Diffstat (limited to 'icu/src/main/java')
-rw-r--r--icu/src/main/java/com/ibm/icu4jni/text/Collator.java4
-rw-r--r--icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java5
-rw-r--r--icu/src/main/java/com/ibm/icu4jni/text/NativeCollation.java2
-rw-r--r--icu/src/main/java/com/ibm/icu4jni/util/Resources.java84
4 files changed, 53 insertions, 42 deletions
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 f108737..3673d32 100644
--- a/icu/src/main/java/com/ibm/icu4jni/text/Collator.java
+++ b/icu/src/main/java/com/ibm/icu4jni/text/Collator.java
@@ -324,8 +324,4 @@ public abstract class Collator implements Cloneable {
* @stable ICU 2.4
*/
public abstract int hashCode();
-
- public static Locale[] getAvailableLocales() {
- return Resources.localesFromStrings(NativeCollation.getAvailableLocalesImpl());
- }
}
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 3f67a64..91f2beb 100644
--- a/icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java
+++ b/icu/src/main/java/com/ibm/icu4jni/text/NativeBreakIterator.java
@@ -125,10 +125,6 @@ public final class NativeBreakIterator implements Cloneable {
return precedingImpl(this.addr, offset);
}
- public static Locale[] getAvailableLocales() {
- return Resources.localesFromStrings(getAvailableLocalesImpl());
- }
-
public static NativeBreakIterator getCharacterInstance(Locale where) {
return new NativeBreakIterator(getCharacterInstanceImpl(where.toString()), BI_CHAR_INSTANCE);
}
@@ -145,7 +141,6 @@ public final class NativeBreakIterator implements Cloneable {
return new NativeBreakIterator(getWordInstanceImpl(where.toString()), BI_WORD_INSTANCE);
}
- private static native String[] getAvailableLocalesImpl();
private static native int getCharacterInstanceImpl(String locale);
private static native int getWordInstanceImpl(String locale);
private static native int getLineInstanceImpl(String locale);
diff --git a/icu/src/main/java/com/ibm/icu4jni/text/NativeCollation.java b/icu/src/main/java/com/ibm/icu4jni/text/NativeCollation.java
index 7d474ef..fbdcf93 100644
--- a/icu/src/main/java/com/ibm/icu4jni/text/NativeCollation.java
+++ b/icu/src/main/java/com/ibm/icu4jni/text/NativeCollation.java
@@ -244,6 +244,4 @@ final class NativeCollation
* @internal ICU 2.4
*/
static native void setOffset(int address, int offset);
-
- static native String[] getAvailableLocalesImpl();
}
diff --git a/icu/src/main/java/com/ibm/icu4jni/util/Resources.java b/icu/src/main/java/com/ibm/icu4jni/util/Resources.java
index aae2ff4..874d9be 100644
--- a/icu/src/main/java/com/ibm/icu4jni/util/Resources.java
+++ b/icu/src/main/java/com/ibm/icu4jni/util/Resources.java
@@ -39,22 +39,17 @@ public final class Resources {
/**
* Cache for ISO language names.
*/
- private static String[] isoLanguages = null;
+ private static String[] isoLanguages;
/**
* Cache for ISO country names.
*/
- private static String[] isoCountries = null;
-
- /**
- * Available locales cache.
- */
- private static String[] availableLocales = null;
+ private static String[] isoCountries;
/**
* Available timezones cache.
*/
- private static String[] availableTimezones = null;
+ private static String[] availableTimezones;
/**
* Returns a shared LocaleData for the given locale.
@@ -102,7 +97,7 @@ public final class Resources {
/**
* Returns an array of ISO language names (two-letter codes), fetched either
* from ICU's database or from our memory cache.
- *
+ *
* @return The array.
*/
public static String[] getISOLanguages() {
@@ -116,7 +111,7 @@ public final class Resources {
/**
* Returns an array of ISO country names (two-letter codes), fetched either
* from ICU's database or from our memory cache.
- *
+ *
* @return The array.
*/
public static String[] getISOCountries() {
@@ -128,23 +123,9 @@ public final class Resources {
}
/**
- * Returns an array of names of locales that are available in the system,
- * fetched either from ICU's database or from our memory cache.
- *
- * @return The array.
- */
- public static String[] getAvailableLocales() {
- if (availableLocales == null) {
- availableLocales = getAvailableLocalesNative();
- }
-
- return availableLocales.clone();
- }
-
- /**
* Returns an array of names of timezones that are available in the system,
* fetched either from the TimeZone class or from our memory cache.
- *
+ *
* @return The array.
*/
public static String[] getKnownTimezones() {
@@ -158,7 +139,7 @@ public final class Resources {
/**
* Returns the display name for the given time zone using the given locale.
- *
+ *
* @param id The time zone ID, for example "Europe/Berlin"
* @param daylight Indicates whether daylight savings is in use
* @param style The style, 0 for long, 1 for short
@@ -261,7 +242,7 @@ public final class Resources {
/**
* Returns the display names for all given timezones using the given locale.
- *
+ *
* @return An array of time zone strings. Each row represents one time zone.
* The first columns holds the ID of the time zone, for example
* "Europe/Berlin". The other columns then hold for each row the
@@ -274,14 +255,14 @@ public final class Resources {
if (locale == null) {
locale = defaultLocale;
}
-
+
// If locale == default and the default locale hasn't changed since
// DefaultTimeZones loaded, return the cached names.
// TODO: We should force a reboot if the default locale changes.
if (defaultLocale.equals(locale) && DefaultTimeZones.locale.equals(defaultLocale)) {
return clone2dStringArray(DefaultTimeZones.names);
}
-
+
return createTimeZoneNamesFor(locale);
}
@@ -322,8 +303,51 @@ public final class Resources {
return result;
}
+ private static Locale[] availableLocalesCache;
+ public static Locale[] getAvailableLocales() {
+ if (availableLocalesCache == null) {
+ availableLocalesCache = localesFromStrings(getAvailableLocalesNative());
+ }
+ return availableLocalesCache.clone();
+ }
+
+ public static Locale[] getAvailableBreakIteratorLocales() {
+ return localesFromStrings(getAvailableBreakIteratorLocalesNative());
+ }
+
+ public static Locale[] getAvailableCalendarLocales() {
+ return localesFromStrings(getAvailableCalendarLocalesNative());
+ }
+
+ public static Locale[] getAvailableCollatorLocales() {
+ return localesFromStrings(getAvailableCollatorLocalesNative());
+ }
+
+ public static Locale[] getAvailableDateFormatLocales() {
+ return localesFromStrings(getAvailableDateFormatLocalesNative());
+ }
+
+ public static Locale[] getAvailableDateFormatSymbolsLocales() {
+ return getAvailableDateFormatLocales();
+ }
+
+ public static Locale[] getAvailableDecimalFormatSymbolsLocales() {
+ return getAvailableNumberFormatLocales();
+ }
+
+ public static Locale[] getAvailableNumberFormatLocales() {
+ return localesFromStrings(getAvailableNumberFormatLocalesNative());
+ }
+
// --- Native methods accessing ICU's database ----------------------------
+ private static native String[] getAvailableBreakIteratorLocalesNative();
+ private static native String[] getAvailableCalendarLocalesNative();
+ private static native String[] getAvailableCollatorLocalesNative();
+ private static native String[] getAvailableDateFormatLocalesNative();
+ private static native String[] getAvailableLocalesNative();
+ private static native String[] getAvailableNumberFormatLocalesNative();
+
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);
@@ -336,8 +360,6 @@ public final class Resources {
public static native int getCurrencyFractionDigitsNative(String currencyCode);
- private static native String[] getAvailableLocalesNative();
-
private static native String[] getISOLanguagesNative();
private static native String[] getISOCountriesNative();