Top Inners Fields Constructors Methods
com.ibm.icu.impl.units

public Class UnitsConverter

extends Object
Class Inheritance
Static Imports
java.math.MathContext.DECIMAL128

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static enum
pack-priv static class
UnitsConverter.Factor

Responsible for all the Factor operation NOTE: This class is immutable

Field Summary

Modifier and TypeField and Description
private BigDecimal
private BigDecimal
private boolean

Constructor Summary

AccessConstructor and Description
public
UnitsConverter(String
represents the source unit identifier.
sourceIdentifier
,
String
represents the target unit identifier.
targetIdentifier
)

Constructor of UnitsConverter.

public
UnitsConverter(MeasureUnitImpl
represents the source unit.
source
,
MeasureUnitImpl
represents the target unit.
target
,
ConversionRates
contains all the needed conversion rates.
conversionRates
)

Constructor of UnitsConverter.

Method Summary

Modifier and TypeMethod and Description
private static boolean
public BigDecimal
convert(BigDecimal inputValue)

public BigDecimal
public static UnitsConverter.Convertibility
public UnitsConverter.ConversionInfo
private static void
insertInMap(HashMap<String, Integer> dimensionMap, ArrayList<SingleUnitImpl> singleUnits, int multiplier)

Helpers

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

conversionRateback to summary
private BigDecimal conversionRate
offsetback to summary
private BigDecimal offset
reciprocalback to summary
private boolean reciprocal

Constructor Detail

UnitsConverterback to summary
public UnitsConverter(String sourceIdentifier, String targetIdentifier)

Constructor of UnitsConverter.

Note

- source and target must be under the same category - e.g. meter to mile --> both of them are length units.

Note

This constructor creates an instance of UnitsConverter internally.

Parameters
sourceIdentifier:String

represents the source unit identifier.

targetIdentifier:String

represents the target unit identifier.

UnitsConverterback to summary
public UnitsConverter(MeasureUnitImpl source, MeasureUnitImpl target, ConversionRates conversionRates)

Constructor of UnitsConverter.

Note

- source and target must be under the same category - e.g. meter to mile --> both of them are length units.

Parameters
source:MeasureUnitImpl

represents the source unit.

target:MeasureUnitImpl

represents the target unit.

conversionRates:ConversionRates

contains all the needed conversion rates.

Method Detail

areDimensionsZeroesback to summary
private static boolean areDimensionsZeroes(HashMap<String, Integer> dimensionMap)
convertback to summary
public BigDecimal convert(BigDecimal inputValue)
convertInverseback to summary
public BigDecimal convertInverse(BigDecimal inputValue)
extractConvertibilityback to summary
public static UnitsConverter.Convertibility extractConvertibility(MeasureUnitImpl source, MeasureUnitImpl target, ConversionRates conversionRates)
getConversionInfoback to summary
public UnitsConverter.ConversionInfo getConversionInfo()
insertInMapback to summary
private static void insertInMap(HashMap<String, Integer> dimensionMap, ArrayList<SingleUnitImpl> singleUnits, int multiplier)

Helpers

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
com.ibm.icu.impl.units back to summary

public Class UnitsConverter.ConversionInfo

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public BigDecimal
public BigDecimal
public boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

conversionRateback to summary
public BigDecimal conversionRate
offsetback to summary
public BigDecimal offset
reciprocalback to summary
public boolean reciprocal

Constructor Detail

ConversionInfoback to summary
public ConversionInfo()
com.ibm.icu.impl.units back to summary

public final Enum UnitsConverter.Convertibility

