• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GENERATED SOURCE. DO NOT MODIFY. */
2 // © 2017 and later: Unicode, Inc. and others.
3 // License & terms of use: http://www.unicode.org/copyright.html#License
4 package ohos.global.icu.impl.number;
5 
6 import java.text.Format.Field;
7 
8 import ohos.global.icu.impl.FormattedStringBuilder;
9 import ohos.global.icu.impl.StandardPlural;
10 
11 /**
12  * A Modifier is an object that can be passed through the formatting pipeline until it is finally applied
13  * to the string builder. A Modifier usually contains a prefix and a suffix that are applied, but it
14  * could contain something else, like a {@link ohos.global.icu.text.SimpleFormatter} pattern.
15  *
16  * A Modifier is usually immutable, except in cases such as {@link MutablePatternModifier}, which are
17  * mutable for performance reasons.
18  * @hide exposed on OHOS
19  */
20 public interface Modifier {
21 
22     static enum Signum {
23         NEG,
24         NEG_ZERO,
25         POS_ZERO,
26         POS;
27 
28         static final int COUNT = Signum.values().length;
29     };
30 
31     /**
32      * Apply this Modifier to the string builder.
33      *
34      * @param output
35      *            The string builder to which to apply this modifier.
36      * @param leftIndex
37      *            The left index of the string within the builder. Equal to 0 when only one number is
38      *            being formatted.
39      * @param rightIndex
40      *            The right index of the string within the string builder. Equal to length when only one
41      *            number is being formatted.
42      * @return The number of characters (UTF-16 code units) that were added to the string builder.
43      */
apply(FormattedStringBuilder output, int leftIndex, int rightIndex)44     public int apply(FormattedStringBuilder output, int leftIndex, int rightIndex);
45 
46     /**
47      * Gets the length of the prefix. This information can be used in combination with {@link #apply} to
48      * extract the prefix and suffix strings.
49      *
50      * @return The number of characters (UTF-16 code units) in the prefix.
51      */
getPrefixLength()52     public int getPrefixLength();
53 
54     /**
55      * Returns the number of code points in the modifier, prefix plus suffix.
56      */
getCodePointCount()57     public int getCodePointCount();
58 
59     /**
60      * Whether this modifier is strong. If a modifier is strong, it should always be applied immediately
61      * and not allowed to bubble up. With regard to padding, strong modifiers are considered to be on the
62      * inside of the prefix and suffix.
63      *
64      * @return Whether the modifier is strong.
65      */
isStrong()66     public boolean isStrong();
67 
68     /**
69      * Whether the modifier contains at least one occurrence of the given field.
70      */
containsField(Field currency)71     public boolean containsField(Field currency);
72 
73     /**
74      * A fill-in for getParameters(). obj will always be set; if non-null, the other
75      * two fields are also safe to read.
76      * @hide exposed on OHOS
77      */
78     public static class Parameters {
79         public ModifierStore obj;
80         public Signum signum;
81         public StandardPlural plural;
82     }
83 
84     /**
85      * Gets a set of "parameters" for this Modifier.
86      */
getParameters()87     public Parameters getParameters();
88 
89     /**
90      * Returns whether this Modifier is *semantically equivalent* to the other Modifier;
91      * in many cases, this is the same as equal, but parameters should be ignored.
92      */
semanticallyEquivalent(Modifier other)93     public boolean semanticallyEquivalent(Modifier other);
94 }
95