// The only keyword we recognize is 'currency'
if (!"currency".equals(key)) {
return EMPTY_STRING_ARRAY;
}
CurrencyMetaInfo info = CurrencyMetaInfo.getInstance();
if (!commonlyUsed) {
// Behavior change from 4.3.3, no longer sort the currencies
List<String> result = info.currencies(null);
return result.toArray(new String[result.size()]);
}
// Don't resolve region if the requested locale is 'und', it will resolve to US
// which we don't want.
String prefRegion = locale.getCountry();
if (prefRegion.length() == 0) {
if (UND.equals(locale)) {
return EMPTY_STRING_ARRAY;
}
ULocale loc = ULocale.addLikelySubtags(locale);
prefRegion = loc.getCountry();
}
CurrencyFilter filter = CurrencyFilter.now().withRegion(prefRegion);
// currencies are in region's preferred order when we're filtering on region, which
// matches our spec
List<String> result = info.currencies(filter);
// No fallback anymore (change from 4.3.3)
if (result.size() == 0) {
return EMPTY_STRING_ARRAY;
}