extends Enum<UnitsConverter.Convertibility>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final UnitsConverter.Convertibility
public static final UnitsConverter.Convertibility
public static final UnitsConverter.Convertibility

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static UnitsConverter.Convertibility
public static UnitsConverter.Convertibility[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CONVERTIBLEback to summary
public static final UnitsConverter.Convertibility CONVERTIBLE
RECIPROCALback to summary
public static final UnitsConverter.Convertibility RECIPROCAL
UNCONVERTIBLEback to summary
public static final UnitsConverter.Convertibility UNCONVERTIBLE

Constructor Detail

Convertibilityback to summary
private Convertibility()

Method Detail

valueOfback to summary
public static UnitsConverter.Convertibility valueOf(String name)
valuesback to summary
public static UnitsConverter.Convertibility[] values()
com.ibm.icu.impl.units back to summary

pack-priv Class UnitsConverter.Factor

extends Object
Class Inheritance

Responsible for all the Factor operation NOTE: This class is immutable

Field Summary

Modifier and TypeField and Description
private int
exponentAMU

Exponent for Atomic Mass Unit

private int
exponentFtToM

Exponent for the ft_to_m constant

private int
exponentG

Exponent for Newtonian constant of gravitation "G".

private int
exponentGalImpToM3

Exponent for the imperial-gallon to cubic-meter conversion rate constant

private int
exponentGlucoseMolarMass

Exponent for the glucose molar mass conversion rate constant

private int
exponentGravity

Exponent for gravity (gravity-of-earth, "g")

private int
exponentItemPerMole

Exponent for the item per mole conversion rate constant

private int
exponentLbToKg

Exponent for the pound to kilogram conversion rate constant

private int
exponentMetersPerAU

Exponent for the meters per AU conversion rate constant

private int
exponentPi

Exponent for PI

private int
exponentSecPerJulianYear

Exponent for the sec per julian year conversion rate constant

private int
exponentShakuToM

Exponent for https://en.wikipedia.org/wiki/Japanese_units_of_measurement

private int
exponentShoToM3

Exponent for https://en.wikipedia.org/wiki/Japanese_units_of_measurement

private int
exponentSpeedOfLightMetersPerSecond

Exponent for the speed of light meters per second" conversion rate constant

private int
exponentTsuboToM2

Exponent for https://en.wikipedia.org/wiki/Japanese_units_of_measurement

private BigDecimal
private BigDecimal

Constructor Summary

AccessConstructor and Description
public
Factor()

Creates Empty Factor

Method Summary

Modifier and TypeMethod and Description
private void
addEntity(String entity, int power)

private void
addPoweredEntity(String poweredEntity)

Adds Entity with power or not.

public UnitsConverter.Factor
applyPrefix(MeasureUnit.MeasurePrefix unitPrefix)

Apply SI or binary prefix to the Factor.

protected UnitsConverter.Factor
copy()

Copy this Factor.

public UnitsConverter.Factor
public BigDecimal
getConversionRate()

Returns a single BigDecimal that represent the conversion rate after substituting all the constants.

private void
multiply(BigDecimal value, int power)

Multiplies the Factor instance by value^power.

public UnitsConverter.Factor
public UnitsConverter.Factor
power(int power)

public static UnitsConverter.Factor
private static UnitsConverter.Factor
processFactorWithoutDivision(String factorWithoutDivision)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exponentAMUback to summary
private int exponentAMU

Exponent for Atomic Mass Unit

exponentFtToMback to summary
private int exponentFtToM

Exponent for the ft_to_m constant

exponentGback to summary
private int exponentG

Exponent for Newtonian constant of gravitation "G".

exponentGalImpToM3back to summary
private int exponentGalImpToM3

Exponent for the imperial-gallon to cubic-meter conversion rate constant

exponentGlucoseMolarMassback to summary
private int exponentGlucoseMolarMass

Exponent for the glucose molar mass conversion rate constant

exponentGravityback to summary
private int exponentGravity

Exponent for gravity (gravity-of-earth, "g")

exponentItemPerMoleback to summary
private int exponentItemPerMole

Exponent for the item per mole conversion rate constant

exponentLbToKgback to summary
private int exponentLbToKg

Exponent for the pound to kilogram conversion rate constant

exponentMetersPerAUback to summary
private int exponentMetersPerAU

Exponent for the meters per AU conversion rate constant

exponentPiback to summary
private int exponentPi

Exponent for PI

exponentSecPerJulianYearback to summary
private int exponentSecPerJulianYear

Exponent for the sec per julian year conversion rate constant

exponentShakuToMback to summary
private int exponentShakuToM

Exponent for https://en.wikipedia.org/wiki/Japanese_units_of_measurement

exponentShoToM3back to summary
private int exponentShoToM3

Exponent for https://en.wikipedia.org/wiki/Japanese_units_of_measurement

exponentSpeedOfLightMetersPerSecondback to summary
private int exponentSpeedOfLightMetersPerSecond

Exponent for the speed of light meters per second" conversion rate constant

exponentTsuboToM2back to summary
private int exponentTsuboToM2

Exponent for https://en.wikipedia.org/wiki/Japanese_units_of_measurement

factorDenback to summary
private BigDecimal factorDen
factorNumback to summary
private BigDecimal factorNum

Constructor Detail

Factorback to summary
public Factor()

Creates Empty Factor

Method Detail

addEntityback to summary
private void addEntity(String entity, int power)
addPoweredEntityback to summary
private void addPoweredEntity(String poweredEntity)

Adds Entity with power or not. For example, 12 ^ 3 or 12.

applyPrefixback to summary
public UnitsConverter.Factor applyPrefix(MeasureUnit.MeasurePrefix unitPrefix)

Apply SI or binary prefix to the Factor.

copyback to summary
protected UnitsConverter.Factor copy()

Copy this Factor.

divideback to summary
public UnitsConverter.Factor divide(UnitsConverter.Factor other)
getConversionRateback to summary
public BigDecimal getConversionRate()

Returns a single BigDecimal that represent the conversion rate after substituting all the constants. In ICU4C, see Factor::substituteConstants().

multiplyback to summary
private void multiply(BigDecimal value, int power)

Multiplies the Factor instance by value^power.

multiplyback to summary
public UnitsConverter.Factor multiply(UnitsConverter.Factor other)
powerback to summary
public UnitsConverter.Factor power(int power)
processFactorback to summary
public static UnitsConverter.Factor processFactor(String factor)
processFactorWithoutDivisionback to summary
private static UnitsConverter.Factor processFactorWithoutDivision(String factorWithoutDivision)