• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GENERATED SOURCE. DO NOT MODIFY. */
2 // © 2018 and later: Unicode, Inc. and others.
3 // License & terms of use: http://www.unicode.org/copyright.html
4 package android.icu.text;
5 
6 import java.text.AttributedCharacterIterator;
7 
8 import android.icu.util.ICUUncheckedIOException;
9 
10 /**
11  * An abstract formatted value: a string with associated field attributes.
12  * Many formatters format to classes implementing FormattedValue.
13  *
14  * @author sffc
15  */
16 public interface FormattedValue extends CharSequence {
17     /**
18      * Returns the formatted string as a Java String.
19      *
20      * Consider using {@link #appendTo} for greater efficiency.
21      *
22      * @return The formatted string.
23      */
24     @Override
toString()25     public String toString();
26 
27     /**
28      * Appends the formatted string to an Appendable.
29      * <p>
30      * If an IOException occurs when appending to the Appendable, an unchecked
31      * {@link ICUUncheckedIOException} is thrown instead.
32      *
33      * @param appendable The Appendable to which to append the string output.
34      * @return The same Appendable, for chaining.
35      * @throws ICUUncheckedIOException if the Appendable throws IOException
36      */
appendTo(A appendable)37     public <A extends Appendable> A appendTo(A appendable);
38 
39     /**
40      * Iterates over field positions in the FormattedValue. This lets you determine the position
41      * of specific types of substrings, like a month or a decimal separator.
42      *
43      * To loop over all field positions:
44      *
45      * <pre>
46      *     ConstrainedFieldPosition cfpos = new ConstrainedFieldPosition();
47      *     while (fmtval.nextPosition(cfpos)) {
48      *         // handle the field position; get information from cfpos
49      *     }
50      * </pre>
51      *
52      * @param cfpos
53      *         The object used for iteration state. This can provide constraints to iterate over
54      *         only one specific field; see {@link ConstrainedFieldPosition#constrainField}.
55      * @return true if a new occurrence of the field was found;
56      *         false otherwise.
57      */
nextPosition(ConstrainedFieldPosition cfpos)58     public boolean nextPosition(ConstrainedFieldPosition cfpos);
59 
60     /**
61      * Exports the formatted number as an AttributedCharacterIterator.
62      * <p>
63      * Consider using {@link #nextPosition} if you are trying to get field information.
64      *
65      * @return An AttributedCharacterIterator containing full field information.
66      */
toCharacterIterator()67     public AttributedCharacterIterator toCharacterIterator();
68 }
69