• 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#License
4 package ohos.global.icu.text;
5 
6 import java.text.AttributedCharacterIterator;
7 
8 import ohos.global.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  * @hide exposed on OHOS
16  */
17 public interface FormattedValue extends CharSequence {
18     /**
19      * Returns the formatted string as a Java String.
20      *
21      * Consider using {@link #appendTo} for greater efficiency.
22      *
23      * @return The formatted string.
24      */
25     @Override
toString()26     public String toString();
27 
28     /**
29      * Appends the formatted string to an Appendable.
30      * <p>
31      * If an IOException occurs when appending to the Appendable, an unchecked
32      * {@link ICUUncheckedIOException} is thrown instead.
33      *
34      * @param appendable The Appendable to which to append the string output.
35      * @return The same Appendable, for chaining.
36      * @throws ICUUncheckedIOException if the Appendable throws IOException
37      */
appendTo(A appendable)38     public <A extends Appendable> A appendTo(A appendable);
39 
40     /**
41      * Iterates over field positions in the FormattedValue. This lets you determine the position
42      * of specific types of substrings, like a month or a decimal separator.
43      *
44      * To loop over all field positions:
45      *
46      * <pre>
47      *     ConstrainableFieldPosition cfpos = new ConstrainableFieldPosition();
48      *     while (fmtval.nextPosition(cfpos)) {
49      *         // handle the field position; get information from cfpos
50      *     }
51      * </pre>
52      *
53      * @param cfpos
54      *         The object used for iteration state. This can provide constraints to iterate over
55      *         only one specific field; see {@link ConstrainedFieldPosition#constrainField}.
56      * @return true if a new occurrence of the field was found;
57      *         false otherwise.
58      */
nextPosition(ConstrainedFieldPosition cfpos)59     public boolean nextPosition(ConstrainedFieldPosition cfpos);
60 
61     /**
62      * Exports the formatted number as an AttributedCharacterIterator.
63      * <p>
64      * Consider using {@link #nextPosition} if you are trying to get field information.
65      *
66      * @return An AttributedCharacterIterator containing full field information.
67      */
toCharacterIterator()68     public AttributedCharacterIterator toCharacterIterator();
69 }
70