001/*
002 *  Unit Systems
003 *  Copyright (c) 2005-2016, Jean-Marie Dautelle, Werner Keil, V2COM.
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 nor the names of its contributors may be used to endorse or promote products
017 *    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 tec.units.ri.unit.MetricPrefix.*;
033import static tec.units.ri.unit.Units.CUBIC_METRE;
034import static tec.units.ri.unit.Units.METRE;
035import static tec.units.ri.unit.Units.SQUARE_METRE;
036import static tec.units.ri.AbstractUnit.ONE;
037import systems.uom.quantity.Information;
038import systems.uom.quantity.InformationRate;
039import tec.units.ri.*;
040import tec.units.ri.format.SimpleUnitFormat;
041import tec.units.ri.function.PiMultiplierConverter;
042import tec.units.ri.function.RationalConverter;
043import tec.units.ri.unit.AlternateUnit;
044import tec.units.ri.unit.ProductUnit;
045import tec.units.ri.unit.TransformedUnit;
046import tec.units.ri.unit.Units;
047
048import javax.measure.Quantity;
049import javax.measure.Unit;
050import javax.measure.quantity.*;
051
052/**
053 * <p>
054 * This class contains {@link SI} and Non-SI units as defined in the <a
055 * href="http//cldr.unicode.org/">Unicode CLDR Project</a>.
056 * </p>
057 *
058 * <p>
059 * Compatibility with {@link SI} units has been given priority over strict
060 * adherence to the standard. We have attempted to note every place where the
061 * definitions in this class deviate from the CLDR standard, but such notes are
062 * likely to be incomplete.
063 * </p>
064 * 
065 * @noextend This class is not intended to be extended by clients.
066 *
067 * @author <a href="mailto:units@catmedia.us">Werner Keil</a>
068 * @see <a href="http://cldr.unicode.org">Unicode CLDR</a>
069 * @version 0.4.3, $Date: 2016-08-026 $
070 */
071public final class CLDR extends AbstractSystemOfUnits {
072
073    /**
074     * The singleton instance.
075     */
076    private static final CLDR INSTANCE = new CLDR();
077
078    /**
079     * Default constructor (prevents this class from being instantiated).
080     */
081    private CLDR() {
082    }
083
084    /**
085     * Returns the singleton instance of this class.
086     *
087     * @return the CLDR system instance.
088     */
089    public static CLDR getInstance() {
090        return INSTANCE;
091    }
092
093    // //////////
094    // Length //
095    // //////////
096    /**
097     * US name for {@link Units#METRE}.
098     */
099    public static final Unit<Length> METER = addUnit(METRE);
100
101    /**
102     * A unit of length equal to <code>0.3048 m</code> (standard name
103     * <code>ft</code>).
104     */
105    public static final Unit<Length> FOOT = addUnit(METER.multiply(3048)
106            .divide(10000));
107
108    /**
109     * A unit of length equal to <code>1200/3937 m</code> (standard name
110     * <code>foot_survey_us</code>). See also: <a
111     * href="http://www.sizes.com/units/foot.htm">foot</a>
112     */
113    public static final Unit<Length> FOOT_SURVEY = addUnit(METER.multiply(1200)
114            .divide(3937));
115
116    /**
117     * A unit of length equal to <code>0.9144 m</code> (standard name
118     * <code>yd</code>).
119     */
120    public static final Unit<Length> YARD = addUnit(FOOT.multiply(3));
121
122    /**
123     * A unit of length equal to <code>0.0254 m</code> (standard name
124     * <code>in</code>).
125     */
126    public static final Unit<Length> INCH = addUnit(FOOT.divide(12));
127
128    /**
129     * A unit of length equal to <code>1609.344 m</code> (standard name
130     * <code>mi</code>).
131     */
132    public static final Unit<Length> MILE = addUnit(METER.multiply(1609344)
133            .divide(1000));
134
135    /**
136     * A unit of length equal to the average distance from the center of the
137     * Earth to the center of the Sun (standard name <code>ua</code>).
138     */
139    public static final Unit<Length> ASTRONOMICAL_UNIT = addUnit(METRE
140            .multiply(149597870691.0));
141
142    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
143    public static final Unit<Time> SECOND = addUnit(Units.SECOND);
144
145    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
146    public static final Unit<Angle> RADIAN = addUnit(Units.RADIAN);
147    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
148    public static final Unit<Temperature> KELVIN = addUnit(Units.KELVIN);
149
150    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
151    public static final Unit<LuminousIntensity> CANDELA = addUnit(Units.CANDELA);
152
153    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
154    public static final Unit<Dimensionless> PI = addUnit(ONE
155            .transform(new PiMultiplierConverter()));
156    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
157    public static final Unit<Dimensionless> PERCENT = addUnit(ONE.divide(100));
158
159    // //////////////////////////
160    // SI UNITS: CLDR //
161    // //////////////////////////
162    /**
163     * We deviate slightly from the standard here, to maintain compatibility
164     * with the existing SI units. In CLDR, the mole is no longer a base unit,
165     * but is defined as <code>Unit.ONE.multiply(6.0221367E23)</code>.
166     */
167    public static final Unit<AmountOfSubstance> MOLE = addUnit(Units.MOLE);
168    /**
169     * We deviate slightly from the standard here, to maintain compatibility
170     * with the existing SI units. In CLDR, the steradian is defined as
171     * <code>RADIAN.pow(2)</code>.
172     */
173    public static final Unit<SolidAngle> STERADIAN = addUnit(Units.STERADIAN);
174
175    public static final Unit<Frequency> HERTZ = addUnit(Units.HERTZ);
176    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
177    public static final Unit<Force> NEWTON = addUnit(Units.NEWTON);
178    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
179    public static final Unit<Pressure> PASCAL = addUnit(Units.PASCAL);
180    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
181    public static final Unit<Energy> JOULE = addUnit(Units.JOULE);
182    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
183    public static final Unit<Power> WATT = addUnit(Units.WATT);
184    /**
185     * We deviate slightly from the standard here, to maintain compatability
186     * with the existing SI units. In CLDR, the ampere is defined as
187     * <code>COULOMB.divide(SECOND)</code>.
188     */
189    public static final Unit<ElectricCurrent> AMPERE = addUnit(Units.AMPERE);
190
191    /**
192     * We deviate slightly from the standard here, to maintain compatibility
193     * with the existing SI units. In CLDR, the volt is defined as
194     * <code>JOULE.divide(COULOMB)</code>.
195     */
196    public static final Unit<ElectricPotential> VOLT = addUnit(Units.VOLT);
197    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
198    public static final Unit<ElectricCapacitance> FARAD = addUnit(Units.FARAD);
199    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
200    public static final Unit<ElectricResistance> OHM = addUnit(Units.OHM);
201    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
202    public static final Unit<ElectricConductance> SIEMENS = addUnit(Units.SIEMENS);
203    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
204    public static final Unit<MagneticFlux> WEBER = addUnit(Units.WEBER);
205    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
206    public static final Unit<Temperature> CELSIUS = addUnit(Units.CELSIUS);
207    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
208    public static final Unit<MagneticFluxDensity> TESLA = addUnit(Units.TESLA);
209    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
210    public static final Unit<ElectricInductance> HENRY = addUnit(Units.HENRY);
211    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
212    public static final Unit<LuminousFlux> LUMEN = addUnit(Units.LUMEN);
213    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
214    public static final Unit<Illuminance> LUX = addUnit(Units.LUX);
215
216    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
217    public static final Unit<RadiationDoseAbsorbed> GRAY = addUnit(Units.GRAY);
218    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
219    public static final Unit<RadiationDoseEffective> SIEVERT = addUnit(Units.SIEVERT);
220
221    // ///////////////////////////////////////////////////////////////
222    // Units outside the SI that are accepted for use with the SI. //
223    // ///////////////////////////////////////////////////////////////
224
225    /**
226     * An angle unit accepted for use with SI units (standard name
227     * <code>deg/code>).
228     */
229    static final Unit<Angle> DEGREE_ANGLE = new TransformedUnit<Angle>(RADIAN,
230            new PiMultiplierConverter().concatenate(new RationalConverter(1,
231                    180)));
232
233    /**
234     * An angle unit accepted for use with SI units (standard name
235     * <code>'/code>).
236     */
237    static final Unit<Angle> MINUTE_ANGLE = new TransformedUnit<Angle>(RADIAN,
238            new PiMultiplierConverter().concatenate(new RationalConverter(1,
239                    180 * 60)));
240
241    /**
242     * An angle unit accepted for use with SI units (standard name
243     * <code>''</code>).
244     */
245    static final Unit<Angle> SECOND_ANGLE = new TransformedUnit<Angle>(RADIAN,
246            new PiMultiplierConverter().concatenate(new RationalConverter(1,
247                    180 * 60 * 60)));
248
249    /**
250     * We deviate slightly from the standard here, to maintain compatibility
251     * with the existing NonSI units. In CLDR, the degree is defined as
252     * <code>PI.multiply(RADIAN.divide(180))</code>.
253     */
254    public static final Unit<Angle> DEGREE = addUnit(DEGREE_ANGLE);
255
256    /**
257     * As per CLDR standard.
258     */
259    public static final Unit<Angle> ARC_MINUTE = addUnit(MINUTE_ANGLE);
260
261    public static final Unit<Angle> ARC_SECOND = addUnit(SECOND_ANGLE);
262
263    // ////////
264    // Area //
265    // ////////
266    /**
267     * A unit of area (standard name <code>sft</code> ).
268     */
269    public static final Unit<Area> SQUARE_FOOT = addUnit(new ProductUnit<Area>(
270            (AbstractUnit<?>) FOOT.multiply(FOOT)));
271
272    /**
273     * A unit of area equal to <code>100 m²</code> (standard name <code>a</code>
274     * ).
275     */
276    private static final Unit<Area> ARE = addUnit(SQUARE_METRE.multiply(100));
277
278    /**
279     * A unit of area equal to <code>100 {@link #ARE}</code> (standard name
280     * <code>ha</code>).
281     */
282    public static final Unit<Area> HECTARE = addUnit(ARE.multiply(100)); // Exact.
283
284    /**
285     * The acre is a unit of area used in the imperial and U.S. customary
286     * systems. It is equivalent to <code>43,560 square feet</code>. An acre is
287     * about 40% of a <code>HECTARE</code> – slightly smaller than an American
288     * football field. (standard name <code>ac</code> ).
289     * 
290     * @see <a href="http://en.wikipedia.org/wiki/Acre">Wikipedia: Acre</a>
291     */
292    public static final Unit<Area> ACRE = addUnit(SQUARE_FOOT.multiply(43560));
293
294    // //////////
295    // Volume //
296    // //////////
297    /**
298     * A unit of volume equal to one cubic decimeter (default label
299     * <code>L</code>, also recognized <code>µL, mL, cL, dL</code>).
300     */
301    public static final Unit<Volume> LITER = new TransformedUnit<Volume>(
302            CUBIC_METRE, new RationalConverter(1, 1000));
303    // private static final Unit<Volume> LITRE = addUnit(Units.LITRE);
304
305    /**
306     * A unit of volume equal to one cubic inch (<code>in³</code>).
307     */
308    public static final Unit<Volume> CUBIC_INCH = addUnit(INCH.pow(3).asType(
309            Volume.class));
310
311    /**
312     * A unit of volume equal to one US gallon, Liquid Unit. The U.S. liquid
313     * gallon is based on the Queen Anne or Wine gallon occupying 231 cubic
314     * inches (standard name <code>gal</code>).
315     */
316    public static final Unit<Volume> GALLON = addUnit(CUBIC_INCH.multiply(231));
317
318    /**
319     * The cubic foot is an imperial and US customary (non-metric) unit of
320     * volume, used in the United States, Canada, and the United Kingdom. It is
321     * defined as the volume of a cube with sides of one foot (0.3048 m) in
322     * length. Its volume is 28.3168 liters or about 1⁄35 of a cubic meter. (
323     * <code>ft³</code>).
324     */
325    public static final Unit<Volume> CUBIC_FOOT = addUnit(CUBIC_INCH.multiply(
326            1728).asType(Volume.class));
327
328    /**
329     * A unit of volume equal to <code>1 / 128 {@link #GALLON_LIQUID}</code>
330     * (standard name <code>oz_fl</code>).
331     */
332    public static final Unit<Volume> FLUID_OUNCE = addUnit(GALLON.divide(128));
333
334    /**
335     * An acre-foot is a unit of volume commonly used in the United States in
336     * reference to large-scale water resources, such as reservoirs, aqueducts,
337     * canals, sewer flow capacity, irrigation water, and river flows.
338     */
339    public static final Unit<Volume> ACRE_FOOT = addUnit(CUBIC_FOOT
340            .multiply(43560));
341
342    /**
343     * Constant for unit of volume: bushel
344     */
345    public static final Unit<Volume> BUSHEL = addUnit(CUBIC_INCH.multiply(
346            215042).divide(100));
347
348    /**
349     * The cup is a unit of measurement for volume, used in cooking to measure
350     * liquids (fluid measurement) and bulk foods such as granulated sugar (dry
351     * measurement). A cup is equal to <code>8 {@link #FLUID_OUNCE}</code>
352     * (standard name <code>cup</code>).
353     */
354    public static final Unit<Volume> CUP = addUnit(FLUID_OUNCE.multiply(8));
355
356    // //////////
357    // Time //
358    // //////////
359    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
360    public static final Unit<Time> MINUTE = addUnit(Units.MINUTE);
361    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
362    public static final Unit<Time> HOUR = addUnit(Units.HOUR);
363    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
364    public static final Unit<Time> DAY = addUnit(Units.DAY);
365
366    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
367    static final Unit<Time> YEAR_JULIAN = addUnit(Units.DAY.multiply(365.25));
368
369    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
370    public static final Unit<Time> YEAR = addUnit(Units.DAY.multiply(365.25));
371    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
372
373    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
374    public static final Unit<Time> MONTH = addUnit(YEAR_JULIAN.divide(12));
375
376    /** Constant for unit of time: century */
377    public static final Unit<Time> CENTURY = addUnit(YEAR.multiply(100));
378
379    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
380    private static final Unit<Pressure> BAR = addUnit(Units.PASCAL
381            .multiply(100000));
382    public static final Unit<Mass> GRAM = addUnit(Units.GRAM);
383
384    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
385    public static final Unit<Mass> TONNE = addUnit(Units.KILOGRAM
386            .multiply(1000));
387
388    // ///////////////////////////////
389    // NATURAL UNITS //
390    // ///////////////////////////////
391    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
392    static final Unit<Speed> C = addUnit(Units.METRES_PER_SECOND
393            .multiply(299792458));
394    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
395    // public static final Unit<Action> PLANCK = addUnit(SI.JOULE_SECOND
396    // .multiply(6.6260755E-24)); // FIXME get rid of JXQ import (where
397    // from??) */
398
399    private static final Unit<Acceleration> ACCELLERATION_OF_FREEFALL = addUnit(Units.METRES_PER_SQUARE_SECOND
400            .multiply(9.80665));
401
402    // //////////
403    // Length //
404    // //////////
405    /**
406     * A unit of length equal to the distance that light travels in one year
407     * through a vacuum (standard name <code>ly</code>).
408     */
409    public static final Unit<Length> LIGHT_YEAR = addUnit(new ProductUnit<Length>(
410            C.multiply(YEAR_JULIAN)));
411    /**
412     * A unit of length equal to the distance that light travels in one year
413     * through a vacuum (standard name <code>ly</code>).
414     */
415    // static final Unit<Length> LIGHT_YEAR = addUnit(METRE
416    // .multiply(9.460528405e15));
417
418    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
419    static final Unit<Length> INCH_INTERNATIONAL = addUnit(CENTI(METRE)
420            .multiply(254).divide(100));
421    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
422    static final Unit<Length> FOOT_INTERNATIONAL = addUnit(INCH_INTERNATIONAL
423            .multiply(12));
424    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
425    public static final Unit<Length> NAUTICAL_MILE = addUnit(METRE
426            .multiply(1852));
427    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
428    public static final Unit<Speed> KNOT = addUnit(new ProductUnit<Speed>(
429            NAUTICAL_MILE.divide(HOUR)));
430
431    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
432    private static final Unit<Mass> GRAIN = addUnit(MILLI(GRAM).multiply(
433            6479891).divide(100000));
434    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
435    static final Unit<Mass> POUND = addUnit(GRAIN.multiply(7000));
436
437    /**
438     * Carat (mass) is a unit of {@link Mass} for gems. It is equal to 0.2 gram
439     * (standard name <code>ct</code>).</br> In the United States, carat almost
440     * exclusively means the unit of mass.
441     * 
442     * @see <a href="https://en.wikipedia.org/wiki/Carat_(mass)">Wikipedia:
443     *      Carat (mass)</a>
444     */
445    public static final Unit<Mass> CARAT = addUnit(GRAM.divide(5));
446    // public static final Unit<Mass> CARAT = addUnit((KILOGRAM.divide(5000)));
447
448    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
449    private static final Unit<Dimensionless> CARAT_GOLD = addUnit(ONE
450            .divide(24));
451
452    private static final Unit<Force> POUND_FORCE = addUnit(POUND.multiply(
453            ACCELLERATION_OF_FREEFALL).asType(Force.class));
454
455    /**
456     * A unit of length equal to the distance at which a star would appear to
457     * shift its position by one arcsecond over the course the time (about 3
458     * months) in which the Earth moves a distance of {@link #ASTRONOMICAL_UNIT}
459     * in the direction perpendicular to the direction to the star (standard
460     * name <code>pc</code>).
461     * @stable ICU 54.
462     */
463    public static final Unit<Length> PARSEC = addUnit(METRE
464            .multiply(30856770e9));
465
466    /**
467     * A unit of length equal to <code>1/72 {@link #INCH}</code> (standard name
468     * <code>pixel</code>). It is the American point rounded to an even 1/72
469     * inch.
470     * 
471     * @see #POINT
472     * @deprecated Does not seem to be in CLDR
473     */
474    static final Unit<Length> PIXEL = addUnit(INCH.divide(72));
475
476    /**
477     * Equivalent {@link #PIXEL}
478     * 
479     * @deprecated Does not seem to be in CLDR
480     */
481    static final Unit<Length> COMPUTER_POINT = PIXEL;
482
483    // ///////////////////////////////////////////
484    // TYPESETTER'S LENGTH UNITS //
485    // ///////////////////////////////////////////
486    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
487    static final Unit<Length> LINE = addUnit(INCH_INTERNATIONAL.divide(12));
488    /**
489     * A unit of length equal to <code>0.013837 {@link #INCH}</code> exactly
490     * (standard name <code>pt</code>).
491     * 
492     * @see #PIXEL
493     */
494    public static final Unit<Length> POINT = addUnit(LINE.divide(6));
495    // static final Unit<Length> POINT = addUnit(INCH.multiply(13837)
496    // .divide(1000000));
497
498    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
499    public static final Unit<Length> PICA = addUnit(POINT.multiply(12));
500    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
501    public static final Unit<Length> POINT_PRINTER = addUnit(INCH_INTERNATIONAL
502            .multiply(13837).divide(1000000));
503    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
504    public static final Unit<Length> PICA_PRINTER = addUnit(POINT_PRINTER
505            .multiply(12));
506
507    // ////////////////////////////////////
508    // OTHER LEGACY UNITS: CLDR //
509    // ////////////////////////////////////
510    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
511    public static final Unit<Temperature> FAHRENHEIT = addUnit(KELVIN
512            .multiply(5).divide(9).shift(459.67));
513
514    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
515    private static final Unit<Energy> CALORIE_THERMOCHEMICAL = addUnit(JOULE
516            .multiply(4184).divide(1000));
517    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
518    public static final Unit<Energy> CALORIE = addUnit(CALORIE_THERMOCHEMICAL);
519    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
520    private static final Unit<Energy> CALORIE_FOOD = addUnit(KILO(CALORIE_THERMOCHEMICAL));
521
522    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
523    public static final Unit<Power> HORSEPOWER = addUnit(new ProductUnit<Power>(
524            FOOT_INTERNATIONAL.multiply(POUND_FORCE).divide(SECOND)));
525
526    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
527    public static final Unit<Pressure> POUND_PER_SQUARE_INCH = addUnit(new ProductUnit<Pressure>(
528            POUND_FORCE.divide(INCH_INTERNATIONAL.pow(2))));
529    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
530    public static final Unit<Angle> CIRCLE = addUnit(new ProductUnit<Angle>(
531            PI.multiply(RADIAN.multiply(2))));
532
533    /** As per <a href="http//cldr.unicode.org/">CLDR</a> standard. */
534    public static final Unit<SolidAngle> SPHERE = addUnit(new ProductUnit<SolidAngle>(
535            PI.multiply(STERADIAN.multiply(4))));
536
537    /**
538     * The unit for binary information (standard name <code>bit</code>).
539     * @stable ICU 54
540     */
541    public static final Unit<Information> BIT = addUnit(
542            new AlternateUnit<Information>(ONE, "bit"), Information.class);
543
544    /**
545     * A unit of data amount equal to <code>8 {@link SI#BIT}</code> (BinarY
546     * TErm, standard name <code>byte</code>).
547     */
548    public static final Unit<Information> BYTE = addUnit(BIT.multiply(8));
549
550    /**
551     * The unit for binary information rate (standard name <code>bit/s</code>).
552     * @draft Non-ICU
553     */
554    static final Unit<InformationRate> BIT_PER_SECOND = addUnit(
555            new ProductUnit<InformationRate>(BIT.divide(SECOND)),
556            InformationRate.class);
557
558    /**
559     * Equivalent {@link #BYTE}
560     */
561    static final Unit<Information> OCTET = BYTE;
562
563    /**
564     * A unit used to measure the frequency (rate) at which an imaging device
565     * produces unique consecutive images (standard name <code>fps</code>).
566     * 
567     * @draft Non-ICU
568     */
569    static final Unit<Frequency> FRAME_PER_SECOND = addUnit(
570            ONE.divide(SECOND)).asType(Frequency.class);
571
572    // ///////////////////
573    // Collection View //
574    // ///////////////////
575
576    @Override
577    public String getName() {
578        return "CLDR";
579    }
580
581    /**
582     * Adds a new unit not mapped to any specified quantity type.
583     *
584     * @param unit
585     *            the unit being added.
586     * @return <code>unit</code>.
587     */
588    private static <U extends Unit<?>> U addUnit(U unit) {
589        INSTANCE.units.add(unit);
590        return unit;
591    }
592
593    /**
594     * Adds a new unit and maps it to the specified quantity type.
595     *
596     * @param unit
597     *            the unit being added.
598     * @param type
599     *            the quantity type.
600     * @return <code>unit</code>.
601     */
602    private static <U extends AbstractUnit<?>> U addUnit(U unit,
603            Class<? extends Quantity<?>> type) {
604        INSTANCE.units.add(unit);
605        INSTANCE.quantityToUnit.put(type, unit);
606        return unit;
607    }
608
609    // //////////////////////////////////////////////////////////////////////////
610    // Label adjustments for CLDR system
611    static {
612        SimpleUnitFormat.getInstance().label(BYTE, "B");
613        SimpleUnitFormat.getInstance().label(CARAT_GOLD, "kt");
614        SimpleUnitFormat.getInstance().label(CARAT, "ct");
615        SimpleUnitFormat.getInstance().label(POUND, "lb");
616        SimpleUnitFormat.getInstance().label(BAR, "b");
617        SimpleUnitFormat.getInstance().label(PARSEC, "pc");
618        SimpleUnitFormat.getInstance().label(SQUARE_FOOT, "sft");
619    }
620}