use of android.icu.util.UResourceBundle in project j2objc by google.
the class ICUResourceBundle method getKeywordValues.
/**
* Given a tree path and keyword, return a string enumeration of all possible values for that keyword.
* @param baseName resource specifier
* @param keyword a particular keyword to consider, must match a top level resource name
* within the tree. (i.e. "collations")
* @hide draft / provisional / internal are hidden on Android
*/
public static final String[] getKeywordValues(String baseName, String keyword) {
Set<String> keywords = new HashSet<String>();
ULocale[] locales = getAvailEntry(baseName, ICU_DATA_CLASS_LOADER).getULocaleList();
int i;
for (i = 0; i < locales.length; i++) {
try {
UResourceBundle b = UResourceBundle.getBundleInstance(baseName, locales[i]);
// downcast to ICUResourceBundle?
ICUResourceBundle irb = (ICUResourceBundle) (b.getObject(keyword));
Enumeration<String> e = irb.getKeys();
while (e.hasMoreElements()) {
String s = e.nextElement();
if (!DEFAULT_TAG.equals(s) && !s.startsWith("private-")) {
// don't add 'default' items, nor unlisted types
keywords.add(s);
}
}
} catch (Throwable t) {
// System.err.println("Error in - " + new Integer(i).toString()
// + " - " + t.toString());
// ignore the err - just skip that resource
}
}
return keywords.toArray(new String[0]);
}
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());
}
use of android.icu.util.UResourceBundle in project j2objc by google.
the class NumberingSystem method lookupInstanceByName.
private static NumberingSystem lookupInstanceByName(String name) {
int radix;
boolean isAlgorithmic;
String description;
try {
UResourceBundle numberingSystemsInfo = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME, "numberingSystems");
UResourceBundle nsCurrent = numberingSystemsInfo.get("numberingSystems");
UResourceBundle nsTop = nsCurrent.get(name);
description = nsTop.getString("desc");
UResourceBundle nsRadixBundle = nsTop.get("radix");
UResourceBundle nsAlgBundle = nsTop.get("algorithmic");
radix = nsRadixBundle.getInt();
int algorithmic = nsAlgBundle.getInt();
isAlgorithmic = (algorithmic == 1);
} catch (MissingResourceException ex) {
return null;
}
return getInstance(name, radix, isAlgorithmic, description);
}
use of android.icu.util.UResourceBundle in project j2objc by google.
the class ICUResourceBundleTest method TestCLDRStyleAliases.
@Test
public void TestCLDRStyleAliases() {
String result = null;
String expected = null;
String[] expects = new String[] { "", "a41", "a12", "a03", "ar4" };
logln("Testing CLDR style aliases......\n");
UResourceBundle rb = UResourceBundle.getBundleInstance("android/icu/dev/data/testdata", "te_IN_REVISED", testLoader);
ICUResourceBundle alias = (ICUResourceBundle) rb.get("a");
for (int i = 1; i < 5; i++) {
String resource = "a" + i;
UResourceBundle a = (alias).getWithFallback(resource);
result = a.getString();
if (result.equals(expected)) {
errln("CLDR style aliases failed resource with name " + resource + "resource, exp " + expects[i] + " , got " + result);
}
}
}
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());
}
}
Aggregations