2. If there is no match, fall back to "en" and try again
3. If there is no match, fall back to root and try again
4. If still no match, parse 3-letter ISO {this code is probably unchanged}.
*/
TextTrieMap symTrie = (TextTrieMap)trieVec.elementAt(0);
TextTrieMap trie = (TextTrieMap)trieVec.elementAt(1);
HashSet visited = new HashSet();
ULocale parentLocale = locale;
while (parentLocale != null) {
UResourceBundle rb = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,parentLocale);
// We can't cast this to String[][]; the cast has to happen later
try {
UResourceBundle currencies = rb.get("Currencies");
// Do a linear search
for (int i=0; i<currencies.getSize(); ++i) {
UResourceBundle item = currencies.get(i);
String ISOCode = item.getKey();
if (!visited.contains(ISOCode)) {
CurrencyStringInfo info = new CurrencyStringInfo(ISOCode, ISOCode);
symTrie.put(ISOCode, info);
String name = item.getString(0);
if (name.length() > 1 && name.charAt(0) == '=' &&
name.charAt(1) != '=') {
// handle choice format here
name = name.substring(1);
ChoiceFormat choice = new ChoiceFormat(name);
Object[] names = choice.getFormats();
for (int nameIndex = 0; nameIndex < names.length;
++nameIndex) {
info = new CurrencyStringInfo(ISOCode,
(String)names[nameIndex]);
symTrie.put((String)names[nameIndex], info);
}
} else {
info = new CurrencyStringInfo(ISOCode, name);
symTrie.put(name, info);
}
info = new CurrencyStringInfo(ISOCode, item.getString(1));
trie.put(item.getString(1), info);
visited.add(ISOCode);
}
}
}
catch (MissingResourceException e) {}
parentLocale = parentLocale.getFallback();
}
// Look up the CurrencyPlurals resource for the given locale. The
// CurrencyPlurals locale data looks like this:
//|en {
//| CurrencyPlurals {
//| USD {
//| one{"US Dollar"}
//| other{"US dollars"}
//| }
//| //...
//| }
//|}
HashMap visitedInMap = new HashMap();
parentLocale = locale;
while (parentLocale != null) {
UResourceBundle rb = UResourceBundle.getBundleInstance(ICUResourceBundle.ICU_BASE_NAME,parentLocale);
try {
UResourceBundle currencies;
currencies = rb.get("CurrencyPlurals");
for (int i=0; i<currencies.getSize(); ++i) {
UResourceBundle item = currencies.get(i);
String ISOCode = item.getKey();
HashSet visitPluralCount = (HashSet)visitedInMap.get(ISOCode);
if (visitPluralCount == null) {
visitPluralCount = new HashSet();
visitedInMap.put(ISOCode, visitPluralCount);
}
for (int j=0; j<item.getSize(); ++j) {
String count = item.get(j).getKey();
if (!visitPluralCount.contains(count)) {
CurrencyStringInfo info = new CurrencyStringInfo(ISOCode, item.get(j).getString());
trie.put(item.get(j).getString(), info);
visitPluralCount.add(count);
}
}
}
}