UErrorCode sts = U_ZERO_ERROR;
UnicodeString ustrValue(value, -1, US_INV);
int32_t len;
- UBool isChoice = FALSE;
const UChar *currencyName = ucurr_getName(ustrValue.getTerminatedBuffer(),
- locale.getBaseName(), UCURR_LONG_NAME, &isChoice, &len, &sts);
+ locale.getBaseName(), UCURR_LONG_NAME, nullptr /* isChoiceFormat */, &len, &sts);
if (U_FAILURE(sts)) {
// Return the value as is on failure
result = ustrValue;
// We no longer support choice format data in names. Data should not contain
// choice patterns.
- *isChoiceFormat = FALSE;
+ if (isChoiceFormat != NULL) {
+ *isChoiceFormat = FALSE;
+ }
if (U_SUCCESS(ec2)) {
U_ASSERT(s != NULL);
return s;
{
U_NAMESPACE_USE
- UBool isChoiceFormat;
int32_t len;
const UChar* currname = ucurr_getName(iso, loc, UCURR_SYMBOL_NAME,
- &isChoiceFormat, &len, &ec);
+ nullptr /* isChoiceFormat */, &len, &ec);
if (U_SUCCESS(ec)) {
result.setTo(currname, len);
}
* @param currency null-terminated 3-letter ISO 4217 code
* @param locale locale in which to display currency
* @param nameStyle selector for which kind of name to return
- * @param isChoiceFormat fill-in set to TRUE if the returned value
- * is a ChoiceFormat pattern; otherwise it is a static string
+ * @param isChoiceFormat always set to FALSE, or can be NULL;
+ * display names are static strings;
+ * since ICU 4.4, ChoiceFormat patterns are no longer supported
* @param len fill-in parameter to receive length of result
* @param ec error code
* @return pointer to display string of 'len' UChars. If the resource
* data contains no entry for 'currency', then 'currency' itself is
- * returned. If *isChoiceFormat is TRUE, then the result is a
- * ChoiceFormat pattern. Otherwise it is a static string.
+ * returned.
* @stable ICU 2.6
*/
U_STABLE const UChar* U_EXPORT2
* currency object in the en_US locale is "US dollar" or "US dollars".
* @param currency null-terminated 3-letter ISO 4217 code
* @param locale locale in which to display currency
- * @param isChoiceFormat fill-in set to TRUE if the returned value
- * is a ChoiceFormat pattern; otherwise it is a static string
+ * @param isChoiceFormat always set to FALSE, or can be NULL;
+ * display names are static strings;
+ * since ICU 4.4, ChoiceFormat patterns are no longer supported
* @param pluralCount plural count
* @param len fill-in parameter to receive length of result
* @param ec error code
* @return pointer to display string of 'len' UChars. If the resource
* data contains no entry for 'currency', then 'currency' itself is
- * returned.
+ * returned.
* @stable ICU 4.2
*/
U_STABLE const UChar* U_EXPORT2
UnicodeString CurrencySymbols::loadSymbol(UCurrNameStyle selector, UErrorCode& status) const {
const char16_t* isoCode = fCurrency.getISOCurrency();
- UBool ignoredIsChoiceFormatFillIn = FALSE;
int32_t symbolLen = 0;
const char16_t* symbol = ucurr_getName(
isoCode,
fLocaleName.data(),
selector,
- &ignoredIsChoiceFormatFillIn,
+ nullptr /* isChoiceFormat */,
&symbolLen,
&status);
// If given an unknown currency, ucurr_getName returns the input string, which we can't alias safely!
UnicodeString CurrencySymbols::getPluralName(StandardPlural::Form plural, UErrorCode& status) const {
const char16_t* isoCode = fCurrency.getISOCurrency();
- UBool isChoiceFormat = FALSE;
int32_t symbolLen = 0;
const char16_t* symbol = ucurr_getPluralName(
isoCode,
fLocaleName.data(),
- &isChoiceFormat,
+ nullptr /* isChoiceFormat */,
StandardPlural::getKeyword(plural),
&symbolLen,
&status);
if (pattern.isBogus()) {
continue;
}
- UBool isChoiceFormat = FALSE;
int32_t longNameLen = 0;
const char16_t *longName = ucurr_getPluralName(
currency.getISOCurrency(),
locale.getName(),
- &isChoiceFormat,
+ nullptr /* isChoiceFormat */,
StandardPlural::getKeyword(static_cast<StandardPlural::Form>(i)),
&longNameLen,
&status);
if (locales == null) {
result = guessLocales();
} else {
- result = new ArrayList<ULocale>();
+ result = new ArrayList<>();
result.addAll(locales);
}
return result;
Currency temp = new Currency(id);
result =temp.getName(locale, type==ID_CURRENCY
? Currency.LONG_NAME
- : Currency.SYMBOL_NAME, new boolean[1]);
+ : Currency.SYMBOL_NAME, null /* isChoiceFormat */);
// TODO: have method that doesn't take parameter. Add
// function to determine whether string is choice
// format.
* @provisional This API might change or be removed in a future release.
*/
protected List<ULocale> processLocales(List<ULocale> inputLocales) {
- List<ULocale> result = new ArrayList<ULocale>();
+ List<ULocale> result = new ArrayList<>();
/*
* Step 1: Relocate later occurrence of more specific locale
* before earlier occurrence of less specific locale.
*/
protected List<ULocale> guessLocales() {
if (implicitLocales == null) {
- List<ULocale> result = new ArrayList<ULocale>(1);
+ List<ULocale> result = new ArrayList<>(1);
result.add(ULocale.getDefault());
implicitLocales = processLocales(result);
}
/*
* Available locales for service types
*/
- private static final HashMap<ULocale, BitSet> available_locales = new HashMap<ULocale, BitSet>();
+ private static final HashMap<ULocale, BitSet> available_locales = new HashMap<>();
private static final int
TYPE_GENERIC = 0,
TYPE_CALENDAR = 1,
/** WARNING: All of this data is temporary, until we start importing from CLDR!!!
*
*/
- private static final Map<String, String> language_territory_hack_map = new HashMap<String, String>();
+ private static final Map<String, String> language_territory_hack_map = new HashMap<>();
private static final String[][] language_territory_hack = {
{"af", "ZA"},
{"am", "ET"},
}
}
- static final Map<String, String> territory_tzid_hack_map = new HashMap<String, String>();
+ static final Map<String, String> territory_tzid_hack_map = new HashMap<>();
static final String[][] territory_tzid_hack = {
{"AQ", "Antarctica/McMurdo"},
{"AR", "America/Buenos_Aires"},
@Override
public String getName(ULocale locale, int nameStyle, boolean[] isChoiceFormat) {
if (nameStyle == SYMBOL_NAME) {
+ if (isChoiceFormat != null) {
+ isChoiceFormat[0] = false;
+ }
return symbol1;
}
return super.getName(locale, nameStyle, isChoiceFormat);
* given locale.
* This is a convenient method for
* getName(ULocale, int, boolean[]);
+ *
+ * @param locale locale in which to display currency
+ * @param nameStyle selector for which kind of name to return.
+ * The nameStyle should be SYMBOL_NAME, NARROW_SYMBOL_NAME,
+ * or LONG_NAME. Otherwise, throw IllegalArgumentException.
+ * @param isChoiceFormat isChoiceFormat[0] is always set to false, or isChoiceFormat can be null;
+ * display names are static strings;
+ * since ICU 4.4, ChoiceFormat patterns are no longer supported
+ * @return display string for this currency. If the resource data
+ * contains no entry for this currency, then the ISO 4217 code is
+ * returned.
* @stable ICU 3.2
*/
public String getName(Locale locale,
* Returns the display name for the given currency in the
* given locale. For example, the display name for the USD
* currency object in the en_US locale is "$".
+ *
* @param locale locale in which to display currency
* @param nameStyle selector for which kind of name to return.
* The nameStyle should be SYMBOL_NAME, NARROW_SYMBOL_NAME,
* or LONG_NAME. Otherwise, throw IllegalArgumentException.
- * @param isChoiceFormat fill-in; isChoiceFormat[0] is set to true
- * if the returned value is a ChoiceFormat pattern; otherwise it
- * is set to false
+ * @param isChoiceFormat isChoiceFormat[0] is always set to false, or isChoiceFormat can be null;
+ * display names are static strings;
+ * since ICU 4.4, ChoiceFormat patterns are no longer supported
* @return display string for this currency. If the resource data
* contains no entry for this currency, then the ISO 4217 code is
- * returned. If isChoiceFormat[0] is true, then the result is a
- * ChoiceFormat pattern. Otherwise it is a static string. <b>Note:</b>
- * as of ICU 4.4, choice formats are not used, and the value returned
- * in isChoiceFormat is always false.
+ * returned.
* <p>
* @throws IllegalArgumentException if the nameStyle is not SYMBOL_NAME
* or LONG_NAME.
/**
* Returns the display name for the given currency in the given locale.
* This is a convenience overload of getName(ULocale, int, String, boolean[]);
+ *
+ * @param locale locale in which to display currency
+ * @param nameStyle selector for which kind of name to return
+ * @param pluralCount plural count string for this locale
+ * @param isChoiceFormat isChoiceFormat[0] is always set to false, or isChoiceFormat can be null;
+ * display names are static strings;
+ * since ICU 4.4, ChoiceFormat patterns are no longer supported
+ * @return display string for this currency. If the resource data
+ * contains no entry for this currency, then the ISO 4217 code is
+ * returned.
* @stable ICU 4.2
*/
public String getName(Locale locale, int nameStyle, String pluralCount,
* amount is plural is "US dollars", such as in "3.00 US dollars";
* while the PLURAL_LONG_NAME for the USD currency object when the currency
* amount is singular is "US dollar", such as in "1.00 US dollar".
+ *
* @param locale locale in which to display currency
* @param nameStyle selector for which kind of name to return
* @param pluralCount plural count string for this locale
- * @param isChoiceFormat fill-in; isChoiceFormat[0] is set to true
- * if the returned value is a ChoiceFormat pattern; otherwise it
- * is set to false
+ * @param isChoiceFormat isChoiceFormat[0] is always set to false, or isChoiceFormat can be null;
+ * display names are static strings;
+ * since ICU 4.4, ChoiceFormat patterns are no longer supported
* @return display string for this currency. If the resource data
* contains no entry for this currency, then the ISO 4217 code is
- * returned. If isChoiceFormat[0] is true, then the result is a
- * ChoiceFormat pattern. Otherwise it is a static string. <b>Note:</b>
- * as of ICU 4.4, choice formats are not used, and the value returned
- * in isChoiceFormat is always false.
+ * returned.
* @throws IllegalArgumentException if the nameStyle is not SYMBOL_NAME,
* LONG_NAME, or PLURAL_LONG_NAME.
* @stable ICU 4.2
@Override
public String get(ULocale loc, String code, Object context) {
Currency s = Currency.getInstance(code);
- return s.getName(loc, ((Integer)context).intValue(), new boolean[1]);
+ return s.getName(loc, ((Integer)context).intValue(), null /* isChoiceFormat */);
}
});
// comment this out, because the zone string information is lost