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

public Class UnitsRouter

extends Object
Class Inheritance
Imports
java.math.BigDecimal, java.util.ArrayList, .List, com.ibm.icu.impl.IllegalIcuArgumentException, com.ibm.icu.impl.number.MicroProps, com.ibm.icu.number.Precision, com.ibm.icu.util.MeasureUnit, .ULocale

UnitsRouter responsible for converting from a single unit (such as meter or meter-per-second) to one of the complex units based on the limits. For example: if the input is meter and the output as following {foot+inch, limit: 3.0} {inch , limit: no value (-inf)} Thus means if the input in meter is greater than or equal to 3.0 feet, the output will be in foot+inch, otherwise, the output will be in inch.

Note

the output units and their limits MUST BE in order, for example, if the output units, from the previous example, are the following: {inch , limit: no value (-inf)} {foot+inch, limit: 3.0} IN THIS CASE THE OUTPUT WILL BE ALWAYS IN inch.

Note

the output units and their limits will be extracted from the units preferences database by knowing the followings: - input unit - locale - usage

DESIGN: UnitRouter uses internally ComplexUnitConverter in order to convert the input units to the desired complex units and to check the limit too.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
UnitsRouter.ConverterPreference

Contains the complex unit converter and the limit which representing the smallest value that the converter should accept.

public class

Field Summary

Modifier and TypeField and Description
private ArrayList<UnitsRouter.ConverterPreference>
private ArrayList<MeasureUnit>

Constructor Summary

AccessConstructor and Description
public
UnitsRouter(String inputUnitIdentifier, ULocale locale, String usage)

public
UnitsRouter(MeasureUnitImpl inputUnit, ULocale locale, String usage)

Method Summary

Modifier and TypeMethod and Description
public List<MeasureUnit>
getOutputUnits()

Returns the list of possible output units, i.e. the full set of preferences, for the localized, usage-specific unit preferences.

private static Precision
parseSkeletonToPrecision(String precisionSkeleton)

public UnitsRouter.RouteResult
route(BigDecimal quantity, MicroProps micros)

If micros.rounder is a BogusRounder, this function replaces it with a valid one.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

converterPreferences_back to summary
private ArrayList<UnitsRouter.ConverterPreference> converterPreferences_
outputUnits_back to summary
private ArrayList<MeasureUnit> outputUnits_

Constructor Detail

UnitsRouterback to summary
public UnitsRouter(String inputUnitIdentifier, ULocale locale, String usage)
UnitsRouterback to summary
public UnitsRouter(MeasureUnitImpl inputUnit, ULocale locale, String usage)

Method Detail

getOutputUnitsback to summary
public List<MeasureUnit> getOutputUnits()

Returns the list of possible output units, i.e. the full set of preferences, for the localized, usage-specific unit preferences.

The returned pointer should be valid for the lifetime of the UnitsRouter instance.

parseSkeletonToPrecisionback to summary
private static Precision parseSkeletonToPrecision(String precisionSkeleton)
routeback to summary
public UnitsRouter.RouteResult route(BigDecimal quantity, MicroProps micros)

If micros.rounder is a BogusRounder, this function replaces it with a valid one.

com.ibm.icu.impl.units back to summary

public Class UnitsRouter.ConverterPreference

extends Object
Class Inheritance

Contains the complex unit converter and the limit which representing the smallest value that the converter should accept. For example, if the converter is converting to foot+inch and the limit equals 3.0, thus means the converter should not convert to a value less than 3.0 feet.

Note

if the limit doest not has a value (i.e. std::numeric_limits<double>::lowest()), this mean there is no limit for the converter.

Field Summary

Modifier and TypeField and Description
pack-priv final ComplexUnitsConverter
pack-priv final BigDecimal
pack-priv final String
pack-priv final MeasureUnitImpl

Constructor Summary

AccessConstructor and Description
public
ConverterPreference(MeasureUnitImpl source, MeasureUnitImpl targetUnit, String precision, ConversionRates conversionRates)

public
ConverterPreference(MeasureUnitImpl source, MeasureUnitImpl targetUnit, BigDecimal limit, String precision, ConversionRates conversionRates)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

converterback to summary
pack-priv final ComplexUnitsConverter converter
limitback to summary
pack-priv final BigDecimal limit
precisionback to summary
pack-priv final String precision
targetUnitback to summary
pack-priv final MeasureUnitImpl targetUnit

Constructor Detail

ConverterPreferenceback to summary
public ConverterPreference(MeasureUnitImpl source, MeasureUnitImpl targetUnit, String precision, ConversionRates conversionRates)
ConverterPreferenceback to summary
public ConverterPreference(MeasureUnitImpl source, MeasureUnitImpl targetUnit, BigDecimal limit, String precision, ConversionRates conversionRates)
com.ibm.icu.impl.units back to summary

public Class UnitsRouter.RouteResult

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public final ComplexUnitsConverter.ComplexConverterResult
public final MeasureUnitImpl

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

complexConverterResultback to summary
public final ComplexUnitsConverter.ComplexConverterResult complexConverterResult
outputUnitback to summary
public final MeasureUnitImpl outputUnit

Constructor Detail

RouteResultback to summary
pack-priv RouteResult(ComplexUnitsConverter.ComplexConverterResult complexConverterResult, MeasureUnitImpl outputUnit)