Package com.ibm.icu.impl.number
Class MixedUnitLongNameHandler
- java.lang.Object
-
- com.ibm.icu.impl.number.MixedUnitLongNameHandler
-
- All Implemented Interfaces:
LongNameMultiplexer.ParentlessMicroPropsGenerator
,MicroPropsGenerator
,ModifierStore
public class MixedUnitLongNameHandler extends java.lang.Object implements MicroPropsGenerator, ModifierStore, LongNameMultiplexer.ParentlessMicroPropsGenerator
Similar to LongNameHandler, but only for MIXED units.
-
-
Field Summary
Fields Modifier and Type Field Description private LocalizedNumberFormatter
fIntegerFormatter
A localized NumberFormatter used to format the integer-valued bigger units of Mixed Unit measurements.private ListFormatter
fListFormatter
A localised list formatter for joining mixed units together.private java.util.List<java.lang.String[]>
fMixedUnitData
Stores unit data for each of the individual units.private MicroPropsGenerator
parent
private PluralRules
rules
-
Constructor Summary
Constructors Modifier Constructor Description private
MixedUnitLongNameHandler(PluralRules rules, MicroPropsGenerator parent)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MixedUnitLongNameHandler
forMeasureUnit(ULocale locale, MeasureUnit mixedUnit, NumberFormatter.UnitWidth width, java.lang.String unitDisplayCase, PluralRules rules, MicroPropsGenerator parent)
Construct a localized MixedUnitLongNameHandler for the specified MeasureUnit.private Modifier
getMixedUnitModifier(DecimalQuantity quantity, MicroProps micros)
For a mixed unit, returns a Modifier that takes only one parameter: the smallest and final unit of the set.Modifier
getModifier(Modifier.Signum signum, StandardPlural plural)
Required for ModifierStore.MicroProps
processQuantity(DecimalQuantity quantity)
Produces a plural-appropriate Modifier for a mixed unit:quantity
is taken as the final smallest unit, while the larger unit values must be provided bymicros.mixedMeasures
, micros being the MicroProps instance returned by the parent.MicroProps
processQuantityWithMicros(DecimalQuantity quantity, MicroProps micros)
Produces a plural-appropriate Modifier for a mixed unit:quantity
is taken as the final smallest unit, while the larger unit values must be provided viamicros.mixedMeasures
.
-
-
-
Field Detail
-
rules
private final PluralRules rules
-
parent
private final MicroPropsGenerator parent
-
fMixedUnitData
private java.util.List<java.lang.String[]> fMixedUnitData
Stores unit data for each of the individual units. For each unit, it stores ARRAY_LENGTH strings, as returned by getMeasureData.
-
fIntegerFormatter
private LocalizedNumberFormatter fIntegerFormatter
A localized NumberFormatter used to format the integer-valued bigger units of Mixed Unit measurements.
-
fListFormatter
private ListFormatter fListFormatter
A localised list formatter for joining mixed units together.
-
-
Constructor Detail
-
MixedUnitLongNameHandler
private MixedUnitLongNameHandler(PluralRules rules, MicroPropsGenerator parent)
-
-
Method Detail
-
forMeasureUnit
public static MixedUnitLongNameHandler forMeasureUnit(ULocale locale, MeasureUnit mixedUnit, NumberFormatter.UnitWidth width, java.lang.String unitDisplayCase, PluralRules rules, MicroPropsGenerator parent)
Construct a localized MixedUnitLongNameHandler for the specified MeasureUnit. It must be a MIXED unit.- Parameters:
locale
- The desired locale.mixedUnit
- The mixed measure unit to construct a MixedUnitLongNameHandler for.width
- Specifies the desired unit rendering.unitDisplayCase
- Specifies the desired grammatical case. If the specified case is not found, we fall back to nominative or no-case.rules
- PluralRules instance.parent
- MicroPropsGenerator instance.
-
processQuantity
public MicroProps processQuantity(DecimalQuantity quantity)
Produces a plural-appropriate Modifier for a mixed unit:quantity
is taken as the final smallest unit, while the larger unit values must be provided bymicros.mixedMeasures
, micros being the MicroProps instance returned by the parent. This function must not be called if this instance has no parent: call processQuantityWithMicros() instead.- Specified by:
processQuantity
in interfaceMicroPropsGenerator
- Parameters:
quantity
- The quantity for consideration and optional mutation.- Returns:
- A MicroProps instance resolved for the quantity.
-
processQuantityWithMicros
public MicroProps processQuantityWithMicros(DecimalQuantity quantity, MicroProps micros)
Produces a plural-appropriate Modifier for a mixed unit:quantity
is taken as the final smallest unit, while the larger unit values must be provided viamicros.mixedMeasures
. Does not call parent.processQuantity, so cannot get a MicroProps instance that way. Instead, the instance is passed in as a parameter.- Specified by:
processQuantityWithMicros
in interfaceLongNameMultiplexer.ParentlessMicroPropsGenerator
-
getModifier
public Modifier getModifier(Modifier.Signum signum, StandardPlural plural)
Required for ModifierStore. And ModifierStore is required by SimpleModifier constructor's last parameter. We assert his will never get called though.- Specified by:
getModifier
in interfaceModifierStore
-
getMixedUnitModifier
private Modifier getMixedUnitModifier(DecimalQuantity quantity, MicroProps micros)
For a mixed unit, returns a Modifier that takes only one parameter: the smallest and final unit of the set. The bigger units' values and labels get baked into this Modifier, together with the unit label of the final unit.
-
-