ICU-20423 Removing deprecated method toNumberFormatter()

This commit is contained in:
Shane Carr 2019-08-08 16:59:04 -07:00 committed by Shane F. Carr
parent f4fc9d06c2
commit 035eead0e8
5 changed files with 26 additions and 32 deletions

View File

@ -1569,11 +1569,6 @@ const number::LocalizedNumberFormatter* DecimalFormat::toNumberFormatter(UErrorC
return &fields->formatter;
}
const number::LocalizedNumberFormatter& DecimalFormat::toNumberFormatter() const {
UErrorCode localStatus = U_ZERO_ERROR;
return *toNumberFormatter(localStatus);
}
/** Rebuilds the formatter object from the property bag. */
void DecimalFormat::touch(UErrorCode& status) {
if (U_FAILURE(status)) {

View File

@ -277,7 +277,14 @@ PluralFormat::format(const Formattable& numberObject, double number,
UnicodeString numberString;
auto *decFmt = dynamic_cast<DecimalFormat *>(numberFormat);
if(decFmt != nullptr) {
decFmt->toNumberFormatter().formatImpl(&data, status); // mutates &data
const number::LocalizedNumberFormatter* lnf = decFmt->toNumberFormatter(status);
if (U_FAILURE(status)) {
return appendTo;
}
lnf->formatImpl(&data, status); // mutates &data
if (U_FAILURE(status)) {
return appendTo;
}
numberString = data.getStringRef().toUnicodeString();
} else {
if (offset == 0) {

View File

@ -188,7 +188,11 @@ void QuantityFormatter::formatAndSelect(
if (df != nullptr) {
number::impl::UFormattedNumberData fn;
fn.quantity.setToDouble(quantity);
df->toNumberFormatter().formatImpl(&fn, status);
const number::LocalizedNumberFormatter* lnf = df->toNumberFormatter(status);
if (U_FAILURE(status)) {
return;
}
lnf->formatImpl(&fn, status);
if (U_FAILURE(status)) {
return;
}

View File

@ -1220,10 +1220,14 @@ _appendSymbolWithMonthPattern(UnicodeString& dst, int32_t value, const UnicodeSt
//----------------------------------------------------------------------
static number::LocalizedNumberFormatter*
createFastFormatter(const DecimalFormat* df, int32_t minInt, int32_t maxInt) {
return new number::LocalizedNumberFormatter(
df->toNumberFormatter()
.integerWidth(number::IntegerWidth::zeroFillTo(minInt).truncateAt(maxInt)));
createFastFormatter(const DecimalFormat* df, int32_t minInt, int32_t maxInt, UErrorCode& status) {
const number::LocalizedNumberFormatter* lnfBase = df->toNumberFormatter(status);
if (U_FAILURE(status)) {
return nullptr;
}
return lnfBase->integerWidth(
number::IntegerWidth::zeroFillTo(minInt).truncateAt(maxInt)
).clone().orphan();
}
void SimpleDateFormat::initFastNumberFormatters(UErrorCode& status) {
@ -1234,11 +1238,11 @@ void SimpleDateFormat::initFastNumberFormatters(UErrorCode& status) {
if (df == nullptr) {
return;
}
fFastNumberFormatters[SMPDTFMT_NF_1x10] = createFastFormatter(df, 1, 10);
fFastNumberFormatters[SMPDTFMT_NF_2x10] = createFastFormatter(df, 2, 10);
fFastNumberFormatters[SMPDTFMT_NF_3x10] = createFastFormatter(df, 3, 10);
fFastNumberFormatters[SMPDTFMT_NF_4x10] = createFastFormatter(df, 4, 10);
fFastNumberFormatters[SMPDTFMT_NF_2x2] = createFastFormatter(df, 2, 2);
fFastNumberFormatters[SMPDTFMT_NF_1x10] = createFastFormatter(df, 1, 10, status);
fFastNumberFormatters[SMPDTFMT_NF_2x10] = createFastFormatter(df, 2, 10, status);
fFastNumberFormatters[SMPDTFMT_NF_3x10] = createFastFormatter(df, 3, 10, status);
fFastNumberFormatters[SMPDTFMT_NF_4x10] = createFastFormatter(df, 4, 10, status);
fFastNumberFormatters[SMPDTFMT_NF_2x2] = createFastFormatter(df, 2, 2, status);
}
void SimpleDateFormat::freeFastNumberFormatters() {

View File

@ -2116,22 +2116,6 @@ class U_I18N_API DecimalFormat : public NumberFormat {
const number::LocalizedNumberFormatter* toNumberFormatter(UErrorCode& status) const;
#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_DEPRECATED_API
/**
* Deprecated: Like {@link #toNumberFormatter(UErrorCode&) const},
* but does not take an error code.
*
* The new signature should be used in case an error occurs while returning the
* LocalizedNumberFormatter.
*
* This old signature will be removed in ICU 65.
*
* @return A reference to an internal object.
* @deprecated ICU 64
*/
const number::LocalizedNumberFormatter& toNumberFormatter() const;
#endif /* U_HIDE_DEPRECATED_API */
/**
* Return the class ID for this class. This is useful only for
* comparing to a return value from getDynamicClassID(). For example: