ICU-13453 Reformatting FormattedNumber.java

X-SVN-Rev: 40848
This commit is contained in:
Shane Carr 2018-02-07 06:27:13 +00:00
parent 9d9471e586
commit 181269a9b2

View File

@ -15,8 +15,8 @@ import com.ibm.icu.text.PluralRules.IFixedDecimal;
import com.ibm.icu.util.ICUUncheckedIOException;
/**
* The result of a number formatting operation. This class allows the result to be exported in several data types,
* including a String, an AttributedCharacterIterator, and a BigDecimal.
* The result of a number formatting operation. This class allows the result to be exported in several
* data types, including a String, an AttributedCharacterIterator, and a BigDecimal.
*
* @draft ICU 60
* @provisional This API might change or be removed in a future release.
@ -47,12 +47,12 @@ public class FormattedNumber {
}
/**
* Append the formatted number to an Appendable, such as a StringBuilder. This may be slightly more efficient than
* creating a String.
* Append the formatted number to an Appendable, such as a StringBuilder. This may be slightly more
* efficient than creating a String.
*
* <p>
* If an IOException occurs when appending to the Appendable, an unchecked {@link ICUUncheckedIOException} is thrown
* instead.
* If an IOException occurs when appending to the Appendable, an unchecked
* {@link ICUUncheckedIOException} is thrown instead.
*
* @param appendable
* The Appendable to which to append the formatted number string.
@ -73,16 +73,18 @@ public class FormattedNumber {
}
/**
* Determine the start and end indices of the first occurrence of the given <em>field</em> in the output string.
* This allows you to determine the locations of the integer part, fraction part, and sign.
* Determine the start and end indices of the first occurrence of the given <em>field</em> in the
* output string. This allows you to determine the locations of the integer part, fraction part, and
* sign.
*
* <p>
* If multiple different field attributes are needed, this method can be called repeatedly, or if <em>all</em> field
* attributes are needed, consider using getFieldIterator().
* If multiple different field attributes are needed, this method can be called repeatedly, or if
* <em>all</em> field attributes are needed, consider using getFieldIterator().
*
* <p>
* If a field occurs multiple times in an output string, such as a grouping separator, this method will only ever
* return the first occurrence. Use getFieldIterator() to access all occurrences of an attribute.
* If a field occurs multiple times in an output string, such as a grouping separator, this method
* will only ever return the first occurrence. Use getFieldIterator() to access all occurrences of an
* attribute.
*
* @param fieldPosition
* The FieldPosition to populate with the start and end indices of the desired field.
@ -106,13 +108,15 @@ public class FormattedNumber {
}
/**
* Export the formatted number as an AttributedCharacterIterator. 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.
* Export the formatted number as an AttributedCharacterIterator. 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.
*
* <p>
* If information on only one field is needed, consider using populateFieldPosition() instead.
*
* @return An AttributedCharacterIterator, containing information on the field attributes of the number string.
* @return An AttributedCharacterIterator, containing information on the field attributes of the
* number string.
* @draft ICU 60
* @provisional This API might change or be removed in a future release.
* @see com.ibm.icu.text.NumberFormat.Field
@ -124,8 +128,9 @@ public class FormattedNumber {
}
/**
* Export the formatted number as a BigDecimal. This endpoint is useful for obtaining the exact number being printed
* after scaling and rounding have been applied by the number formatting pipeline.
* Export the formatted number as a BigDecimal. This endpoint is useful for obtaining the exact
* number being printed after scaling and rounding have been applied by the number formatting
* pipeline.
*
* @return A BigDecimal representation of the formatted number.
* @draft ICU 60
@ -183,7 +188,9 @@ public class FormattedNumber {
public int hashCode() {
// NumberStringBuilder and BigDecimal are mutable, so we can't call
// #equals() or #hashCode() on them directly.
return Arrays.hashCode(nsb.toCharArray()) ^ Arrays.hashCode(nsb.toFieldArray()) ^ fq.toBigDecimal().hashCode();
return Arrays.hashCode(nsb.toCharArray())
^ Arrays.hashCode(nsb.toFieldArray())
^ fq.toBigDecimal().hashCode();
}
/**