001/* 002 * Units of Measurement Systems for Java 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, are permitted provided that the following conditions are met: 008 * 009 * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 010 * 011 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 012 * 013 * 3. Neither the name of JSR-363, Units of Measurement nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. 014 * 015 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 016 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 017 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 018 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 019 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 020 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 021 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 022 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 024 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 025 */ 026package systems.uom.ucum; 027 028import static tec.uom.se.unit.MetricPrefix.*; 029import static tec.uom.se.AbstractUnit.ONE; 030import si.uom.quantity.*; 031import systems.uom.quantity.*; 032import si.uom.SI; 033import tec.uom.se.*; 034import tec.uom.se.format.SimpleUnitFormat; 035import tec.uom.se.function.LogConverter; 036import tec.uom.se.function.MultiplyConverter; 037import tec.uom.se.function.PiMultiplierConverter; 038import tec.uom.se.unit.AlternateUnit; 039import tec.uom.se.unit.ProductUnit; 040import tec.uom.se.unit.TransformedUnit; 041import tec.uom.se.unit.Units; 042 043import javax.measure.Quantity; 044import javax.measure.Unit; 045import javax.measure.quantity.*; 046 047/** 048 * <p> 049 * This class contains {@link SI} and Non-SI units as defined in the 050 * <a href="http://unitsofmeasure.org/"> Unified Code for Units of Measure</a>. 051 * </p> 052 * 053 * <p> 054 * Compatibility with {@link SI} units has been given priority over strict 055 * adherence to the standard. We have attempted to note every place where the 056 * definitions in this class deviate from the UCUM standard, but such notes are 057 * likely to be incomplete. 058 * </p> 059 * 060 * @author <a href="mailto:eric-r@northwestern.edu">Eric Russell</a> 061 * @author <a href="mailto:units@catmedia.us">Werner Keil</a> 062 * @see <a href="http://www.unitsofmeasure.org">UCUM</a> 063 * @version 0.7.9, $Date: 2017-06-13 $ 064 */ 065public final class UCUM extends AbstractSystemOfUnits { 066 067 /** 068 * The singleton instance. 069 */ 070 private static final UCUM INSTANCE = new UCUM(); 071 072 /** 073 * Default constructor (prevents this class from being instantiated). 074 */ 075 private UCUM() { 076 } 077 078 /** 079 * Returns the singleton instance of this class. 080 * 081 * @return the UCUM system instance. 082 */ 083 public static UCUM getInstance() { 084 return INSTANCE; 085 } 086 087 ////////////////////////////// 088 // BASE UNITS: UCUM 4.2 §28 // 089 ////////////////////////////// 090 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 091 public static final Unit<Length> METER = addUnit(Units.METRE); 092 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 093 public static final Unit<Time> SECOND = addUnit(Units.SECOND); 094 /** 095 * We deviate slightly from the standard here, to maintain compatibility 096 * with the existing SI units. In UCUM, the gram is the base unit of mass, 097 * rather than the kilogram. This doesn't have much effect on the units 098 * themselves, but it does make formatting the units a challenge. 099 */ 100 public static final Unit<Mass> GRAM = addUnit(Units.GRAM); 101 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 102 public static final Unit<Angle> RADIAN = addUnit(Units.RADIAN); 103 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 104 public static final Unit<Temperature> KELVIN = addUnit(Units.KELVIN); 105 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 106 public static final Unit<ElectricCharge> COULOMB = addUnit(Units.COULOMB); 107 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 108 public static final Unit<LuminousIntensity> CANDELA = addUnit(Units.CANDELA); 109 110 /////////////////////////////////////////////// 111 // DIMENSIONLESS DERIVED UNITS: UCUM 4.3 §29 // 112 /////////////////////////////////////////////// 113 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 114 public static final Unit<Dimensionless> TRILLIONS = addUnit(ONE.multiply(1000000000000L)); 115 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 116 public static final Unit<Dimensionless> BILLIONS = addUnit(ONE.multiply(1000000000)); 117 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 118 public static final Unit<Dimensionless> MILLIONS = addUnit(ONE.multiply(1000000)); 119 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 120 public static final Unit<Dimensionless> THOUSANDS = addUnit(ONE.multiply(1000)); 121 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 122 public static final Unit<Dimensionless> HUNDREDS = addUnit(ONE.multiply(100)); 123 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 124 public static final Unit<Dimensionless> PI = addUnit(ONE.transform(new PiMultiplierConverter())); 125 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 126 public static final Unit<Dimensionless> PERCENT = addUnit(ONE.divide(100)); 127 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 128 public static final Unit<Dimensionless> PER_THOUSAND = addUnit(ONE.divide(1000)); 129 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 130 public static final Unit<Dimensionless> PER_MILLION = addUnit(ONE.divide(1000000)); 131 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 132 public static final Unit<Dimensionless> PER_BILLION = addUnit(ONE.divide(1000000000)); 133 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 134 public static final Unit<Dimensionless> PER_TRILLION = addUnit(ONE.divide(1000000000000L)); 135 //////////////////////////// 136 // SI UNITS: UCUM 4.3 §30 // 137 //////////////////////////// 138 /** 139 * We deviate slightly from the standard here, to maintain compatibility 140 * with the existing SI units. In UCUM, the mole is no longer a base unit, 141 * but is defined as <code>Unit.ONE.multiply(6.0221367E23)</code>. 142 */ 143 public static final Unit<AmountOfSubstance> MOLE = addUnit(Units.MOLE); 144 /** 145 * We deviate slightly from the standard here, to maintain compatibility 146 * with the existing SI units. In UCUM, the steradian is defined as 147 * <code>RADIAN.pow(2)</code>. 148 */ 149 public static final Unit<SolidAngle> STERADIAN = addUnit(Units.STERADIAN); 150 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 151 public static final Unit<Frequency> HERTZ = addUnit(Units.HERTZ); 152 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 153 public static final Unit<Force> NEWTON = addUnit(Units.NEWTON); 154 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 155 public static final Unit<Pressure> PASCAL = addUnit(Units.PASCAL); 156 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 157 public static final Unit<Energy> JOULE = addUnit(Units.JOULE); 158 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 159 public static final Unit<Power> WATT = addUnit(Units.WATT); 160 /** 161 * We deviate slightly from the standard here, to maintain compatibility 162 * with the existing SI units. In UCUM, the ampere is defined as 163 * <code>COULOMB.divide(SECOND)</code>. 164 */ 165 public static final Unit<ElectricCurrent> AMPERE = addUnit(Units.AMPERE); 166 // public static final Unit<MagnetomotiveForce> AMPERE_TURN = 167 // addUnit(Units.AMPERE_TURN); 168 /** 169 * We deviate slightly from the standard here, to maintain compatibility 170 * with the existing SI units. In UCUM, the volt is defined as 171 * <code>JOULE.divide(COULOMB)</code>. 172 */ 173 public static final Unit<ElectricPotential> VOLT = addUnit(Units.VOLT); 174 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 175 public static final Unit<ElectricCapacitance> FARAD = addUnit(Units.FARAD); 176 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 177 public static final Unit<ElectricResistance> OHM = addUnit(Units.OHM); 178 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 179 public static final Unit<ElectricConductance> SIEMENS = addUnit(Units.SIEMENS); 180 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 181 public static final Unit<MagneticFlux> WEBER = addUnit(Units.WEBER); 182 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 183 public static final Unit<Temperature> CELSIUS = addUnit(Units.CELSIUS); 184 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 185 public static final Unit<MagneticFluxDensity> TESLA = addUnit(Units.TESLA); 186 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 187 public static final Unit<ElectricInductance> HENRY = addUnit(Units.HENRY); 188 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 189 public static final Unit<LuminousFlux> LUMEN = addUnit(Units.LUMEN); 190 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 191 public static final Unit<Illuminance> LUX = addUnit(Units.LUX); 192 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 193 public static final Unit<Radioactivity> BECQUEREL = addUnit(Units.BECQUEREL); 194 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 195 public static final Unit<RadiationDoseAbsorbed> GRAY = addUnit(Units.GRAY); 196 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 197 public static final Unit<RadiationDoseEffective> SIEVERT = addUnit(Units.SIEVERT); 198 199 /////////////////////////////////////////////////////////////////////// 200 // OTHER UNITS FROM ISO 1000, ISO 2955, AND ANSI X3.50: UCUM 4.3 §31 // 201 /////////////////////////////////////////////////////////////////////// 202 // The order of GON and DEGREE has been inverted because GON is defined in 203 // terms of DEGREE 204 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 205 public static final Unit<Angle> DEGREE = addUnit(new ProductUnit<Angle>(PI.multiply(RADIAN.divide(180)))); 206 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 207 public static final Unit<Angle> GRADE = addUnit(DEGREE.multiply(0.9)); 208 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 209 public static final Unit<Angle> GON = GRADE; 210 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 211 public static final Unit<Angle> MINUTE_ANGLE = addUnit(DEGREE.divide(60)); 212 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 213 public static final Unit<Angle> SECOND_ANGLE = addUnit(MINUTE_ANGLE.divide(60)); 214 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 215 public static final Unit<Volume> LITER = addUnit(Units.LITRE); 216 /** 217 * As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. Liter has 218 * <b>two</b> definitions. 219 * 220 * @see <a href="http://unitsofmeasure.org/ucum.html#iso1000">UCUM Table 221 * 5</a> 222 */ 223 public static final Unit<Volume> LITER_DM3 = addUnit(DECI(Units.CUBIC_METRE)); 224 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 225 public static final Unit<Area> ARE = addUnit(Units.SQUARE_METRE.multiply(100)); 226 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 227 public static final Unit<Time> MINUTE = addUnit(Units.MINUTE); 228 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 229 public static final Unit<Time> HOUR = addUnit(Units.HOUR); 230 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 231 public static final Unit<Time> DAY = addUnit(Units.DAY); 232 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 233 public static final Unit<Time> YEAR_TROPICAL = addUnit(Units.DAY.multiply(365.24219)); 234 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 235 public static final Unit<Time> YEAR_JULIAN = addUnit(Units.DAY.multiply(365.25)); 236 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 237 public static final Unit<Time> YEAR_GREGORIAN = addUnit(Units.DAY.multiply(365.2425)); 238 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 239 public static final Unit<Time> YEAR = addUnit(Units.DAY.multiply(365.25)); 240 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 241 public static final Unit<Time> WEEK = addUnit(Units.DAY.multiply(7)); 242 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 243 public static final Unit<Time> MONTH_SYNODAL = addUnit(Units.DAY.multiply(29.53059)); 244 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 245 public static final Unit<Time> MONTH_JULIAN = addUnit(YEAR_JULIAN.divide(12)); 246 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 247 public static final Unit<Time> MONTH_GREGORIAN = addUnit(YEAR_GREGORIAN.divide(12)); 248 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 249 public static final Unit<Time> MONTH = addUnit(YEAR_JULIAN.divide(12)); 250 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 251 public static final Unit<Mass> TONNE = addUnit(Units.KILOGRAM.multiply(1000)); 252 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 253 public static final Unit<Pressure> BAR = addUnit(Units.PASCAL.multiply(100000)); 254 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 255 public static final Unit<Mass> ATOMIC_MASS_UNIT = addUnit(SI.UNIFIED_ATOMIC_MASS); 256 // public static final Unit<Mass> ATOMIC_MASS_UNIT = addUnit( 257 // new AlternateUnit<Mass>(Units.UNIFIED_ATOMIC_MASS, 258 // Units.UNIFIED_ATOMIC_MASS.getSymbol()), Mass.class); 259 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 260 public static final Unit<Energy> ELECTRON_VOLT = addUnit(SI.ELECTRON_VOLT); 261 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 262 public static final Unit<Length> ASTRONOMIC_UNIT = addUnit(SI.ASTRONOMICAL_UNIT); 263 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 264 public static final Unit<Length> PARSEC = addUnit(Units.METRE.multiply(3.085678E16)); 265 266 ///////////////////////////////// 267 // NATURAL UNITS: UCUM 4.3 §32 // 268 ///////////////////////////////// 269 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 270 public static final Unit<Speed> VELOCITY_OF_LIGHT = addUnit(Units.METRE_PER_SECOND.multiply(299792458)); 271 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 272 public static final Unit<Action> PLANCK = addUnit(SI.JOULE_SECOND.multiply(6.6260755E-34)); 273 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 274 public static final Unit<?> BOLTZMAN = addUnit(JOULE.divide(KELVIN).multiply(1.380658E-23)); 275 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 276 public static final Unit<ElectricPermittivity> PERMITTIVITY_OF_VACUUM = addUnit( 277 SI.FARAD_PER_METRE.multiply(8.854187817E-12)); 278 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 279 public static final Unit<MagneticPermeability> PERMEABILITY_OF_VACUUM = addUnit( 280 new ProductUnit<MagneticPermeability>(SI.NEWTON_PER_SQUARE_AMPERE.multiply(PI.multiply(4).divide(1E7))), 281 MagneticPermeability.class); 282 // public static final Unit<MagneticPermeability> PERMEABILITY_OF_VACUUM = 283 // addUnit( 284 // new ProductUnit<MagneticPermeability>(Units.NEWTONS_PER_SQUARE_AMPERE 285 // .multiply(PI).multiply(4).divide(1E7)), 286 // MagneticPermeability.class); 287 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 288 public static final Unit<ElectricCharge> ELEMENTARY_CHARGE = addUnit( 289 Units.COULOMB.transform(((AbstractUnit<Energy>) SI.ELECTRON_VOLT).getSystemConverter())); 290 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 291 public static final Unit<Mass> ELECTRON_MASS = addUnit(GRAM.multiply(9.1093897E-28)); 292 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 293 public static final Unit<Mass> PROTON_MASS = addUnit(GRAM.multiply(1.6726231E-24)); 294 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 295 public static final Unit<?> NEWTON_CONSTANT_OF_GRAVITY = addUnit( 296 METER.pow(3).multiply(Units.KILOGRAM.pow(-1)).multiply(SECOND.pow(-2)).multiply(6.67259E-11)); 297 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 298 public static final Unit<Acceleration> ACCELERATION_OF_FREEFALL = addUnit( 299 Units.METRE_PER_SQUARE_SECOND.multiply(9.80665)); 300 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 301 public static final Unit<Pressure> ATMOSPHERE = addUnit(Units.PASCAL.multiply(101325)); 302 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 303 public static final Unit<Length> LIGHT_YEAR = addUnit( 304 new ProductUnit<Length>(VELOCITY_OF_LIGHT.multiply(YEAR_JULIAN))); 305 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 306 public static final Unit<Force> GRAM_FORCE = addUnit( 307 new ProductUnit<Force>(GRAM.multiply(ACCELERATION_OF_FREEFALL))); 308 // POUND_FORCE contains a forward reference to avoirdupois pound weight, so 309 // it has been moved after section §39 below 310 311 ///////////////////////////// 312 // CGS UNITS: UCUM 4.3 §33 // 313 ///////////////////////////// 314 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 315 public static final Unit<WaveNumber> KAYSER = addUnit(SI.RECIPROCAL_METRE.divide(100)); 316 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 317 public static final Unit<Acceleration> GAL = addUnit( 318 new ProductUnit<Acceleration>(CENTI(METER).divide(SECOND.pow(2)))); 319 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 320 public static final Unit<Force> DYNE = addUnit( 321 new ProductUnit<Force>(Units.GRAM.multiply(CENTI(Units.METRE).divide(Units.SECOND.pow(2))))); 322 // public static final Unit<Force> DYNE = addUnit(new ProductUnit<Force>( 323 // Units.GRAM.multiply(new 324 // ProductUnit(CENTI(Units.METRE)).divide(Units.SECOND 325 // .pow(2))))); 326 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 327 public static final Unit<Energy> ERG = addUnit(new ProductUnit<Energy>(DYNE.multiply(CENTI(Units.METRE)))); 328 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 329 public static final Unit<DynamicViscosity> POISE = addUnit( 330 new ProductUnit<DynamicViscosity>(DYNE.multiply(SECOND).divide(CENTI(Units.METRE).pow(2)))); 331 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 332 public static final Unit<ElectricCurrent> BIOT = addUnit(AMPERE.multiply(10)); 333 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 334 public static final Unit<KinematicViscosity> STOKES = addUnit( 335 new ProductUnit<KinematicViscosity>(CENTI(Units.METRE).pow(2).divide(Units.SECOND))); 336 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 337 public static final Unit<MagneticFlux> MAXWELL = addUnit(Units.WEBER.divide(1E8)); 338 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 339 public static final Unit<MagneticFluxDensity> GAUSS = addUnit(Units.TESLA.divide(1E4)); 340 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 341 public static final Unit<MagneticFieldStrength> OERSTED = addUnit( 342 new ProductUnit<MagneticFieldStrength>(SI.AMPERE_PER_METRE.multiply(250).divide(PI))); 343 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 344 public static final Unit<MagnetomotiveForce> GILBERT = addUnit( 345 new ProductUnit<MagnetomotiveForce>(OERSTED.multiply(CENTI(Units.METRE)))); 346 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 347 public static final Unit<Luminance> STILB = addUnit( 348 new ProductUnit<Luminance>(CANDELA.divide(CENTI(METER).pow(2)))); 349 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 350 public static final Unit<Luminance> LAMBERT = addUnit(new ProductUnit<Luminance>(STILB.divide(PI))); 351 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 352 public static final Unit<Illuminance> PHOT = addUnit(LUX.divide(1E4)); 353 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 354 public static final Unit<Radioactivity> CURIE = addUnit(Units.BECQUEREL.multiply(3.7E10)); 355 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 356 public static final Unit<IonizingRadiation> ROENTGEN = addUnit(SI.COULOMB_PER_KILOGRAM.multiply(2.58E-4)); 357 // add later when JMQ issue fixed 358 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 359 public static final Unit<RadiationDoseAbsorbed> RAD = addUnit( 360 new ProductUnit<RadiationDoseAbsorbed>(ERG.divide(Units.GRAM.multiply(100)))); 361 // public static final Unit<RadiationDoseAbsorbed> RAD = addUnit(new 362 // ProductUnit<RadiationDoseAbsorbed>( 363 // ERG.divide(Units.GRAM).multiply(100))); 364 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 365 public static final Unit<RadiationDoseEffective> REM = addUnit( 366 new ProductUnit<RadiationDoseEffective>(ERG.divide(Units.GRAM.multiply(100)))); 367 // public static final Unit<RadiationDoseEffective> REM = addUnit(new 368 // AlternateUnit<RadiationDoseEffective>( 369 // RAD, RAD.getSymbol())); // TODO are symbols for RAD and REM same? 370 ///////////////////////////////////////////////// 371 // INTERNATIONAL CUSTOMARY UNITS: UCUM 4.4 §34 // 372 ///////////////////////////////////////////////// 373 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 374 public static final Unit<Length> INCH_INTERNATIONAL = addUnit(CENTI(METER).multiply(254).divide(100)); 375 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 376 public static final Unit<Length> FOOT_INTERNATIONAL = addUnit(INCH_INTERNATIONAL.multiply(12)); 377 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 378 public static final Unit<Length> YARD_INTERNATIONAL = addUnit(FOOT_INTERNATIONAL.multiply(3)); 379 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 380 public static final Unit<Length> MILE_INTERNATIONAL = addUnit(FOOT_INTERNATIONAL.multiply(5280)); 381 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 382 public static final Unit<Length> FATHOM_INTERNATIONAL = addUnit(FOOT_INTERNATIONAL.multiply(6)); 383 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 384 public static final Unit<Length> NAUTICAL_MILE_INTERNATIONAL = addUnit(METER.multiply(1852)); 385 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 386 public static final Unit<Speed> KNOT_INTERNATIONAL = addUnit( 387 new ProductUnit<Speed>(NAUTICAL_MILE_INTERNATIONAL.divide(HOUR))); 388 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 389 public static final Unit<Area> SQUARE_INCH_INTERNATIONAL = addUnit( 390 new ProductUnit<Area>(INCH_INTERNATIONAL.pow(2))); 391 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 392 public static final Unit<Area> SQUARE_FOOT_INTERNATIONAL = addUnit( 393 new ProductUnit<Area>(FOOT_INTERNATIONAL.pow(2))); 394 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 395 public static final Unit<Area> SQUARE_YARD_INTERNATIONAL = addUnit( 396 new ProductUnit<Area>(YARD_INTERNATIONAL.pow(2))); 397 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 398 public static final Unit<Volume> CUBIC_INCH_INTERNATIONAL = addUnit( 399 new ProductUnit<Volume>(INCH_INTERNATIONAL.pow(3))); 400 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 401 public static final Unit<Volume> CUBIC_FOOT_INTERNATIONAL = addUnit( 402 new ProductUnit<Volume>(FOOT_INTERNATIONAL.pow(3))); 403 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 404 public static final Unit<Volume> CUBIC_YARD_INTERNATIONAL = addUnit( 405 new ProductUnit<Volume>(YARD_INTERNATIONAL.pow(3))); 406 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 407 public static final Unit<Volume> BOARD_FOOT_INTERNATIONAL = addUnit(CUBIC_INCH_INTERNATIONAL.multiply(144)); 408 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 409 public static final Unit<Volume> CORD_INTERNATIONAL = addUnit(CUBIC_FOOT_INTERNATIONAL.multiply(128)); 410 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 411 public static final Unit<Length> MIL_INTERNATIONAL = addUnit(INCH_INTERNATIONAL.divide(1000)); 412 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 413 public static final Unit<Area> CIRCULAR_MIL_INTERNATIONAL = addUnit( 414 new ProductUnit<Area>(MIL_INTERNATIONAL.pow(2).multiply(PI.divide(4)))); 415 // public static final Unit<Area> CIRCULAR_MIL_INTERNATIONAL = addUnit(new 416 // ProductUnit<Area>( 417 // MIL_INTERNATIONAL.pow(2).multiply(PI).divide(4))); 418 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 419 public static final Unit<Length> HAND_INTERNATIONAL = addUnit(INCH_INTERNATIONAL.multiply(4)); 420 ////////////////////////////////////////// 421 // US SURVEY LENGTH UNITS: UCUM 4.4 §35 // 422 ////////////////////////////////////////// 423 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 424 public static final Unit<Length> FOOT_US_SURVEY = addUnit(METER.multiply(1200).divide(3937)); 425 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 426 public static final Unit<Length> YARD_US_SURVEY = addUnit(FOOT_US_SURVEY.multiply(3)); 427 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 428 public static final Unit<Length> INCH_US_SURVEY = addUnit(FOOT_US_SURVEY.divide(12)); 429 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 430 public static final Unit<Length> ROD_US_SURVEY = addUnit(FOOT_US_SURVEY.multiply(33).divide(2)); 431 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 432 public static final Unit<Length> CHAIN_US_SURVEY = addUnit(ROD_US_SURVEY.multiply(4)); 433 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 434 public static final Unit<Length> LINK_US_SURVEY = addUnit(CHAIN_US_SURVEY.divide(100)); 435 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 436 public static final Unit<Length> RAMDEN_CHAIN_US_SURVEY = addUnit(FOOT_US_SURVEY.multiply(100)); 437 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 438 public static final Unit<Length> RAMDEN_LINK_US_SURVEY = addUnit(CHAIN_US_SURVEY.divide(100)); 439 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 440 public static final Unit<Length> FATHOM_US_SURVEY = addUnit(FOOT_US_SURVEY.multiply(6)); 441 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 442 public static final Unit<Length> FURLONG_US_SURVEY = addUnit(ROD_US_SURVEY.multiply(40)); 443 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 444 public static final Unit<Length> MILE_US_SURVEY = addUnit(FURLONG_US_SURVEY.multiply(8)); 445 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 446 public static final Unit<Area> ACRE_US_SURVEY = addUnit(new ProductUnit<Area>(ROD_US_SURVEY.pow(2)).multiply(160)); 447 // public static final Unit<Area> ACRE_US_SURVEY = addUnit(new 448 // ProductUnit<Area>( 449 // ROD_US_SURVEY.pow(2).multiply(160))); 450 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 451 public static final Unit<Area> SQUARE_ROD_US_SURVEY = addUnit(new ProductUnit<Area>(ROD_US_SURVEY.pow(2))); 452 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 453 public static final Unit<Area> SQUARE_MILE_US_SURVEY = addUnit(new ProductUnit<Area>(MILE_US_SURVEY.pow(2))); 454 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 455 public static final Unit<Area> SECTION_US_SURVEY = addUnit(new ProductUnit<Area>(MILE_US_SURVEY.pow(2))); 456 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 457 public static final Unit<Area> TOWNSHP_US_SURVEY = addUnit(SECTION_US_SURVEY.multiply(36)); 458 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 459 public static final Unit<Length> MIL_US_SURVEY = addUnit(INCH_US_SURVEY.divide(1000)); 460 ///////////////////////////////////////////////// 461 // BRITISH IMPERIAL LENGTH UNITS: UCUM 4.4 §36 // 462 ///////////////////////////////////////////////// 463 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 464 public static final Unit<Length> INCH_BRITISH = addUnit(CENTI(METER).multiply(2539998).divide(1000000)); 465 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 466 public static final Unit<Length> FOOT_BRITISH = addUnit(INCH_BRITISH.multiply(12)); 467 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 468 public static final Unit<Length> ROD_BRITISH = addUnit(FOOT_BRITISH.multiply(33).divide(2)); 469 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 470 public static final Unit<Length> CHAIN_BRITISH = addUnit(ROD_BRITISH.multiply(4)); 471 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 472 public static final Unit<Length> LINK_BRITISH = addUnit(CHAIN_BRITISH.divide(100)); 473 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 474 public static final Unit<Length> FATHOM_BRITISH = addUnit(FOOT_BRITISH.multiply(6)); 475 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 476 public static final Unit<Length> PACE_BRITISH = addUnit(FOOT_BRITISH.multiply(5).divide(2)); 477 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 478 public static final Unit<Length> YARD_BRITISH = addUnit(FOOT_BRITISH.multiply(3)); 479 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 480 public static final Unit<Length> MILE_BRITISH = addUnit(FOOT_BRITISH.multiply(5280)); 481 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 482 public static final Unit<Length> NAUTICAL_MILE_BRITISH = addUnit(FOOT_BRITISH.multiply(6080)); 483 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 484 public static final Unit<Speed> KNOT_BRITISH = addUnit(new ProductUnit<Speed>(NAUTICAL_MILE_BRITISH.divide(HOUR))); 485 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 486 public static final Unit<Area> ACRE_BRITISH = addUnit(new ProductUnit<Area>(YARD_BRITISH.pow(2)).multiply(4840)); 487 // public static final Unit<Area> ACRE_BRITISH = addUnit(new 488 // ProductUnit<Area>( 489 // YARD_BRITISH.pow(2).multiply(4840))); 490 /////////////////////////////////// 491 // US VOLUME UNITS: UCUM 4.4 §37 // 492 /////////////////////////////////// 493 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 494 public static final Unit<Volume> GALLON_US = addUnit(CUBIC_INCH_INTERNATIONAL.multiply(231)); 495 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 496 public static final Unit<Volume> BARREL_US = addUnit(GALLON_US.multiply(42)); 497 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 498 public static final Unit<Volume> QUART_US = addUnit(GALLON_US.divide(4)); 499 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 500 public static final Unit<Volume> PINT_US = addUnit(QUART_US.divide(2)); 501 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 502 public static final Unit<Volume> GILL_US = addUnit(PINT_US.divide(4)); 503 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 504 public static final Unit<Volume> FLUID_OUNCE_US = addUnit(GILL_US.divide(4)); 505 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 506 public static final Unit<Volume> FLUID_DRAM_US = addUnit(FLUID_OUNCE_US.divide(8)); 507 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 508 public static final Unit<Volume> MINIM_US = addUnit(FLUID_DRAM_US.divide(60)); 509 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 510 public static final Unit<Volume> CORD_US = addUnit(CUBIC_FOOT_INTERNATIONAL.multiply(128)); 511 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 512 public static final Unit<Volume> BUSHEL_US = addUnit(CUBIC_INCH_INTERNATIONAL.multiply(215042).divide(100)); 513 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 514 public static final Unit<Volume> GALLON_WINCHESTER = addUnit(BUSHEL_US.divide(8)); 515 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 516 public static final Unit<Volume> PECK_US = addUnit(BUSHEL_US.divide(4)); 517 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 518 public static final Unit<Volume> DRY_QUART_US = addUnit(PECK_US.divide(8)); 519 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 520 public static final Unit<Volume> DRY_PINT_US = addUnit(DRY_QUART_US.divide(2)); 521 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 522 public static final Unit<Volume> TABLESPOON_US = addUnit(FLUID_OUNCE_US.divide(2)); 523 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 524 public static final Unit<Volume> TEASPOON_US = addUnit(TABLESPOON_US.divide(3)); 525 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 526 public static final Unit<Volume> CUP_US = addUnit(TABLESPOON_US.multiply(16)); 527 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 528 public static final Unit<Volume> METRIC_FLUID_OUNCE_US = addUnit(MILLI(LITER).multiply(30)); 529 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 530 public static final Unit<Volume> METRIC_CUP_US = addUnit(MILLI(LITER).multiply(240)); 531 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 532 public static final Unit<Volume> METRIC_TEASPOON_CUP_US = addUnit(MILLI(LITER).multiply(5)); 533 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 534 public static final Unit<Volume> METRIC_TABLESPOON_CUP_US = addUnit(MILLI(LITER).multiply(15)); 535 ///////////////////////////////////////////////// 536 // BRITISH IMPERIAL VOLUME UNITS: UCUM 4.4 §38 // 537 ///////////////////////////////////////////////// 538 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 539 public static final Unit<Volume> GALLON_BRITISH = addUnit(LITER.multiply(454609).divide(100000)); 540 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 541 public static final Unit<Volume> PECK_BRITISH = addUnit(GALLON_BRITISH.multiply(2)); 542 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 543 public static final Unit<Volume> BUSHEL_BRITISH = addUnit(PECK_BRITISH.multiply(4)); 544 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 545 public static final Unit<Volume> QUART_BRITISH = addUnit(GALLON_BRITISH.divide(4)); 546 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 547 public static final Unit<Volume> PINT_BRITISH = addUnit(QUART_BRITISH.divide(2)); 548 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 549 public static final Unit<Volume> GILL_BRITISH = addUnit(PINT_BRITISH.divide(4)); 550 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 551 public static final Unit<Volume> FLUID_OUNCE_BRITISH = addUnit(GILL_BRITISH.divide(5)); 552 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 553 public static final Unit<Volume> FLUID_DRAM_BRITISH = addUnit(FLUID_OUNCE_BRITISH.divide(8)); 554 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 555 public static final Unit<Volume> MINIM_BRITISH = addUnit(FLUID_DRAM_BRITISH.divide(60)); 556 //////////////////////////////////////////// 557 // AVOIRDUPOIS WIEGHT UNITS: UCUM 4.4 §39 // 558 //////////////////////////////////////////// 559 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 560 public static final Unit<Mass> GRAIN = addUnit(MILLI(GRAM).multiply(6479891).divide(100000)); 561 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 562 public static final Unit<Mass> POUND = addUnit(GRAIN.multiply(7000)); 563 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 564 public static final Unit<Mass> OUNCE = addUnit(POUND.divide(16)); 565 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 566 public static final Unit<Mass> DRAM = addUnit(OUNCE.divide(16)); 567 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 568 public static final Unit<Mass> SHORT_HUNDREDWEIGHT = addUnit(POUND.multiply(100)); 569 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 570 public static final Unit<Mass> LONG_HUNDREDWEIGHT = addUnit(POUND.multiply(112)); 571 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 572 public static final Unit<Mass> SHORT_TON = addUnit(SHORT_HUNDREDWEIGHT.multiply(20)); 573 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 574 public static final Unit<Mass> LONG_TON = addUnit(LONG_HUNDREDWEIGHT.multiply(20)); 575 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 576 public static final Unit<Mass> STONE = addUnit(POUND.multiply(14)); 577 // CONTINUED FROM SECTION §32 578 // contains a forward reference to POUND, so we had to move it here, below 579 // section §39 580 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 581 // public static final Unit<Force> POUND_FORCE = addUnit(new 582 // ProductUnit<Force>( 583 // POUND.multiply(ACCELLERATION_OF_FREEFALL))); 584 public static final Unit<Force> POUND_FORCE = addUnit( 585 POUND.multiply(ACCELERATION_OF_FREEFALL).asType(Force.class)); 586 587 // public static final Unit<InformationRate> POUND_FORCE2 = 588 // addUnit(POUND.multiply(ACCELLERATION_OF_FREEFALL).asType(InformationRate.class)); 589 590 ///////////////////////////////////// 591 // TROY WEIGHT UNITS: UCUM 4.4 §40 // 592 ///////////////////////////////////// 593 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 594 public static final Unit<Mass> PENNYWEIGHT_TROY = addUnit(GRAIN.multiply(24)); 595 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 596 public static final Unit<Mass> OUNCE_TROY = addUnit(PENNYWEIGHT_TROY.multiply(20)); 597 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 598 public static final Unit<Mass> POUND_TROY = addUnit(OUNCE_TROY.multiply(12)); 599 ///////////////////////////////////////////// 600 // APOTECARIES' WEIGHT UNITS: UCUM 4.4 §41 // 601 ///////////////////////////////////////////// 602 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 603 public static final Unit<Mass> SCRUPLE_APOTHECARY = addUnit(GRAIN.multiply(20)); 604 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 605 public static final Unit<Mass> DRAM_APOTHECARY = addUnit(SCRUPLE_APOTHECARY.multiply(3)); 606 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 607 public static final Unit<Mass> OUNCE_APOTHECARY = addUnit(DRAM_APOTHECARY.multiply(8)); 608 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 609 public static final Unit<Mass> POUND_APOTHECARY = addUnit(OUNCE_APOTHECARY.multiply(12)); 610 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 611 public static final Unit<Mass> METRIC_OUNCE = addUnit(GRAM.multiply(28)); 612 613 ///////////////////////////////////////////// 614 // TYPESETTER'S LENGTH UNITS: UCUM 4.4 §42 // 615 ///////////////////////////////////////////// 616 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 617 public static final Unit<Length> LINE = addUnit(INCH_INTERNATIONAL.divide(12)); 618 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 619 public static final Unit<Length> POINT = addUnit(LINE.divide(6)); 620 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 621 public static final Unit<Length> PICA = addUnit(POINT.multiply(12)); 622 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 623 public static final Unit<Length> POINT_PRINTER = addUnit(INCH_INTERNATIONAL.multiply(13837).divide(1000000)); 624 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 625 public static final Unit<Length> PICA_PRINTER = addUnit(POINT_PRINTER.multiply(12)); 626 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 627 public static final Unit<Length> PIED = addUnit(CENTI(METER).multiply(3248).divide(100)); 628 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 629 public static final Unit<Length> POUCE = addUnit(PIED.divide(12)); 630 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 631 public static final Unit<Length> LIGNE = addUnit(POUCE.divide(12)); 632 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 633 public static final Unit<Length> DIDOT = addUnit(LIGNE.divide(6)); 634 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 635 public static final Unit<Length> CICERO = addUnit(DIDOT.multiply(12)); 636 ////////////////////////////////////// 637 // OTHER LEGACY UNITS: UCUM 4.5 §43 // 638 ////////////////////////////////////// 639 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 640 public static final Unit<Temperature> RANKINE = addUnit(KELVIN.divide(9).multiply(5)); 641 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 642 public static final Unit<Temperature> FAHRENHEIT = addUnit(RANKINE.shift(459.67)); 643 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 644 public static final Unit<Temperature> REAUMUR = addUnit((KELVIN.multiply(4).divide(5)).shift(218.52)); 645 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 646 public static final Unit<Energy> CALORIE_AT_15C = addUnit(JOULE.multiply(41858).divide(10000)); 647 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 648 public static final Unit<Energy> CALORIE_AT_20C = addUnit(JOULE.multiply(41819).divide(10000)); 649 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 650 public static final Unit<Energy> CALORIE_MEAN = addUnit(JOULE.multiply(419002).divide(100000)); 651 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 652 public static final Unit<Energy> CALORIE_INTERNATIONAL_TABLE = addUnit(JOULE.multiply(41868).divide(10000)); 653 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 654 public static final Unit<Energy> CALORIE_THERMOCHEMICAL = addUnit(JOULE.multiply(4184).divide(1000)); 655 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 656 public static final Unit<Energy> CALORIE = addUnit(CALORIE_THERMOCHEMICAL); 657 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 658 public static final Unit<Energy> CALORIE_FOOD = addUnit(KILO(CALORIE_THERMOCHEMICAL)); 659 660 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 661 public static final Unit<Energy> BTU_AT_39F = addUnit(KILO(JOULE).multiply(105967).divide(100000)); 662 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 663 public static final Unit<Energy> BTU_AT_59F = addUnit(KILO(JOULE).multiply(105480).divide(100000)); 664 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 665 public static final Unit<Energy> BTU_AT_60F = addUnit(KILO(JOULE).multiply(105468).divide(100000)); 666 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 667 public static final Unit<Energy> BTU_MEAN = addUnit(KILO(JOULE).multiply(105587).divide(100000)); 668 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 669 public static final Unit<Energy> BTU_INTERNATIONAL_TABLE = addUnit( 670 KILO(JOULE).multiply(105505585262L).divide(100000000000L)); 671 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 672 public static final Unit<Energy> BTU_THERMOCHEMICAL = addUnit(KILO(JOULE).multiply(105435).divide(100000)); 673 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 674 public static final Unit<Energy> BTU = addUnit(BTU_THERMOCHEMICAL); 675 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 676 public static final Unit<Power> HORSEPOWER = addUnit( 677 new ProductUnit<Power>(FOOT_INTERNATIONAL.multiply(POUND_FORCE).divide(SECOND))); 678 679 //////////////////////////////////////////// 680 // CLINICAL MEDICINE UNITS: UCUM 4.5 §44 // 681 /////////////////////////////////////////// 682 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 683 public static final Unit<Pressure> METER_OF_WATER_COLUMN = addUnit(KILO(PASCAL).multiply(980665).divide(100000)); 684 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 685 public static final Unit<Pressure> METER_OF_MERCURY_COLUMN = addUnit(KILO(PASCAL).multiply(1333220).divide(10000)); 686 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 687 public static final Unit<Pressure> INCH_OF_WATER_COLUMN = addUnit( 688 new ProductUnit<Pressure>(METER_OF_WATER_COLUMN.multiply(INCH_INTERNATIONAL).divide(METER))); 689 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 690 public static final Unit<Pressure> INCH_OF_MERCURY_COLUMN = addUnit( 691 new ProductUnit<Pressure>(METER_OF_MERCURY_COLUMN.multiply(INCH_INTERNATIONAL).divide(METER))); 692 693 public static final Unit<Drag> PERIPHERAL_VASCULAR_RESISTANCE = addUnit( 694 MILLI(METER_OF_MERCURY_COLUMN).multiply(SECOND).divide(MILLI(LITER)).asType(Drag.class)); 695 public static final Unit<Drag> WOOD = addUnit(MILLI(METER_OF_MERCURY_COLUMN).multiply(MINUTE).divide(LITER).asType(Drag.class)); 696 // public static final Unit DIOPTER = addUnit(ONE.divide(METER)); 697 // public static final Unit PRISM_DIOPTER = 698 // addUnit(ONE.multiply(100).multiply(Math.tan(1))); 699 // public static final Unit PERCENT_OF_SLOPE = 700 // addUnit(ONE.multiply(100).multiply(Math.tan(1))); 701 // public static final Unit MESH = addUnit(ONE.divide(INCH_INTERNATIONAL)); 702 // public static final Unit CHARRIERE = addUnit(MILLI(METER).divide(3)); 703 704 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 705 public static final Unit<Volume> DROP = addUnit(MILLI(LITER).divide(20)); 706 707 // public static final Unit HOUNSFIELD = addUnit(ONE); 708 // public static final Unit METABOLIC_EQUIVALENT = 709 // addUnit(MILLI(LITER).divide(MINUTE).divide(KILO(GRAM))); 710 711 // public static final Unit HOMEOPATHIC_POTENCY_OF_DECIMAL = 712 // addUnit(ONE.multiply(-1).multiply(Math.log10(1))); 713 // public static final Unit HOMEOPATHIC_POTENCY_OF_CENTESIMAL = 714 // addUnit(ONE.multiply(-1).multiply(Math.log(1)).divide(Math.log(100))); 715 // public static final Unit HOMEOPATHIC_POTENCY_OF_MILLESIMAL = 716 // addUnit(ONE.multiply(-1).multiply(Math.log(1)).divide(Math.log(1000))); 717 // public static final Unit HOMEOPATHIC_POTENCY_OF_QUINTALLESIMAL = 718 // addUnit(ONE.multiply(-1).multiply(Math.log(1)).divide(Math.log(50000))); 719 720 // public static final Unit HOMEOPATHIC_POTENCY_OF_DECIMAL_HAHNEMANNIAN = 721 // UNDEFINED; 722 // public static final Unit HOMEOPATHIC_POTENCY_OF_CENTESIMAL_HAHNEMANNIAN = 723 // UNDEFINED; 724 // public static final Unit HOMEOPATHIC_POTENCY_OF_MILLESIMAL_HAHNEMANNIAN = 725 // UNDEFINED; 726 // public static final Unit 727 // HOMEOPATHIC_POTENCY_OF_QUINTAMILLESIMAL_HAHNEMANNIAN = UNDEFINED; 728 // public static final Unit HOMEOPATHIC_POTENCY_OF_DECIMAL_KORSAKOVIAN = 729 // UNDEFINED; 730 // public static final Unit HOMEOPATHIC_POTENCY_OF_CENTESIMAL_KORSAKOVIAN = 731 // UNDEFINED; 732 // public static final Unit HOMEOPATHIC_POTENCY_OF_MILLESIMAL_KORSAKOVIAN = 733 // UNDEFINED; 734 // public static final Unit 735 // HOMEOPATHIC_POTENCY_OF_QUINTAMILLESIMAL_KORSAKOVIAN = UNDEFINED; 736 737 ////////////////////////////////////////////////// 738 // CHEMICAL AND BIOCHEMICAL UNITS: UCUM 4.5 §45 // 739 ////////////////////////////////////////////////// 740 // public static final Unit EQUIVALENTS = addUnit(MOLE); 741 // public static final Unit OSMOLE = addUnit(MOLE); 742 743 public static final Unit<Acidity> PH = addUnit( 744 MOLE.divide(LITER).transform(new LogConverter(10)).multiply(-1).asType(Acidity.class)); 745 746 // @SuppressWarnings("unchecked") 747 public static final Unit<Concentration<Mass>> GRAM_PERCENT = addUnit( 748 GRAM.divide(DECI(LITER)).asType(Concentration.class)); 749 750 // public static final Unit SVEDBERG = addUnit(SECOND.multiply(1E-13)); 751 752 public static final Unit<Dimensionless> HIGH_POWER_FIELD = addUnit(ONE); 753 public static final Unit<Dimensionless> LOW_POWER_FIELD = addUnit(ONE.multiply(100)); 754 755 // public static final Unit KATAL = addUnit(MOLE.divide(SECOND)); 756 // public static final Unit UNIT = addUnit(MICRO(MOLE).divide(MINUTE)); 757 758 // public static final Unit INTERNATIONAL_UNIT = UNDEFINED; 759 // public static final Unit ARBITRARY_UNIT = UNDEFINED; 760 // public static final Unit US_PHARMACOPEIA = UNDEFINED; 761 // public static final Unit GPL = UNDEFINED; 762 // public static final Unit MPL = UNDEFINED; 763 // public static final Unit APL = UNDEFINED; 764 // public static final Unit BETHESDA = UNDEFINED; 765 // public static final Unit ANTI_FACTOR_XA = UNDEFINED; 766 // public static final Unit TODD = UNDEFINED; 767 // public static final Unit DYE = UNDEFINED; 768 // public static final Unit SOMOGYI = UNDEFINED; 769 // public static final Unit BODANSKY = UNDEFINED; 770 // public static final Unit KING_ARMSTRONG = UNDEFINED; 771 // public static final Unit KUNKEL = UNDEFINED; 772 // public static final Unit MAC_LAGAN = UNDEFINED; 773 // public static final Unit TUBERCULIN = UNDEFINED; 774 // public static final Unit CELL_CULTURE_INFECTIOUS_50_PERCENT_DOSE = 775 // UNDEFINED; 776 // public static final Unit TISSUE_CULTURE_INFECTIOUS_50_PERCENT_DOSE = 777 // UNDEFINED; 778 // public static final Unit EMBRYO_CULTURE_INFECTIOUS_50_PERCENT_DOSE = 779 // UNDEFINED; 780 // public static final Unit PLAQUE_FORMING = UNDEFINED; 781 // public static final Unit FOCUS_FORMING = UNDEFINED; 782 // public static final Unit COLONY_FORMING = UNDEFINED; 783 // public static final Unit INDEX_OF_REACTIVITY = UNDEFINED; 784 // public static final Unit BIOEQUIVALENT_ALLERGEN = UNDEFINED; 785 // public static final Unit ALLERGEN = UNDEFINED; 786 // public static final Unit ALLERGEN_FOR_AMBROSIA_ARTEMISIIFOLIA = 787 // UNDEFINED; 788 // public static final Unit PROTEIN_NITROGEN = UNDEFINED; 789 // public static final Unit LIMIT_OF_FLOCCULATION = UNDEFINED; 790 // public static final Unit D_ANTIGEN = UNDEFINED; 791 // public static final Unit FIBRINOGEN_EQUIVALENT = UNDEFINED; 792 // public static final Unit ELISA = UNDEFINED; 793 // public static final Unit EHRLICH = UNDEFINED; 794 // public static final Unit CHEMICAL = UNDEFINED; 795 796 ///////////////////////////////// 797 // LEVELS UNITS: UCUM 4.5 §46 // 798 //////////////////////////////// 799 @SuppressWarnings("unchecked") 800 public static final Unit<Level<Dimensionless>> NEPER = addUnit( 801 ONE.transform(new LogConverter(Math.E)).asType(Level.class)); 802 /** 803 * A logarithmic unit used to describe a power {@link Level} ratio (standard 804 * name <code>dB</code>). 805 */ 806 // public static final Unit<Level<Power>> DECIBEL = addUnit(NEPER 807 // .transform(new LogConverter(10).inverse().concatenate( 808 // RationalConverter.of(1d, 10d)))); 809 810 @SuppressWarnings("unchecked") 811 public static final Unit<Level<Dimensionless>> BEL = addUnit( 812 ONE.transform(new LogConverter(10)).asType(Level.class)); 813 814 @SuppressWarnings("unchecked") 815 public static final Unit<Level<Pressure>> BEL_SOUND = addUnit( 816 PASCAL.divide(1E5).multiply(2).transform(new LogConverter(10)).multiply(2).asType(Level.class)); 817 818 @SuppressWarnings("unchecked") 819 public static final Unit<Level<ElectricPotential>> BEL_VOLT = addUnit( 820 VOLT.transform(new LogConverter(10)).multiply(2).asType(Level.class)); 821 822 @SuppressWarnings("unchecked") 823 public static final Unit<Level<ElectricPotential>> BEL_MILLIVOLT = addUnit( 824 MILLI(VOLT).transform(new LogConverter(10)).multiply(2).asType(Level.class)); 825 826 @SuppressWarnings("unchecked") 827 public static final Unit<Level<ElectricPotential>> BEL_MICROVOLT = addUnit( 828 MICRO(VOLT).transform(new LogConverter(10)).multiply(2).asType(Level.class)); 829 830 @SuppressWarnings("unchecked") 831 public static final Unit<Level<ElectricPotential>> BEL_10_NANOVOLT = addUnit( 832 NANO(VOLT).multiply(10).transform(new LogConverter(10)).multiply(2).asType(Level.class)); 833 834 @SuppressWarnings("unchecked") 835 public static final Unit<Level<ElectricPotential>> BEL_WATT = addUnit( 836 WATT.transform(new LogConverter(10)).asType(Level.class)); 837 838 @SuppressWarnings("unchecked") 839 public static final Unit<Level<ElectricPotential>> BEL_KILOWATT = addUnit( 840 KILO(WATT).transform(new LogConverter(10)).asType(Level.class)); 841 842 /////////////////////////////////////// 843 // MISCELLANEOUS UNITS: UCUM 4.5 §47 // 844 /////////////////////////////////////// 845 /** temporary helper for MHO */ 846 private static final Unit<? extends Quantity<?>> TMP_MHO = SIEMENS.alternate("mho"); 847 848 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 849 //public static final Unit<Volume> STERE = addUnit(new ProductUnit<Volume>(METER.pow(3))); 850 public static final Unit<Volume> STERE = addUnit(new TransformedUnit<Volume>("st", Units.CUBIC_METRE, Units.CUBIC_METRE, MultiplyConverter.IDENTITY)); 851 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 852 public static final Unit<Length> ANGSTROM = addUnit(NANO(METER).divide(10)); 853 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 854 public static final Unit<Area> BARN = addUnit(new ProductUnit<Area>(FEMTO(METER).pow(2)).multiply(100)); 855 // public static final Unit<Area> BARN = addUnit(new 856 // ProductUnit<Area>(FEMTO( 857 // METER).pow(2).multiply(100))); 858 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 859 public static final Unit<Pressure> ATMOSPHERE_TECHNICAL = addUnit( 860 new ProductUnit<Pressure>(KILO(GRAM_FORCE).divide(CENTI(METER).pow(2)))); 861 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 862 public static final Unit<ElectricConductance> MHO = addUnit( 863 new AlternateUnit<ElectricConductance>(TMP_MHO, TMP_MHO.getSymbol())); 864 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 865 public static final Unit<Pressure> POUND_PER_SQUARE_INCH = addUnit( 866 new ProductUnit<Pressure>(POUND_FORCE.divide(INCH_INTERNATIONAL.pow(2)))); 867 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 868 public static final Unit<Angle> CIRCLE = addUnit(new ProductUnit<Angle>(PI.multiply(RADIAN.multiply(2)))); 869 // public static final Unit<Angle> CIRCLE = addUnit(new 870 // ProductUnit<Angle>(PI 871 // .multiply(RADIAN).multiply(2))); 872 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 873 public static final Unit<SolidAngle> SPHERE = addUnit( 874 new ProductUnit<SolidAngle>(PI.multiply(STERADIAN.multiply(4)))); 875 // public static final Unit<SolidAngle> SPHERE = addUnit(new 876 // ProductUnit<SolidAngle>( 877 // PI.multiply(STERADIAN).multiply(4))); 878 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 879 public static final Unit<Mass> CARAT_METRIC = addUnit(GRAM.divide(5)); 880 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 881 public static final Unit<Dimensionless> CARAT_GOLD = addUnit(ONE.divide(24)); 882 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 883 public static final Unit<Length> SMOOT = addUnit(INCH_INTERNATIONAL.multiply(67)); 884 885 //////////////////////////////////////////////// 886 // INFORMATION TECHNOLOGY UNITS: UCUM 4.6 §48 // 887 //////////////////////////////////////////////// 888 /** 889 * The unit for binary information (standard name <code>bit</code>). 890 * As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. 891 */ 892 public static final Unit<Information> BIT = addUnit(new AlternateUnit<Information>(ONE, "bit"), Information.class); 893 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 894 public static final Unit<Information> BYTE = addUnit(BIT.multiply(8)); 895 /** 896 * The SI unit for binary information rate (standard name 897 * <code>bit/s</code>). 898 */ 899 protected static final ProductUnit<InformationRate> BITS_PER_SECOND = addUnit( 900 new ProductUnit<InformationRate>(BIT.divide(SECOND)), InformationRate.class); 901 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 902 public static final Unit<InformationRate> BAUD = addUnit(BITS_PER_SECOND); 903 904 ///////////////////// 905 // Collection View // 906 ///////////////////// 907 908 @Override 909 public String getName() { 910 return "Unified Code for Units of Measure"; 911 } 912 913 private static <U extends Unit<Q>, Q extends Quantity<Q>> U addUnit(U unit) { 914 INSTANCE.units.add(unit); 915 return unit; 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, Class<? extends Quantity<?>> type) { 928 INSTANCE.units.add(unit); 929 INSTANCE.quantityToUnit.put(type, unit); 930 return unit; 931 } 932 933 //////////////////////////////////////////////////////////////////////////// 934 // Label adjustments for UCUM system 935 static { 936 SimpleUnitFormat.getInstance().label(ATOMIC_MASS_UNIT, "AMU"); 937 SimpleUnitFormat.getInstance().label(LITER, "L"); 938 SimpleUnitFormat.getInstance().label(LITER_DM3, "l"); 939 SimpleUnitFormat.getInstance().label(OUNCE, "oz"); 940 SimpleUnitFormat.getInstance().label(POUND, "lb"); 941 SimpleUnitFormat.getInstance().label(PLANCK, "h"); 942 // TODO maybe we can find a better solution, but it would require to 943 // "harvest" the entire UCUMFormat ResourceBundle and label every 944 // matching UCUM unit in a loop. 945 } 946}