Package com.ibm.icu.impl.number
Class SimpleModifier
- java.lang.Object
-
- com.ibm.icu.impl.number.SimpleModifier
-
- All Implemented Interfaces:
Modifier
public class SimpleModifier extends java.lang.Object implements Modifier
The second primary implementation ofModifier
, this one consuming aSimpleFormatter
pattern.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.ibm.icu.impl.number.Modifier
Modifier.Parameters, Modifier.Signum
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ARG_NUM_LIMIT
TODO: This is copied from SimpleFormatterImpl.private java.lang.String
compiledPattern
private java.text.Format.Field
field
private Modifier.Parameters
parameters
private boolean
strong
-
Constructor Summary
Constructors Constructor Description SimpleModifier(java.lang.String compiledPattern, java.text.Format.Field field, boolean strong)
Creates a modifier that uses the SimpleFormatter string formats.SimpleModifier(java.lang.String compiledPattern, java.text.Format.Field field, boolean strong, Modifier.Parameters parameters)
Creates a modifier that uses the SimpleFormatter string formats.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
apply(FormattedStringBuilder output, int leftIndex, int rightIndex)
Apply this Modifier to the string builder.boolean
containsField(java.text.Format.Field field)
Whether the modifier contains at least one occurrence of the given field.static void
formatTwoArgPattern(java.lang.String compiledPattern, FormattedStringBuilder result, int index, PrefixInfixSuffixLengthHelper h, java.text.Format.Field field)
TODO: Like above, this belongs with the rest of the SimpleFormatterImpl code.int
getCodePointCount()
Returns the number of code points in the modifier, prefix plus suffix.Modifier.Parameters
getParameters()
Gets a set of "parameters" for this Modifier.int
getPrefixLength()
Gets the length of the prefix.boolean
isStrong()
Whether this modifier is strong.boolean
strictEquals(Modifier other)
Returns whether this Modifier equals another Modifier.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ibm.icu.impl.number.Modifier
semanticallyEquivalent
-
-
-
-
Field Detail
-
compiledPattern
private final java.lang.String compiledPattern
-
field
private final java.text.Format.Field field
-
strong
private final boolean strong
-
parameters
private final Modifier.Parameters parameters
-
ARG_NUM_LIMIT
private static final int ARG_NUM_LIMIT
TODO: This is copied from SimpleFormatterImpl.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SimpleModifier
public SimpleModifier(java.lang.String compiledPattern, java.text.Format.Field field, boolean strong)
Creates a modifier that uses the SimpleFormatter string formats.
-
SimpleModifier
public SimpleModifier(java.lang.String compiledPattern, java.text.Format.Field field, boolean strong, Modifier.Parameters parameters)
Creates a modifier that uses the SimpleFormatter string formats.
-
-
Method Detail
-
apply
public int apply(FormattedStringBuilder output, int leftIndex, int rightIndex)
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
public boolean containsField(java.text.Format.Field field)
Description copied from interface:Modifier
Whether the modifier contains at least one occurrence of the given field.- Specified by:
containsField
in interfaceModifier
-
getParameters
public Modifier.Parameters getParameters()
Description copied from interface:Modifier
Gets a set of "parameters" for this Modifier.- Specified by:
getParameters
in interfaceModifier
-
strictEquals
public boolean strictEquals(Modifier other)
Description copied from interface:Modifier
Returns whether this Modifier equals another Modifier.- Specified by:
strictEquals
in interfaceModifier
-
formatTwoArgPattern
public static void formatTwoArgPattern(java.lang.String compiledPattern, FormattedStringBuilder result, int index, PrefixInfixSuffixLengthHelper h, java.text.Format.Field field)
TODO: Like above, this belongs with the rest of the SimpleFormatterImpl code. I put it here so that the SimpleFormatter uses in FormattedStringBuilder are near each other.Applies the compiled two-argument pattern to the FormattedStringBuilder.
This method is optimized for the case where the prefix and suffix are often empty, such as in the range pattern like "{0}-{1}".
-
-