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);
* 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
* </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.
* 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 &;
* 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 &;
* 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
*/
* </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.
* 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.
@Deprecated
public void populateFieldPosition(FieldPosition fieldPosition) {
// in case any users were depending on the old behavior:
+ fieldPosition.setBeginIndex(0);
fieldPosition.setEndIndex(0);
nextFieldPosition(fieldPosition);
}
* 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.
* 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.
}
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);