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.
| Modifier and Type | Class 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 |
| Modifier and Type | Field and Description |
|---|---|
| private ArrayList | |
| private ArrayList |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public List | 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 | |
| public UnitsRouter. | route(BigDecimal quantity, MicroProps micros)
If micros.rounder is a BogusRounder, this function replaces it with a valid one. |
| converterPreferences_ | back to summary |
|---|---|
| private ArrayList<UnitsRouter. | |
| outputUnits_ | back to summary |
|---|---|
| private ArrayList<MeasureUnit> outputUnits_ | |
| UnitsRouter | back to summary |
|---|---|
| public UnitsRouter(String inputUnitIdentifier, ULocale locale, String usage) | |
| UnitsRouter | back to summary |
|---|---|
| public UnitsRouter(MeasureUnitImpl inputUnit, ULocale locale, String usage) | |
| getOutputUnits | back to summary |
|---|---|
| public List 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. | |
| parseSkeletonToPrecision | back to summary |
|---|---|
| private static Precision parseSkeletonToPrecision(String precisionSkeleton) | |
| route | back to summary |
|---|---|
| public UnitsRouter. If micros.rounder is a BogusRounder, this function replaces it with a valid one. | |
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.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final ComplexUnitsConverter | |
| pack-priv final BigDecimal | |
| pack-priv final String | |
| pack-priv final MeasureUnitImpl |
| Access | Constructor and Description |
|---|---|
| public | ConverterPreference(MeasureUnitImpl source, MeasureUnitImpl targetUnit, String precision, ConversionRates conversionRates)
|
| public | ConverterPreference(MeasureUnitImpl source, MeasureUnitImpl targetUnit, BigDecimal limit, String precision, ConversionRates conversionRates)
|
| converter | back to summary |
|---|---|
| pack-priv final ComplexUnitsConverter converter | |
| limit | back to summary |
|---|---|
| pack-priv final BigDecimal limit | |
| precision | back to summary |
|---|---|
| pack-priv final String precision | |
| targetUnit | back to summary |
|---|---|
| pack-priv final MeasureUnitImpl targetUnit | |
| ConverterPreference | back to summary |
|---|---|
| public ConverterPreference(MeasureUnitImpl source, MeasureUnitImpl targetUnit, String precision, ConversionRates conversionRates) | |
| ConverterPreference | back to summary |
|---|---|
| public ConverterPreference(MeasureUnitImpl source, MeasureUnitImpl targetUnit, BigDecimal limit, String precision, ConversionRates conversionRates) | |
| Modifier and Type | Field and Description |
|---|---|
| public final ComplexUnitsConverter. | |
| public final MeasureUnitImpl |
| Access | Constructor and Description |
|---|---|
| pack-priv | RouteResult(ComplexUnitsConverter.
|
| complexConverterResult | back to summary |
|---|---|
| public final ComplexUnitsConverter. | |
| outputUnit | back to summary |
|---|---|
| public final MeasureUnitImpl outputUnit | |
| RouteResult | back to summary |
|---|---|
| pack-priv RouteResult(ComplexUnitsConverter. | |