Top Description Fields Constructors Methods
com.ibm.icu.impl.number

public Class SimpleModifier

extends Object
implements Modifier
Class Inheritance
All Implemented Interfaces
com.ibm.icu.impl.number.Modifier
Imports
java.text.Format.Field, com.ibm.icu.impl.FormattedStringBuilder, .SimpleFormatterImpl, com.ibm.icu.impl.number.range.PrefixInfixSuffixLengthHelper, com.ibm.icu.util.ICUException

The second primary implementation of Modifier, this one consuming a com.ibm.icu.text.SimpleFormatter pattern.

Field Summary

Modifier and TypeField and Description
private static final int
ARG_NUM_LIMIT

Todo

This is copied from SimpleFormatterImpl.

private final String
private final Format.Field
private final Modifier.Parameters
private final boolean

Constructor Summary

AccessConstructor and Description
public
SimpleModifier(String compiledPattern, Format.Field field, boolean strong)

Creates a modifier that uses the SimpleFormatter string formats.

public
SimpleModifier(String compiledPattern, Format.Field field, boolean strong, Modifier.Parameters parameters)

Creates a modifier that uses the SimpleFormatter string formats.

Method Summary

Modifier and TypeMethod and Description
public int
apply(FormattedStringBuilder
The string builder to which to apply this modifier.
output
,
int
The left index of the string within the builder. Equal to 0 when only one number is being formatted.
leftIndex
,
int
The right index of the string within the string builder. Equal to length when only one number is being formatted.
rightIndex
)

Implements com.ibm.icu.impl.number.Modifier.apply.

Apply this Modifier to the string builder.
public boolean
containsField(Format.Field field)

Implements com.ibm.icu.impl.number.Modifier.containsField.

Whether the modifier contains at least one occurrence of the given field.
public static void
formatTwoArgPattern(String compiledPattern, FormattedStringBuilder result, int index, PrefixInfixSuffixLengthHelper h, Format.Field field)

Applies the compiled two-argument pattern to the FormattedStringBuilder.

public int
getCodePointCount()

Implements com.ibm.icu.impl.number.Modifier.getCodePointCount.

Returns the number of code points in the modifier, prefix plus suffix.
public Modifier.Parameters
getParameters()

Implements com.ibm.icu.impl.number.Modifier.getParameters.

Gets a set of "parameters" for this Modifier.
public int
getPrefixLength()

Implements com.ibm.icu.impl.number.Modifier.getPrefixLength.

Gets the length of the prefix.
public boolean
isStrong()

Implements com.ibm.icu.impl.number.Modifier.isStrong.

Whether this modifier is strong.
public boolean
semanticallyEquivalent(Modifier other)

Implements com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

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.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ARG_NUM_LIMITback to summary
private static final int ARG_NUM_LIMIT

Todo

This is copied from SimpleFormatterImpl.

compiledPatternback to summary
private final String compiledPattern
fieldback to summary
private final Format.Field field
parametersback to summary
private final Modifier.Parameters parameters
strongback to summary
private final boolean strong

Constructor Detail

SimpleModifierback to summary
public SimpleModifier(String compiledPattern, Format.Field field, boolean strong)

Creates a modifier that uses the SimpleFormatter string formats.

SimpleModifierback to summary
public SimpleModifier(String compiledPattern, Format.Field field, boolean strong, Modifier.Parameters parameters)

Creates a modifier that uses the SimpleFormatter string formats.

Method Detail

applyback to summary
public int apply(FormattedStringBuilder output, int leftIndex, int rightIndex)

Implements com.ibm.icu.impl.number.Modifier.apply.

Doc from com.ibm.icu.impl.number.Modifier.apply.

Apply this Modifier to the string builder.

Parameters
output:FormattedStringBuilder

The string builder to which to apply this modifier.

leftIndex:int

The left index of the string within the builder. Equal to 0 when only one number is being formatted.

rightIndex:int

The right index of the string within the string builder. Equal to length when only one number is being formatted.

Returns:int

The number of characters (UTF-16 code units) that were added to the string builder.

Annotations
@Override
containsFieldback to summary
public boolean containsField(Format.Field field)

Implements com.ibm.icu.impl.number.Modifier.containsField.

Doc from com.ibm.icu.impl.number.Modifier.containsField.

Whether the modifier contains at least one occurrence of the given field.

Annotations
@Override
formatTwoArgPatternback to summary
public 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. 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}".

getCodePointCountback to summary
public int getCodePointCount()

Implements com.ibm.icu.impl.number.Modifier.getCodePointCount.

Doc from com.ibm.icu.impl.number.Modifier.getCodePointCount.

Returns the number of code points in the modifier, prefix plus suffix.

Annotations
@Override
getParametersback to summary
public Modifier.Parameters getParameters()

Implements com.ibm.icu.impl.number.Modifier.getParameters.

Doc from com.ibm.icu.impl.number.Modifier.getParameters.

Gets a set of "parameters" for this Modifier.

Annotations
@Override
getPrefixLengthback to summary
public int getPrefixLength()

Implements com.ibm.icu.impl.number.Modifier.getPrefixLength.

Doc from com.ibm.icu.impl.number.Modifier.getPrefixLength.

Gets the length of the prefix. This information can be used in combination with apply to extract the prefix and suffix strings.

Returns:int

The number of characters (UTF-16 code units) in the prefix.

Annotations
@Override
isStrongback to summary
public boolean isStrong()

Implements com.ibm.icu.impl.number.Modifier.isStrong.

Doc from com.ibm.icu.impl.number.Modifier.isStrong.

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.

Returns:boolean

Whether the modifier is strong.

Annotations
@Override
semanticallyEquivalentback to summary
public boolean semanticallyEquivalent(Modifier other)

Implements com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

Doc from com.ibm.icu.impl.number.Modifier.semanticallyEquivalent.

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.

Annotations
@Override