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.LogConverter;
016: import javax.measure.converter.RationalConverter;
017: import javax.measure.quantity.*;
018:
019: import static javax.measure.unit.SI.*;
020:
021: /**
022: * <p> This class contains units that are not part of the International
023: * System of Units, that is, they are outside the SI, but are important
024: * and widely used.</p>
025: *
026: * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
027: * @version 4.2, August 26, 2007
028: */
029: public final class NonSI extends SystemOfUnits {
030:
031: /**
032: * Holds collection of NonSI units.
033: */
034: private static HashSet<Unit<?>> UNITS = new HashSet<Unit<?>>();
035:
036: /**
037: * Holds the standard gravity constant: 9.80665 m/s² exact.
038: */
039: private static final int STANDARD_GRAVITY_DIVIDEND = 980665;
040: private static final int STANDARD_GRAVITY_DIVISOR = 100000;
041:
042: /**
043: * Holds the international foot: 0.3048 m exact.
044: */
045: private static final int INTERNATIONAL_FOOT_DIVIDEND = 3048;
046: private static final int INTERNATIONAL_FOOT_DIViSOR = 10000;
047:
048: /**
049: * Holds the avoirdupois pound: 0.45359237 kg exact
050: */
051: private static final int AVOIRDUPOIS_POUND_DIVIDEND = 45359237;
052: private static final int AVOIRDUPOIS_POUND_DIVISOR = 100000000;
053:
054: /**
055: * Holds the Avogadro constant.
056: */
057: private static final double AVOGADRO_CONSTANT = 6.02214199e23; // (1/mol).
058:
059: /**
060: * Holds the electric charge of one electron.
061: */
062: private static final double ELEMENTARY_CHARGE = 1.602176462e-19; // (C).
063:
064: /**
065: * Default constructor (prevents this class from being instantiated).
066: */
067: private NonSI() {
068: }
069:
070: /**
071: * Returns the unique instance of this class.
072: *
073: * @return the NonSI instance.
074: */
075: public static NonSI getInstance() {
076: return INSTANCE;
077: }
078:
079: private static final NonSI INSTANCE = new NonSI();
080:
081: ///////////////////
082: // Dimensionless //
083: ///////////////////
084:
085: /**
086: * A dimensionless unit equals to <code>0.01</code>
087: * (standard name <code>%</code>).
088: */
089: public static final Unit<Dimensionless> PERCENT = nonSI(Unit.ONE
090: .divide(100));
091:
092: /**
093: * A logarithmic unit used to describe a ratio
094: * (standard name <code>dB</code>).
095: */
096: public static final Unit<Dimensionless> DECIBEL = nonSI(Unit.ONE
097: .transform(new LogConverter(10).inverse().concatenate(
098: new RationalConverter(1, 10))));
099:
100: /////////////////////////
101: // Amount of substance //
102: /////////////////////////
103:
104: /**
105: * A unit of amount of substance equals to one atom
106: * (standard name <code>atom</code>).
107: */
108: public static final Unit<AmountOfSubstance> ATOM = nonSI(MOLE
109: .divide(AVOGADRO_CONSTANT));
110:
111: ////////////
112: // Length //
113: ////////////
114:
115: /**
116: * A unit of length equal to <code>0.3048 m</code>
117: * (standard name <code>ft</code>).
118: */
119: public static final Unit<Length> FOOT = nonSI(METRE.times(
120: INTERNATIONAL_FOOT_DIVIDEND).divide(
121: INTERNATIONAL_FOOT_DIViSOR));
122:
123: /**
124: * A unit of length equal to <code>1200/3937 m</code>
125: * (standard name <code>foot_survey_us</code>).
126: * See also: <a href="http://www.sizes.com/units/foot.htm">foot</a>
127: */
128: public static final Unit<Length> FOOT_SURVEY_US = nonSI(METRE
129: .times(1200).divide(3937));
130:
131: /**
132: * A unit of length equal to <code>0.9144 m</code>
133: * (standard name <code>yd</code>).
134: */
135: public static final Unit<Length> YARD = nonSI(FOOT.times(3));
136:
137: /**
138: * A unit of length equal to <code>0.0254 m</code>
139: * (standard name <code>in</code>).
140: */
141: public static final Unit<Length> INCH = nonSI(FOOT.divide(12));
142:
143: /**
144: * A unit of length equal to <code>1609.344 m</code>
145: * (standard name <code>mi</code>).
146: */
147: public static final Unit<Length> MILE = nonSI(METRE.times(1609344)
148: .divide(1000));
149:
150: /**
151: * A unit of length equal to <code>1852.0 m</code>
152: * (standard name <code>nmi</code>).
153: */
154: public static final Unit<Length> NAUTICAL_MILE = nonSI(METRE
155: .times(1852));
156:
157: /**
158: * A unit of length equal to <code>1E-10 m</code>
159: * (standard name <code>Å</code>).
160: */
161: public static final Unit<Length> ANGSTROM = nonSI(METRE
162: .divide(10000000000L));
163:
164: /**
165: * A unit of length equal to the average distance from the center of the
166: * Earth to the center of the Sun (standard name <code>ua</code>).
167: */
168: public static final Unit<Length> ASTRONOMICAL_UNIT = nonSI(METRE
169: .times(149597870691.0));
170:
171: /**
172: * A unit of length equal to the distance that light travels in one year
173: * through a vacuum (standard name <code>ly</code>).
174: */
175: public static final Unit<Length> LIGHT_YEAR = nonSI(METRE
176: .times(9.460528405e15));
177:
178: /**
179: * A unit of length equal to the distance at which a star would appear to
180: * shift its position by one arcsecond over the course the time
181: * (about 3 months) in which the Earth moves a distance of
182: * {@link #ASTRONOMICAL_UNIT} in the direction perpendicular to the
183: * direction to the star (standard name <code>pc</code>).
184: */
185: public static final Unit<Length> PARSEC = nonSI(METRE
186: .times(30856770e9));
187:
188: /**
189: * A unit of length equal to <code>0.013837 {@link #INCH}</code> exactly
190: * (standard name <code>pt</code>).
191: * @see #PIXEL
192: */
193: public static final Unit<Length> POINT = nonSI(INCH.times(13837)
194: .divide(1000000));
195:
196: /**
197: * A unit of length equal to <code>1/72 {@link #INCH}</code>
198: * (standard name <code>pixel</code>).
199: * It is the American point rounded to an even 1/72 inch.
200: * @see #POINT
201: */
202: public static final Unit<Length> PIXEL = nonSI(INCH.divide(72));
203:
204: /**
205: * Equivalent {@link #PIXEL}
206: */
207: public static final Unit<Length> COMPUTER_POINT = PIXEL;
208:
209: //////////////
210: // Duration //
211: //////////////
212:
213: /**
214: * A unit of duration equal to <code>60 s</code>
215: * (standard name <code>min</code>).
216: */
217: public static final Unit<Duration> MINUTE = nonSI(SI.SECOND
218: .times(60));
219:
220: /**
221: * A unit of duration equal to <code>60 {@link #MINUTE}</code>
222: * (standard name <code>h</code>).
223: */
224: public static final Unit<Duration> HOUR = nonSI(MINUTE.times(60));
225:
226: /**
227: * A unit of duration equal to <code>24 {@link #HOUR}</code>
228: * (standard name <code>d</code>).
229: */
230: public static final Unit<Duration> DAY = nonSI(HOUR.times(24));
231:
232: /**
233: * A unit of duration equal to <code>7 {@link #DAY}</code>
234: * (standard name <code>week</code>).
235: */
236: public static final Unit<Duration> WEEK = nonSI(DAY.times(7));
237:
238: /**
239: * A unit of duration equal to 365 days, 5 hours, 49 minutes,
240: * and 12 seconds (standard name <code>year</code>).
241: */
242: public static final Unit<Duration> YEAR = nonSI(SECOND
243: .times(31556952));
244:
245: /**
246: * A unit of duration equal to one twelfth of a year
247: * (standard name <code>month</code>).
248: */
249: public static final Unit<Duration> MONTH = nonSI(YEAR.divide(12));
250:
251: /**
252: * A unit of duration equal to the time required for a complete rotation of
253: * the earth in reference to any star or to the vernal equinox at the
254: * meridian, equal to 23 hours, 56 minutes, 4.09 seconds
255: * (standard name <code>day_sidereal</code>).
256: */
257: public static final Unit<Duration> DAY_SIDEREAL = nonSI(SECOND
258: .times(86164.09));
259:
260: /**
261: * A unit of duration equal to one complete revolution of the
262: * earth about the sun, relative to the fixed stars, or 365 days, 6 hours,
263: * 9 minutes, 9.54 seconds (standard name <code>year_sidereal</code>).
264: */
265: public static final Unit<Duration> YEAR_SIDEREAL = nonSI(SECOND
266: .times(31558149.54));
267:
268: /**
269: * A unit of duration equal to <code>365 {@link #DAY}</code>
270: * (standard name <code>year_calendar</code>).
271: */
272: public static final Unit<Duration> YEAR_CALENDAR = nonSI(DAY
273: .times(365));
274:
275: //////////
276: // Mass //
277: //////////
278:
279: /**
280: * A unit of mass equal to 1/12 the mass of the carbon-12 atom
281: * (standard name <code>u</code>).
282: */
283: public static final Unit<Mass> ATOMIC_MASS = nonSI(KILOGRAM
284: .times(1e-3 / AVOGADRO_CONSTANT));
285:
286: /**
287: * A unit of mass equal to the mass of the electron
288: * (standard name <code>me</code>).
289: */
290: public static final Unit<Mass> ELECTRON_MASS = nonSI(KILOGRAM
291: .times(9.10938188e-31));
292:
293: /**
294: * A unit of mass equal to <code>453.59237 grams</code> (avoirdupois pound,
295: * standard name <code>lb</code>).
296: */
297: public static final Unit<Mass> POUND = nonSI(KILOGRAM.times(
298: AVOIRDUPOIS_POUND_DIVIDEND).divide(
299: AVOIRDUPOIS_POUND_DIVISOR));
300:
301: /**
302: * A unit of mass equal to <code>1 / 16 {@link #POUND}</code>
303: * (standard name <code>oz</code>).
304: */
305: public static final Unit<Mass> OUNCE = nonSI(POUND.divide(16));
306:
307: /**
308: * A unit of mass equal to <code>2000 {@link #POUND}</code> (short ton,
309: * standard name <code>ton_us</code>).
310: */
311: public static final Unit<Mass> TON_US = nonSI(POUND.times(2000));
312:
313: /**
314: * A unit of mass equal to <code>2240 {@link #POUND}</code> (long ton,
315: * standard name <code>ton_uk</code>).
316: */
317: public static final Unit<Mass> TON_UK = nonSI(POUND.times(2240));
318:
319: /**
320: * A unit of mass equal to <code>1000 kg</code> (metric ton,
321: * standard name <code>t</code>).
322: */
323: public static final Unit<Mass> METRIC_TON = nonSI(KILOGRAM
324: .times(1000));
325:
326: /////////////////////
327: // Electric charge //
328: /////////////////////
329:
330: /**
331: * A unit of electric charge equal to the charge on one electron
332: * (standard name <code>e</code>).
333: */
334: public static final Unit<ElectricCharge> E = nonSI(COULOMB
335: .times(ELEMENTARY_CHARGE));
336:
337: /**
338: * A unit of electric charge equal to equal to the product of Avogadro's
339: * number (see {@link SI#MOLE}) and the charge (1 e) on a single electron
340: * (standard name <code>Fd</code>).
341: */
342: public static final Unit<ElectricCharge> FARADAY = nonSI(COULOMB
343: .times(ELEMENTARY_CHARGE * AVOGADRO_CONSTANT)); // e/mol
344:
345: /**
346: * A unit of electric charge which exerts a force of one dyne on an equal
347: * charge at a distance of one centimeter
348: * (standard name <code>Fr</code>).
349: */
350: public static final Unit<ElectricCharge> FRANKLIN = nonSI(COULOMB
351: .times(3.3356e-10));
352:
353: /////////////////
354: // Temperature //
355: /////////////////
356:
357: /**
358: * A unit of temperature equal to <code>5/9 °K</code>
359: * (standard name <code>°R</code>).
360: */
361: public static final Unit<Temperature> RANKINE = nonSI(KELVIN.times(
362: 5).divide(9));
363:
364: /**
365: * A unit of temperature equal to degree Rankine minus
366: * <code>459.67 °R</code> (standard name <code>°F</code>).
367: * @see #RANKINE
368: */
369: public static final Unit<Temperature> FAHRENHEIT = nonSI(RANKINE
370: .plus(459.67));
371:
372: ///////////
373: // Angle //
374: ///////////
375:
376: /**
377: * A unit of angle equal to a full circle or <code>2<i>π</i>
378: * {@link SI#RADIAN}</code> (standard name <code>rev</code>).
379: */
380: public static final Unit<Angle> REVOLUTION = nonSI(RADIAN
381: .times(2.0 * Math.PI));
382:
383: /**
384: * A unit of angle equal to <code>1/360 {@link #REVOLUTION}</code>
385: * (standard name <code>°</code>).
386: */
387: public static final Unit<Angle> DEGREE_ANGLE = nonSI(REVOLUTION
388: .divide(360));
389:
390: /**
391: * A unit of angle equal to <code>1/60 {@link #DEGREE_ANGLE}</code>
392: * (standard name <code>′</code>).
393: */
394: public static final Unit<Angle> MINUTE_ANGLE = nonSI(DEGREE_ANGLE
395: .divide(60));
396:
397: /**
398: * A unit of angle equal to <code>1/60 {@link #MINUTE_ANGLE}</code>
399: * (standard name <code>"</code>).
400: */
401: public static final Unit<Angle> SECOND_ANGLE = nonSI(MINUTE_ANGLE
402: .divide(60));
403:
404: /**
405: * A unit of angle equal to <code>0.01 {@link SI#RADIAN}</code>
406: * (standard name <code>centiradian</code>).
407: */
408: public static final Unit<Angle> CENTIRADIAN = nonSI(RADIAN
409: .divide(100));
410:
411: /**
412: * A unit of angle measure equal to <code>1/400 {@link #REVOLUTION}</code>
413: * (standard name <code>grade</code>).
414: */
415: public static final Unit<Angle> GRADE = nonSI(REVOLUTION
416: .divide(400));
417:
418: //////////////
419: // Velocity //
420: //////////////
421:
422: /**
423: * A unit of velocity expressing the number of international {@link
424: * #MILE miles} per {@link #HOUR hour} (abbreviation <code>mph</code>).
425: */
426: public static final Unit<Velocity> MILES_PER_HOUR = nonSI(
427: NonSI.MILE.divide(NonSI.HOUR)).asType(Velocity.class);
428:
429: /**
430: * A unit of velocity expressing the number of {@link SI#KILOMETRE} per
431: * {@link #HOUR hour}.
432: */
433: public static final Unit<Velocity> KILOMETRES_PER_HOUR = nonSI(
434: SI.KILOMETRE.divide(NonSI.HOUR)).asType(Velocity.class);
435:
436: /**
437: * Equivalent to {@link #KILOMETRES_PER_HOUR}.
438: */
439: public static final Unit<Velocity> KILOMETERS_PER_HOUR = KILOMETRES_PER_HOUR;
440:
441: /**
442: * A unit of velocity expressing the number of {@link #NAUTICAL_MILE
443: * nautical miles} per {@link #HOUR hour} (abbreviation <code>kn</code>).
444: */
445: public static final Unit<Velocity> KNOT = nonSI(
446: NonSI.NAUTICAL_MILE.divide(NonSI.HOUR)).asType(
447: Velocity.class);
448:
449: /**
450: * A unit of velocity to express the speed of an aircraft relative to
451: * the speed of sound (standard name <code>Mach</code>).
452: */
453: public static final Unit<Velocity> MACH = nonSI(METRES_PER_SECOND
454: .times(331.6));
455:
456: /**
457: * A unit of velocity relative to the speed of light
458: * (standard name <code>c</code>).
459: */
460: public static final Unit<Velocity> C = nonSI(METRES_PER_SECOND
461: .times(299792458));
462:
463: //////////////////
464: // Acceleration //
465: //////////////////
466:
467: /**
468: * A unit of acceleration equal to the gravity at the earth's surface
469: * (standard name <code>grav</code>).
470: */
471: public static final Unit<Acceleration> G = nonSI(METRES_PER_SQUARE_SECOND
472: .times(STANDARD_GRAVITY_DIVIDEND).divide(
473: STANDARD_GRAVITY_DIVISOR));
474:
475: //////////
476: // Area //
477: //////////
478:
479: /**
480: * A unit of area equal to <code>100 m²</code>
481: * (standard name <code>a</code>).
482: */
483: public static final Unit<Area> ARE = nonSI(SQUARE_METRE.times(100));
484:
485: /**
486: * A unit of area equal to <code>100 {@link #ARE}</code>
487: * (standard name <code>ha</code>).
488: */
489: public static final Unit<Area> HECTARE = nonSI(ARE.times(100)); // Exact.
490:
491: /////////////////
492: // Data Amount //
493: /////////////////
494:
495: /**
496: * A unit of data amount equal to <code>8 {@link SI#BIT}</code>
497: * (BinarY TErm, standard name <code>byte</code>).
498: */
499: public static final Unit<DataAmount> BYTE = nonSI(BIT.times(8));
500:
501: /**
502: * Equivalent {@link #BYTE}
503: */
504: public static final Unit<DataAmount> OCTET = BYTE;
505:
506: //////////////////////
507: // Electric current //
508: //////////////////////
509:
510: /**
511: * A unit of electric charge equal to the centimeter-gram-second
512: * electromagnetic unit of magnetomotive force, equal to <code>10/4
513: * πampere-turn</code> (standard name <code>Gi</code>).
514: */
515: public static final Unit<ElectricCurrent> GILBERT = nonSI(SI.AMPERE
516: .times(10.0 / (4.0 * Math.PI)));
517:
518: ////////////
519: // Energy //
520: ////////////
521:
522: /**
523: * A unit of energy equal to <code>1E-7 J</code>
524: * (standard name <code>erg</code>).
525: */
526: public static final Unit<Energy> ERG = nonSI(JOULE.divide(10000000));
527:
528: /**
529: * A unit of energy equal to one electron-volt (standard name
530: * <code>eV</code>, also recognized <code>keV, MeV, GeV</code>).
531: */
532: public static final Unit<Energy> ELECTRON_VOLT = nonSI(JOULE
533: .times(ELEMENTARY_CHARGE));
534:
535: /////////////////
536: // Illuminance //
537: /////////////////
538:
539: /**
540: * A unit of illuminance equal to <code>1E4 Lx</code>
541: * (standard name <code>La</code>).
542: */
543: public static final Unit<Illuminance> LAMBERT = nonSI(LUX
544: .times(10000));
545:
546: ///////////////////
547: // Magnetic Flux //
548: ///////////////////
549:
550: /**
551: * A unit of magnetic flux equal <code>1E-8 Wb</code>
552: * (standard name <code>Mx</code>).
553: */
554: public static final Unit<MagneticFlux> MAXWELL = nonSI(WEBER
555: .divide(100000000));
556:
557: ///////////////////////////
558: // Magnetic Flux Density //
559: ///////////////////////////
560:
561: /**
562: * A unit of magnetic flux density equal <code>1000 A/m</code>
563: * (standard name <code>G</code>).
564: */
565: public static final Unit<MagneticFluxDensity> GAUSS = nonSI(TESLA
566: .divide(10000));
567:
568: ///////////
569: // Force //
570: ///////////
571:
572: /**
573: * A unit of force equal to <code>1E-5 N</code>
574: * (standard name <code>dyn</code>).
575: */
576: public static final Unit<Force> DYNE = nonSI(NEWTON.divide(100000));
577:
578: /**
579: * A unit of force equal to <code>9.80665 N</code>
580: * (standard name <code>kgf</code>).
581: */
582: public static final Unit<Force> KILOGRAM_FORCE = nonSI(NEWTON
583: .times(STANDARD_GRAVITY_DIVIDEND).divide(
584: STANDARD_GRAVITY_DIVISOR));
585:
586: /**
587: * A unit of force equal to <code>{@link #POUND}·{@link #G}</code>
588: * (standard name <code>lbf</code>).
589: */
590: public static final Unit<Force> POUND_FORCE = nonSI(NEWTON
591: .times(
592: 1L * AVOIRDUPOIS_POUND_DIVIDEND
593: * STANDARD_GRAVITY_DIVIDEND).divide(
594: 1L * AVOIRDUPOIS_POUND_DIVISOR
595: * STANDARD_GRAVITY_DIVISOR));
596:
597: ///////////
598: // Power //
599: ///////////
600:
601: /**
602: * A unit of power equal to the power required to raise a mass of 75
603: * kilograms at a velocity of 1 meter per second (metric,
604: * standard name <code>hp</code>).
605: */
606: public static final Unit<Power> HORSEPOWER = nonSI(WATT
607: .times(735.499));
608:
609: //////////////
610: // Pressure //
611: //////////////
612:
613: /**
614: * A unit of pressure equal to the average pressure of the Earth's
615: * atmosphere at sea level (standard name <code>atm</code>).
616: */
617: public static final Unit<Pressure> ATMOSPHERE = nonSI(PASCAL
618: .times(101325));
619:
620: /**
621: * A unit of pressure equal to <code>100 kPa</code>
622: * (standard name <code>bar</code>).
623: */
624: public static final Unit<Pressure> BAR = nonSI(PASCAL.times(100000));
625:
626: /**
627: * A unit of pressure equal to the pressure exerted at the Earth's
628: * surface by a column of mercury 1 millimeter high
629: * (standard name <code>mmHg</code>).
630: */
631: public static final Unit<Pressure> MILLIMETER_OF_MERCURY = nonSI(PASCAL
632: .times(133.322));
633:
634: /**
635: * A unit of pressure equal to the pressure exerted at the Earth's
636: * surface by a column of mercury 1 inch high
637: * (standard name <code>inHg</code>).
638: */
639: public static final Unit<Pressure> INCH_OF_MERCURY = nonSI(PASCAL
640: .times(3386.388));
641:
642: /////////////////////////////
643: // Radiation dose absorbed //
644: /////////////////////////////
645:
646: /**
647: * A unit of radiation dose absorbed equal to a dose of 0.01 joule of
648: * energy per kilogram of mass (J/kg) (standard name <code>rd</code>).
649: */
650: public static final Unit<RadiationDoseAbsorbed> RAD = nonSI(GRAY
651: .divide(100));
652:
653: /**
654: * A unit of radiation dose effective equal to <code>0.01 Sv</code>
655: * (standard name <code>rem</code>).
656: */
657: public static final Unit<RadiationDoseEffective> REM = nonSI(SIEVERT
658: .divide(100));
659:
660: //////////////////////////
661: // Radioactive activity //
662: //////////////////////////
663:
664: /**
665: * A unit of radioctive activity equal to the activity of a gram of radium
666: * (standard name <code>Ci</code>).
667: */
668: public static final Unit<RadioactiveActivity> CURIE = nonSI(BECQUEREL
669: .times(37000000000L));
670:
671: /**
672: * A unit of radioctive activity equal to 1 million radioactive
673: * disintegrations per second (standard name <code>Rd</code>).
674: */
675: public static final Unit<RadioactiveActivity> RUTHERFORD = nonSI(SI.BECQUEREL
676: .times(1000000));
677:
678: /////////////////
679: // Solid angle //
680: /////////////////
681:
682: /**
683: * A unit of solid angle equal to <code>4 <i>π</i> steradians</code>
684: * (standard name <code>sphere</code>).
685: */
686: public static final Unit<SolidAngle> SPHERE = nonSI(STERADIAN
687: .times(4.0 * Math.PI));
688:
689: ////////////
690: // Volume //
691: ////////////
692:
693: /**
694: * A unit of volume equal to one cubic decimeter (default label
695: * <code>L</code>, also recognized <code>µL, mL, cL, dL</code>).
696: */
697: public static final Unit<Volume> LITRE = nonSI(CUBIC_METRE
698: .divide(1000));
699:
700: /**
701: * Equivalent to {@link #LITRE} (American spelling).
702: */
703: public static final Unit<Volume> LITER = LITRE;
704:
705: /**
706: * A unit of volume equal to one cubic inch (<code>in³</code>).
707: */
708: public static final Unit<Volume> CUBIC_INCH = nonSI(INCH.pow(3)
709: .asType(Volume.class));
710:
711: /**
712: * A unit of volume equal to one US gallon, Liquid Unit. The U.S. liquid
713: * gallon is based on the Queen Anne or Wine gallon occupying 231 cubic
714: * inches (standard name <code>gal</code>).
715: */
716: public static final Unit<Volume> GALLON_LIQUID_US = nonSI(CUBIC_INCH
717: .times(231));
718:
719: /**
720: * A unit of volume equal to <code>1 / 128 {@link #GALLON_LIQUID_US}</code>
721: * (standard name <code>oz_fl</code>).
722: */
723: public static final Unit<Volume> OUNCE_LIQUID_US = nonSI(GALLON_LIQUID_US
724: .divide(128));
725:
726: /**
727: * A unit of volume equal to one US dry gallon.
728: * (standard name <code>gallon_dry_us</code>).
729: */
730: public static final Unit<Volume> GALLON_DRY_US = nonSI(CUBIC_INCH
731: .times(2688025).divide(10000));
732:
733: /**
734: * A unit of volume equal to <code>4.546 09 {@link #LITRE}</code>
735: * (standard name <code>gal_uk</code>).
736: */
737: public static final Unit<Volume> GALLON_UK = nonSI(LITRE.times(
738: 454609).divide(100000));
739:
740: /**
741: * A unit of volume equal to <code>1 / 160 {@link #GALLON_UK}</code>
742: * (standard name <code>oz_fl_uk</code>).
743: */
744: public static final Unit<Volume> OUNCE_LIQUID_UK = nonSI(GALLON_UK
745: .divide(160));
746:
747: ///////////////
748: // Viscosity //
749: ///////////////
750:
751: /**
752: * A unit of dynamic viscosity equal to <code>1 g/(cm·s)</code>
753: * (cgs unit).
754: */
755: @SuppressWarnings("unchecked")
756: public static final Unit<DynamicViscosity> POISE = nonSI((Unit<DynamicViscosity>) GRAM
757: .divide(CENTI(METRE).times(SECOND)));
758:
759: /**
760: * A unit of kinematic viscosity equal to <code>1 cm²/s</code>
761: * (cgs unit).
762: */
763: @SuppressWarnings("unchecked")
764: public static final Unit<KinematicViscosity> STOKE = nonSI((Unit<KinematicViscosity>) CENTI(
765: METRE).pow(2).divide(SECOND));
766:
767: ////////////
768: // Others //
769: ////////////
770:
771: /**
772: * A unit used to measure the ionizing ability of radiation
773: * (standard name <code>Roentgen</code>).
774: */
775: public static final Unit<?> ROENTGEN = nonSI(COULOMB.divide(
776: KILOGRAM).times(2.58e-4));
777:
778: /////////////////////
779: // Collection View //
780: /////////////////////
781:
782: /**
783: * Returns a read only view over the units defined in this class.
784: *
785: * @return the collection of NonSI units.
786: */
787: public Set<Unit<?>> getUnits() {
788: return Collections.unmodifiableSet(UNITS);
789: }
790:
791: /**
792: * Adds a new unit to the collection.
793: *
794: * @param unit the unit being added.
795: * @return <code>unit</code>.
796: */
797: private static <U extends Unit<?>> U nonSI(U unit) {
798: UNITS.add(unit);
799: return unit;
800: }
801:
802: }
|