1 9 package javax.measure.units; 10 11 import java.util.Collections ; 12 import java.util.HashSet ; 13 import java.util.Set ; 14 15 import javax.measure.converters.MultiplyConverter; 16 import javax.measure.converters.RationalConverter; 17 import javax.measure.quantities.*; 18 19 39 public final class SI { 40 41 44 private static HashSet <Unit<?>> INSTANCES = new HashSet <Unit<?>>(); 45 46 49 private SI() { 50 } 51 52 56 64 public static final BaseUnit<ElectricCurrent> AMPERE = si(new BaseUnit<ElectricCurrent>( 65 "A")); 66 67 76 public static final BaseUnit<LuminousIntensity> CANDELA = si(new BaseUnit<LuminousIntensity>( 77 "cd")); 78 79 85 public static final BaseUnit<Temperature> KELVIN = si(new BaseUnit<Temperature>( 86 "K")); 87 88 95 public static final BaseUnit<Mass> KILOGRAM = si(new BaseUnit<Mass>("kg")); 96 97 102 public static final BaseUnit<Length> METER = si(new BaseUnit<Length>("m")); 103 104 109 public static final BaseUnit<AmountOfSubstance> MOLE = si(new BaseUnit<AmountOfSubstance>( 110 "mol")); 111 112 118 public static final BaseUnit<Duration> SECOND = si(new BaseUnit<Duration>( 119 "s")); 120 121 125 129 public static final Unit<Mass> GRAM = KILOGRAM.divide(1000); 130 131 136 public static final AlternateUnit<Angle> RADIAN = si(new AlternateUnit<Angle>( 137 "rad", Unit.ONE)); 138 139 145 public static final AlternateUnit<SolidAngle> STERADIAN = si(new AlternateUnit<SolidAngle>( 146 "sr", Unit.ONE)); 147 148 151 public static final AlternateUnit<DataAmount> BIT = si(new AlternateUnit<DataAmount>( 152 "bit", Unit.ONE)); 153 154 160 public static final AlternateUnit<Frequency> HERTZ = si(new AlternateUnit<Frequency>( 161 "Hz", Unit.ONE.divide(SECOND))); 162 163 169 public static final AlternateUnit<Force> NEWTON = si(new AlternateUnit<Force>( 170 "N", METER.times(KILOGRAM).divide(SECOND.pow(2)))); 171 172 177 public static final AlternateUnit<Pressure> PASCAL = si(new AlternateUnit<Pressure>( 178 "Pa", NEWTON.divide(METER.pow(2)))); 179 180 186 public static final AlternateUnit<Energy> JOULE = si(new AlternateUnit<Energy>( 187 "J", NEWTON.times(METER))); 188 189 194 public static final AlternateUnit<Power> WATT = si(new AlternateUnit<Power>( 195 "W", JOULE.divide(SECOND))); 196 197 204 public static final AlternateUnit<ElectricCharge> COULOMB = si(new AlternateUnit<ElectricCharge>( 205 "C", SECOND.times(AMPERE))); 206 207 215 public static final AlternateUnit<ElectricPotential> VOLT = si(new AlternateUnit<ElectricPotential>( 216 "V", WATT.divide(AMPERE))); 217 218 225 public static final AlternateUnit<ElectricCapacitance> FARAD = si(new AlternateUnit<ElectricCapacitance>( 226 "F", COULOMB.divide(VOLT))); 227 228 235 public static final AlternateUnit<ElectricResistance> OHM = si(new AlternateUnit<ElectricResistance>( 236 "Ω", VOLT.divide(AMPERE))); 237 238 243 public static final AlternateUnit<ElectricConductance> SIEMENS = si(new AlternateUnit<ElectricConductance>( 244 "S", AMPERE.divide(VOLT))); 245 246 253 public static final AlternateUnit<MagneticFlux> WEBER = si(new AlternateUnit<MagneticFlux>( 254 "Wb", VOLT.times(SECOND))); 255 256 262 public static final AlternateUnit<MagneticFluxDensity> TESLA = si(new AlternateUnit<MagneticFluxDensity>( 263 "T", WEBER.divide(METER.pow(2)))); 264 265 272 public static final AlternateUnit<ElectricInductance> HENRY = si(new AlternateUnit<ElectricInductance>( 273 "H", WEBER.divide(AMPERE))); 274 275 281 public static final Unit<Temperature> CELSIUS = si(KELVIN.plus(273.15)); 282 283 288 public static final AlternateUnit<LuminousFlux> LUMEN = si(new AlternateUnit<LuminousFlux>( 289 "lm", CANDELA.times(STERADIAN))); 290 291 295 public static final AlternateUnit<Illuminance> LUX = si(new AlternateUnit<Illuminance>( 296 "lx", LUMEN.divide(METER.pow(2)))); 297 298 304 public static final AlternateUnit<RadioactiveActivity> BECQUEREL = si(new AlternateUnit<RadioactiveActivity>( 305 "Bq", Unit.ONE.divide(SECOND))); 306 307 314 public static final AlternateUnit<RadiationDoseAbsorbed> GRAY = si(new AlternateUnit<RadiationDoseAbsorbed>( 315 "Gy", JOULE.divide(KILOGRAM))); 316 317 324 public static final AlternateUnit<RadiationDoseEffective> SIEVERT = si(new AlternateUnit<RadiationDoseEffective>( 325 "Sv", JOULE.divide(KILOGRAM))); 326 327 330 public static final AlternateUnit<CatalyticActivity> KATAL = si(new AlternateUnit<CatalyticActivity>( 331 "kat", MOLE.divide(SECOND))); 332 333 337 340 public static final Unit<Velocity> METER_PER_SECOND 341 = si(new ProductUnit<Velocity>(METER.divide(SECOND))); 342 343 346 public static final Unit<Acceleration> METER_PER_SQUARE_SECOND 347 = si(new ProductUnit<Acceleration>(METER_PER_SECOND.divide(SECOND))); 348 349 352 public static final Unit<Area> SQUARE_METER = 353 si(new ProductUnit<Area>(METER.times(METER))); 354 355 358 public static final Unit<Volume> CUBIC_METER 359 = si(new ProductUnit<Volume>(SQUARE_METER.times(METER))); 360 361 365 372 public static <Q extends Quantity> Unit<Q> YOTTA(Unit<Q> unit) { 373 return unit.transform(E24); 374 } 375 376 383 public static <Q extends Quantity> Unit<Q> ZETTA(Unit<Q> unit) { 384 return unit.transform(E21); 385 } 386 387 394 public static <Q extends Quantity> Unit<Q> EXA(Unit<Q> unit) { 395 return unit.transform(E18); 396 } 397 398 405 public static <Q extends Quantity> Unit<Q> PETA(Unit<Q> unit) { 406 return unit.transform(E15); 407 } 408 409 416 public static <Q extends Quantity> Unit<Q> TERA(Unit<Q> unit) { 417 return unit.transform(E12); 418 } 419 420 427 public static <Q extends Quantity> Unit<Q> GIGA(Unit<Q> unit) { 428 return unit.transform(E9); 429 } 430 431 438 public static <Q extends Quantity> Unit<Q> MEGA(Unit<Q> unit) { 439 return unit.transform(E6); 440 } 441 442 449 public static <Q extends Quantity> Unit<Q> KILO(Unit<Q> unit) { 450 return unit.transform(E3); 451 } 452 453 460 public static <Q extends Quantity> Unit<Q> HECTO(Unit<Q> unit) { 461 return unit.transform(E2); 462 } 463 464 471 public static <Q extends Quantity> Unit<Q> DEKA(Unit<Q> unit) { 472 return unit.transform(E1); 473 } 474 475 482 public static <Q extends Quantity> Unit<Q> DECI(Unit<Q> unit) { 483 return unit.transform(Em1); 484 } 485 486 493 public static <Q extends Quantity> Unit<Q> CENTI(Unit<Q> unit) { 494 return unit.transform(Em2); 495 } 496 497 504 public static <Q extends Quantity> Unit<Q> MILLI(Unit<Q> unit) { 505 return unit.transform(Em3); 506 } 507 508 515 public static <Q extends Quantity> Unit<Q> MICRO(Unit<Q> unit) { 516 return unit.transform(Em6); 517 } 518 519 526 public static <Q extends Quantity> Unit<Q> NANO(Unit<Q> unit) { 527 return unit.transform(Em9); 528 } 529 530 537 public static <Q extends Quantity> Unit<Q> PICO(Unit<Q> unit) { 538 return unit.transform(Em12); 539 } 540 541 548 public static <Q extends Quantity> Unit<Q> FEMTO(Unit<Q> unit) { 549 return unit.transform(Em15); 550 } 551 552 559 public static <Q extends Quantity> Unit<Q> ATTO(Unit<Q> unit) { 560 return unit.transform(Em18); 561 } 562 563 570 public static <Q extends Quantity> Unit<Q> ZEPTO(Unit<Q> unit) { 571 return unit.transform(Em21); 572 } 573 574 581 public static <Q extends Quantity> Unit<Q> YOCTO(Unit<Q> unit) { 582 return unit.transform(Em24); 583 } 584 585 589 594 public static Set <Unit<?>> units() { 595 return Collections.unmodifiableSet(INSTANCES); 596 } 597 598 604 private static <U extends Unit> U si(U unit) { 605 INSTANCES.add(unit); 606 return unit; 607 } 608 609 611 static final MultiplyConverter E24 = new MultiplyConverter(1E24); 612 613 static final MultiplyConverter E21 = new MultiplyConverter(1E21); 614 615 static final RationalConverter E18 = new RationalConverter( 616 1000000000000000000L, 1); 617 618 static final RationalConverter E15 = new RationalConverter( 619 1000000000000000L, 1); 620 621 static final RationalConverter E12 = new RationalConverter(1000000000000L, 622 1); 623 624 static final RationalConverter E9 = new RationalConverter(1000000000L, 1); 625 626 static final RationalConverter E6 = new RationalConverter(1000000L, 1); 627 628 static final RationalConverter E3 = new RationalConverter(1000L, 1); 629 630 static final RationalConverter E2 = new RationalConverter(100L, 1); 631 632 static final RationalConverter E1 = new RationalConverter(10L, 1); 633 634 static final RationalConverter Em1 = new RationalConverter(1, 10L); 635 636 static final RationalConverter Em2 = new RationalConverter(1, 100L); 637 638 static final RationalConverter Em3 = new RationalConverter(1, 1000L); 639 640 static final RationalConverter Em6 = new RationalConverter(1, 1000000L); 641 642 static final RationalConverter Em9 = new RationalConverter(1, 1000000000L); 643 644 static final RationalConverter Em12 = new RationalConverter(1, 645 1000000000000L); 646 647 static final RationalConverter Em15 = new RationalConverter(1, 648 1000000000000000L); 649 650 static final RationalConverter Em18 = new RationalConverter(1, 651 1000000000000000000L); 652 653 static final MultiplyConverter Em21 = new MultiplyConverter(1E-21); 654 655 static final MultiplyConverter Em24 = new MultiplyConverter(1E-24); 656 } | Popular Tags |