public class FormattedNumberRange extends Object implements FormattedValue
NumberRangeFormatter
Modifier and Type | Method and Description |
---|---|
<A extends Appendable> |
appendTo(A appendable)
Appends the formatted string to an Appendable.
|
char |
charAt(int index) |
boolean |
equals(Object other) |
BigDecimal |
getFirstBigDecimal()
Export the first formatted number as a BigDecimal.
|
NumberRangeFormatter.RangeIdentityResult |
getIdentityResult()
Returns whether the pair of numbers was successfully formatted as a range or whether an identity fallback was
used.
|
BigDecimal |
getSecondBigDecimal()
Export the second formatted number as a BigDecimal.
|
int |
hashCode() |
int |
length() |
boolean |
nextFieldPosition(FieldPosition fieldPosition)
Determines the start (inclusive) and end (exclusive) indices of the next occurrence of the given
field in the output string.
|
boolean |
nextPosition(ConstrainedFieldPosition cfpos)
Iterates over field positions in the FormattedValue.
|
CharSequence |
subSequence(int start,
int end) |
AttributedCharacterIterator |
toCharacterIterator()
Exports the formatted number as an AttributedCharacterIterator.
|
String |
toString()
Returns the formatted string as a Java String.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
chars, codePoints
public String toString()
FormattedValue.appendTo(A)
for greater efficiency.toString
in interface FormattedValue
toString
in interface CharSequence
toString
in class Object
public <A extends Appendable> A appendTo(A appendable)
If an IOException occurs when appending to the Appendable, an unchecked
ICUUncheckedIOException
is thrown instead.
appendTo
in interface FormattedValue
appendable
- The Appendable to which to append the string output.public char charAt(int index)
charAt
in interface CharSequence
public int length()
length
in interface CharSequence
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public boolean nextPosition(ConstrainedFieldPosition cfpos)
ConstrainableFieldPosition cfpos = new ConstrainableFieldPosition(); while (fmtval.nextPosition(cfpos)) { // handle the field position; get information from cfpos }
nextPosition
in interface FormattedValue
cfpos
- The object used for iteration state. This can provide constraints to iterate over
only one specific field; see ConstrainedFieldPosition.constrainField(java.text.Format.Field)
.public boolean nextFieldPosition(FieldPosition fieldPosition)
If both sides of the range have the same field, the field will occur twice, once before the range separator and once after the range separator, if applicable.
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:
FieldPosition fpos = new FieldPosition(NumberFormat.Field.INTEGER); while (formattedNumberRange.nextFieldPosition(fpos, status)) { // do something with fpos. }
This method is useful if you know which field to query. If you want all available field position information, use
toCharacterIterator()
.
fieldPosition
- Input+output variable. See FormattedNumber.nextFieldPosition(FieldPosition)
.NumberFormat.Field
,
NumberRangeFormatter
public AttributedCharacterIterator toCharacterIterator()
Consider using FormattedValue.nextPosition(com.ibm.icu.text.ConstrainedFieldPosition)
if you are trying to get field information.
toCharacterIterator
in interface FormattedValue
public BigDecimal getFirstBigDecimal()
NumberRangeFormatter
,
getSecondBigDecimal()
public BigDecimal getSecondBigDecimal()
NumberRangeFormatter
,
getFirstBigDecimal()
public NumberRangeFormatter.RangeIdentityResult getIdentityResult()
NumberRangeFormatter
,
NumberRangeFormatter.RangeIdentityFallback
Copyright ? 2016 Unicode, Inc. and others.