|
From: Tom Z. <tom...@ca...> - 2014-05-16 21:29:52
|
[proposed:2014-05-16] Add Currency_Context Field to NumberFormat class I would like to propose the following API for ICU 54 Please provide feedback by: Tuesday, 2014-05-27 Designated API reviewer: Yoshito Ticket: http://bugs.icu-project.org/trac/ticket/10344 I propose that we add a Currency_Context filed in NumberFormat class. The recent currency will have two contexts: the official one and the cash one. The Fraction Digit and Rounding may be different for some locales. Also, if we want to change the currency, the same context should be kept. JAVA API: NumberFormat.java & DecimalFormat.java /** * Sets the <tt>Currency Context</tt> object used to display currency. * This takes effect immediately, if this format is a * currency format. * @param newContext new currency context object to use. * @stable ICU 53 */ public void setCurrencyContext(int newContext) {} /** * Returns the <tt>Currency Context</tt> object used to display currency * @stable ICU 53 */ public int getCurrencyContext() {} /** * Helper function to get the Currency Rounding for Cash_Context * @stable ICU 53 */ private double getCurrencyRounding(){} /** * Helper function to get the Currency Fraction for Cash_Context * @stable ICU 53 */ private int getCurrencyFractionDigits(){} /** * Helper function to setthe Currency Fraction/Rounding for Cash/Official Contexts * @stable ICU 53 */ private void setCurrencyWithContext(){} CurrencyMetaInfo.java & ICUCurrencyMetaInfo.java /** * Returns the CurrencyDigits for the currency code with Context purpose. * @param isoCode the currency code * @param currencyContext the currency purpose * @return the CurrencyDigits * @stable ICU 53 */ public CurrencyDigits currencyDigits(String isoCode, int currencyContext) {} C/C++ API: unum.h /** * Set a particular UCurrencyPurpose value in the formatter, such as * UNUM_CURRENCY_OFFICIAL. * @param fmt The formatter for which to set a UCurrencyPurpose value. * @param value The UCurrencyPurpose value to set. * @param status A pointer to an UErrorCode to receive any errors * @draft ICU 53 */ U_CAPI void U_EXPORT2 unum_setCurrencyPurpose(UNumberFormat* fmt, UCurrencyPurpose value, UErrorCode* status); /** * Get the formatter's UCurrencyPurpose value * such as UNUM_CURRENCY_OFFICIAL. * @param fmt The formatter to query. * @param status A pointer to an UErrorCode to receive any errors * @return The UCurrencyPurpose for the specified type. * @draft ICU 53 */ U_CAPI UCurrencyPurpose U_EXPORT2 unum_getCurrencyPurpose(const UNumberFormat *fmt, UErrorCode* status); numfmt.h /** * Sets the <tt>Currency Context</tt> object used to display currency. * This takes effect immediately, if this format is a * currency format. * @param currencyContext new currency context object to use. * @stable ICU 53 */ virtual void setCurrencyPurpose(UCurrencyPurpose newContext); /** * Returns the <tt>Currency Context</tt> object used to display currency * @stable ICU 53 */ const UCurrencyPurpose getCurrencyPurpose() const; decimfmt.h /** * Sets the <tt>Currency Context</tt> object used to display currency. * This takes effect immediately, if this format is a * currency format. * @param currencyContext new currency context object to use. * @stable ICU 53 */ virtual void setCurrencyPurpose(UCurrencyPurpose newContext); |