Class ComplexUnitsConverter
java.lang.Object
org.graalvm.shadowed.com.ibm.icu.impl.units.ComplexUnitsConverter
Converts from single or compound unit to single, compound or mixed units. For example, from
meter
to foot+inch.
DESIGN: This class uses UnitsConverter in order to perform the single converter (i.e. converters from
a single unit to another single unit). Therefore, ComplexUnitsConverter class contains multiple
instances of the UnitsConverter to perform the conversion.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BigDecimalstatic final BigDecimalIndividual units of mixed units, sorted big to small, with indices indicating the requested output mixed unit order. -
Constructor Summary
ConstructorsConstructorDescriptionComplexUnitsConverter(String inputUnitIdentifier, String outputUnitsIdentifier) ConstructsComplexUnitsConverterNOTE: - inputUnit and outputUnits must be under the same category - e.g.ComplexUnitsConverter(MeasureUnitImpl targetUnit, ConversionRates conversionRates) ConstructsComplexUnitsConverterfor aninputUnitthat could be Single, Compound or Mixed.ComplexUnitsConverter(MeasureUnitImpl inputUnit, MeasureUnitImpl outputUnits, ConversionRates conversionRates) ConstructsComplexUnitsConverterNOTE: - inputUnit and outputUnits must be under the same category - e.g. -
Method Summary
Modifier and TypeMethodDescriptionconvert(BigDecimal quantity, Precision rounder) Returns outputMeasures which is an array with the corresponding values.booleangreaterThanOrEqual(BigDecimal quantity, BigDecimal limit) Returns true if the specifiedquantityof theinputUnit, expressed in terms of the biggest unit in the MeasureUnitoutputUnit, is greater than or equal tolimit.toString()
-
Field Details
-
EPSILON
-
EPSILON_MULTIPLIER
-
unitsConverters_
-
units_
Individual units of mixed units, sorted big to small, with indices indicating the requested output mixed unit order.
-
-
Constructor Details
-
ComplexUnitsConverter
ConstructsComplexUnitsConverterfor aninputUnitthat could be Single, Compound or Mixed. In case of: 1- Single and Compound units, the conversion will not perform anything, the input will be equal to the output. 2- Mixed Unit the conversion will consider the input in the biggest unit. and will convert it to be spread throw the input units. For example: if input unit is "inch-and-foot", and the input is 2.5. The converter will consider the input value in "foot", because foot is the biggest unit. Then, it will convert 2.5 feet to "inch-and-foot".- Parameters:
targetUnit- represents the input unit. could be any type. (single, compound or mixed).
-
ComplexUnitsConverter
ConstructsComplexUnitsConverterNOTE: - inputUnit and outputUnits must be under the same category - e.g. meter to feet and inches --> all of them are length units.- Parameters:
inputUnitIdentifier- represents the source unit identifier. (should be single or compound unit).outputUnitsIdentifier- represents the output unit identifier. could be any type. (single, compound or mixed).
-
ComplexUnitsConverter
public ComplexUnitsConverter(MeasureUnitImpl inputUnit, MeasureUnitImpl outputUnits, ConversionRates conversionRates) ConstructsComplexUnitsConverterNOTE: - inputUnit and outputUnits must be under the same category - e.g. meter to feet and inches --> all of them are length units.- Parameters:
inputUnit- represents the source unit. (should be single or compound unit).outputUnits- represents the output unit. could be any type. (single, compound or mixed).conversionRates- a ConversionRates instance containing the unit conversion rates.
-
-
Method Details
-
greaterThanOrEqual
Returns true if the specifiedquantityof theinputUnit, expressed in terms of the biggest unit in the MeasureUnitoutputUnit, is greater than or equal tolimit.For example, if the input unit is
meterand the target unit isfoot+inch. Therefore, this function will convert thequantityfrommetertofoot, then, it will compare the value infootwith thelimit. -
convert
Returns outputMeasures which is an array with the corresponding values. - E.g. converting meters to feet and inches. 1 meter --> 3 feet, 3.3701 inches NOTE: the smallest element is the only element that could have fractional values. And all other elements are floored to the nearest integer -
toString
-