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.ucum; 031 032import static tec.uom.se.unit.MetricPrefix.*; 033import static tec.uom.se.AbstractUnit.ONE; 034import si.uom.quantity.Action; 035import si.uom.quantity.DynamicViscosity; 036import si.uom.quantity.ElectricPermittivity; 037import si.uom.quantity.IonizingRadiation; 038import si.uom.quantity.KinematicViscosity; 039import si.uom.quantity.Luminance; 040import si.uom.quantity.MagneticFieldStrength; 041import si.uom.quantity.MagneticPermeability; 042import si.uom.quantity.MagnetomotiveForce; 043import si.uom.quantity.WaveNumber; 044import systems.uom.quantity.Information; 045import systems.uom.quantity.InformationRate; 046import systems.uom.ucum.internal.SI; 047import tec.uom.se.*; 048import tec.uom.se.format.SimpleUnitFormat; 049import tec.uom.se.function.PiMultiplierConverter; 050import tec.uom.se.unit.AlternateUnit; 051import tec.uom.se.unit.ProductUnit; 052import tec.uom.se.unit.Units; 053 054import javax.measure.Quantity; 055import javax.measure.Unit; 056import javax.measure.quantity.*; 057 058/** 059 * <p> 060 * This class contains {@link SI} and Non-SI units as defined in the <a 061 * href="http://unitsofmeasure.org/"> Unified Code for Units of Measure</a>. 062 * </p> 063 * 064 * <p> 065 * Compatibility with {@link SI} units has been given priority over strict 066 * adherence to the standard. We have attempted to note every place where the 067 * definitions in this class deviate from the UCUM standard, but such notes are 068 * likely to be incomplete. 069 * </p> 070 * 071 * @author <a href="mailto:eric-r@northwestern.edu">Eric Russell</a> 072 * @author <a href="mailto:units@catmedia.us">Werner Keil</a> 073 * @see <a href="http://www.unitsofmeasure.org">UCUM</a> 074 * @version 0.7.1, $Date: 2016-03-16 $ 075 */ 076public final class UCUM extends AbstractSystemOfUnits { 077 078 /** 079 * The singleton instance. 080 */ 081 private static final UCUM INSTANCE = new UCUM(); 082 083 /** 084 * Default constructor (prevents this class from being instantiated). 085 */ 086 private UCUM() { 087 } 088 089 /** 090 * Returns the singleton instance of this class. 091 * 092 * @return the UCUM system instance. 093 */ 094 public static UCUM getInstance() { 095 return INSTANCE; 096 } 097 098 // //////////////////////////// 099 // BASE UNITS: UCUM 4.2 §25 // 100 // //////////////////////////// 101 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 102 public static final Unit<Length> METER = addUnit(Units.METRE); 103 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 104 public static final Unit<Time> SECOND = addUnit(Units.SECOND); 105 /** 106 * We deviate slightly from the standard here, to maintain compatibility 107 * with the existing SI units. In UCUM, the gram is the base unit of mass, 108 * rather than the kilogram. This doesn't have much effect on the units 109 * themselves, but it does make formatting the units a challenge. 110 */ 111 public static final Unit<Mass> GRAM = addUnit(Units.GRAM); 112 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 113 public static final Unit<Angle> RADIAN = addUnit(Units.RADIAN); 114 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 115 public static final Unit<Temperature> KELVIN = addUnit(Units.KELVIN); 116 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 117 public static final Unit<ElectricCharge> COULOMB = addUnit(Units.COULOMB); 118 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 119 public static final Unit<LuminousIntensity> CANDELA = addUnit(Units.CANDELA); 120 121 // ///////////////////////////////////////////// 122 // DIMENSIONLESS DERIVED UNITS: UCUM 4.3 §26 // 123 // ///////////////////////////////////////////// 124 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 125 public static final Unit<Dimensionless> TRILLIONS = addUnit(ONE 126 .multiply(1000000000000L)); 127 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 128 public static final Unit<Dimensionless> BILLIONS = addUnit(ONE 129 .multiply(1000000000)); 130 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 131 public static final Unit<Dimensionless> MILLIONS = addUnit(ONE 132 .multiply(1000000)); 133 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 134 public static final Unit<Dimensionless> THOUSANDS = addUnit(ONE 135 .multiply(1000)); 136 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 137 public static final Unit<Dimensionless> HUNDREDS = addUnit(ONE 138 .multiply(100)); 139 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 140 public static final Unit<Dimensionless> PI = addUnit(ONE 141 .transform(new PiMultiplierConverter())); 142 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 143 public static final Unit<Dimensionless> PERCENT = addUnit(ONE 144 .divide(100)); 145 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 146 public static final Unit<Dimensionless> PER_THOUSAND = addUnit(ONE 147 .divide(1000)); 148 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 149 public static final Unit<Dimensionless> PER_MILLION = addUnit(ONE 150 .divide(1000000)); 151 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 152 public static final Unit<Dimensionless> PER_BILLION = addUnit(ONE 153 .divide(1000000000)); 154 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 155 public static final Unit<Dimensionless> PER_TRILLION = addUnit(ONE 156 .divide(1000000000000L)); 157 // ////////////////////////// 158 // SI UNITS: UCUM 4.3 §27 // 159 // ////////////////////////// 160 /** 161 * We deviate slightly from the standard here, to maintain compatibility 162 * with the existing SI units. In UCUM, the mole is no longer a base unit, 163 * but is defined as <code>Unit.ONE.multiply(6.0221367E23)</code>. 164 */ 165 public static final Unit<AmountOfSubstance> MOLE = addUnit(Units.MOLE); 166 /** 167 * We deviate slightly from the standard here, to maintain compatibility 168 * with the existing SI units. In UCUM, the steradian is defined as 169 * <code>RADIAN.pow(2)</code>. 170 */ 171 public static final Unit<SolidAngle> STERADIAN = addUnit(Units.STERADIAN); 172 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 173 public static final Unit<Frequency> HERTZ = addUnit(Units.HERTZ); 174 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 175 public static final Unit<Force> NEWTON = addUnit(Units.NEWTON); 176 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 177 public static final Unit<Pressure> PASCAL = addUnit(Units.PASCAL); 178 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 179 public static final Unit<Energy> JOULE = addUnit(Units.JOULE); 180 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 181 public static final Unit<Power> WATT = addUnit(Units.WATT); 182 /** 183 * We deviate slightly from the standard here, to maintain compatability 184 * with the existing SI units. In UCUM, the ampere is defined as 185 * <code>COULOMB.divide(SECOND)</code>. 186 */ 187 public static final Unit<ElectricCurrent> AMPERE = addUnit(Units.AMPERE); 188// public static final Unit<MagnetomotiveForce> AMPERE_TURN = addUnit(Units.AMPERE_TURN); 189 /** 190 * We deviate slightly from the standard here, to maintain compatibility 191 * with the existing SI units. In UCUM, the volt is defined as 192 * <code>JOULE.divide(COULOMB)</code>. 193 */ 194 public static final Unit<ElectricPotential> VOLT = addUnit(Units.VOLT); 195 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 196 public static final Unit<ElectricCapacitance> FARAD = addUnit(Units.FARAD); 197 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 198 public static final Unit<ElectricResistance> OHM = addUnit(Units.OHM); 199 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 200 public static final Unit<ElectricConductance> SIEMENS = addUnit(Units.SIEMENS); 201 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 202 public static final Unit<MagneticFlux> WEBER = addUnit(Units.WEBER); 203 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 204 public static final Unit<Temperature> CELSIUS = addUnit(Units.CELSIUS); 205 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 206 public static final Unit<MagneticFluxDensity> TESLA = addUnit(Units.TESLA); 207 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 208 public static final Unit<ElectricInductance> HENRY = addUnit(Units.HENRY); 209 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 210 public static final Unit<LuminousFlux> LUMEN = addUnit(Units.LUMEN); 211 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 212 public static final Unit<Illuminance> LUX = addUnit(Units.LUX); 213 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 214 public static final Unit<Radioactivity> BECQUEREL = addUnit(Units.BECQUEREL); 215 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 216 public static final Unit<RadiationDoseAbsorbed> GRAY = addUnit(Units.GRAY); 217 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 218 public static final Unit<RadiationDoseEffective> SIEVERT = addUnit(Units.SIEVERT); 219 220 // ///////////////////////////////////////////////////////////////////// 221 // OTHER UNITS FROM ISO 1000, ISO 2955, AND ANSI X3.50: UCUM 4.3 §28 // 222 // ///////////////////////////////////////////////////////////////////// 223 // The order of GON and DEGREE has been inverted because GON is defined in 224 // terms of DEGREE 225 /** 226 * We deviate slightly from the standard here, to maintain compatibility 227 * with the existing NonSI units. In UCUM, the degree is defined as 228 * <code>PI.multiply(RADIAN.divide(180))</code>. 229 */ 230 public static final Unit<Angle> DEGREE = addUnit(Units.DEGREE_ANGLE); 231 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 232 public static final Unit<Angle> GRADE = addUnit(Units.DEGREE_ANGLE 233 .multiply(0.9)); 234 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 235 public static final Unit<Angle> GON = GRADE; 236 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 237 public static final Unit<Angle> MINUTE_ANGLE = addUnit(Units.MINUTE_ANGLE); 238 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 239 public static final Unit<Angle> SECOND_ANGLE = addUnit(Units.SECOND_ANGLE); 240 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 241 public static final Unit<Volume> LITER = addUnit(Units.LITRE); 242 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 243 public static final Unit<Area> ARE = addUnit(Units.SQUARE_METRE.multiply(100)); 244 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 245 public static final Unit<Time> MINUTE = addUnit(Units.MINUTE); 246 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 247 public static final Unit<Time> HOUR = addUnit(Units.HOUR); 248 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 249 public static final Unit<Time> DAY = addUnit(Units.DAY); 250 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 251 public static final Unit<Time> YEAR_TROPICAL = addUnit(Units.DAY 252 .multiply(365.24219)); 253 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 254 public static final Unit<Time> YEAR_JULIAN = addUnit(Units.DAY 255 .multiply(365.25)); 256 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 257 public static final Unit<Time> YEAR_GREGORIAN = addUnit(Units.DAY 258 .multiply(365.2425)); 259 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 260 public static final Unit<Time> YEAR = addUnit(Units.DAY.multiply(365.25)); 261 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 262 public static final Unit<Time> MONTH_SYNODAL = addUnit(Units.DAY 263 .multiply(29.53059)); 264 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 265 public static final Unit<Time> MONTH_JULIAN = addUnit(YEAR_JULIAN 266 .divide(12)); 267 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 268 public static final Unit<Time> MONTH_GREGORIAN = addUnit(YEAR_GREGORIAN 269 .divide(12)); 270 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 271 public static final Unit<Time> MONTH = addUnit(YEAR_JULIAN.divide(12)); 272 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 273 public static final Unit<Mass> TONNE = addUnit(Units.KILOGRAM.multiply(1000)); 274 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 275 public static final Unit<Pressure> BAR = addUnit(Units.PASCAL.multiply(100000)); 276 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 277 public static final Unit<Mass> ATOMIC_MASS_UNIT = addUnit(SI.UNIFIED_ATOMIC_MASS); 278// public static final Unit<Mass> ATOMIC_MASS_UNIT = addUnit( 279// new AlternateUnit<Mass>(Units.UNIFIED_ATOMIC_MASS, 280// Units.UNIFIED_ATOMIC_MASS.getSymbol()), Mass.class); 281 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 282 public static final Unit<Energy> ELECTRON_VOLT = addUnit(SI.ELECTRON_VOLT); 283 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 284 public static final Unit<Length> ASTRONOMIC_UNIT = addUnit(SI.ASTRONOMICAL_UNIT); 285 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 286 public static final Unit<Length> PARSEC = addUnit(Units.METRE 287 .multiply(3.085678E16)); 288 289 // /////////////////////////////// 290 // NATURAL UNITS: UCUM 4.3 §29 // 291 // /////////////////////////////// 292 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 293 public static final Unit<Speed> C = addUnit(Units.METRES_PER_SECOND 294 .multiply(299792458)); 295 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 296 public static final Unit<Action> PLANCK = addUnit(SI.JOULE_SECOND 297 .multiply(6.6260755E-24)); //FIXME get rid of JXQ import (where from??) */ 298 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 299 public static final Unit<?> BOLTZMAN = addUnit(JOULE.divide(KELVIN) 300 .multiply(1.380658E-23)); 301 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 302 public static final Unit<ElectricPermittivity> PERMITTIVITY_OF_VACUUM = addUnit(SI.FARADS_PER_METRE 303 .multiply(8.854187817E-12)); 304 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 305 public static final Unit<MagneticPermeability> PERMEABILITY_OF_VACUUM = addUnit( 306 new ProductUnit<MagneticPermeability>(SI.NEWTONS_PER_SQUARE_AMPERE 307 .multiply(PI.multiply(4).divide(1E7))), 308 MagneticPermeability.class); 309// public static final Unit<MagneticPermeability> PERMEABILITY_OF_VACUUM = addUnit( 310// new ProductUnit<MagneticPermeability>(Units.NEWTONS_PER_SQUARE_AMPERE 311// .multiply(PI).multiply(4).divide(1E7)), 312// MagneticPermeability.class); 313 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 314 public static final Unit<ElectricCharge> ELEMENTARY_CHARGE = addUnit(Units.COULOMB 315 .transform(((AbstractUnit<Energy>)SI.ELECTRON_VOLT).getSystemConverter())); 316 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 317 public static final Unit<Mass> ELECTRON_MASS = addUnit(GRAM 318 .multiply(9.1093897E-28)); 319 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 320 public static final Unit<Mass> PROTON_MASS = addUnit(GRAM 321 .multiply(1.6726231E-24)); 322 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 323 public static final Unit<?> NEWTON_CONSTANT_OF_GRAVITY = addUnit(METER 324 .pow(3).multiply(Units.KILOGRAM.pow(-1)).multiply(SECOND.pow(-2)) 325 .multiply(6.67259E-11)); 326 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 327 public static final Unit<Acceleration> ACCELLERATION_OF_FREEFALL = addUnit(Units.METRES_PER_SQUARE_SECOND 328 .multiply(9.80665)); 329 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 330 public static final Unit<Pressure> ATMOSPHERE = addUnit(Units.PASCAL 331 .multiply(101325)); 332 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 333 public static final Unit<Length> LIGHT_YEAR = addUnit(new ProductUnit<Length>( 334 C.multiply(YEAR_JULIAN))); 335 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 336 public static final Unit<Force> GRAM_FORCE = addUnit(new ProductUnit<Force>( 337 GRAM.multiply(ACCELLERATION_OF_FREEFALL))); 338 // POUND_FORCE contains a forward reference to avoirdupois pound weight, so 339 // it has been moved after section §36 below 340 341 // /////////////////////////// 342 // CGS UNITS: UCUM 4.3 §30 // 343 // /////////////////////////// 344 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 345 public static final Unit<WaveNumber> KAYSER = addUnit(SI.RECIPROCAL_METRE 346 .divide(100)); // get rid of JXQ import (where from??) */ 347 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 348 public static final Unit<Acceleration> GAL = addUnit(new ProductUnit<Acceleration>( 349 CENTI(METER).divide(SECOND.pow(2)))); 350 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 351 public static final Unit<Force> DYNE = addUnit(new ProductUnit<Force>( 352 Units.GRAM.multiply(CENTI(Units.METRE).divide(Units.SECOND 353 .pow(2))))); 354// public static final Unit<Force> DYNE = addUnit(new ProductUnit<Force>( 355// Units.GRAM.multiply(new ProductUnit(CENTI(Units.METRE)).divide(Units.SECOND 356// .pow(2))))); 357 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 358 public static final Unit<Energy> ERG = addUnit(new ProductUnit<Energy>( 359 DYNE.multiply(CENTI(Units.METRE)))); 360 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 361 public static final Unit<DynamicViscosity> POISE = addUnit(new ProductUnit<DynamicViscosity>( 362 DYNE.multiply(SECOND).divide(CENTI(Units.METRE).pow(2)))); 363 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 364 public static final Unit<ElectricCurrent> BIOT = addUnit(AMPERE 365 .multiply(10)); 366 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 367 public static final Unit<KinematicViscosity> STOKES = addUnit(new ProductUnit<KinematicViscosity>( 368 CENTI(Units.METRE).pow(2).divide(Units.SECOND))); 369 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 370 public static final Unit<MagneticFlux> MAXWELL = addUnit(Units.WEBER 371 .divide(1E8)); 372 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 373 public static final Unit<MagneticFluxDensity> GAUSS = addUnit(Units.TESLA 374 .divide(1E4)); 375 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 376 public static final Unit<MagneticFieldStrength> OERSTED = addUnit(new ProductUnit<MagneticFieldStrength>( 377 SI.AMPERES_PER_METRE.multiply(250).divide(PI))); 378 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 379 public static final Unit<MagnetomotiveForce> GILBERT = addUnit(new ProductUnit<MagnetomotiveForce>( 380 OERSTED.multiply(CENTI(Units.METRE)))); 381 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 382 public static final Unit<Luminance> STILB = addUnit(new ProductUnit<Luminance>( 383 CANDELA.divide(CENTI(METER).pow(2)))); 384 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 385 public static final Unit<Luminance> LAMBERT = addUnit(new ProductUnit<Luminance>( 386 STILB.divide(PI))); 387 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 388 public static final Unit<Illuminance> PHOT = addUnit(LUX.divide(1E4)); 389 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 390 public static final Unit<Radioactivity> CURIE = addUnit(Units.BECQUEREL 391 .multiply(3.7E10)); 392 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 393 public static final Unit<IonizingRadiation> ROENTGEN = addUnit(SI.COULOMBS_PER_KILOGRAM 394 .multiply(2.58E-4)); // add later when JMQ issue fixed */ 395 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 396 public static final Unit<RadiationDoseAbsorbed> RAD = addUnit(new ProductUnit<RadiationDoseAbsorbed>( 397 ERG.divide(Units.GRAM.multiply(100)))); 398// public static final Unit<RadiationDoseAbsorbed> RAD = addUnit(new ProductUnit<RadiationDoseAbsorbed>( 399// ERG.divide(Units.GRAM).multiply(100))); 400 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 401 public static final Unit<RadiationDoseEffective> REM = addUnit(new ProductUnit<RadiationDoseEffective>( 402 ERG.divide(Units.GRAM.multiply(100)))); 403// public static final Unit<RadiationDoseEffective> REM = addUnit(new AlternateUnit<RadiationDoseEffective>( 404// RAD, RAD.getSymbol())); // TODO are symbols for RAD and REM same? 405 // /////////////////////////////////////////////// 406 // INTERNATIONAL CUSTOMARY UNITS: UCUM 4.4 §31 // 407 // /////////////////////////////////////////////// 408 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 409 public static final Unit<Length> INCH_INTERNATIONAL = addUnit(CENTI(METER) 410 .multiply(254).divide(100)); 411 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 412 public static final Unit<Length> FOOT_INTERNATIONAL = addUnit(INCH_INTERNATIONAL 413 .multiply(12)); 414 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 415 public static final Unit<Length> YARD_INTERNATIONAL = addUnit(FOOT_INTERNATIONAL 416 .multiply(3)); 417 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 418 public static final Unit<Length> MILE_INTERNATIONAL = addUnit(FOOT_INTERNATIONAL 419 .multiply(5280)); 420 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 421 public static final Unit<Length> FATHOM_INTERNATIONAL = addUnit(FOOT_INTERNATIONAL 422 .multiply(6)); 423 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 424 public static final Unit<Length> NAUTICAL_MILE_INTERNATIONAL = addUnit(METER 425 .multiply(1852)); 426 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 427 public static final Unit<Speed> KNOT_INTERNATIONAL = addUnit(new ProductUnit<Speed>( 428 NAUTICAL_MILE_INTERNATIONAL.divide(HOUR))); 429 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 430 public static final Unit<Area> SQUARE_INCH_INTERNATIONAL = addUnit(new ProductUnit<Area>( 431 INCH_INTERNATIONAL.pow(2))); 432 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 433 public static final Unit<Area> SQUARE_FOOT_INTERNATIONAL = addUnit(new ProductUnit<Area>( 434 FOOT_INTERNATIONAL.pow(2))); 435 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 436 public static final Unit<Area> SQUARE_YARD_INTERNATIONAL = addUnit(new ProductUnit<Area>( 437 YARD_INTERNATIONAL.pow(2))); 438 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 439 public static final Unit<Volume> CUBIC_INCH_INTERNATIONAL = addUnit(new ProductUnit<Volume>( 440 INCH_INTERNATIONAL.pow(3))); 441 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 442 public static final Unit<Volume> CUBIC_FOOT_INTERNATIONAL = addUnit(new ProductUnit<Volume>( 443 FOOT_INTERNATIONAL.pow(3))); 444 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 445 public static final Unit<Volume> CUBIC_YARD_INTERNATIONAL = addUnit(new ProductUnit<Volume>( 446 YARD_INTERNATIONAL.pow(3))); 447 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 448 public static final Unit<Volume> BOARD_FOOT_INTERNATIONAL = addUnit(CUBIC_INCH_INTERNATIONAL 449 .multiply(144)); 450 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 451 public static final Unit<Volume> CORD_INTERNATIONAL = addUnit(CUBIC_FOOT_INTERNATIONAL 452 .multiply(128)); 453 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 454 public static final Unit<Length> MIL_INTERNATIONAL = addUnit(INCH_INTERNATIONAL 455 .divide(1000)); 456 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 457 public static final Unit<Area> CIRCULAR_MIL_INTERNATIONAL = addUnit(new ProductUnit<Area>( 458 MIL_INTERNATIONAL.pow(2).multiply(PI.divide(4)))); 459// public static final Unit<Area> CIRCULAR_MIL_INTERNATIONAL = addUnit(new ProductUnit<Area>( 460// MIL_INTERNATIONAL.pow(2).multiply(PI).divide(4))); 461 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 462 public static final Unit<Length> HAND_INTERNATIONAL = addUnit(INCH_INTERNATIONAL 463 .multiply(4)); 464 // //////////////////////////////////////// 465 // US SURVEY LENGTH UNITS: UCUM 4.4 §32 // 466 // //////////////////////////////////////// 467 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 468 public static final Unit<Length> FOOT_US_SURVEY = addUnit(METER.multiply( 469 1200).divide(3937)); 470 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 471 public static final Unit<Length> YARD_US_SURVEY = addUnit(FOOT_US_SURVEY 472 .multiply(3)); 473 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 474 public static final Unit<Length> INCH_US_SURVEY = addUnit(FOOT_US_SURVEY 475 .divide(12)); 476 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 477 public static final Unit<Length> ROD_US_SURVEY = addUnit(FOOT_US_SURVEY 478 .multiply(33).divide(2)); 479 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 480 public static final Unit<Length> CHAIN_US_SURVEY = addUnit(ROD_US_SURVEY 481 .multiply(4)); 482 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 483 public static final Unit<Length> LINK_US_SURVEY = addUnit(CHAIN_US_SURVEY 484 .divide(100)); 485 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 486 public static final Unit<Length> RAMDEN_CHAIN_US_SURVEY = addUnit(FOOT_US_SURVEY 487 .multiply(100)); 488 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 489 public static final Unit<Length> RAMDEN_LINK_US_SURVEY = addUnit(CHAIN_US_SURVEY 490 .divide(100)); 491 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 492 public static final Unit<Length> FATHOM_US_SURVEY = addUnit(FOOT_US_SURVEY 493 .multiply(6)); 494 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 495 public static final Unit<Length> FURLONG_US_SURVEY = addUnit(ROD_US_SURVEY 496 .multiply(40)); 497 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 498 public static final Unit<Length> MILE_US_SURVEY = addUnit(FURLONG_US_SURVEY 499 .multiply(8)); 500 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 501 public static final Unit<Area> ACRE_US_SURVEY = addUnit(new ProductUnit<Area>( 502 ROD_US_SURVEY.pow(2)).multiply(160)); 503// public static final Unit<Area> ACRE_US_SURVEY = addUnit(new ProductUnit<Area>( 504// ROD_US_SURVEY.pow(2).multiply(160))); 505 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 506 public static final Unit<Area> SQUARE_ROD_US_SURVEY = addUnit(new ProductUnit<Area>( 507 ROD_US_SURVEY.pow(2))); 508 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 509 public static final Unit<Area> SQUARE_MILE_US_SURVEY = addUnit(new ProductUnit<Area>( 510 MILE_US_SURVEY.pow(2))); 511 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 512 public static final Unit<Area> SECTION_US_SURVEY = addUnit(new ProductUnit<Area>( 513 MILE_US_SURVEY.pow(2))); 514 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 515 public static final Unit<Area> TOWNSHP_US_SURVEY = addUnit(SECTION_US_SURVEY 516 .multiply(36)); 517 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 518 public static final Unit<Length> MIL_US_SURVEY = addUnit(INCH_US_SURVEY 519 .divide(1000)); 520 // /////////////////////////////////////////////// 521 // BRITISH IMPERIAL LENGTH UNITS: UCUM 4.4 §33 // 522 // /////////////////////////////////////////////// 523 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 524 public static final Unit<Length> INCH_BRITISH = addUnit(CENTI(METER) 525 .multiply(2539998).divide(1000000)); 526 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 527 public static final Unit<Length> FOOT_BRITISH = addUnit(INCH_BRITISH 528 .multiply(12)); 529 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 530 public static final Unit<Length> ROD_BRITISH = addUnit(FOOT_BRITISH 531 .multiply(33).divide(2)); 532 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 533 public static final Unit<Length> CHAIN_BRITISH = addUnit(ROD_BRITISH 534 .multiply(4)); 535 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 536 public static final Unit<Length> LINK_BRITISH = addUnit(CHAIN_BRITISH 537 .divide(100)); 538 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 539 public static final Unit<Length> FATHOM_BRITISH = addUnit(FOOT_BRITISH 540 .multiply(6)); 541 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 542 public static final Unit<Length> PACE_BRITISH = addUnit(FOOT_BRITISH 543 .multiply(5).divide(20)); 544 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 545 public static final Unit<Length> YARD_BRITISH = addUnit(FOOT_BRITISH 546 .multiply(3)); 547 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 548 public static final Unit<Length> MILE_BRITISH = addUnit(FOOT_BRITISH 549 .multiply(5280)); 550 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 551 public static final Unit<Length> NAUTICAL_MILE_BRITISH = addUnit(FOOT_BRITISH 552 .multiply(6080)); 553 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 554 public static final Unit<Speed> KNOT_BRITISH = addUnit(new ProductUnit<Speed>( 555 NAUTICAL_MILE_BRITISH.divide(HOUR))); 556 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 557 public static final Unit<Area> ACRE_BRITISH = addUnit(new ProductUnit<Area>( 558 YARD_BRITISH.pow(2)).multiply(4840)); 559// public static final Unit<Area> ACRE_BRITISH = addUnit(new ProductUnit<Area>( 560// YARD_BRITISH.pow(2).multiply(4840))); 561 // ///////////////////////////////// 562 // US VOLUME UNITS: UCUM 4.4 §34 // 563 // ///////////////////////////////// 564 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 565 public static final Unit<Volume> GALLON_US = addUnit(CUBIC_INCH_INTERNATIONAL 566 .multiply(231)); 567 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 568 public static final Unit<Volume> BARREL_US = addUnit(GALLON_US.multiply(42)); 569 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 570 public static final Unit<Volume> QUART_US = addUnit(GALLON_US.divide(4)); 571 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 572 public static final Unit<Volume> PINT_US = addUnit(QUART_US.divide(2)); 573 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 574 public static final Unit<Volume> GILL_US = addUnit(PINT_US.divide(4)); 575 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 576 public static final Unit<Volume> FLUID_OUNCE_US = addUnit(GILL_US.divide(4)); 577 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 578 public static final Unit<Volume> FLUID_DRAM_US = addUnit(FLUID_OUNCE_US 579 .divide(8)); 580 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 581 public static final Unit<Volume> MINIM_US = addUnit(FLUID_DRAM_US 582 .divide(60)); 583 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 584 public static final Unit<Volume> CORD_US = addUnit(CUBIC_FOOT_INTERNATIONAL 585 .multiply(128)); 586 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 587 public static final Unit<Volume> BUSHEL_US = addUnit(CUBIC_INCH_INTERNATIONAL 588 .multiply(215042).divide(100)); 589 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 590 public static final Unit<Volume> GALLON_WINCHESTER = addUnit(BUSHEL_US 591 .divide(8)); 592 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 593 public static final Unit<Volume> PECK_US = addUnit(BUSHEL_US.divide(4)); 594 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 595 public static final Unit<Volume> DRY_QUART_US = addUnit(PECK_US.divide(8)); 596 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 597 public static final Unit<Volume> DRY_PINT_US = addUnit(DRY_QUART_US 598 .divide(2)); 599 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 600 public static final Unit<Volume> TABLESPOON_US = addUnit(FLUID_OUNCE_US 601 .divide(2)); 602 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 603 public static final Unit<Volume> TEASPOON_US = addUnit(TABLESPOON_US 604 .divide(3)); 605 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 606 public static final Unit<Volume> CUP_US = addUnit(TABLESPOON_US 607 .multiply(16)); 608 // /////////////////////////////////////////////// 609 // BRITISH IMPERIAL VOLUME UNITS: UCUM 4.4 §35 // 610 // /////////////////////////////////////////////// 611 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 612 public static final Unit<Volume> GALLON_BRITISH = addUnit(LITER.multiply( 613 454609).divide(100000)); 614 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 615 public static final Unit<Volume> PECK_BRITISH = addUnit(GALLON_BRITISH 616 .multiply(2)); 617 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 618 public static final Unit<Volume> BUSHEL_BRITISH = addUnit(PECK_BRITISH 619 .multiply(4)); 620 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 621 public static final Unit<Volume> QUART_BRITISH = addUnit(GALLON_BRITISH 622 .divide(4)); 623 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 624 public static final Unit<Volume> PINT_BRITISH = addUnit(QUART_BRITISH 625 .divide(2)); 626 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 627 public static final Unit<Volume> GILL_BRITISH = addUnit(PINT_BRITISH 628 .divide(4)); 629 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 630 public static final Unit<Volume> FLUID_OUNCE_BRITISH = addUnit(GILL_BRITISH 631 .divide(5)); 632 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 633 public static final Unit<Volume> FLUID_DRAM_BRITISH = addUnit(FLUID_OUNCE_BRITISH 634 .divide(8)); 635 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 636 public static final Unit<Volume> MINIM_BRITISH = addUnit(FLUID_DRAM_BRITISH 637 .divide(60)); 638 // ////////////////////////////////////////// 639 // AVOIRDUPOIS WIEGHT UNITS: UCUM 4.4 §36 // 640 // ////////////////////////////////////////// 641 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 642 public static final Unit<Mass> GRAIN = addUnit(MILLI(GRAM) 643 .multiply(6479891).divide(100000)); 644 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 645 public static final Unit<Mass> POUND = addUnit(GRAIN.multiply(7000)); 646 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 647 public static final Unit<Mass> OUNCE = addUnit(POUND.divide(16)); 648 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 649 public static final Unit<Mass> DRAM = addUnit(OUNCE.divide(16)); 650 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 651 public static final Unit<Mass> SHORT_HUNDREDWEIGHT = addUnit(POUND 652 .multiply(100)); 653 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 654 public static final Unit<Mass> LONG_HUNDREDWEIGHT = addUnit(POUND 655 .multiply(112)); 656 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 657 public static final Unit<Mass> SHORT_TON = addUnit(SHORT_HUNDREDWEIGHT 658 .multiply(20)); 659 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 660 public static final Unit<Mass> LONG_TON = addUnit(LONG_HUNDREDWEIGHT 661 .multiply(20)); 662 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 663 public static final Unit<Mass> STONE = addUnit(POUND.multiply(14)); 664 // CONTINUED FROM SECTION §29 665 // contains a forward reference to POUND, so we had to move it here, below 666 // section §36 667 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 668// public static final Unit<Force> POUND_FORCE = addUnit(new ProductUnit<Force>( 669// POUND.multiply(ACCELLERATION_OF_FREEFALL))); 670 public static final Unit<Force> POUND_FORCE = addUnit(POUND.multiply(ACCELLERATION_OF_FREEFALL).asType(Force.class)); 671 672 //public static final Unit<InformationRate> POUND_FORCE2 = addUnit(POUND.multiply(ACCELLERATION_OF_FREEFALL).asType(InformationRate.class)); 673 674 // /////////////////////////////////// 675 // TROY WIEGHT UNITS: UCUM 4.4 §37 // 676 // /////////////////////////////////// 677 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 678 public static final Unit<Mass> PENNYWEIGHT_TROY = addUnit(GRAIN 679 .multiply(24)); 680 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 681 public static final Unit<Mass> OUNCE_TROY = addUnit(PENNYWEIGHT_TROY 682 .multiply(24)); 683 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 684 public static final Unit<Mass> POUND_TROY = addUnit(OUNCE_TROY.multiply(12)); 685 // /////////////////////////////////////////// 686 // APOTECARIES' WEIGHT UNITS: UCUM 4.4 §38 // 687 // /////////////////////////////////////////// 688 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 689 public static final Unit<Mass> SCRUPLE_APOTHECARY = addUnit(GRAIN 690 .multiply(20)); 691 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 692 public static final Unit<Mass> DRAM_APOTHECARY = addUnit(SCRUPLE_APOTHECARY 693 .multiply(3)); 694 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 695 public static final Unit<Mass> OUNCE_APOTHECARY = addUnit(DRAM_APOTHECARY 696 .multiply(8)); 697 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 698 public static final Unit<Mass> POUND_APOTHECARY = addUnit(OUNCE_APOTHECARY 699 .multiply(12)); 700 // /////////////////////////////////////////// 701 // TYPESETTER'S LENGTH UNITS: UCUM 4.4 §39 // 702 // /////////////////////////////////////////// 703 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 704 public static final Unit<Length> LINE = addUnit(INCH_INTERNATIONAL 705 .divide(12)); 706 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 707 public static final Unit<Length> POINT = addUnit(LINE.divide(6)); 708 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 709 public static final Unit<Length> PICA = addUnit(POINT.multiply(12)); 710 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 711 public static final Unit<Length> POINT_PRINTER = addUnit(INCH_INTERNATIONAL 712 .multiply(13837).divide(1000000)); 713 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 714 public static final Unit<Length> PICA_PRINTER = addUnit(POINT_PRINTER 715 .multiply(12)); 716 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 717 public static final Unit<Length> PIED = addUnit(CENTI(METER).multiply(3248) 718 .divide(100)); 719 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 720 public static final Unit<Length> POUCE = addUnit(PIED.divide(12)); 721 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 722 public static final Unit<Length> LINGE = addUnit(POUCE.divide(12)); 723 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 724 public static final Unit<Length> DIDOT = addUnit(LINGE.divide(6)); 725 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 726 public static final Unit<Length> CICERO = addUnit(DIDOT.multiply(12)); 727 // //////////////////////////////////// 728 // OTHER LEGACY UNITS: UCUM 4.5 §40 // 729 // //////////////////////////////////// 730 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 731 public static final Unit<Temperature> FAHRENHEIT = addUnit(KELVIN 732 .multiply(5).divide(9).shift(459.67)); 733 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 734 public static final Unit<Energy> CALORIE_AT_15C = addUnit(JOULE.multiply( 735 41858).divide(10000)); 736 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 737 public static final Unit<Energy> CALORIE_AT_20C = addUnit(JOULE.multiply( 738 41819).divide(10000)); 739 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 740 public static final Unit<Energy> CALORIE_MEAN = addUnit(JOULE.multiply( 741 419002).divide(100000)); 742 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 743 public static final Unit<Energy> CALORIE_INTERNATIONAL_TABLE = addUnit(JOULE 744 .multiply(41868).divide(10000)); 745 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 746 public static final Unit<Energy> CALORIE_THERMOCHEMICAL = addUnit(JOULE 747 .multiply(4184).divide(1000)); 748 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 749 public static final Unit<Energy> CALORIE = addUnit(CALORIE_THERMOCHEMICAL); 750 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 751 public static final Unit<Energy> CALORIE_FOOD = addUnit(KILO(CALORIE_THERMOCHEMICAL)); 752 753 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 754 public static final Unit<Energy> BTU_AT_39F = addUnit(KILO(JOULE).multiply( 755 105967).divide(100000)); 756 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 757 public static final Unit<Energy> BTU_AT_59F = addUnit(KILO(JOULE).multiply( 758 105480).divide(100000)); 759 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 760 public static final Unit<Energy> BTU_AT_60F = addUnit(KILO(JOULE).multiply( 761 105468).divide(100000)); 762 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 763 public static final Unit<Energy> BTU_MEAN = addUnit(KILO(JOULE).multiply( 764 105587).divide(100000)); 765 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 766 public static final Unit<Energy> BTU_INTERNATIONAL_TABLE = addUnit(KILO( 767 JOULE).multiply(105505585262L).divide(100000000000L)); 768 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 769 public static final Unit<Energy> BTU_THERMOCHEMICAL = addUnit(KILO(JOULE) 770 .multiply(105735).divide(100000)); 771 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 772 public static final Unit<Energy> BTU = addUnit(BTU_THERMOCHEMICAL); 773 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 774 public static final Unit<Power> HORSEPOWER = addUnit(new ProductUnit<Power>( 775 FOOT_INTERNATIONAL.multiply(POUND_FORCE).divide(SECOND))); 776 // /////////////////////////////////////////////////////// 777 // SECTIONS §41-§43 skipped; implement later if needed // 778 // /////////////////////////////////////////////////////// 779 // ///////////////////////////////////// 780 // MISCELLANEOUS UNITS: UCUM 4.5 §44 // 781 // ///////////////////////////////////// 782 /** temporary helper for MHO */ 783 private static final Unit<? extends Quantity<?>> TMP_MHO = SIEMENS 784 .alternate("mho"); 785 786 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 787 public static final Unit<Volume> STERE = addUnit(new ProductUnit<Volume>( 788 METER.pow(3))); 789 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 790 public static final Unit<Length> ANGSTROM = addUnit(NANO(METER).divide(10)); 791 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 792 public static final Unit<Area> BARN = addUnit(new ProductUnit<Area>(FEMTO( 793 METER).pow(2)).multiply(100)); 794// public static final Unit<Area> BARN = addUnit(new ProductUnit<Area>(FEMTO( 795// METER).pow(2).multiply(100))); 796 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 797 public static final Unit<Pressure> ATMOSPHERE_TECHNICAL = addUnit(new ProductUnit<Pressure>( 798 KILO(GRAM_FORCE).divide(CENTI(METER).pow(2)))); 799 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 800 public static final Unit<ElectricConductance> MHO = addUnit(new AlternateUnit<ElectricConductance>( 801 TMP_MHO, TMP_MHO.getSymbol())); 802 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 803 public static final Unit<Pressure> POUND_PER_SQUARE_INCH = addUnit(new ProductUnit<Pressure>( 804 POUND_FORCE.divide(INCH_INTERNATIONAL.pow(2)))); 805 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 806 public static final Unit<Angle> CIRCLE = addUnit(new ProductUnit<Angle>(PI 807 .multiply(RADIAN.multiply(2)))); 808// public static final Unit<Angle> CIRCLE = addUnit(new ProductUnit<Angle>(PI 809// .multiply(RADIAN).multiply(2))); 810 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 811 public static final Unit<SolidAngle> SPHERE = addUnit(new ProductUnit<SolidAngle>( 812 PI.multiply(STERADIAN.multiply(4)))); 813// public static final Unit<SolidAngle> SPHERE = addUnit(new ProductUnit<SolidAngle>( 814// PI.multiply(STERADIAN).multiply(4))); 815 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 816 public static final Unit<Mass> CARAT_METRIC = addUnit(GRAM.divide(5)); 817 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 818 public static final Unit<Dimensionless> CARAT_GOLD = addUnit(ONE 819 .divide(24)); 820 821 // ////////////////////////////////////////////// 822 // INFORMATION TECHNOLOGY UNITS: UCUM 4.6 §45 // 823 // ////////////////////////////////////////////// 824 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 825 public static final Unit<Information> BIT = addUnit(NonSI.BIT); 826 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 827 public static final Unit<Information> BYTE = addUnit(NonSI.BIT.multiply(8)); 828 /** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */ 829 public static final Unit<InformationRate> BAUD = addUnit(NonSI.BITS_PER_SECOND); 830 831 // ///////////////////// 832 // MISSING FROM UCUM // 833 // ///////////////////// 834 835 /** 836 * To be added to the <a href="http://unitsofmeasure.org/">UCUM</a> 837 * standard. 838 * @deprecated so far not in UCUM 839 */ 840 public static final Unit<Frequency> FRAMES_PER_SECOND = addUnit( 841 ONE.divide(SECOND)).asType(Frequency.class); 842 843 // /////////////////// 844 // Collection View // 845 // /////////////////// 846 847 @Override 848 public String getName() { 849 return "UCUM"; 850 } 851 852 private static <U extends Unit<Q>, Q extends Quantity<Q>> U addUnit(U unit) { 853 INSTANCE.units.add(unit); 854 return unit; 855 } 856 857 /** 858 * Adds a new unit and maps it to the specified quantity type. 859 * 860 * @param unit 861 * the unit being added. 862 * @param type 863 * the quantity type. 864 * @return <code>unit</code>. 865 */ 866 private static <U extends AbstractUnit<?>> U addUnit(U unit, 867 Class<? extends Quantity<?>> type) { 868 INSTANCE.units.add(unit); 869 INSTANCE.quantityToUnit.put(type, unit); 870 return unit; 871 } 872 873 // ////////////////////////////////////////////////////////////////////////// 874 // Label adjustments for UCUM system 875 static { 876 SimpleUnitFormat.getInstance().label(ATOMIC_MASS_UNIT, "AMU"); 877 SimpleUnitFormat.getInstance().label(LITER, "l"); 878 SimpleUnitFormat.getInstance().label(OUNCE, "oz"); 879 SimpleUnitFormat.getInstance().label(POUND, "lb"); 880 } 881}