Methods Summary |
---|
private static java.lang.String[][] | createTimeZoneNamesFor(java.lang.String locale)Creates array of time zone names for the given locale. This method takes
about 2s to run on a 400mhz ARM11.
long start = System.currentTimeMillis();
/*
* The following code is optimized for fast native response (the time a
* method call can be in native code is limited). It prepares an empty
* array to keep native code from having to create new Java objects. It
* also fill in the time zone IDs to speed things up a bit. There's one
* array for each time zone name type. (standard/long, standard/short,
* daylight/long, daylight/short) The native method that fetches these
* strings is faster if it can do all entries of one type, before having
* to change to the next type. That's why the array passed down to
* native has 5 entries, each providing space for all time zone names of
* one type. Likely this access to the fields is much faster in the
* native code because there's less array access overhead.
*/
String[][] arrayToFill = new String[5][];
arrayToFill[0] = getKnownTimezones();
arrayToFill[1] = new String[availableTimezones.length];
arrayToFill[2] = new String[availableTimezones.length];
arrayToFill[3] = new String[availableTimezones.length];
arrayToFill[4] = new String[availableTimezones.length];
/*
* Fill in the zone names in native.
*/
getTimeZonesNative(arrayToFill, locale);
/*
* Finally we need to reorder the entries so we get the expected result.
*/
String[][] result = new String[availableTimezones.length][5];
for (int i = 0; i < availableTimezones.length; i++) {
result[i][0] = arrayToFill[0][i];
result[i][1] = arrayToFill[1][i];
result[i][2] = arrayToFill[2][i];
result[i][3] = arrayToFill[3][i];
result[i][4] = arrayToFill[4][i];
}
Logger.getLogger(Resources.class.getSimpleName()).info(
"Loaded time zone names for " + locale + " in "
+ (System.currentTimeMillis() - start) + "ms.");
return result;
|
public static java.lang.String[] | getAvailableLocales()Returns an array of names of locales that are available in the system,
fetched either from ICU's database or from our memory cache.
if (availableLocales == null) {
availableLocales = getAvailableLocalesNative();
}
return availableLocales;
|
private static native java.lang.String[] | getAvailableLocalesNative()
|
private static native java.lang.Object[][] | getContentImpl(java.lang.String locale, boolean needsTimeZones)
|
private static native java.lang.String | getCurrencyCodeNative(java.lang.String locale)
|
private static native java.lang.String | getCurrencySymbolNative(java.lang.String locale, java.lang.String currencyCode)
|
private static java.lang.String | getDefaultLocaleName()Gets the name of the default locale.
return java.util.Locale.getDefault().toString();
|
private static native java.lang.String | getDisplayCountryNative(java.lang.String countryCode, java.lang.String locale)
|
private static native java.lang.String | getDisplayLanguageNative(java.lang.String languageCode, java.lang.String locale)
|
public static java.lang.String | getDisplayTimeZone(java.lang.String id, boolean isDST, int style, java.lang.String locale)Returns the display name for the given time zone using the given locale.
return getDisplayTimeZoneNative(id, isDST, style, locale);
|
private static native java.lang.String | getDisplayTimeZoneNative(java.lang.String id, boolean isDST, int style, java.lang.String locale)
|
public static java.lang.String[][] | getDisplayTimeZones(java.lang.String locale)Returns the display names for all given timezones using the given locale.
// Note: Defer loading DefaultTimeZones as long as possible.
String defaultLocaleName = getDefaultLocaleName();
if (locale == null) {
locale = defaultLocaleName;
}
// 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 (defaultLocaleName.equals(locale)
&& initialLocale.equals(defaultLocaleName)) {
if (defaultTimezoneNames == null) {
defaultTimezoneNames = createTimeZoneNamesFor(locale);
}
return defaultTimezoneNames;
}
return createTimeZoneNamesFor(locale);
|
private static native java.lang.String | getDisplayVariantNative(java.lang.String variantCode, java.lang.String locale)
|
private static native int | getFractionDigitsNative(java.lang.String currencyCode)
|
private static native java.lang.String | getISO3CountryNative(java.lang.String locale)
|
private static native java.lang.String | getISO3LanguageNative(java.lang.String locale)
|
public static java.lang.String[] | getISOCountries()Returns an array of ISO country names (two-letter codes), fetched either
from ICU's database or from our memory cache.
if (isoCountries == null) {
isoCountries = getISOCountriesNative();
}
return isoCountries;
|
private static native java.lang.String[] | getISOCountriesNative()
|
public static java.lang.String[] | getISOLanguages()Returns an array of ISO language names (two-letter codes), fetched either
from ICU's database or from our memory cache.
if (isoLanguages == null) {
isoLanguages = getISOLanguagesNative();
}
return isoLanguages;
|
private static native java.lang.String[] | getISOLanguagesNative()
|
public static java.util.ResourceBundle | getInstance(java.lang.String bundleName, java.lang.String locale)Creates ResourceBundle instance and fills it with ICU data.
if (locale == null) {
locale = java.util.Locale.getDefault().toString();
}
if (bundleName.startsWith("Locale")) {
return new Locale(locale);
} else if (bundleName.startsWith("Country")) {
return new Country(locale);
} else if (bundleName.startsWith("Currency")) {
return new Currency(locale);
} else if (bundleName.startsWith("Language")) {
return new Language(locale);
} else if (bundleName.startsWith("Variant")) {
return new Variant(locale);
} else if (bundleName.equals("ISO3Countries")) {
return new ISO3Countries();
} else if (bundleName.equals("ISO3Languages")) {
return new ISO3Languages();
} else if (bundleName.equals("ISO4CurrenciesToDigits")) {
return new ISO4CurrenciesToDigits();
} else if (bundleName.equals("ISO4Currencies")) {
return new ISO4Currencies();
}
return null;
|
public static java.lang.String[] | getKnownTimezones()Returns an array of names of timezones that are available in the system,
fetched either from the TimeZone class or from our memory cache.
// TODO Drop the Linux ZoneInfo stuff in favor of ICU.
if (availableTimezones == null) {
availableTimezones = TimeZone.getAvailableIDs();
}
return availableTimezones;
|
private static native void | getTimeZonesNative(java.lang.String[][] arrayToFill, java.lang.String locale)
|