Search in sources :

Example 11 with UResourceBundle

use of android.icu.util.UResourceBundle in project j2objc by google.

the class TimeZoneNamesImpl method _getAvailableMetaZoneIDs.

static Set<String> _getAvailableMetaZoneIDs() {
    if (METAZONE_IDS == null) {
        synchronized (TimeZoneNamesImpl.class) {
            if (METAZONE_IDS == null) {
                UResourceBundle bundle = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, "metaZones");
                UResourceBundle mapTimezones = bundle.get("mapTimezones");
                Set<String> keys = mapTimezones.keySet();
                METAZONE_IDS = Collections.unmodifiableSet(keys);
            }
        }
    }
    return METAZONE_IDS;
}
Also used : UResourceBundle(android.icu.util.UResourceBundle)

Example 12 with UResourceBundle

use of android.icu.util.UResourceBundle in project j2objc by google.

the class OlsonTimeZone method readObject.

private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    if (serialVersionOnStream < 1) {
        // No version - 4.2 or older
        // Just reloading the rule from bundle
        boolean initialized = false;
        String tzid = getID();
        if (tzid != null) {
            try {
                UResourceBundle top = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, ZONEINFORES, ICUResourceBundle.ICU_DATA_CLASS_LOADER);
                UResourceBundle res = ZoneMeta.openOlsonResource(top, tzid);
                construct(top, res);
                if (finalZone != null) {
                    finalZone.setID(tzid);
                }
                initialized = true;
            } catch (Exception ignored) {
            // throw away
            }
        }
        if (!initialized) {
            // final resort
            constructEmpty();
        }
    }
    // need to rebuild transition rules when requested
    transitionRulesInitialized = false;
}
Also used : UResourceBundle(android.icu.util.UResourceBundle) MissingResourceException(java.util.MissingResourceException) IOException(java.io.IOException)

Example 13 with UResourceBundle

use of android.icu.util.UResourceBundle in project j2objc by google.

the class OlsonTimeZone method loadRule.

private static UResourceBundle loadRule(UResourceBundle top, String ruleid) {
    UResourceBundle r = top.get("Rules");
    r = r.get(ruleid);
    return r;
}
Also used : UResourceBundle(android.icu.util.UResourceBundle)

Example 14 with UResourceBundle

use of android.icu.util.UResourceBundle in project j2objc by google.

the class ICUDataVersion method getDataVersion.

/**
 * This function retrieves the data version from icuver and returns a VersionInfo object with that version information.
 *
 * @return Current icu data version
 */
public static VersionInfo getDataVersion() {
    UResourceBundle icudatares = null;
    try {
        icudatares = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, ICUDataVersion.U_ICU_VERSION_BUNDLE, ICUResourceBundle.ICU_DATA_CLASS_LOADER);
        icudatares = icudatares.get(ICUDataVersion.U_ICU_DATA_KEY);
    } catch (MissingResourceException ex) {
        return null;
    }
    return VersionInfo.getInstance(icudatares.getString());
}
Also used : UResourceBundle(android.icu.util.UResourceBundle) MissingResourceException(java.util.MissingResourceException)

Example 15 with UResourceBundle

use of android.icu.util.UResourceBundle in project j2objc by google.

the class ICUResourceBundleTest method TestT6844.

/*
     * UResouceBundle should be able to load a resource bundle even if
     * a similarly named class (only case differences) exists in the
     * same package.  See Ticket#6844
     */
@Test
public void TestT6844() {
    try {
        UResourceBundle rb1 = UResourceBundle.getBundleInstance("android.icu.dev.data.resources.TestMessages", ULocale.getDefault(), testLoader);
        assertEquals("bundleContainer in TestMessages", "TestMessages.class", rb1.getString("bundleContainer"));
        UResourceBundle rb2 = UResourceBundle.getBundleInstance("android.icu.dev.data.resources.testmessages", ULocale.getDefault(), testLoader);
        assertEquals("bundleContainer in testmessages", "testmessages.properties", rb2.getString("bundleContainer"));
    } catch (Throwable t) {
        errln(t.getMessage());
    }
}
Also used : ICUResourceBundle(android.icu.impl.ICUResourceBundle) UResourceBundle(android.icu.util.UResourceBundle) Test(org.junit.Test)

Aggregations

UResourceBundle (android.icu.util.UResourceBundle)46 ICUResourceBundle (android.icu.impl.ICUResourceBundle)26 MissingResourceException (java.util.MissingResourceException)24 Test (org.junit.Test)17 ULocale (android.icu.util.ULocale)8 UResourceBundleIterator (android.icu.util.UResourceBundleIterator)6 UResourceTypeMismatchException (android.icu.util.UResourceTypeMismatchException)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 SimpleTimeZone (android.icu.util.SimpleTimeZone)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 EnumSet (java.util.EnumSet)2 Locale (java.util.Locale)2 Map (java.util.Map)2 Set (java.util.Set)2 TreeMap (java.util.TreeMap)2 JavaTimeZone (android.icu.impl.JavaTimeZone)1