|
From: Mark D. ☕ <ma...@ma...> - 2013-01-31 21:34:21
|
Dear ICU team & users, I would like to propose the following API for: *ICU 52* Please provide feedback by: *next Tuesday, 2013-02-06* Designated API reviewer: *Markus* Ticket: *http://bugs.icu-project.org/trac/ticket/8474* ------------------------------ I would like to propose the following Java API changes for ICU 52. (However, I'd like to develop consensus early so that we can have patch APIs that match as closely as possible.) Although I don't supply the C++ API, I'd like feedback on what that would look like. PluralRules OLD (for comparison) /** * Given a number, returns the keyword of the first rule that applies to * the number. * * @param number The number for which the rule has to be determined. * @return The keyword of the selected rule. * @stable ICU 4.0 */ public String select(double number); ADDITION /** * Given a number and information about the visible fractions, returns the keyword of the first rule that applies to * the number. * * @param number The number for which the rule has to be determined. * @param countVisibleFractionDigits The number of visible fraction digits. "1.230" => 3; "1" => 0; "1.05" => 2. * @param visibleFractionalDigits The fractional digits. "1.230" => 230; "1" => 0; "1.05" => 5 * @param number The number for which the rule has to be determined. * @return The keyword of the selected rule. * @stable ICU 4.0 */ public String select(double number, int countVisibleFractionDigits, int visibleFractionalDigits) We also need to be able to find out the information for the visible fractions. I'm not quite sure about the best way to do that, but here is an initial proposal. We define a new class: public class NumericFieldPosition extends FieldPosition { int getCountVisibleFractionDigits(); int getVisibleFractionDigits(); } In NumberFormat, change the internals of the many format methods that take a FieldPosition, like the following: public abstract StringBuffer format(BigInteger number, StringBuffer toAppendTo, FieldPosition pos); We would do a runtime check and if pos is actually a NumericFieldPosition, we'd fill in the extra values. Mark <https://plus.google.com/114199149796022210033> * * *— Il meglio è l’inimico del bene —* ** |