]> granicus.if.org Git - icu/commitdiff
ICU-13662 Replying to code review feedback.
authorShane Carr <shane@unicode.org>
Wed, 9 May 2018 02:00:22 +0000 (02:00 +0000)
committerShane Carr <shane@unicode.org>
Wed, 9 May 2018 02:00:22 +0000 (02:00 +0000)
X-SVN-Rev: 41365

icu4c/source/i18n/decimfmt.cpp
icu4c/source/i18n/unicode/numberformatter.h
icu4j/main/classes/core/src/com/ibm/icu/number/FormattedNumber.java
icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java

index 16412535a85c9949eda50f483d91dd5bd1ef384d..161861d732683c62f7f0053db962345eeec2234a 100644 (file)
@@ -1232,7 +1232,9 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getCurrencyParser(UErrorC
 void
 DecimalFormat::fieldPositionHelper(const number::FormattedNumber& formatted, FieldPosition& fieldPosition,
                                    int32_t offset, UErrorCode& status) {
-    fieldPosition.setEndIndex(0); // always return first occurrence
+    // always return first occurrence:
+    fieldPosition.setBeginIndex(0);
+    fieldPosition.setEndIndex(0);
     bool found = formatted.nextFieldPosition(fieldPosition, status);
     if (found && offset != 0) {
         fieldPosition.setBeginIndex(fieldPosition.getBeginIndex() + offset);
index c325ff345a3706ffbfcfbcb8d63f54a99d914bc3..8904a308191cf4c4e51926099bb3df614a8a8af1 100644 (file)
@@ -1791,8 +1791,8 @@ class U_I18N_API NumberFormatterSettings {
      * numbering system.
      *
      * <p>
-     * <strong>Note:</strong> The instance of DecimalFormatSymbols will be copied: changes made to the symbols object
-     * after passing it into the fluent chain will not be seen.
+     * <strong>Note:</strong> Calling this method will override any previously specified DecimalFormatSymbols
+     * or NumberingSystem.
      *
      * <p>
      * <strong>Note:</strong> Calling this method will override the NumberingSystem previously specified in
@@ -1838,8 +1838,8 @@ class U_I18N_API NumberFormatterSettings {
      * </pre>
      *
      * <p>
-     * <strong>Note:</strong> Calling this method will override the DecimalFormatSymbols previously specified in
-     * {@link #symbols(DecimalFormatSymbols)}.
+     * <strong>Note:</strong> Calling this method will override any previously specified DecimalFormatSymbols
+     * or NumberingSystem.
      *
      * <p>
      * The default is to choose the best numbering system for the locale.
@@ -1927,7 +1927,6 @@ class U_I18N_API NumberFormatterSettings {
      *            The sign display strategy to use when rendering numbers.
      * @return The fluent chain
      * @see UNumberSignDisplay
-     * @provisional This API might change or be removed in a future release.
      * @draft ICU 60
      */
     Derived sign(UNumberSignDisplay style) const &;
@@ -1966,7 +1965,6 @@ class U_I18N_API NumberFormatterSettings {
      *            The decimal separator display strategy to use when rendering numbers.
      * @return The fluent chain
      * @see UNumberDecimalSeparatorDisplay
-     * @provisional This API might change or be removed in a future release.
      * @draft ICU 60
      */
     Derived decimal(UNumberDecimalSeparatorDisplay style) const &;
@@ -2423,7 +2421,7 @@ class U_I18N_API FormattedNumber : public UMemory {
      *            The FieldPosition to populate with the start and end indices of the desired field.
      * @param status
      *            Set if an error occurs while populating the FieldPosition.
-     * @deprecated ICU 62 Use {@link #toCharacterIterator} instead. This method will be removed in a future
+     * @deprecated ICU 62 Use {@link #nextFieldPosition} instead. This method will be removed in a future
      *             release. See http://bugs.icu-project.org/trac/ticket/13746
      * @see UNumberFormatFields
      */
@@ -2445,15 +2443,15 @@ class U_I18N_API FormattedNumber : public UMemory {
      * </pre>
      *
      * This method is useful if you know which field to query. If you want all available field position
-     * information, use #getAllFields().
+     * information, use #getAllFieldPositions().
      *
      * @param fieldPosition
-     *            Input+output variable. On input, the "field" property determines which field to look up,
-     *            and the "endIndex" property determines where to begin the search. On output, the
-     *            "beginIndex" field is set to the beginning of the first occurrence of the field after the
-     *            input "endIndex", and "endIndex" is set to the end of that occurrence of the field
-     *            (exclusive index). If a field position is not found, the FieldPosition is not changed and
-     *            the method returns FALSE.
+     *            Input+output variable. On input, the "field" property determines which field to look
+     *            up, and the "beginIndex" and "endIndex" properties determine where to begin the search.
+     *            On output, the "beginIndex" is set to the beginning of the first occurrence of the
+     *            field with either begin or end indices after the input indices, "endIndex" is set to
+     *            the end of that occurrence of the field (exclusive index). If a field position is not
+     *            found, the method returns FALSE and the FieldPosition may or may not be changed.
      * @param status
      *            Set if an error occurs while populating the FieldPosition.
      * @return TRUE if a new occurrence of the field was found; FALSE otherwise.
@@ -2483,7 +2481,7 @@ class U_I18N_API FormattedNumber : public UMemory {
      * Export the formatted number to a FieldPositionIterator. This allows you to determine which characters in
      * the output string correspond to which <em>fields</em>, such as the integer part, fraction part, and sign.
      *
-     * If information on only one field is needed, use #nextFieldPosition().
+     * If information on only one field is needed, use #nextFieldPosition() instead.
      *
      * @param iterator
      *            The FieldPositionIterator to populate with all of the fields present in the formatted number.
index 72acb399bec4c6508a22f9acb995bcb374aa3fd9..965f5629b5e47f708f2f0821ef15fc9471de5aa7 100644 (file)
@@ -93,6 +93,7 @@ public class FormattedNumber {
     @Deprecated
     public void populateFieldPosition(FieldPosition fieldPosition) {
         // in case any users were depending on the old behavior:
+        fieldPosition.setBeginIndex(0);
         fieldPosition.setEndIndex(0);
         nextFieldPosition(fieldPosition);
     }
@@ -105,23 +106,24 @@ public class FormattedNumber {
      * If a field occurs just once, calling this method will find that occurrence and return it. If a
      * field occurs multiple times, this method may be called repeatedly with the following pattern:
      * <p>
+     *
      * <pre>
      * FieldPosition fpos = new FieldPosition(NumberFormat.Field.GROUPING_SEPARATOR);
      * while (formattedNumber.nextFieldPosition(fpos, status)) {
-     *   // do something with fpos.
+     *     // do something with fpos.
      * }
      * </pre>
      * <p>
      * This method is useful if you know which field to query. If you want all available field position
-     * information, use #getAllFields().
+     * information, use {@link #toCharacterIterator()}.
      *
      * @param fieldPosition
-     *            Input+output variable. On input, the "field" property determines which field to look up,
-     *            and the "endIndex" property determines where to begin the search. On output, the
-     *            "beginIndex" field is set to the beginning of the first occurrence of the field after the
-     *            input "endIndex", and "endIndex" is set to the end of that occurrence of the field
-     *            (exclusive index). If a field position is not found, the FieldPosition is not changed and
-     *            the method returns false.
+     *            Input+output variable. On input, the "field" property determines which field to look
+     *            up, and the "beginIndex" and "endIndex" properties determine where to begin the search.
+     *            On output, the "beginIndex" is set to the beginning of the first occurrence of the
+     *            field with either begin or end indices after the input indices, "endIndex" is set to
+     *            the end of that occurrence of the field (exclusive index). If a field position is not
+     *            found, the method returns FALSE and the FieldPosition may or may not be changed.
      * @return true if a new occurrence of the field was found; false otherwise.
      * @draft ICU 62
      * @provisional This API might change or be removed in a future release.
@@ -158,7 +160,7 @@ public class FormattedNumber {
      * characters in the output string correspond to which <em>fields</em>, such as the integer part,
      * fraction part, and sign.
      * <p>
-     * If information on only one field is needed, consider using populateFieldPosition() instead.
+     * If information on only one field is needed, use {@link #nextFieldPosition(FieldPosition)} instead.
      *
      * @return An AttributedCharacterIterator, containing information on the field attributes of the
      *         number string.
index 7bf58f9273f854e9623bb54c9423f516a3b6cd0b..f23154074cc1ee48eb8d1fd94f49332f19862d37 100644 (file)
@@ -2567,7 +2567,9 @@ public class DecimalFormat extends NumberFormat {
   }
 
   static void fieldPositionHelper(FormattedNumber formatted, FieldPosition fieldPosition, int offset) {
-      fieldPosition.setEndIndex(0); // always return first occurrence
+      // always return first occurrence:
+      fieldPosition.setBeginIndex(0);
+      fieldPosition.setEndIndex(0);
       boolean found = formatted.nextFieldPosition(fieldPosition);
       if (found && offset != 0) {
           fieldPosition.setBeginIndex(fieldPosition.getBeginIndex() + offset);