001: /*
002: * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
003: * Copyright (C) 2006 - JScience (http://jscience.org/)
004: * All rights reserved.
005: *
006: * Permission to use, copy, modify, and distribute this software is
007: * freely granted, provided that this notice is preserved.
008: */
009: package javax.measure.unit;
010:
011: import java.util.Collections;
012: import java.util.HashSet;
013: import java.util.Set;
014:
015: import javax.measure.converter.MultiplyConverter;
016: import javax.measure.converter.RationalConverter;
017: import javax.measure.quantity.*;
018:
019: /**
020: * <p> This class contains SI (Système International d'Unités) base units,
021: * and derived units.</p>
022: *
023: * <p> It also defines the 20 SI prefixes used to form decimal multiples and
024: * submultiples of SI units. For example:[code]
025: * import static org.jscience.physics.units.SI.*; // Static import.
026: * ...
027: * Unit<Pressure> HECTO_PASCAL = HECTO(PASCAL);
028: * Unit<Length> KILO_METER = KILO(METER);
029: * [/code]</p>
030: *
031: * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
032: * @version 4.2, August 26, 2006
033: * @see <a href="http://en.wikipedia.org/wiki/SI">Wikipedia: SI</a>
034: * @see <a href="http://en.wikipedia.org/wiki/SI_prefix">Wikipedia: SI prefix</a>
035: */
036: public final class SI extends SystemOfUnits {
037:
038: /**
039: * Holds collection of SI units.
040: */
041: private static HashSet<Unit<?>> UNITS = new HashSet<Unit<?>>();
042:
043: /**
044: * Default constructor (prevents this class from being instantiated).
045: */
046: private SI() {
047: }
048:
049: /**
050: * Returns the unique instance of this class.
051: *
052: * @return the SI instance.
053: */
054: public static SI getInstance() {
055: return INSTANCE;
056: }
057:
058: private static final SI INSTANCE = new SI();
059:
060: ////////////////
061: // BASE UNITS //
062: ////////////////
063:
064: /**
065: * The base unit for electric current quantities (<code>A</code>).
066: * The Ampere is that constant current which, if maintained in two straight
067: * parallel conductors of infinite length, of negligible circular
068: * cross-section, and placed 1 metre apart in vacuum, would produce between
069: * these conductors a force equal to 2 × 10-7 newton per metre of length.
070: * It is named after the French physicist Andre Ampere (1775-1836).
071: */
072: public static final BaseUnit<ElectricCurrent> AMPERE = si(new BaseUnit<ElectricCurrent>(
073: "A"));
074:
075: /**
076: * The base unit for luminous intensity quantities (<code>cd</code>).
077: * The candela is the luminous intensity, in a given direction,
078: * of a source that emits monochromatic radiation of frequency
079: * 540 × 1012 hertz and that has a radiant intensity in that
080: * direction of 1/683 watt per steradian
081: * @see <a href="http://en.wikipedia.org/wiki/Candela">
082: * Wikipedia: Candela</a>
083: */
084: public static final BaseUnit<LuminousIntensity> CANDELA = si(new BaseUnit<LuminousIntensity>(
085: "cd"));
086:
087: /**
088: * The base unit for thermodynamic temperature quantities (<code>K</code>).
089: * The kelvin is the 1/273.16th of the thermodynamic temperature of the
090: * triple point of water. It is named after the Scottish mathematician and
091: * physicist William Thomson 1st Lord Kelvin (1824-1907)
092: */
093: public static final BaseUnit<Temperature> KELVIN = si(new BaseUnit<Temperature>(
094: "K"));
095:
096: /**
097: * The base unit for mass quantities (<code>kg</code>).
098: * It is the only SI unit with a prefix as part of its name and symbol.
099: * The kilogram is equal to the mass of an international prototype in the
100: * form of a platinum-iridium cylinder kept at Sevres in France.
101: * @see #GRAM
102: */
103: public static final BaseUnit<Mass> KILOGRAM = si(new BaseUnit<Mass>(
104: "kg"));
105:
106: /**
107: * The base unit for length quantities (<code>m</code>).
108: * One meter was redefined in 1983 as the distance traveled by light in
109: * a vacuum in 1/299,792,458 of a second.
110: */
111: public static final BaseUnit<Length> METRE = si(new BaseUnit<Length>(
112: "m"));
113:
114: /**
115: * Equivalent to {@link #METRE} (American spelling).
116: */
117: public static final Unit<Length> METER = METRE;
118:
119: /**
120: * The base unit for amount of substance quantities (<code>mol</code>).
121: * The mole is the amount of substance of a system which contains as many
122: * elementary entities as there are atoms in 0.012 kilogram of carbon 12.
123: */
124: public static final BaseUnit<AmountOfSubstance> MOLE = si(new BaseUnit<AmountOfSubstance>(
125: "mol"));
126:
127: /**
128: * The base unit for duration quantities (<code>s</code>).
129: * It is defined as the duration of 9,192,631,770 cycles of radiation
130: * corresponding to the transition between two hyperfine levels of
131: * the ground state of cesium (1967 Standard).
132: */
133: public static final BaseUnit<Duration> SECOND = si(new BaseUnit<Duration>(
134: "s"));
135:
136: ////////////////////////////////
137: // SI DERIVED ALTERNATE UNITS //
138: ////////////////////////////////
139:
140: /**
141: * The derived unit for mass quantities (<code>g</code>).
142: * The base unit for mass quantity is {@link #KILOGRAM}.
143: */
144: public static final Unit<Mass> GRAM = KILOGRAM.divide(1000);
145:
146: /**
147: * The unit for plane angle quantities (<code>rad</code>).
148: * One radian is the angle between two radii of a circle such that the
149: * length of the arc between them is equal to the radius.
150: */
151: public static final AlternateUnit<Angle> RADIAN = si(new AlternateUnit<Angle>(
152: "rad", Unit.ONE));
153:
154: /**
155: * The unit for solid angle quantities (<code>sr</code>).
156: * One steradian is the solid angle subtended at the center of a sphere by
157: * an area on the surface of the sphere that is equal to the radius squared.
158: * The total solid angle of a sphere is 4*Pi steradians.
159: */
160: public static final AlternateUnit<SolidAngle> STERADIAN = si(new AlternateUnit<SolidAngle>(
161: "sr", Unit.ONE));
162:
163: /**
164: * The unit for binary information (<code>bit</code>).
165: */
166: public static final AlternateUnit<DataAmount> BIT = si(new AlternateUnit<DataAmount>(
167: "bit", Unit.ONE));
168:
169: /**
170: * The derived unit for frequency (<code>Hz</code>).
171: * A unit of frequency equal to one cycle per second.
172: * After Heinrich Rudolf Hertz (1857-1894), German physicist who was the
173: * first to produce radio waves artificially.
174: */
175: public static final AlternateUnit<Frequency> HERTZ = si(new AlternateUnit<Frequency>(
176: "Hz", Unit.ONE.divide(SECOND)));
177:
178: /**
179: * The derived unit for force (<code>N</code>).
180: * One newton is the force required to give a mass of 1 kilogram an Force
181: * of 1 metre per second per second. It is named after the English
182: * mathematician and physicist Sir Isaac Newton (1642-1727).
183: */
184: public static final AlternateUnit<Force> NEWTON = si(new AlternateUnit<Force>(
185: "N", METRE.times(KILOGRAM).divide(SECOND.pow(2))));
186:
187: /**
188: * The derived unit for pressure, stress (<code>Pa</code>).
189: * One pascal is equal to one newton per square meter. It is named after
190: * the French philosopher and mathematician Blaise Pascal (1623-1662).
191: */
192: public static final AlternateUnit<Pressure> PASCAL = si(new AlternateUnit<Pressure>(
193: "Pa", NEWTON.divide(METRE.pow(2))));
194:
195: /**
196: * The derived unit for energy, work, quantity of heat (<code>J</code>).
197: * One joule is the amount of work done when an applied force of 1 newton
198: * moves through a distance of 1 metre in the direction of the force.
199: * It is named after the English physicist James Prescott Joule (1818-1889).
200: */
201: public static final AlternateUnit<Energy> JOULE = si(new AlternateUnit<Energy>(
202: "J", NEWTON.times(METRE)));
203:
204: /**
205: * The derived unit for power, radiant, flux (<code>W</code>).
206: * One watt is equal to one joule per second. It is named after the British
207: * scientist James Watt (1736-1819).
208: */
209: public static final AlternateUnit<Power> WATT = si(new AlternateUnit<Power>(
210: "W", JOULE.divide(SECOND)));
211:
212: /**
213: * The derived unit for electric charge, quantity of electricity
214: * (<code>C</code>).
215: * One Coulomb is equal to the quantity of charge transferred in one second
216: * by a steady current of one ampere. It is named after the French physicist
217: * Charles Augustin de Coulomb (1736-1806).
218: */
219: public static final AlternateUnit<ElectricCharge> COULOMB = si(new AlternateUnit<ElectricCharge>(
220: "C", SECOND.times(AMPERE)));
221:
222: /**
223: * The derived unit for electric potential difference, electromotive force
224: * (<code>V</code>).
225: * One Volt is equal to the difference of electric potential between two
226: * points on a conducting wire carrying a constant current of one ampere
227: * when the power dissipated between the points is one watt. It is named
228: * after the Italian physicist Count Alessandro Volta (1745-1827).
229: */
230: public static final AlternateUnit<ElectricPotential> VOLT = si(new AlternateUnit<ElectricPotential>(
231: "V", WATT.divide(AMPERE)));
232:
233: /**
234: * The derived unit for capacitance (<code>F</code>).
235: * One Farad is equal to the capacitance of a capacitor having an equal
236: * and opposite charge of 1 coulomb on each plate and a potential difference
237: * of 1 volt between the plates. It is named after the British physicist
238: * and chemist Michael Faraday (1791-1867).
239: */
240: public static final AlternateUnit<ElectricCapacitance> FARAD = si(new AlternateUnit<ElectricCapacitance>(
241: "F", COULOMB.divide(VOLT)));
242:
243: /**
244: * The derived unit for electric resistance (<code>Ω</code> or
245: * <code>Ohm</code>).
246: * One Ohm is equal to the resistance of a conductor in which a current of
247: * one ampere is produced by a potential of one volt across its terminals.
248: * It is named after the German physicist Georg Simon Ohm (1789-1854).
249: */
250: public static final AlternateUnit<ElectricResistance> OHM = si(new AlternateUnit<ElectricResistance>(
251: "Ω", VOLT.divide(AMPERE)));
252:
253: /**
254: * The derived unit for electric conductance (<code>S</code>).
255: * One Siemens is equal to one ampere per volt. It is named after
256: * the German engineer Ernst Werner von Siemens (1816-1892).
257: */
258: public static final AlternateUnit<ElectricConductance> SIEMENS = si(new AlternateUnit<ElectricConductance>(
259: "S", AMPERE.divide(VOLT)));
260:
261: /**
262: * The derived unit for magnetic flux (<code>Wb</code>).
263: * One Weber is equal to the magnetic flux that in linking a circuit of one
264: * turn produces in it an electromotive force of one volt as it is uniformly
265: * reduced to zero within one second. It is named after the German physicist
266: * Wilhelm Eduard Weber (1804-1891).
267: */
268: public static final AlternateUnit<MagneticFlux> WEBER = si(new AlternateUnit<MagneticFlux>(
269: "Wb", VOLT.times(SECOND)));
270:
271: /**
272: * The derived unit for magnetic flux density (<code>T</code>).
273: * One Tesla is equal equal to one weber per square meter. It is named
274: * after the Serbian-born American electrical engineer and physicist
275: * Nikola Tesla (1856-1943).
276: */
277: public static final AlternateUnit<MagneticFluxDensity> TESLA = si(new AlternateUnit<MagneticFluxDensity>(
278: "T", WEBER.divide(METRE.pow(2))));
279:
280: /**
281: * The derived unit for inductance (<code>H</code>).
282: * One Henry is equal to the inductance for which an induced electromotive
283: * force of one volt is produced when the current is varied at the rate of
284: * one ampere per second. It is named after the American physicist
285: * Joseph Henry (1791-1878).
286: */
287: public static final AlternateUnit<ElectricInductance> HENRY = si(new AlternateUnit<ElectricInductance>(
288: "H", WEBER.divide(AMPERE)));
289:
290: /**
291: * The derived unit for Celsius temperature (<code>℃</code>).
292: * This is a unit of temperature such as the freezing point of water
293: * (at one atmosphere of pressure) is 0 ℃, while the boiling point is
294: * 100 ℃.
295: */
296: public static final Unit<Temperature> CELSIUS = si(KELVIN
297: .plus(273.15));
298:
299: /**
300: * The derived unit for luminous flux (<code>lm</code>).
301: * One Lumen is equal to the amount of light given out through a solid angle
302: * by a source of one candela intensity radiating equally in all directions.
303: */
304: public static final AlternateUnit<LuminousFlux> LUMEN = si(new AlternateUnit<LuminousFlux>(
305: "lm", CANDELA.times(STERADIAN)));
306:
307: /**
308: * The derived unit for illuminance (<code>lx</code>).
309: * One Lux is equal to one lumen per square meter.
310: */
311: public static final AlternateUnit<Illuminance> LUX = si(new AlternateUnit<Illuminance>(
312: "lx", LUMEN.divide(METRE.pow(2))));
313:
314: /**
315: * The derived unit for activity of a radionuclide (<code>Bq</code>).
316: * One becquerel is the radiation caused by one disintegration per second.
317: * It is named after the French physicist, Antoine-Henri Becquerel
318: * (1852-1908).
319: */
320: public static final AlternateUnit<RadioactiveActivity> BECQUEREL = si(new AlternateUnit<RadioactiveActivity>(
321: "Bq", Unit.ONE.divide(SECOND)));
322:
323: /**
324: * The derived unit for absorbed dose, specific energy (imparted), kerma
325: * (<code>Gy</code>).
326: * One gray is equal to the dose of one joule of energy absorbed per one
327: * kilogram of matter. It is named after the British physician
328: * L. H. Gray (1905-1965).
329: */
330: public static final AlternateUnit<RadiationDoseAbsorbed> GRAY = si(new AlternateUnit<RadiationDoseAbsorbed>(
331: "Gy", JOULE.divide(KILOGRAM)));
332:
333: /**
334: * The derived unit for dose equivalent (<code>Sv</code>).
335: * One Sievert is equal is equal to the actual dose, in grays, multiplied
336: * by a "quality factor" which is larger for more dangerous forms of
337: * radiation. It is named after the Swedish physicist Rolf Sievert
338: * (1898-1966).
339: */
340: public static final AlternateUnit<RadiationDoseEffective> SIEVERT = si(new AlternateUnit<RadiationDoseEffective>(
341: "Sv", JOULE.divide(KILOGRAM)));
342:
343: /**
344: * The derived unit for catalytic activity (<code>kat</code>).
345: */
346: public static final AlternateUnit<CatalyticActivity> KATAL = si(new AlternateUnit<CatalyticActivity>(
347: "kat", MOLE.divide(SECOND)));
348:
349: //////////////////////////////
350: // SI DERIVED PRODUCT UNITS //
351: //////////////////////////////
352:
353: /**
354: * The metric unit for velocity quantities (<code>m/s</code>).
355: */
356: public static final Unit<Velocity> METRES_PER_SECOND = si(new ProductUnit<Velocity>(
357: METRE.divide(SECOND)));
358:
359: /**
360: * Equivalent to {@link #METRES_PER_SECOND}.
361: */
362: public static final Unit<Velocity> METERS_PER_SECOND = METRES_PER_SECOND;
363:
364: /**
365: * The metric unit for acceleration quantities (<code>m/s²</code>).
366: */
367: public static final Unit<Acceleration> METRES_PER_SQUARE_SECOND = si(new ProductUnit<Acceleration>(
368: METRES_PER_SECOND.divide(SECOND)));
369:
370: /**
371: * Equivalent to {@link #METRES_PER_SQUARE_SECOND}.
372: */
373: public static final Unit<Acceleration> METERS_PER_SQUARE_SECOND = METRES_PER_SQUARE_SECOND;
374:
375: /**
376: * The metric unit for area quantities (<code>m²</code>).
377: */
378: public static final Unit<Area> SQUARE_METRE = si(new ProductUnit<Area>(
379: METRE.times(METRE)));
380:
381: /**
382: * The metric unit for volume quantities (<code>m³</code>).
383: */
384: public static final Unit<Volume> CUBIC_METRE = si(new ProductUnit<Volume>(
385: SQUARE_METRE.times(METRE)));
386:
387: /**
388: * Equivalent to <code>KILO(METRE)</code>.
389: */
390: public static final Unit<Length> KILOMETRE = METER.times(1000);
391:
392: /**
393: * Equivalent to {@link #KILOMETRE}.
394: */
395: public static final Unit<Length> KILOMETER = KILOMETRE;
396:
397: /**
398: * Equivalent to <code>CENTI(METRE)</code>.
399: */
400: public static final Unit<Length> CENTIMETRE = METRE.divide(100);
401:
402: /**
403: * Equivalent to {@link #CENTIMETRE}.
404: */
405: public static final Unit<Length> CENTIMETER = CENTIMETRE;
406:
407: /**
408: * Equivalent to <code>MILLI(METRE)</code>.
409: */
410: public static final Unit<Length> MILLIMETRE = METRE.divide(1000);
411:
412: /**
413: * Equivalent to {@link #MILLIMETRE}.
414: */
415: public static final Unit<Length> MILLIMETER = MILLIMETRE;
416:
417: /////////////////
418: // SI PREFIXES //
419: /////////////////
420:
421: /**
422: * Returns the specified unit multiplied by the factor
423: * <code>10<sup>24</sup></code>
424: *
425: * @param unit any unit.
426: * @return <code>unit.multiply(1e24)</code>.
427: */
428: public static <Q extends Quantity> Unit<Q> YOTTA(Unit<Q> unit) {
429: return unit.transform(E24);
430: }
431:
432: /**
433: * Returns the specified unit multiplied by the factor
434: * <code>10<sup>21</sup></code>
435: *
436: * @param unit any unit.
437: * @return <code>unit.multiply(1e21)</code>.
438: */
439: public static <Q extends Quantity> Unit<Q> ZETTA(Unit<Q> unit) {
440: return unit.transform(E21);
441: }
442:
443: /**
444: * Returns the specified unit multiplied by the factor
445: * <code>10<sup>18</sup></code>
446: *
447: * @param unit any unit.
448: * @return <code>unit.multiply(1e18)</code>.
449: */
450: public static <Q extends Quantity> Unit<Q> EXA(Unit<Q> unit) {
451: return unit.transform(E18);
452: }
453:
454: /**
455: * Returns the specified unit multiplied by the factor
456: * <code>10<sup>15</sup></code>
457: *
458: * @param unit any unit.
459: * @return <code>unit.multiply(1e15)</code>.
460: */
461: public static <Q extends Quantity> Unit<Q> PETA(Unit<Q> unit) {
462: return unit.transform(E15);
463: }
464:
465: /**
466: * Returns the specified unit multiplied by the factor
467: * <code>10<sup>12</sup></code>
468: *
469: * @param unit any unit.
470: * @return <code>unit.multiply(1e12)</code>.
471: */
472: public static <Q extends Quantity> Unit<Q> TERA(Unit<Q> unit) {
473: return unit.transform(E12);
474: }
475:
476: /**
477: * Returns the specified unit multiplied by the factor
478: * <code>10<sup>9</sup></code>
479: *
480: * @param unit any unit.
481: * @return <code>unit.multiply(1e9)</code>.
482: */
483: public static <Q extends Quantity> Unit<Q> GIGA(Unit<Q> unit) {
484: return unit.transform(E9);
485: }
486:
487: /**
488: * Returns the specified unit multiplied by the factor
489: * <code>10<sup>6</sup></code>
490: *
491: * @param unit any unit.
492: * @return <code>unit.multiply(1e6)</code>.
493: */
494: public static <Q extends Quantity> Unit<Q> MEGA(Unit<Q> unit) {
495: return unit.transform(E6);
496: }
497:
498: /**
499: * Returns the specified unit multiplied by the factor
500: * <code>10<sup>3</sup></code>
501: *
502: * @param unit any unit.
503: * @return <code>unit.multiply(1e3)</code>.
504: */
505: public static <Q extends Quantity> Unit<Q> KILO(Unit<Q> unit) {
506: return unit.transform(E3);
507: }
508:
509: /**
510: * Returns the specified unit multiplied by the factor
511: * <code>10<sup>2</sup></code>
512: *
513: * @param unit any unit.
514: * @return <code>unit.multiply(1e2)</code>.
515: */
516: public static <Q extends Quantity> Unit<Q> HECTO(Unit<Q> unit) {
517: return unit.transform(E2);
518: }
519:
520: /**
521: * Returns the specified unit multiplied by the factor
522: * <code>10<sup>1</sup></code>
523: *
524: * @param unit any unit.
525: * @return <code>unit.multiply(1e1)</code>.
526: */
527: public static <Q extends Quantity> Unit<Q> DEKA(Unit<Q> unit) {
528: return unit.transform(E1);
529: }
530:
531: /**
532: * Returns the specified unit multiplied by the factor
533: * <code>10<sup>-1</sup></code>
534: *
535: * @param unit any unit.
536: * @return <code>unit.multiply(1e-1)</code>.
537: */
538: public static <Q extends Quantity> Unit<Q> DECI(Unit<Q> unit) {
539: return unit.transform(Em1);
540: }
541:
542: /**
543: * Returns the specified unit multiplied by the factor
544: * <code>10<sup>-2</sup></code>
545: *
546: * @param unit any unit.
547: * @return <code>unit.multiply(1e-2)</code>.
548: */
549: public static <Q extends Quantity> Unit<Q> CENTI(Unit<Q> unit) {
550: return unit.transform(Em2);
551: }
552:
553: /**
554: * Returns the specified unit multiplied by the factor
555: * <code>10<sup>-3</sup></code>
556: *
557: * @param unit any unit.
558: * @return <code>unit.multiply(1e-3)</code>.
559: */
560: public static <Q extends Quantity> Unit<Q> MILLI(Unit<Q> unit) {
561: return unit.transform(Em3);
562: }
563:
564: /**
565: * Returns the specified unit multiplied by the factor
566: * <code>10<sup>-6</sup></code>
567: *
568: * @param unit any unit.
569: * @return <code>unit.multiply(1e-6)</code>.
570: */
571: public static <Q extends Quantity> Unit<Q> MICRO(Unit<Q> unit) {
572: return unit.transform(Em6);
573: }
574:
575: /**
576: * Returns the specified unit multiplied by the factor
577: * <code>10<sup>-9</sup></code>
578: *
579: * @param unit any unit.
580: * @return <code>unit.multiply(1e-9)</code>.
581: */
582: public static <Q extends Quantity> Unit<Q> NANO(Unit<Q> unit) {
583: return unit.transform(Em9);
584: }
585:
586: /**
587: * Returns the specified unit multiplied by the factor
588: * <code>10<sup>-12</sup></code>
589: *
590: * @param unit any unit.
591: * @return <code>unit.multiply(1e-12)</code>.
592: */
593: public static <Q extends Quantity> Unit<Q> PICO(Unit<Q> unit) {
594: return unit.transform(Em12);
595: }
596:
597: /**
598: * Returns the specified unit multiplied by the factor
599: * <code>10<sup>-15</sup></code>
600: *
601: * @param unit any unit.
602: * @return <code>unit.multiply(1e-15)</code>.
603: */
604: public static <Q extends Quantity> Unit<Q> FEMTO(Unit<Q> unit) {
605: return unit.transform(Em15);
606: }
607:
608: /**
609: * Returns the specified unit multiplied by the factor
610: * <code>10<sup>-18</sup></code>
611: *
612: * @param unit any unit.
613: * @return <code>unit.multiply(1e-18)</code>.
614: */
615: public static <Q extends Quantity> Unit<Q> ATTO(Unit<Q> unit) {
616: return unit.transform(Em18);
617: }
618:
619: /**
620: * Returns the specified unit multiplied by the factor
621: * <code>10<sup>-21</sup></code>
622: *
623: * @param unit any unit.
624: * @return <code>unit.multiply(1e-21)</code>.
625: */
626: public static <Q extends Quantity> Unit<Q> ZEPTO(Unit<Q> unit) {
627: return unit.transform(Em21);
628: }
629:
630: /**
631: * Returns the specified unit multiplied by the factor
632: * <code>10<sup>-24</sup></code>
633: *
634: * @param unit any unit.
635: * @return <code>unit.multiply(1e-24)</code>.
636: */
637: public static <Q extends Quantity> Unit<Q> YOCTO(Unit<Q> unit) {
638: return unit.transform(Em24);
639: }
640:
641: /////////////////////
642: // Collection View //
643: /////////////////////
644:
645: /**
646: * Returns a read only view over theunits defined in this class.
647: *
648: * @return the collection of SI units.
649: */
650: public Set<Unit<?>> getUnits() {
651: return Collections.unmodifiableSet(UNITS);
652: }
653:
654: /**
655: * Adds a new unit to the collection.
656: *
657: * @param unit the unit being added.
658: * @return <code>unit</code>.
659: */
660: private static <U extends Unit<?>> U si(U unit) {
661: UNITS.add(unit);
662: return unit;
663: }
664:
665: // Holds prefix converters (optimization).
666:
667: static final MultiplyConverter E24 = new MultiplyConverter(1E24);
668:
669: static final MultiplyConverter E21 = new MultiplyConverter(1E21);
670:
671: static final RationalConverter E18 = new RationalConverter(
672: 1000000000000000000L, 1);
673:
674: static final RationalConverter E15 = new RationalConverter(
675: 1000000000000000L, 1);
676:
677: static final RationalConverter E12 = new RationalConverter(
678: 1000000000000L, 1);
679:
680: static final RationalConverter E9 = new RationalConverter(
681: 1000000000L, 1);
682:
683: static final RationalConverter E6 = new RationalConverter(1000000L,
684: 1);
685:
686: static final RationalConverter E3 = new RationalConverter(1000L, 1);
687:
688: static final RationalConverter E2 = new RationalConverter(100L, 1);
689:
690: static final RationalConverter E1 = new RationalConverter(10L, 1);
691:
692: static final RationalConverter Em1 = new RationalConverter(1, 10L);
693:
694: static final RationalConverter Em2 = new RationalConverter(1, 100L);
695:
696: static final RationalConverter Em3 = new RationalConverter(1, 1000L);
697:
698: static final RationalConverter Em6 = new RationalConverter(1,
699: 1000000L);
700:
701: static final RationalConverter Em9 = new RationalConverter(1,
702: 1000000000L);
703:
704: static final RationalConverter Em12 = new RationalConverter(1,
705: 1000000000000L);
706:
707: static final RationalConverter Em15 = new RationalConverter(1,
708: 1000000000000000L);
709:
710: static final RationalConverter Em18 = new RationalConverter(1,
711: 1000000000000000000L);
712:
713: static final MultiplyConverter Em21 = new MultiplyConverter(1E-21);
714:
715: static final MultiplyConverter Em24 = new MultiplyConverter(1E-24);
716:
717: /**
718: * @deprecated replaced by {@link #METRES_PER_SECOND}.
719: */
720: public static final Unit<Velocity> METRE_PER_SECOND = METRES_PER_SECOND;
721:
722: /**
723: * @deprecated replaced by {@link #METRES_PER_SQUARE_SECOND}.
724: */
725: public static final Unit<Acceleration> METRE_PER_SQUARE_SECOND = METRES_PER_SQUARE_SECOND;
726: }
|