001/*
002 * Units of Measurement Systems
003 * Copyright (c) 2005-2017, Jean-Marie Dautelle, Werner Keil and others.
004 *
005 * All rights reserved.
006 *
007 * Redistribution and use in source and binary forms, with or without modification,
008 * are permitted provided that the following conditions are met:
009 *
010 * 1. Redistributions of source code must retain the above copyright notice,
011 *    this list of conditions and the following disclaimer.
012 *
013 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
014 *    and the following disclaimer in the documentation and/or other materials provided with the distribution.
015 *
016 * 3. Neither the name of JSR-363, Units of Measurement nor the names of their contributors may be used to
017 *    endorse or promote products derived from this software without specific prior written permission.
018 *
019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
021 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029 */
030package systems.uom.unicode;
031
032import static javax.measure.MetricPrefix.*;
033import static tech.units.indriya.unit.Units.CUBIC_METRE;
034import static tech.units.indriya.unit.Units.METRE;
035import static tech.units.indriya.unit.Units.SQUARE_METRE;
036import static tech.units.indriya.AbstractUnit.ONE;
037
038import systems.uom.quantity.Concentration;
039import systems.uom.quantity.Consumption;
040import systems.uom.quantity.Information;
041import systems.uom.quantity.InformationRate;
042import tech.units.indriya.*;
043import tech.units.indriya.format.SimpleUnitFormat;
044import tech.units.indriya.function.MultiplyConverter;
045import tech.units.indriya.unit.AlternateUnit;
046import tech.units.indriya.unit.ProductUnit;
047import tech.units.indriya.unit.TransformedUnit;
048import tech.units.indriya.unit.Units;
049
050import javax.measure.Quantity;
051import javax.measure.Unit;
052import javax.measure.quantity.*;
053
054/**
055 * <p>
056 * This class contains {@linkplain SI} and Non-SI units as defined in the <a href="http//cldr.unicode.org/">Unicode CLDR Project</a>.
057 * </p>
058 *
059 * <p>
060 * Compatibility with {@linkplain SI} units has been given priority over strict adherence to the standard. We have attempted to note every place where
061 * the definitions in this class deviate from the CLDR standard, but such notes are likely to be incomplete.
062 * </p>
063 * 
064 * @noextend This class is not intended to be extended by clients.
065 *
066 * @author <a href="mailto:units@catmedia.us">Werner Keil</a>
067 * @see <a href="http://cldr.unicode.org">Unicode CLDR</a>
068 * @version 1.0, $Date: 2019-06-23 $
069 */
070public final class CLDR extends AbstractSystemOfUnits {
071
072    /**
073     * The singleton instance.
074     */
075    private static final CLDR INSTANCE = new CLDR();
076
077    /**
078     * Default constructor (prevents this class from being instantiated).
079     */
080    private CLDR() {
081    }
082
083    /**
084     * Returns the singleton instance of this class.
085     *
086     * @return the CLDR system instance.
087     */
088    public static CLDR getInstance() {
089        return INSTANCE;
090    }
091
092    ////////////
093    // Length //
094    ////////////
095    /**
096     * US name for {@link Units#METRE}. Constant for unit of length: meter
097     * 
098     * @stable ICU 53.
099     */
100    public static final Unit<Length> METER = addUnit(METRE);
101
102    /**
103     * Constant for unit of length: millimeter<br>
104     * This is a <b>convenience method</b> for <code>MILLI(METER)</code>.
105     * 
106     * @stable ICU 53.
107     */
108    public static final Unit<Length> MILLIMETER = MILLI(METER);
109
110    /**
111     * Constant for unit of length: centimeter<br>
112     * This is a <b>convenience method</b> for <code>CENTI(METER)</code>.
113     * 
114     * @stable ICU 53.
115     */
116    public static final Unit<Length> CENTIMETER = CENTI(METER);
117
118    /**
119     * Constant for unit of length: kilometer<br>
120     * This is a <b>convenience method</b> for <code>KILO(METER)</code>.
121     * 
122     * @stable ICU 53
123     */
124    public static final Unit<Length> KILOMETER = KILO(METRE);
125
126    /**
127     * A unit of length equal to <code>0.3048 m</code> (standard name <code>ft</code>).
128     */
129    public static final Unit<Length> FOOT = addUnit(METER.multiply(3048).divide(10000));
130
131    /**
132     * Constant for unit of length: furlong<br>
133     * A unit of length equal to <code>201.168 m</code> (standard name <code>fur</code>).
134     * 
135     * @see <a href="https://en.wikipedia.org/wiki/Furlong">Wikipedia: Furlong</a>
136     * @stable ICU 54.
137     */
138    public static final Unit<Length> FURLONG = addUnit(FOOT.multiply(660));
139
140    /**
141     * A unit of length equal to <code>0.9144 m</code> (standard name <code>yd</code>).
142     */
143    public static final Unit<Length> YARD = addUnit(FOOT.multiply(3));
144
145    /**
146     * A unit of length equal to <code>0.0254 m</code> (standard name <code>in</code>).
147     */
148    public static final Unit<Length> INCH = addUnit(FOOT.divide(12));
149
150    /**
151     * Constant for unit of length: mile<br>
152     * A unit of length equal to <code>1609.344 m</code> (standard name <code>mi</code>).
153     * 
154     * @stable ICU 53
155     */
156    public static final Unit<Length> MILE = addUnit(METER.multiply(1609344).divide(1000));
157
158    /**
159     * A unit of length equal to the average distance from the center of the Earth to the center of the Sun (standard name <code>ua</code>).
160     */
161    public static final Unit<Length> ASTRONOMICAL_UNIT = addUnit(METRE.multiply(149597870691.0));
162
163    /**
164     * Constant for unit of length: fathom<br>
165     * A unit of length equal to <code>1.8288 m</code> (standard name <code>fm</code>).
166     * 
167     * @stable ICU 53.
168     */
169    public static final Unit<Length> FATHOM = addUnit(FOOT.multiply(6));
170
171    /**
172     * Constant for unit of length: mile-scandinavian
173     * 
174     * @draft ICU 56
175     * @provisional This API might change or be removed in a future release.
176     * @see <a href="https://en.wikipedia.org/wiki/Scandinavian_mile">Wikipedia: Scandinavian mile</a>
177     */
178    public static final Unit<Length> MILE_SCANDINAVIAN = addUnit(KILOMETER.multiply(10));
179
180    /**
181     * Constant for unit of duration: second
182     * 
183     * @stable ICU 4.0
184     */
185    public static final Unit<Time> SECOND = addUnit(Units.SECOND);
186
187    /**
188     * Constant for unit of duration: week<br>
189     * A unit of duration equal to 7 {@link #DAY} (standard name <code>week</code>).
190     * 
191     * @stable ICU 4.0
192     */
193    public static final Unit<Time> WEEK = addUnit(Units.WEEK);
194
195    /**
196     * Constant for unit of angle: radian
197     * 
198     * @stable ICU 54
199     */
200    public static final Unit<Angle> RADIAN = addUnit(Units.RADIAN);
201
202    /**
203     * Constant for unit of angle: revolution<br>
204     * A unit of angle equal to a full circle or <code>2<i>&pi;</i>
205     * * {@link #RADIAN}</code> (standard name <code>rev</code>).
206     * 
207     * @draft ICU 56
208     * @provisional This API might change or be removed in a future release.
209     */
210    public static final Unit<Angle> REVOLUTION_ANGLE = addUnit(RADIAN.multiply(2).multiply(Math.PI).asType(Angle.class), "rev", true);
211
212    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
213    public static final Unit<Temperature> KELVIN = addUnit(Units.KELVIN);
214
215    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
216    public static final Unit<Dimensionless> PI = addUnit(ONE.transform(MultiplyConverter.ofPiExponent(1)));
217    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
218    public static final Unit<Dimensionless> PERCENT = addUnit(ONE.divide(100), "Percent", "%");
219
220    ////////////////////
221    // SI UNITS: CLDR //
222    ////////////////////
223    /**
224     * Constant for unit of concentr: mole.
225     * @draft ICU 64.
226     */
227    public static final Unit<AmountOfSubstance> MOLE = addUnit(Units.MOLE);
228    /**
229     * We deviate slightly from the standard here, to maintain compatibility with the existing SI units. In CLDR, the steradian is defined as
230     * <code>RADIAN.pow(2)</code>.
231     */
232    public static final Unit<SolidAngle> STERADIAN = addUnit(Units.STERADIAN);
233
234    public static final Unit<Frequency> HERTZ = addUnit(Units.HERTZ);
235    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
236    public static final Unit<Force> NEWTON = addUnit(Units.NEWTON);
237    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
238    public static final Unit<Pressure> PASCAL = addUnit(Units.PASCAL);
239
240    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
241    // private static final Unit<Pressure> METER_OF_WATER_COLUMN =
242    // KILO(PASCAL).multiply(980665).divide(100000);
243    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
244    private static final Unit<Pressure> METER_OF_MERCURY_COLUMN = KILO(PASCAL).multiply(1333220).divide(10000);
245    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
246    // private static final Unit<Pressure> INCH_OF_WATER_COLUMN =
247    // new
248    // ProductUnit<Pressure>(METER_OF_WATER_COLUMN.multiply(INCH).divide(METER));
249    /**
250     * Constant for unit of pressure: inch-hg
251     * 
252     * @stable ICU 53
253     */
254    public static final Unit<Pressure> INCH_HG = addUnit(new ProductUnit<Pressure>(METER_OF_MERCURY_COLUMN.multiply(INCH).divide(METER)));
255
256    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
257    public static final Unit<Energy> JOULE = addUnit(Units.JOULE);
258    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
259    public static final Unit<Power> WATT = addUnit(Units.WATT);
260    /**
261     * We deviate slightly from the standard here, to maintain compatability with the existing SI units. In CLDR, the ampere is defined as
262     * <code>COULOMB.divide(SECOND)</code>.
263     */
264    public static final Unit<ElectricCurrent> AMPERE = addUnit(Units.AMPERE);
265
266    /**
267     * We deviate slightly from the standard here, to maintain compatibility with the existing SI units. In CLDR, the volt is defined as
268     * <code>JOULE.divide(COULOMB)</code>.
269     */
270    public static final Unit<ElectricPotential> VOLT = addUnit(Units.VOLT);
271
272    /**
273     * Constant for unit of electric: ohm
274     * 
275     * @stable ICU 54
276     */
277    public static final Unit<ElectricResistance> OHM = addUnit(Units.OHM);
278    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
279    public static final Unit<Temperature> CELSIUS = addUnit(Units.CELSIUS);
280    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
281    public static final Unit<ElectricInductance> HENRY = addUnit(Units.HENRY);
282
283    /**
284     * Constant for unit of light: lux
285     * 
286     * @stable ICU 54
287     */
288    public static final Unit<Illuminance> LUX = addUnit(Units.LUX);
289
290    /////////////////////////////////////////////////////////////////
291    // Units outside the SI that are accepted for use with the SI. //
292    /////////////////////////////////////////////////////////////////
293
294    /**
295     * An angle unit accepted for use with SI units (standard name <code>deg/code>).
296     */
297    static final Unit<Angle> DEGREE_ANGLE = new TransformedUnit<Angle>(RADIAN,
298                MultiplyConverter.ofPiExponent(1).concatenate(MultiplyConverter.ofRational(1, 180)));
299
300    /**
301     * An angle unit accepted for use with SI units (standard name <code>'/code>).
302     */
303    static final Unit<Angle> MINUTE_ANGLE = new TransformedUnit<Angle>(RADIAN,
304            MultiplyConverter.ofPiExponent(1).concatenate(MultiplyConverter.ofRational(1, 180 * 60)));
305
306    /**
307     * An angle unit accepted for use with SI units (standard name <code>''</code>).
308     */
309    static final Unit<Angle> SECOND_ANGLE = new TransformedUnit<Angle>(RADIAN,
310                MultiplyConverter.ofPiExponent(1).concatenate(MultiplyConverter.ofRational(1, 180 * 60 * 60)));
311
312    /**
313     * We deviate slightly from the standard here, to maintain compatibility with the existing NonSI units. In CLDR, the degree is defined as
314     * <code>PI.multiply(RADIAN.divide(180))</code>.
315     */
316    public static final Unit<Angle> DEGREE = addUnit(DEGREE_ANGLE);
317
318    /**
319     * As per CLDR standard.
320     */
321    public static final Unit<Angle> ARC_MINUTE = addUnit(MINUTE_ANGLE);
322
323    public static final Unit<Angle> ARC_SECOND = addUnit(SECOND_ANGLE);
324
325    //////////
326    // Area //
327    //////////
328    /**
329     * Constant for unit of area: square-foot<br>
330     * A unit of area (standard name <code>sft</code> ).
331     * 
332     * @stable ICU 53
333     */
334    public static final Unit<Area> SQUARE_FOOT = addUnit(new ProductUnit<Area>((AbstractUnit<?>) FOOT.multiply(FOOT)));
335
336    /**
337     * A unit of area equal to <code>100 m²</code> (standard name <code>a</code> ).
338     */
339    private static final Unit<Area> ARE = SQUARE_METRE.multiply(100);
340
341    /**
342     * A unit of area equal to <code>100 {@link #ARE}</code> (standard name <code>ha</code>).
343     * 
344     * @stable ICU 53.
345     */
346    public static final Unit<Area> HECTARE = addUnit(ARE.multiply(100)); // Exact.
347
348    /**
349     * The acre is a unit of area used in the imperial and U.S. customary systems. It is equivalent to <code>43,560 square feet</code>. An acre is
350     * about 40% of a <code>HECTARE</code> – slightly smaller than an American football field. (standard name <code>ac</code> ).
351     * 
352     * @see <a href="http://en.wikipedia.org/wiki/Acre">Wikipedia: Acre</a>
353     */
354    public static final Unit<Area> ACRE = addUnit(SQUARE_FOOT.multiply(43560));
355
356    /**
357     * Constant for unit of area: square-inch
358     * 
359     * @stable ICU 54
360     */
361    public static final Unit<Area> SQUARE_INCH = addUnit(new ProductUnit<Area>(INCH.pow(2)));
362
363    /**
364     * Constant for unit of area: square-yard
365     * 
366     * @stable ICU 54
367     */
368    public static final Unit<Area> SQUARE_YARD = addUnit(new ProductUnit<Area>(YARD.pow(2)));
369
370    ////////////
371    // Volume //
372    ////////////
373    /**
374     * Constant for unit of volume: liter<br>
375     * A unit of volume equal to one cubic decimeter (default label <code>L</code>, also recognized <code>µL, mL, cL, dL</code>).
376     * 
377     * @stable ICU 53
378     */
379    public static final Unit<Volume> LITER = new TransformedUnit<Volume>(CUBIC_METRE, MultiplyConverter.ofRational(1, 1000));
380    // private static final Unit<Volume> LITRE = addUnit(Units.LITRE);
381
382    /**
383     * Constant for unit of volume: cubic-meter (<code>m³</code>).
384     * 
385     * @stable ICU 54.
386     */
387    public static final Unit<Volume> CUBIC_METER = addUnit(CUBIC_METRE);
388
389    /**
390     * A unit of volume equal to one cubic inch (<code>in³</code>).
391     */
392    public static final Unit<Volume> CUBIC_INCH = addUnit(INCH.pow(3).asType(Volume.class));
393
394    /**
395     * Constant for unit of volume: gallon A unit of volume equal to one US gallon, Liquid Unit. The U.S. liquid gallon is based on the Queen Anne or
396     * Wine gallon occupying 231 cubic inches (standard name <code>gal</code>).
397     * 
398     * @stable ICU 54.
399     */
400    public static final Unit<Volume> GALLON = addUnit(CUBIC_INCH.multiply(231));
401
402    /**
403     * Constant for unit of volume: gallon-imperial
404     * 
405     * @stable ICU 57.
406     */
407    public static final Unit<Volume> GALLON_IMPERIAL = addUnit(LITER.multiply(454609).divide(100000));
408
409    /**
410     * Constant for unit of volume: cubic-foot<br>
411     * The cubic foot is an imperial and US customary (non-metric) unit of volume, used in the United States, Canada, and the United Kingdom. It is
412     * defined as the volume of a cube with sides of one foot (0.3048 m) in length. Its volume is 28.3168 liters or about 1⁄35 of a cubic meter. (
413     * <code>ft³</code>).
414     * 
415     * @stable ICU 54.
416     */
417    public static final Unit<Volume> CUBIC_FOOT = addUnit(CUBIC_INCH.multiply(1728).asType(Volume.class));
418
419    /**
420     * Constant for unit of volume: cubic-mile<br>
421     * A unit of volume equal to one cubic-mile (<code>cu mi</code>).
422     * 
423     * @stable ICU 53.
424     */
425    public static final Unit<Volume> CUBIC_MILE = addUnit(CUBIC_FOOT.multiply(147197952000L));
426
427    /**
428     * Constant for unit of volume: cubic-yard<br>
429     * A unit of volume equal to one cubic-yard (<code>cyd.</code>).
430     * 
431     * @stable ICU 54.
432     */
433    public static final Unit<Volume> CUBIC_YARD = addUnit(CUBIC_FOOT.multiply(27));
434
435    /**
436     * A unit of volume equal to <code>1 / 128 {@link #GALLON_LIQUID}</code> (standard name <code>oz_fl</code>).
437     */
438    public static final Unit<Volume> FLUID_OUNCE = addUnit(GALLON.divide(128));
439
440    /**
441     * An acre-foot is a unit of volume commonly used in the United States in reference to large-scale water resources, such as reservoirs, aqueducts,
442     * canals, sewer flow capacity, irrigation water, and river flows.
443     */
444    public static final Unit<Volume> ACRE_FOOT = addUnit(CUBIC_FOOT.multiply(43560));
445
446    /**
447     * Constant for unit of volume: bushel
448     */
449    public static final Unit<Volume> BUSHEL = addUnit(CUBIC_INCH.multiply(215042).divide(100));
450
451    /**
452     * Constant for unit of volume: cup<br>
453     * The cup is a unit of measurement for volume, used in cooking to measure liquids (fluid measurement) and bulk foods such as granulated sugar
454     * (dry measurement). A cup is equal to <code>8 {@link #FLUID_OUNCE}</code> (standard name <code>cup</code>).
455     * 
456     * @stable ICU 54.
457     */
458    public static final Unit<Volume> CUP = addUnit(FLUID_OUNCE.multiply(8));
459
460    /**
461     * Constant for unit of volume: cup-metric
462     * 
463     * @see <a href= "https://en.wikipedia.org/wiki/Cup_(unit)#Metric_cup">Wikipedia: Metric cup</a>
464     * @stable ICU 56.
465     */
466    public static final Unit<Volume> CUP_METRIC = addUnit(MILLI(LITER).multiply(250));
467
468    /**
469     * Constant for unit of volume: pint<br>
470     * A unit of volume equal to <code>20 {@link #FLUID_OUNCE}</code> (standard name <code>pt</code>).
471     * 
472     * @stable ICU 54
473     */
474    public static final Unit<Volume> PINT = addUnit(FLUID_OUNCE.multiply(20), "Pint", "pt", true);
475
476    /**
477     * Constant for unit of volume: pint-metric
478     * 
479     * @draft ICU 56
480     * @provisional This API might change or be removed in a future release.
481     */
482    public static final Unit<Volume> PINT_METRIC = addUnit(MILLI(LITER).multiply(500), "Metric Pint", "metr. pt", true);
483
484    /**
485     * Constant for unit of volume: quart<br>
486     * A unit of volume equal to <code>40 {@link #FLUID_OUNCE}</code> (standard name <code>qt</code>).
487     * 
488     * @stable ICU 54
489     */
490    public static final Unit<Volume> QUART = addUnit(FLUID_OUNCE.multiply(40), "Quart", "qt");
491
492    /**
493     * A unit of volume <code>~ 1 drop or 0.95 grain of water </code> (standard name <code>min</code>).
494     */
495    private static final Unit<Volume> MINIM = MICRO(LITER).multiply(61.61152d);
496
497    /**
498     * Constant for unit of volume: teaspoon<br>
499     * A unit of volume equal to <code>80 {@link #MINIM}</code> (standard name <code>tsp</code>).
500     * 
501     * @stable ICU 54
502     */
503    public static final Unit<Volume> TEASPOON = addUnit(MINIM.multiply(80));
504
505    /**
506     * Constant for unit of volume: tablespoon<br>
507     * A unit of volume equal to <code>3 {@link #TEASPOON}</code> (standard name <code>Tbsp</code>).
508     * 
509     * @stable ICU 54
510     */
511    public static final Unit<Volume> TABLESPOON = addUnit(TEASPOON.multiply(3));
512
513    //////////
514    // Time //
515    //////////
516    /**
517     * Constant for unit of duration: minute
518     * 
519     * @stable ICU 4.0
520     */
521    public static final Unit<Time> MINUTE = addUnit(Units.MINUTE);
522    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
523    public static final Unit<Time> HOUR = addUnit(Units.HOUR);
524    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
525    public static final Unit<Time> DAY = addUnit(Units.DAY);
526
527    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
528    static final Unit<Time> YEAR_JULIAN = addUnit(Units.DAY.multiply(365.25));
529
530    /**
531     * Constant for unit of duration: year<br>
532     * A time unit accepted for use with SI units (standard name <code>y</code> ).
533     * 
534     * @stable ICU 4.0
535     */
536    public static final Unit<Time> YEAR = addUnit(Units.DAY.multiply(365.25));
537
538    /**
539     * Constant for unit of duration: month
540     * 
541     * @stable ICU 4.0
542     */
543    public static final Unit<Time> MONTH = addUnit(YEAR_JULIAN.divide(12));
544
545    /**
546     * Constant for unit of time: century
547     * 
548     * @see <a href="http://www.aqua-calc.com/what-is/time/century">What Is century?</a>
549     * @stable ICU 56.
550     */
551    public static final Unit<Time> CENTURY = addUnit(YEAR.multiply(100));
552
553    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
554    private static final Unit<Pressure> BAR = addUnit(Units.PASCAL.multiply(100000));
555    public static final Unit<Mass> GRAM = addUnit(Units.GRAM);
556
557    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
558    public static final Unit<Mass> TONNE = addUnit(Units.KILOGRAM.multiply(1000));
559
560    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
561    private static final Unit<Mass> GRAIN = MILLI(GRAM).multiply(6479891).divide(100000);
562    /**
563     * Constant for unit of mass: pound
564     * 
565     * @stable ICU 53
566     */
567    public static final Unit<Mass> POUND = addUnit(GRAIN.multiply(7000));
568
569    /**
570     * Constant for unit of mass: ounce<br>
571     * A unit of mass equal to <code>1 / 16 {@link #POUND}</code> (standard name <code>oz</code>).
572     * 
573     * @stable ICU 53
574     */
575    public static final Unit<Mass> OUNCE = addUnit(POUND.divide(16), "oz", true);
576
577    /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
578    private static final Unit<Mass> PENNYWEIGHT_TROY = GRAIN.multiply(24);
579    /**
580     * Constant for unit of mass: ounce-troy
581     * 
582     * @stable ICU 54
583     */
584    public static final Unit<Mass> OUNCE_TROY = addUnit(PENNYWEIGHT_TROY.multiply(20));
585
586    /**
587     * Constant for unit of area: square-yard
588     * 
589     * @stable ICU 54
590     */
591    public static final Unit<Mass> STONE = addUnit(POUND.multiply(14));
592
593    ///////////////////
594    // NATURAL UNITS //
595    ///////////////////
596    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
597    static final Unit<Speed> C = addUnit(Units.METRE_PER_SECOND.multiply(299792458));
598    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
599    // public static final Unit<Action> PLANCK = addUnit(SI.JOULE_SECOND
600    // .multiply(6.6260755E-24)); // FIXME get rid of JXQ import (where
601    // from??) */
602
603    /**
604     * Constant for unit of acceleration: g-force
605     * 
606     * @stable ICU 53.
607     */
608    public static final Unit<Acceleration> G_FORCE = addUnit(Units.METRE_PER_SQUARE_SECOND.multiply(9.80665));
609
610    ////////////
611    // Length //
612    ////////////
613    /**
614     * Constant for unit of length: light-year<br>
615     * A unit of length equal to the distance that light travels in one year through a vacuum (standard name <code>ly</code>).
616     * 
617     * @stable ICU 53
618     */
619    public static final Unit<Length> LIGHT_YEAR = addUnit(new ProductUnit<Length>(C.multiply(YEAR_JULIAN)));
620    /**
621     * A unit of length equal to the distance that light travels in one year through a vacuum (standard name <code>ly</code>).
622     */
623    // static final Unit<Length> LIGHT_YEAR = addUnit(METRE
624    // .multiply(9.460528405e15));
625
626    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
627    static final Unit<Length> INCH_INTERNATIONAL = addUnit(CENTI(METRE).multiply(254).divide(100));
628    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
629    static final Unit<Length> FOOT_INTERNATIONAL = addUnit(INCH_INTERNATIONAL.multiply(12));
630    /**
631     * Constant for unit of length: nautical-mile
632     * 
633     * @stable ICU 54
634     */
635    public static final Unit<Length> NAUTICAL_MILE = addUnit(METRE.multiply(1852));
636
637    /**
638     * Constant for unit of speed: knot
639     * 
640     * @draft ICU 56
641     * @provisional This API might change or be removed in a future release.
642     */
643    public static final Unit<Speed> KNOT = addUnit(new ProductUnit<Speed>(NAUTICAL_MILE.divide(HOUR)));
644
645    /**
646     * Constant for unit of speed: meter-per-second<br>
647     * The unit for speed (standard name <code>m/s</code>).
648     * 
649     * @stable ICU 53
650     */
651    public static final Unit<Speed> METER_PER_SECOND = addUnit(new ProductUnit<Speed>(METER.divide(SECOND)), Speed.class);
652
653    /**
654     * Constant for unit of speed: mile-per-hour<br>
655     * A unit of velocity expressing the number of international {@link #MILE miles} per {@link #HOUR hour} (abbreviation <code>mph</code>).
656     * 
657     * @stable ICU 53
658     */
659    public static final Unit<Speed> MILE_PER_HOUR = addUnit(MILE.divide(HOUR).asType(Speed.class), "Mile per hour", "mph");
660
661    /**
662     * Constant for unit of speed: mile-per-hour<br>
663     * The unit for acceleration (standard name <code>m/s2</code> ).
664     * 
665     * @stable ICU 53
666     */
667    public static final Unit<Acceleration> METER_PER_SECOND_SQUARED = addUnit(new ProductUnit<Acceleration>(METER_PER_SECOND.divide(SECOND)),
668            Acceleration.class);
669
670    /**
671     * Constant for unit of mass: carat<br>
672     * Carat (mass) is a unit of {@link Mass} for gems. It is equal to 0.2 gram (standard name <code>ct</code>).</br>
673     * In the United States, carat almost exclusively means the unit of mass.
674     * 
675     * @see <a href="https://en.wikipedia.org/wiki/Carat_(mass)">Wikipedia: Carat (mass)</a>
676     *
677     * @stable ICU 54
678     */
679    public static final Unit<Mass> CARAT = addUnit(GRAM.divide(5));
680    // public static final Unit<Mass> CARAT = addUnit((KILOGRAM.divide(5000)));
681
682    /**
683     * Constant for unit of proportion: karat
684     * 
685     * @stable ICU 54
686     */
687    public static final Unit<Dimensionless> KARAT = addUnit(ONE.divide(24));
688
689    private static final Unit<Force> POUND_FORCE = addUnit(POUND.multiply(G_FORCE).asType(Force.class));
690
691    /**
692     * Constant for unit of length: parsec<br>
693     * A unit of length equal to the distance at which a star would appear to shift its position by one arcsecond over the course the time (about 3
694     * months) in which the Earth moves a distance of {@link #ASTRONOMICAL_UNIT} in the direction perpendicular to the direction to the star (standard
695     * name <code>pc</code>).
696     * 
697     * @stable ICU 54.
698     */
699    public static final Unit<Length> PARSEC = addUnit(METRE.multiply(30856770e9));
700
701    ///////////////////////////////
702    // TYPESETTER'S LENGTH UNITS //
703    ///////////////////////////////
704    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
705    static final Unit<Length> LINE = addUnit(INCH_INTERNATIONAL.divide(12));
706    /**
707     * A unit of length equal to <code>0.013837 {@link #INCH}</code> exactly (standard name <code>pt</code>).
708     * 
709     * @see #PIXEL
710     */
711    /*
712     * public static final Unit<Length> POINT = addUnit(LINE.divide(6)); //
713     * static final Unit<Length> POINT = addUnit(INCH.multiply(13837) //
714     * .divide(1000000));
715     * 
716     * /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. public
717     * static final Unit<Length> PICA = addUnit(POINT.multiply(12)); /** As per
718     * <a href="http//cldr.unicode.org/">CLDR</a> standard. public static final
719     * Unit<Length> POINT_PRINTER =
720     * addUnit(INCH_INTERNATIONAL.multiply(13837).divide(1000000)); /** As per
721     * <a href="http//cldr.unicode.org/">CLDR</a> standard. public static final
722     * Unit<Length> PICA_PRINTER = addUnit(POINT_PRINTER.multiply(12));
723     */
724    //////////////////////////////
725    // OTHER LEGACY UNITS: CLDR //
726    //////////////////////////////
727    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
728    public static final Unit<Temperature> FAHRENHEIT = addUnit(KELVIN.multiply(5).divide(9).shift(459.67));
729
730    /**
731     * Constant for unit of energy: foodcalorie.
732     * 
733     * @see <a href= "http://www.convertunits.com/info/calorie+[nutritional]">Calorie (nutritional)</a>
734     * 
735     * @stable ICU 54
736     */
737    public static final Unit<Energy> FOODCALORIE = addUnit(JOULE.multiply(4186.8));
738
739    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
740    private static final Unit<Energy> CALORIE_THERMOCHEMICAL = addUnit(JOULE.multiply(4184).divide(1000));
741    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
742    public static final Unit<Energy> CALORIE = addUnit(CALORIE_THERMOCHEMICAL);
743    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
744    // private static final Unit<Energy> CALORIE_FOOD =
745    // addUnit(KILO(CALORIE_THERMOCHEMICAL));
746
747    /**
748     * Constant for unit of power: horsepower
749     * 
750     * @stable ICU 53
751     */
752    public static final Unit<Power> HORSEPOWER = addUnit(new ProductUnit<Power>(FOOT_INTERNATIONAL.multiply(POUND_FORCE).divide(SECOND)));
753
754    /**
755     * Constant for unit of pressure: pound-per-square-inch
756     * 
757     * @stable ICU 54
758     */
759    public static final Unit<Pressure> POUND_PER_SQUARE_INCH = addUnit(new ProductUnit<Pressure>(POUND_FORCE.divide(INCH_INTERNATIONAL.pow(2))));
760    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
761    // private static final Unit<Angle> CIRCLE = new
762    // ProductUnit<Angle>(PI.multiply(RADIAN.multiply(2)));
763
764    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
765    public static final Unit<SolidAngle> SPHERE = addUnit(new ProductUnit<SolidAngle>(PI.multiply(STERADIAN.multiply(4))));
766
767    /**
768     * The unit for binary information (standard name <code>bit</code>).
769     * 
770     * @stable ICU 54
771     */
772    public static final Unit<Information> BIT = addUnit(new AlternateUnit<Information>(ONE, "bit"), "Bit", "bit", Information.class);
773
774    /**
775     * A unit of data amount equal to <code>8 {@link #BIT}</code> (BinarY TErm, standard name <code>byte</code>).
776     */
777    public static final Unit<Information> BYTE = addUnit(BIT.multiply(8), "Byte", "byte");
778
779    /**
780     * The unit for binary information rate (standard name <code>bit/s</code>).
781     * 
782     * @draft Non-ICU
783     */
784    static final Unit<InformationRate> BIT_PER_SECOND = addUnit(new ProductUnit<InformationRate>(BIT.divide(SECOND)), InformationRate.class);
785
786    /**
787     * Equivalent {@link #BYTE}
788     */
789    static final Unit<Information> OCTET = BYTE;
790
791    /**
792     * A unit used to measure the frequency (rate) at which an imaging device produces unique consecutive images (standard name <code>fps</code>).
793     * 
794     * @draft Non-ICU
795     */
796    static final Unit<Frequency> FRAME_PER_SECOND = ONE.divide(SECOND).asType(Frequency.class);
797
798    ///////////////////
799    // Concentration //
800    ///////////////////
801
802    /**
803     * Constant for unit of concentr: milligram-per-deciliter
804     * 
805     * @stable ICU 57
806     */
807    @SuppressWarnings("unchecked")
808    public static final Unit<Concentration<Mass>> MILLIGRAM_PER_DECILITER = addUnit(MILLI(GRAM).divide(DECI(LITER)).asType(Concentration.class));
809
810    ///////////////////
811    // Consumption //
812    ///////////////////
813
814    /**
815     * Constant for unit of consumption: liter-per-100kilometers
816     * 
817     * @draft ICU 56
818     * @provisional This API might change or be removed in a future release.
819     */
820    @SuppressWarnings("unchecked")
821    public static final Unit<Consumption<Volume>> LITER_PER_100KILOMETERS = addUnit(
822            (KILOMETER.multiply(100)).divide(LITER).asType(Consumption.class));;
823
824    /**
825     * Constant for unit of consumption: liter-per-kilometer
826     * 
827     * @stable ICU 54
828     */
829    @SuppressWarnings("unchecked")
830    public static final Unit<Consumption<Volume>> LITER_PER_KILOMETER = addUnit(KILOMETER.divide(LITER).asType(Consumption.class));
831
832    /**
833     * Constant for unit of consumption: mile-per-gallon
834     * 
835     * @stable ICU 54
836     */
837    @SuppressWarnings("unchecked")
838    public static final Unit<Consumption<Volume>> MILE_PER_GALLON = addUnit(MILE.divide(GALLON).asType(Consumption.class));
839
840    /////////////////////
841    // Collection View //
842    /////////////////////
843
844    @Override
845    public String getName() {
846        return "Unicode CLDR";
847    }
848
849    /**
850     * Adds a new unit not mapped to any specified quantity type.
851     *
852     * @param unit
853     *            the unit being added.
854     * @return <code>unit</code>.
855     */
856    private static <U extends Unit<Q>, Q extends Quantity<Q>> U addUnit(U unit) {
857        INSTANCE.units.add(unit);
858        return unit;
859    }
860
861    /**
862     * Adds a new unit and maps it to the specified quantity type.
863     *
864     * @param unit
865     *            the unit being added.
866     * @param type
867     *            the quantity type.
868     * @return <code>unit</code>.
869     */
870    private static <U extends Unit<?>> U addUnit(U unit, Class<? extends Quantity<?>> type) {
871        INSTANCE.units.add(unit);
872        INSTANCE.quantityToUnit.put(type, unit);
873        return unit;
874    }
875
876    /**
877     * Adds a new unit not mapped to any specified quantity type and puts a text as symbol or label.
878     *
879     * @param unit
880     *            the unit being added.
881     * @param name
882     *            the string to use as name
883     * @param text
884     *            the string to use as label or symbol
885     * @param isLabel
886     *            if the string should be used as a label or not
887     * @return <code>unit</code>.
888     */
889    private static <U extends Unit<?>> U addUnit(U unit, String name, String text, boolean isLabel) {
890        if (isLabel) {
891            SimpleUnitFormat.getInstance().label(unit, text);
892        }
893        if (name != null && unit instanceof AbstractUnit) {
894            return Helper.addUnit(INSTANCE.units, unit, name);
895        } else {
896            INSTANCE.units.add(unit);
897        }
898        return unit;
899    }
900
901    /**
902     * Adds a new unit not mapped to any specified quantity type and puts a text as symbol or label.
903     *
904     * @param unit
905     *            the unit being added.
906     * @param name
907     *            the string to use as name
908     * @param text
909     *            the string to use as label or symbol
910     * @param isLabel
911     *            if the string should be used as a label or not
912     * @return <code>unit</code>.
913     */
914    private static <U extends Unit<?>> U addUnit(U unit, String name, String text) {
915        return addUnit(unit, name, text, true);
916    }
917
918    /**
919     * Adds a new unit and maps it to the specified quantity type.
920     *
921     * @param unit
922     *            the unit being added.
923     * @param type
924     *            the quantity type.
925     * @return <code>unit</code>.
926     */
927    private static <U extends AbstractUnit<?>> U addUnit(U unit, String name, String label, Class<? extends Quantity<?>> type) {
928        INSTANCE.quantityToUnit.put(type, unit);
929        return addUnit(unit, name, label);
930    }
931
932    /**
933     * Adds a new unit not mapped to any specified quantity type and puts a text as symbol or label.
934     *
935     * @param unit
936     *            the unit being added.
937     * @param text
938     *            the string to use as label or symbol
939     * @param isLabel
940     *            if the string should be used as a label or not
941     * @return <code>unit</code>.
942     */
943    private static <U extends Unit<?>> U addUnit(U unit, String text, boolean isLabel) {
944        return addUnit(unit, null, text, isLabel);
945    }
946
947    // //////////////////////////////////////////////////////////////////////////
948    // Label adjustments for CLDR system
949    static {
950        SimpleUnitFormat.getInstance().alias(BYTE, "B");
951        SimpleUnitFormat.getInstance().label(KARAT, "kt");
952        SimpleUnitFormat.getInstance().label(CARAT, "ct");
953        SimpleUnitFormat.getInstance().label(POUND, "lb");
954        SimpleUnitFormat.getInstance().label(BAR, "b");
955        SimpleUnitFormat.getInstance().label(PARSEC, "pc");
956        SimpleUnitFormat.getInstance().label(SQUARE_FOOT, "sft");
957    }
958
959    public Unit<?> getUnit(String string) {
960        // TODO Auto-generated method stub
961        return null;
962    }
963}