public class SimpleModifier extends Object implements Modifier
Modifier, this one consuming a
SimpleFormatter pattern.Modifier.Parameters, Modifier.Signum| Constructor and Description |
|---|
SimpleModifier(String compiledPattern,
Format.Field field,
boolean strong)
Creates a modifier that uses the SimpleFormatter string formats.
|
SimpleModifier(String compiledPattern,
Format.Field field,
boolean strong,
Modifier.Parameters parameters)
Creates a modifier that uses the SimpleFormatter string formats.
|
| Modifier and Type | Method and Description |
|---|---|
int |
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.
|
static void |
formatTwoArgPattern(String compiledPattern,
FormattedStringBuilder result,
int index,
PrefixInfixSuffixLengthHelper h,
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 |
semanticallyEquivalent(Modifier other)
Returns whether this Modifier is *semantically equivalent* to the other Modifier;
in many cases, this is the same as equal, but parameters should be ignored.
|
public SimpleModifier(String compiledPattern, Format.Field field, boolean strong)
public SimpleModifier(String compiledPattern, Format.Field field, boolean strong, Modifier.Parameters parameters)
public int apply(FormattedStringBuilder output, int leftIndex, int rightIndex)
Modifierapply in interface Modifieroutput - 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.public int getPrefixLength()
ModifierModifier.apply(org.graalvm.shadowed.com.ibm.icu.impl.FormattedStringBuilder, int, int) to
extract the prefix and suffix strings.getPrefixLength in interface Modifierpublic int getCodePointCount()
ModifiergetCodePointCount in interface Modifierpublic boolean isStrong()
Modifierpublic boolean containsField(Format.Field field)
ModifiercontainsField in interface Modifierpublic Modifier.Parameters getParameters()
ModifiergetParameters in interface Modifierpublic boolean semanticallyEquivalent(Modifier other)
ModifiersemanticallyEquivalent in interface Modifierpublic static void formatTwoArgPattern(String compiledPattern, FormattedStringBuilder result, int index, PrefixInfixSuffixLengthHelper h, Format.Field field)
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}".