Package com.ibm.icu.impl.units
Class UnitsRouter
- java.lang.Object
-
- com.ibm.icu.impl.units.UnitsRouter
-
public class UnitsRouter extends java.lang.Object
UnitsRouter
responsible for converting from a single unit (such asmeter
ormeter-per-second
) to one of the complex units based on the limits. For example: if the input ismeter
and the output as following {foot+inch
, limit: 3.0} {inch
, limit: no value (-inf)} Thus means if the input inmeter
is greater than or equal to3.0 feet
, the output will be infoot+inch
, otherwise, the output will be ininch
.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 INinch
.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 internallyComplexUnitConverter
in order to convert the input units to the desired complex units and to check the limit too.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UnitsRouter.ConverterPreference
Contains the complex unit converter and the limit which representing the smallest value that the converter should accept.class
UnitsRouter.RouteResult
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<UnitsRouter.ConverterPreference>
converterPreferences_
private java.util.ArrayList<MeasureUnit>
outputUnits_
-
Constructor Summary
Constructors Constructor Description UnitsRouter(MeasureUnitImpl inputUnit, ULocale locale, java.lang.String usage)
UnitsRouter(java.lang.String inputUnitIdentifier, ULocale locale, java.lang.String usage)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<MeasureUnit>
getOutputUnits()
Returns the list of possible output units, i.e.private static Precision
parseSkeletonToPrecision(java.lang.String precisionSkeleton)
UnitsRouter.RouteResult
route(java.math.BigDecimal quantity, MicroProps micros)
If micros.rounder is a BogusRounder, this function replaces it with a valid one.
-
-
-
Field Detail
-
outputUnits_
private java.util.ArrayList<MeasureUnit> outputUnits_
-
converterPreferences_
private java.util.ArrayList<UnitsRouter.ConverterPreference> converterPreferences_
-
-
Constructor Detail
-
UnitsRouter
public UnitsRouter(java.lang.String inputUnitIdentifier, ULocale locale, java.lang.String usage)
-
UnitsRouter
public UnitsRouter(MeasureUnitImpl inputUnit, ULocale locale, java.lang.String usage)
-
-
Method Detail
-
route
public UnitsRouter.RouteResult route(java.math.BigDecimal quantity, MicroProps micros)
If micros.rounder is a BogusRounder, this function replaces it with a valid one.
-
parseSkeletonToPrecision
private static Precision parseSkeletonToPrecision(java.lang.String precisionSkeleton)
-
getOutputUnits
public java.util.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.
-
-