Package com.ibm.icu.impl.number
Class ConstantAffixModifier
java.lang.Object
com.ibm.icu.impl.number.ConstantAffixModifier
- All Implemented Interfaces:
Modifier
The canonical implementation of
Modifier
, containing a prefix and suffix string.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.ibm.icu.impl.number.Modifier
Modifier.Parameters, Modifier.Signum
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ConstantAffixModifier
private final Format.Field
private final String
private final boolean
private final String
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance with an empty prefix, suffix, and field.ConstantAffixModifier
(String prefix, String suffix, Format.Field field, boolean strong) Constructs an instance with the given strings. -
Method Summary
Modifier and TypeMethodDescriptionint
apply
(FormattedStringBuilder output, int leftIndex, int rightIndex) Apply this Modifier to the string builder.boolean
containsField
(Format.Field field) Whether the modifier contains at least one occurrence of the given field.int
Returns the number of code points in the modifier, prefix plus suffix.Gets a set of "parameters" for this Modifier.int
Gets the length of the prefix.boolean
isStrong()
Whether this modifier is strong.boolean
strictEquals
(Modifier other) Returns whether this Modifier equals another Modifier.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.ibm.icu.impl.number.Modifier
semanticallyEquivalent
-
Field Details
-
EMPTY
-
prefix
-
suffix
-
field
-
strong
private final boolean strong
-
-
Constructor Details
-
ConstantAffixModifier
Constructs an instance with the given strings.The arguments need to be Strings, not CharSequences, because Strings are immutable but CharSequences are not.
- Parameters:
prefix
- The prefix string.suffix
- The suffix string.field
- The field type to be associated with this modifier. Can be null.strong
- Whether this modifier should be strongly applied.- See Also:
-
ConstantAffixModifier
public ConstantAffixModifier()Constructs a new instance with an empty prefix, suffix, and field.
-
-
Method Details
-
apply
Description copied from interface:Modifier
Apply this Modifier to the string builder.- Specified by:
apply
in interfaceModifier
- Parameters:
output
- The string builder to which to apply this modifier.leftIndex
- The left index of the string within the builder. Equal to 0 when only one number is being formatted.rightIndex
- The right index of the string within the string builder. Equal to length when only one number is being formatted.- Returns:
- The number of characters (UTF-16 code units) that were added to the string builder.
-
getPrefixLength
public int getPrefixLength()Description copied from interface:Modifier
Gets the length of the prefix. This information can be used in combination withModifier.apply(com.ibm.icu.impl.FormattedStringBuilder, int, int)
to extract the prefix and suffix strings.- Specified by:
getPrefixLength
in interfaceModifier
- Returns:
- The number of characters (UTF-16 code units) in the prefix.
-
getCodePointCount
public int getCodePointCount()Description copied from interface:Modifier
Returns the number of code points in the modifier, prefix plus suffix.- Specified by:
getCodePointCount
in interfaceModifier
-
isStrong
public boolean isStrong()Description copied from interface:Modifier
Whether this modifier is strong. If a modifier is strong, it should always be applied immediately and not allowed to bubble up. With regard to padding, strong modifiers are considered to be on the inside of the prefix and suffix. -
containsField
Description copied from interface:Modifier
Whether the modifier contains at least one occurrence of the given field.- Specified by:
containsField
in interfaceModifier
-
getParameters
Description copied from interface:Modifier
Gets a set of "parameters" for this Modifier.- Specified by:
getParameters
in interfaceModifier
-
strictEquals
Description copied from interface:Modifier
Returns whether this Modifier equals another Modifier.- Specified by:
strictEquals
in interfaceModifier
-
toString
-