[jscience~subversion:49] Intermediate release for Martin/GeoAPI
- From: dautelle@kenai.com
- To: commits@jscience.kenai.com
- Subject: [jscience~subversion:49] Intermediate release for Martin/GeoAPI
- Date: Sun, 11 Apr 2010 05:33:11 +0000
Project: jscience
Repository: subversion
Revision: 49
Author: dautelle
Date: 2010-04-11 05:33:04 UTC
Link:
Log Message:
------------
Intermediate release for Martin/GeoAPI
Revisions:
----------
49
Modified Paths:
---------------
jscience/src/main/java/org/unitsofmeasure/quantity/Volume.java
jscience/src/main/java/org/unitsofmeasure/quantity/Length.java
jscience/src/main/java/org/unitsofmeasure/quantity/Frequency.java
jscience/src/main/java/org/unitsofmeasure/quantity/Force.java
jscience/src/main/java/org/unitsofmeasure/quantity/Time.java
jscience/src/main/java/org/unitsofmeasure/quantity/Mass.java
jscience/src/main/java/org/unitsofmeasure/quantity/Pressure.java
jscience/src/main/java/org/unitsofmeasure/quantity/RadiationDoseEffective.java
jscience/src/main/java/org/unitsofmeasure/quantity/AmountOfSubstance.java
jscience/src/main/java/org/unitsofmeasure/quantity/ElectricResistance.java
jscience/src/main/java/org/unitsofmeasure/quantity/MagneticFlux.java
jscience/src/main/java/org/unitsofmeasure/quantity/Angle.java
jscience/src/main/java/org/unitsofmeasure/quantity/RadioactiveActivity.java
jscience/src/main/java/org/unitsofmeasure/quantity/Acceleration.java
jscience/src/main/java/org/unitsofmeasure/quantity/Temperature.java
jscience/src/main/java/org/unitsofmeasure/quantity/Power.java
jscience/src/main/java/org/unitsofmeasure/quantity/ElectricCharge.java
jscience/src/main/java/org/unitsofmeasure/quantity/Area.java
jscience/src/main/java/org/unitsofmeasure/quantity/ElectricPotential.java
jscience/src/main/java/org/unitsofmeasure/quantity/CatalyticActivity.java
jscience/src/main/java/org/unitsofmeasure/quantity/Energy.java
jscience/src/main/java/org/unitsofmeasure/quantity/ElectricInductance.java
jscience/src/main/java/org/unitsofmeasure/quantity/MagneticFluxDensity.java
jscience/src/main/java/org/unitsofmeasure/Unit.java
jscience/src/main/java/org/unitsofmeasure/quantity/DataAmount.java
jscience/src/main/java/org/unitsofmeasure/quantity/ElectricCurrent.java
jscience/src/main/java/org/unitsofmeasure/quantity/ElectricConductance.java
jscience/src/main/java/org/unitsofmeasure/quantity/SolidAngle.java
jscience/src/main/java/org/unitsofmeasure/quantity/LuminousFlux.java
jscience/src/main/java/org/unitsofmeasure/quantity/LuminousIntensity.java
jscience/src/main/java/org/unitsofmeasure/quantity/Illuminance.java
jscience/src/main/java/org/unitsofmeasure/quantity/Velocity.java
jscience/src/main/java/org/unitsofmeasure/quantity/ElectricCapacitance.java
jscience/src/main/java/org/unitsofmeasure/quantity/RadiationDoseAbsorbed.java
jscience/src/main/java/org/unitsofmeasure/quantity/MagnetomotiveForce.java
jscience/src/main/java/org/unitsofmeasure/quantity/Dimensionless.java
Added Paths:
------------
jscience/src/main/java/org/unitsofmeasure/util/NonMetric.java
jscience/src/main/java/org/unitsofmeasure/service
jscience/src/main/java/org/unitsofmeasure/util/UnitFormat.java
jscience/src/main/java/org/unitsofmeasure/util
jscience/src/main/java/org/unitsofmeasure/util/UnitFormatProvider.java
jscience/src/main/java/org/unitsofmeasure/quantity/Quantity.java
jscience/src/main/java/org/unitsofmeasure/service/UnitFormatService.java
jscience/src/main/java/org/unitsofmeasure/util/Metric.java
Diffs:
------
Index: jscience/src/main/java/org/unitsofmeasure/Measure.java
===================================================================
--- jscience/src/main/java/org/unitsofmeasure/Measure.java (revision 48)
+++ jscience/src/main/java/org/unitsofmeasure/Measure.java (revision 49)
@@ -1,48 +0,0 @@
-/*
- * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
- * Copyright (C) 2010 - JScience (http://jscience.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package org.unitsofmeasure;
-
-/**
- * <p> Represents the result of a measurement.</p>
- *
- * @param <Q> The type of the quantity.
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @author <a href="mailto:desruisseaux@users.sourceforge.net">Martin
Desruisseaux</a>
- * @author <a href="mailto:jsr275@catmedia.us">Werner Keil</a>
- * @version 1.0
- */
-public interface Measure<Q extends Quantity<Q>> {
-
-
- /**
- * Returns the magnitude or multitude value of this measure stated in its
- * {@linkplain #getUnit() unit}.
- *
- * @return the numeric value of this measure in the units returned by
{@link #getUnit()}.
- */
- Number getValue();
-
- /**
- * Returns the original unit of this measure (the one specified at
creation).
- *
- * @return the original unit of this measure.
- */
- Unit<Q> getUnit();
-
- /**
- * Returns the value of this measure as <code>double</code> stated
- * in the specified unit. This method is recommended over <code>
- *
m.getUnit().getConverterTo(unit).convert(m.getValue()).doubleValue()</code>
- *
- * @param unit the unit in which the returned value is stated.
- * @return the value of this measure when stated in the specified unit.
- */
- double doubleValue(Unit<Q> unit);
-}
Index: jscience/src/main/java/org/unitsofmeasure/Metric.java
===================================================================
--- jscience/src/main/java/org/unitsofmeasure/Metric.java (revision 48)
+++ jscience/src/main/java/org/unitsofmeasure/Metric.java (revision 49)
@@ -1,599 +0,0 @@
-/*
- * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
- * Copyright (C) 2010 - JScience (http://jscience.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package org.unitsofmeasure;
-
-import org.unitsofmeasure.quantity.Acceleration;
-import org.unitsofmeasure.quantity.AmountOfSubstance;
-import org.unitsofmeasure.quantity.Angle;
-import org.unitsofmeasure.quantity.Area;
-import org.unitsofmeasure.quantity.CatalyticActivity;
-import org.unitsofmeasure.quantity.DataAmount;
-import org.unitsofmeasure.quantity.ElectricCapacitance;
-import org.unitsofmeasure.quantity.ElectricCharge;
-import org.unitsofmeasure.quantity.ElectricConductance;
-import org.unitsofmeasure.quantity.ElectricCurrent;
-import org.unitsofmeasure.quantity.ElectricInductance;
-import org.unitsofmeasure.quantity.ElectricPotential;
-import org.unitsofmeasure.quantity.ElectricResistance;
-import org.unitsofmeasure.quantity.Energy;
-import org.unitsofmeasure.quantity.Force;
-import org.unitsofmeasure.quantity.Frequency;
-import org.unitsofmeasure.quantity.Illuminance;
-import org.unitsofmeasure.quantity.Length;
-import org.unitsofmeasure.quantity.LuminousFlux;
-import org.unitsofmeasure.quantity.LuminousIntensity;
-import org.unitsofmeasure.quantity.MagneticFlux;
-import org.unitsofmeasure.quantity.MagneticFluxDensity;
-import org.unitsofmeasure.quantity.MagnetomotiveForce;
-import org.unitsofmeasure.quantity.Mass;
-import org.unitsofmeasure.quantity.Power;
-import org.unitsofmeasure.quantity.Pressure;
-import org.unitsofmeasure.quantity.RadiationDoseAbsorbed;
-import org.unitsofmeasure.quantity.RadiationDoseEffective;
-import org.unitsofmeasure.quantity.RadioactiveActivity;
-import org.unitsofmeasure.quantity.SolidAngle;
-import org.unitsofmeasure.quantity.Temperature;
-import org.unitsofmeasure.quantity.Time;
-import org.unitsofmeasure.quantity.Velocity;
-import org.unitsofmeasure.quantity.Volume;
-
-/**
- * <p> This utility class contains metric base units and derived units
- * as specified by the "Système International d'Unités" (SI).</p>
- *
- * <p> It provides direct support for the 20 SI prefixes used in the
- * metric system (decimal multiples and submultiples of SI units).
- * For example:<pre><code>
- * import org.unitsofmeasure.quantity.*;
- * import static org.unitsofmeasure.Metric.*; // Static import.
- * ...
- * Unit<Pressure> HECTOPASCAL = HECTO(PASCAL);
- * Unit<Length> KILOMETRE = KILO(METRE);
- * </pre></code></p>
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @see <a
href="http://en.wikipedia.org/wiki/International_System_of_Units">Wikipedia:
International System of Units</a>
- * @version 1.0
- */
-public final class Metric {
-
- /**
- * Holds the UCUM unit format instance.
- */
- private static final UnitFormat UCUM = UnitFormat.getStandard();
-
- /**
- * Private constructor (utility class, cannot be instantiated).
- */
- private Metric() {
- }
-
- ////////////////
- // BASE UNITS //
- ////////////////
- /**
- * The base unit for electric current quantities (<code>A</code>).
- * The Ampere is that constant current which, if maintained in two
straight
- * parallel conductors of infinite length, of negligible circular
- * cross-section, and placed 1 meter apart in vacuum, would produce
between
- * these conductors a force equal to 2 * 10-7 newton per meter of length.
- * It is named after the French physicist Andre Ampere (1775-1836).
- */
- public static final Unit<ElectricCurrent> AMPERE =
UCUM.parse("A").asType(ElectricCurrent.class);
-
- /**
- * The base unit for luminous intensity quantities (<code>cd</code>).
- * The candela is the luminous intensity, in a given direction,
- * of a source that emits monochromatic radiation of frequency
- * 540 * 1012 hertz and that has a radiant intensity in that
- * direction of 1/683 watt per steradian
- * @see <a href="http://en.wikipedia.org/wiki/Candela">
- * Wikipedia: Candela</a>
- */
- public static final Unit<LuminousIntensity> CANDELA =
UCUM.parse("cd").asType(LuminousIntensity.class);
-
- /**
- * The base unit for thermodynamic temperature quantities
(<code>K</code>).
- * The kelvin is the 1/273.16th of the thermodynamic temperature of the
- * triple point of water. It is named after the Scottish mathematician
and
- * physicist William Thomson 1st Lord Kelvin (1824-1907)
- */
- public static final Unit<Temperature> KELVIN =
UCUM.parse("K").asType(Temperature.class);
-
- /**
- * The base unit for mass quantities (<code>kg</code>).
- * It is the only SI unit with a prefix as part of its name and symbol.
- * The kilogram is equal to the mass of an international prototype in the
- * form of a platinum-iridium cylinder kept at Sevres in France.
- * @see #GRAM
- */
- public static final Unit<Mass> KILOGRAM =
UCUM.parse("Kg").asType(Mass.class);
-
- /**
- * The base unit for length quantities (<code>m</code>).
- * One metre was redefined in 1983 as the distance traveled by light in
- * a vacuum in 1/299,792,458 of a second.
- */
- public static final Unit<Length> METRE =
UCUM.parse("m").asType(Length.class);
-
- /**
- * The base unit for amount of substance quantities (<code>mol</code>).
- * The mole is the amount of substance of a system which contains as many
- * elementary entities as there are atoms in 0.012 kilogram of carbon 12.
- */
- public static final Unit<AmountOfSubstance> MOLE =
UCUM.parse("mol").asType(AmountOfSubstance.class);
-
- /**
- * The base unit for duration quantities (<code>s</code>).
- * It is defined as the duration of 9,192,631,770 cycles of radiation
- * corresponding to the transition between two hyperfine levels of
- * the ground state of cesium (1967 Standard).
- */
- public static final Unit<Time> SECOND =
UCUM.parse("s").asType(Time.class);
-
- ////////////////////////////////
- // SI DERIVED ALTERNATE UNITS //
- ////////////////////////////////
-
- /**
- * The unit for magnetomotive force (<code>At</code>).
- */
- public static final Unit<MagnetomotiveForce> AMPERE_TURN =
AMPERE.alternate("At").asType(MagnetomotiveForce.class);
-
- /**
- * The derived unit for mass quantities (<code>g</code>).
- * The base unit for mass quantity is {@link #KILOGRAM}.
- */
- public static final Unit<Mass> GRAM = KILOGRAM.divide(1000);
-
- /**
- * The unit for plane angle quantities (<code>rad</code>).
- * One radian is the angle between two radii of a circle such that the
- * length of the arc between them is equal to the radius.
- */
- public static final Unit<Angle> RADIAN =
Unit.ONE.alternate("rad").asType(Angle.class);;
-
- /**
- * The unit for solid angle quantities (<code>sr</code>).
- * One steradian is the solid angle subtended at the center of a sphere
by
- * an area on the surface of the sphere that is equal to the radius
squared.
- * The total solid angle of a sphere is 4*Pi steradians.
- */
- public static final Unit<SolidAngle> STERADIAN =
Unit.ONE.alternate("sr").asType(SolidAngle.class);;
-
- /**
- * The unit for binary information (<code>bit</code>).
- */
- public static final Unit<DataAmount> BIT =
Unit.ONE.alternate("bit").asType(DataAmount.class);
-
- /**
- * The derived unit for frequency (<code>Hz</code>).
- * A unit of frequency equal to one cycle per second.
- * After Heinrich Rudolf Hertz (1857-1894), German physicist who was the
- * first to produce radio waves artificially.
- */
- public static final Unit<Frequency> HERTZ =
Unit.ONE.divide(SECOND).alternate("Hz").asType(Frequency.class);
-
- /**
- * The derived unit for force (<code>N</code>).
- * One newton is the force required to give a mass of 1 kilogram an Force
- * of 1 metre per second per second. It is named after the English
- * mathematician and physicist Sir Isaac Newton (1642-1727).
- */
- public static final Unit<Force> NEWTON =
METRE.multiply(KILOGRAM).divide(SECOND.pow(2)).alternate("N").asType(Force.class);
-
- /**
- * The derived unit for pressure, stress (<code>Pa</code>).
- * One pascal is equal to one newton per square meter. It is named after
- * the French philosopher and mathematician Blaise Pascal (1623-1662).
- */
- public static final Unit<Pressure> PASCAL =
NEWTON.divide(METRE.pow(2)).alternate("Pa").asType(Pressure.class);
-
- /**
- * The derived unit for energy, work, quantity of heat (<code>J</code>).
- * One joule is the amount of work done when an applied force of 1 newton
- * moves through a distance of 1 metre in the direction of the force.
- * It is named after the English physicist James Prescott Joule
(1818-1889).
- */
- public static final Unit<Energy> JOULE =
NEWTON.multiply(METRE).alternate("J").asType(Energy.class);
-
- /**
- * The derived unit for power, radiant, flux (<code>W</code>).
- * One watt is equal to one joule per second. It is named after the
British
- * scientist James Watt (1736-1819).
- */
- public static final Unit<Power> WATT =
JOULE.divide(SECOND).alternate("W").asType(Power.class);
-
- /**
- * The derived unit for electric charge, quantity of electricity
- * (<code>C</code>).
- * One Coulomb is equal to the quantity of charge transferred in one
second
- * by a steady current of one ampere. It is named after the French
physicist
- * Charles Augustin de Coulomb (1736-1806).
- */
- public static final Unit<ElectricCharge> COULOMB =
SECOND.multiply(AMPERE).alternate("C").asType(ElectricCharge.class);
-
- /**
- * The derived unit for electric potential difference, electromotive
force
- * (<code>V</code>).
- * One Volt is equal to the difference of electric potential between two
- * points on a conducting wire carrying a constant current of one ampere
- * when the power dissipated between the points is one watt. It is named
- * after the Italian physicist Count Alessandro Volta (1745-1827).
- */
- public static final Unit<ElectricPotential> VOLT =
WATT.divide(AMPERE).alternate("V").asType(ElectricPotential.class);
-
- /**
- * The derived unit for capacitance (<code>F</code>).
- * One Farad is equal to the capacitance of a capacitor having an equal
- * and opposite charge of 1 coulomb on each plate and a potential
difference
- * of 1 volt between the plates. It is named after the British physicist
- * and chemist Michael Faraday (1791-1867).
- */
- public static final Unit<ElectricCapacitance> FARAD =
COULOMB.divide(VOLT).alternate("F").asType(ElectricCapacitance.class);
-
- /**
- * The derived unit for electric resistance (<code>Ohm</code>).
- * One Ohm is equal to the resistance of a conductor in which a current
of
- * one ampere is produced by a potential of one volt across its
terminals.
- * It is named after the German physicist Georg Simon Ohm (1789-1854).
- */
- public static final Unit<ElectricResistance> OHM =
VOLT.divide(AMPERE).alternate("Ω").asType(ElectricResistance.class);
-
- /**
- * The derived unit for electric conductance (<code>S</code>).
- * One Siemens is equal to one ampere per volt. It is named after
- * the German engineer Ernst Werner von Siemens (1816-1892).
- */
- public static final Unit<ElectricConductance> SIEMENS =
AMPERE.divide(VOLT).alternate("S").asType(ElectricConductance.class);
-
- /**
- * The derived unit for magnetic flux (<code>Wb</code>).
- * One Weber is equal to the magnetic flux that in linking a circuit of
one
- * turn produces in it an electromotive force of one volt as it is
uniformly
- * reduced to zero within one second. It is named after the German
physicist
- * Wilhelm Eduard Weber (1804-1891).
- */
- public static final Unit<MagneticFlux> WEBER =
VOLT.multiply(SECOND).alternate("Wb").asType(MagneticFlux.class);
-
- /**
- * The derived unit for magnetic flux density (<code>T</code>).
- * One Tesla is equal equal to one weber per square metre. It is named
- * after the Serbian-born American electrical engineer and physicist
- * Nikola Tesla (1856-1943).
- */
- public static final Unit<MagneticFluxDensity> TESLA =
WEBER.divide(METRE.pow(2)).alternate("T").asType(MagneticFluxDensity.class);
-
- /**
- * The derived unit for inductance (<code>H</code>).
- * One Henry is equal to the inductance for which an induced
electromotive
- * force of one volt is produced when the current is varied at the rate
of
- * one ampere per second. It is named after the American physicist
- * Joseph Henry (1791-1878).
- */
- public static final Unit<ElectricInductance> HENRY =
WEBER.divide(AMPERE).alternate("H").asType(ElectricInductance.class);
-
- /**
- * The derived unit for Celsius temperature (<code>Cel</code>).
- * This is a unit of temperature such as the freezing point of water
- * (at one atmosphere of pressure) is 0 Cel, while the boiling point is
- * 100 Cel.
- */
- public static final Unit<Temperature> CELSIUS = KELVIN.add(273.15);
-
- /**
- * The derived unit for luminous flux (<code>lm</code>).
- * One Lumen is equal to the amount of light given out through a solid
angle
- * by a source of one candela intensity radiating equally in all
directions.
- */
- public static final Unit<LuminousFlux> LUMEN =
CANDELA.multiply(STERADIAN).alternate("lm").asType(LuminousFlux.class);
-
- /**
- * The derived unit for illuminance (<code>lx</code>).
- * One Lux is equal to one lumen per square metre.
- */
- public static final Unit<Illuminance> LUX =
LUMEN.divide(METRE.pow(2)).alternate("lx").asType(Illuminance.class);
-
- /**
- * The derived unit for activity of a radionuclide (<code>Bq</code>).
- * One becquerel is the radiation caused by one disintegration per
second.
- * It is named after the French physicist, Antoine-Henri Becquerel
- * (1852-1908).
- */
- public static final Unit<RadioactiveActivity> BECQUEREL =
Unit.ONE.divide(SECOND).alternate("Bq").asType(RadioactiveActivity.class);
-
- /**
- * The derived unit for absorbed dose, specific energy (imparted), kerma
- * (<code>Gy</code>).
- * One gray is equal to the dose of one joule of energy absorbed per one
- * kilogram of matter. It is named after the British physician
- * L. H. Gray (1905-1965).
- */
- public static final Unit<RadiationDoseAbsorbed> GRAY =
JOULE.divide(KILOGRAM).alternate("Gy").asType(RadiationDoseAbsorbed.class);
-
- /**
- * The derived unit for dose equivalent (<code>Sv</code>).
- * One Sievert is equal is equal to the actual dose, in grays,
multiplied
- * by a "quality factor" which is larger for more dangerous forms of
- * radiation. It is named after the Swedish physicist Rolf Sievert
- * (1898-1966).
- */
- public static final Unit<RadiationDoseEffective> SIEVERT =
JOULE.divide(KILOGRAM).alternate("Sv").asType(RadiationDoseEffective.class);
-
- /**
- * The derived unit for catalytic activity (<code>kat</code>).
- */
- public static final Unit<CatalyticActivity> KATAL =
MOLE.divide(SECOND).alternate("kat").asType(CatalyticActivity.class);
-
- //////////////////////////////
- // SI DERIVED PRODUCT UNITS //
- //////////////////////////////
-
- /**
- * The metric unit for velocity quantities (<code>m/s</code>).
- *
- */
- public static final Unit<Velocity> METRES_PER_SECOND =
METRE.divide(SECOND).asType(Velocity.class);
-
- /**
- * The metric unit for acceleration quantities (<code>m/s2</code>).
- */
- public static final Unit<Acceleration> METRES_PER_SQUARE_SECOND =
METRES_PER_SECOND.divide(SECOND).asType(Acceleration.class);
-
- /**
- * The metric unit for area quantities (<code>m2</code>).
- */
- public static final Unit<Area> SQUARE_METRE =
METRE.multiply(METRE).asType(Area.class);
-
- /**
- * The metric unit for volume quantities (<code>m3</code>).
- */
- public static final Unit<Volume> CUBIC_METRE =
SQUARE_METRE.multiply(METRE).asType(Volume.class);
-
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>24</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.multiply(1e24)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> YOTTA(Unit<Q> unit) {
- return unit.multiply(1E24);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>21</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.multiply(1e21)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> ZETTA(Unit<Q> unit) {
- return unit.multiply(1E21);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>18</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.multiply(1e18)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> EXA(Unit<Q> unit) {
- return unit.multiply(1E18);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>15</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.multiply(1e15)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> PETA(Unit<Q> unit) {
- return unit.multiply(1E15);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>12</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.multiply(1e12)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> TERA(Unit<Q> unit) {
- return unit.multiply(1E12);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>9</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.multiply(1e9)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> GIGA(Unit<Q> unit) {
- return unit.multiply(1E9);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>6</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.multiply(1e6)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> MEGA(Unit<Q> unit) {
- return unit.multiply(1E6);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>3</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.multiply(1e3)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> KILO(Unit<Q> unit) {
- return unit.multiply(1E3);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>2</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.multiply(1e2)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> HECTO(Unit<Q> unit) {
- return unit.multiply(1E2);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>1</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.multiply(1e1)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> DEKA(Unit<Q> unit) {
- return unit.multiply(1E1);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>-1</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.divide(1e1)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> DECI(Unit<Q> unit) {
- return unit.divide(1E1);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>-2</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.divide(1e2)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> CENTI(Unit<Q> unit) {
- return unit.divide(1E2);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>-3</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.divide(1e3)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> MILLI(Unit<Q> unit) {
- return unit.divide(1E3);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>-6</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.divide(1e6)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> MICRO(Unit<Q> unit) {
- return unit.divide(1E6);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>-9</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.divide(1e9)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> NANO(Unit<Q> unit) {
- return unit.divide(1E9);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>-12</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.divide(1e12)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> PICO(Unit<Q> unit) {
- return unit.divide(1E12);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>-15</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.divide(1e15)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> FEMTO(Unit<Q> unit) {
- return unit.divide(1E15);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>-18</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.divide(1e18)</code>.
- */
- public static final <Q extends Quantity<Q>> Unit<Q> ATTO(Unit<Q> unit) {
- return unit.divide(1E18);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>-21</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.divide(1e21)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> ZEPTO(Unit<Q> unit) {
- return unit.divide(1E21);
- }
-
- /**
- * Returns the specified unit multiplied by the factor
- * <code>10<sup>-24</sup></code>
- *
- * @param <Q> The type of the quantity measured by the unit.
- * @param unit any unit.
- * @return <code>unit.divide(1e24)</code>.
- */
- public static <Q extends Quantity<Q>> Unit<Q> YOCTO(Unit<Q> unit) {
- return unit.divide(1E24);
- }
-}
Index: jscience/src/main/java/org/unitsofmeasure/UnitFormatProvider.java
===================================================================
--- jscience/src/main/java/org/unitsofmeasure/UnitFormatProvider.java
(revision 48)
+++ jscience/src/main/java/org/unitsofmeasure/UnitFormatProvider.java
(revision 49)
@@ -1,55 +0,0 @@
-/*
- * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
- * Copyright (C) 2010 - JScience (http://jscience.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package org.unitsofmeasure;
-
-import java.util.Locale;
-import java.util.spi.LocaleServiceProvider;
-
-/**
- * <p> The abstract class for service providers that provide concrete
- * implementations of the {@link UnitFormat} class.</p>
- *
- * <p> An implementation of the {@link UnitFormatProvider} class should take
- * the form of a jar file which contains the file:<pre><code>
- * META-INF/services/org.unitsofmeasure.UnitFormatProvider
- * </code></pre>
- * And the file <code>org.unitsofmeasure.UnitFormatProvider</code>
- * should have a line such as:
- * <code>org.jscience.physics.unit.UnitFormatProviderImpl</code>
- * which is the fully qualified class name of the class implementing
- * {@link UnitFormatProvider}.</p>
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @version 1.0
- */
-public abstract class UnitFormatProvider extends LocaleServiceProvider {
-
- /**
- * Default constructor (for implementing class).
- */
- protected UnitFormatProvider() {
- }
-
- /**
- * Returns the standard instance (<a
href="http://org.unitsofmeasure">UCUM</a>).
- *
- * @return the "Unified Code for Units of Measure" instance (UCUM).
- */
- public abstract UnitFormat getStandardInstance();
-
- /**
- * Returns the locale sensitive instance.
- *
- * @param locale the locale for the format.
- * @return the "Unified Code for Units of Measure" instance (UCUM).
- */
- public abstract UnitFormat getLocaleInstance(Locale locale);
-
-
-}
Index: jscience/src/main/java/org/unitsofmeasure/UnitFormat.java
===================================================================
--- jscience/src/main/java/org/unitsofmeasure/UnitFormat.java (revision 48)
+++ jscience/src/main/java/org/unitsofmeasure/UnitFormat.java (revision 49)
@@ -1,194 +0,0 @@
-/*
- * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
- * Copyright (C) 2010 - JScience (http://jscience.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package org.unitsofmeasure;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.text.FieldPosition;
-import java.text.Format;
-import java.text.ParsePosition;
-import java.util.Locale;
-
-/**
- * <p> This class provides the interface for formatting and parsing {@link
- * Unit units}.</p>
- *
- * <p> The {@link #getStandard standard} instance (UCUM) recognizes all
metric
- * units and the 20 SI prefixes used to form decimal multiples and some
- * customory units (see <a href="http://org.unitsofmeasure">UCUM</a>
specification).
- * For example:<pre><code>
- * UnitFormat.getStandard().valueOf("kW").equals(SI.KILO(SI.WATT))
- *
UnitFormat.getStandard().valueOf("[ft]").equals(SI.METRE.multiply(3048).divide(10000))
- *
UnitFormat.getInstance(Locale.USA).valueOf("ft").equals(SI.METRE.multiply(3048).divide(10000))
- * [/code]</p>
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @author <a href="mailto:jsr275@catmedia.us">Werner Keil</a>
- * @author Eric Russell
- * @version 1.0
- */
-public abstract class UnitFormat extends Format {
-
- /**
- * Holds the provider instance.
- */
- private static final UnitFormatProvider PROVIDER =
- (UnitFormatProvider)
findJarServiceProvider("org.unitsofmeasure.UnitFormatProvider");
-
- /**
- * Returns the standard unit format (UCUM).
- *
- * @return the standard format.
- */
- public static UnitFormat getStandard() {
- return PROVIDER.getStandardInstance();
- }
-
- /**
- * Returns the unit format for the default locale.
- *
- * @return the locale format.
- */
- public static UnitFormat getInstance() {
- return PROVIDER.getLocaleInstance(null);
- }
-
- /**
- * Returns the unit format for the specified locale.
- *
- * @param locale the locale for which the format is returned.
- * @return the format for the specified locale.
- */
- public static UnitFormat getInstance(Locale locale) {
- return PROVIDER.getLocaleInstance(locale);
- }
-
- /**
- * Base constructor.
- */
- protected UnitFormat() {
- }
-
- /**
- * Formats the specified unit.
- *
- * @param unit the unit to format.
- * @param appendable the appendable destination.
- * @return The appendable destination passed in as {@code appendable},
- * with formatted text appended.
- * @throws IOException if an error occurs.
- */
- public abstract Appendable format(Unit<?> unit, Appendable appendable)
- throws IOException;
-
- /**
- * Parses a portion of the specified <code>CharSequence</code> from the
- * specified position to produce a unit.
- * If there is no unit to parse the unitary unit (dimensionless) is
- * returned.
- *
- * @param csq the <code>CharSequence</code> to parse.
- * @param cursor the cursor holding the current parsing index or <code>
- * null</code> to parse the whole character sequence.
- * @return the unit parsed from the specified character sub-sequence.
- * @throws IllegalArgumentException if any problem occurs while parsing
the
- * specified character sequence (e.g. illegal syntax).
- */
- public abstract Unit<?> parse(CharSequence csq, ParsePosition cursor)
- throws IllegalArgumentException;
-
- /**
- * Parses the specified character sequence to produce a unit
- * (convenience method). If the specified sequence is empty,
- * the unitary unit (dimensionless) is returned.
- *
- * @param csq the <code>CharSequence</code> to parse.
- * @return the unit parsed from the specified character sub-sequence.
- * @throws IllegalArgumentException if any problem occurs while parsing
the
- * specified character sequence (e.g. illegal syntax).
- */
- public final Unit<?> parse(CharSequence csq) throws
IllegalArgumentException {
- return parse(csq, null);
- }
-
- @Override
- public final StringBuffer format(Object obj, final StringBuffer
toAppendTo,
- FieldPosition pos) {
- if (!(obj instanceof Unit<?>))
- throw new IllegalArgumentException("obj: Not an instance of
Unit"); //$NON-NLS-1$
- if ((toAppendTo == null) || (pos == null))
- throw new NullPointerException(); // Format contract.
- try {
- return (StringBuffer) format((Unit<?>) obj, (Appendable)
toAppendTo);
- } catch (IOException ex) {
- throw new Error(ex); // Cannot happen.
- }
- }
-
- @Override
- public final Unit<?> parseObject(String source, ParsePosition pos) {
- try {
- return parse(source, pos);
- } catch (IllegalArgumentException e) {
- return null; // Unfortunately the message why the parsing failed
- } // is lost; but we have to follow the Format spec.
-
- }
-
- private static Object findJarServiceProvider(String factoryId) {
- String serviceId = "META-INF/services/" + factoryId;
- InputStream stream = null;
-
- // First try the Context ClassLoader
- ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
- if (classLoader != null) {
- stream = classLoader.getResourceAsStream(serviceId);
- }
-
- // If no provider found then try the current ClassLoader
- if (stream == null) {
- classLoader = UnitFormat.class.getClassLoader();
- stream = classLoader.getResourceAsStream(serviceId);
- }
-
- if (stream == null)
- throw new Error("No service provider found for " + factoryId);
-
-
- BufferedReader reader;
- try {
- reader = new BufferedReader(new InputStreamReader(stream,
"UTF-8"));
- } catch (java.io.UnsupportedEncodingException e) {
- reader = new BufferedReader(new InputStreamReader(stream));
- }
-
- String factoryClassName = null;
- try {
- // XXX Does not handle all possible input as specified by the
- // Jar Service Provider specification
- factoryClassName = reader.readLine();
- reader.close();
- } catch (IOException x) {
- throw new Error("Error reading service provider file for " +
factoryId);
- }
-
- if (factoryClassName != null && !"".equals(factoryClassName))
- throw new Error("No provider name is service provider file for "
+ factoryId);
-
- try {
- Class cls = classLoader.loadClass(factoryClassName);
- return cls.newInstance();
- } catch (Exception ex) {
- throw new Error(ex);
- }
- }
-
-}
Index: jscience/src/main/java/org/unitsofmeasure/Quantity.java
===================================================================
--- jscience/src/main/java/org/unitsofmeasure/Quantity.java (revision 48)
+++ jscience/src/main/java/org/unitsofmeasure/Quantity.java (revision 49)
@@ -1,38 +0,0 @@
-/*
- * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
- * Copyright (C) 2010 - JScience (http://jscience.org/)
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software is
- * freely granted, provided that this notice is preserved.
- */
-package org.unitsofmeasure;
-
-/**
- * <p> Represents a quantitative properties or attributes of thing.
- * Mass, time, distance, heat, and angular separation
- * are among the familiar examples of quantitative properties.</p>
- *
- * <p> This interface has no method (tagging interface) is used solely
- * to specify the quantitative property associated
- * to a class through class parameterization and to provide limited
- * compile time dimension consistency.[code]
- * Unit<Mass> pound = ...
- * Measure<Length> size = ...
- * Sensor<Temperature> thermometer = ...
- * Vector3D<Velocity> aircraftSpeed = ...
- * [/code] </p>
- *
- * @param <Q> The type of the quantity.
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @author <a href="mailto:desruisseaux@users.sourceforge.net">Martin
Desruisseaux</a>
- * @author <a href="mailto:jsr275@catmedia.us">Werner Keil</a>
- * @see <a href="http://en.wikipedia.org/wiki/Quantity">Wikipedia:
Quantity</a>
- * @version 1.0
- */
-public interface Quantity<Q extends Quantity<Q>> {
-
- // No method, tagging interface.
-
-}
Index: jscience/src/main/java/org/unitsofmeasure/Unit.java
===================================================================
--- jscience/src/main/java/org/unitsofmeasure/Unit.java (revision 48)
+++ jscience/src/main/java/org/unitsofmeasure/Unit.java (revision 49)
@@ -8,6 +8,8 @@
*/
package org.unitsofmeasure;
+import org.unitsofmeasure.quantity.Quantity;
+import org.unitsofmeasure.util.UnitFormat;
import java.util.Map;
import org.unitsofmeasure.quantity.Dimensionless;
@@ -44,17 +46,11 @@
* Units of measurement</a>
* @version 1.0
*/
-public interface Unit<Q extends Quantity<Q>> {
+public interface Unit<Q extends Quantity<Q>> {
- /**
- * Holds the dimensionless unit <code>ONE</code>.
- */
- public Unit<Dimensionless> ONE =
UnitFormat.getStandard().parse("").asType(Dimensionless.class);
-
/*******************/
/** Units Queries **/
/*******************/
-
/**
* Returns the symbol (if any) of this unit.
*
@@ -75,9 +71,8 @@
/**
* Returns the unscaled metric unit from which this unit is derived.
*
- * <p> Metric units are either {@link UnitFactory#getBaseUnit base
units},
- * {@link #alternate alternate units} or product of rational powers
of
- * metric units.</p>
+ * <p> Metric units are either base units, {@link #alternate alternate
+ * units} or product of rational powers of metric units.</p>
*
* <p> Because the metric unit is unique by quantity type, it can be
* be used to identify the quantity given the unit. For
example:[code]
@@ -121,7 +116,7 @@
* @throws UnsupportedOperationException if the specified type is
* not recognized.
*/
- <T extends Quantity<T>> Unit<T> asType(Class<T> type);
+ <T extends Quantity<T>> Unit<T> asType(Class<T> type);
/**
* Returns the dimension of this unit.
@@ -141,7 +136,7 @@
UnitConverter getConverterTo(Unit<Q> that) throws UnconvertibleException;
/**
- * Returns a converter form this unit to the specified unit of type
unknown.
+ * Returns a converter from this unit to the specified unit of type
unknown.
* This method can be used when the quantity type of the specified unit
* is unknown at compile-time or when dimensional analysis allows for
* conversion between units of different type.
@@ -160,7 +155,6 @@
/**********************/
/** Units Operations **/
/**********************/
-
/**
* Returns a metric unit equivalent to this unscaled metric unit but used
* in expressions to distinguish between quantities of a different nature
@@ -200,20 +194,20 @@
*
* @param offset the offset added (expressed in this unit, e.g.
* <code>CELSIUS = KELVIN.add(273.15)</code>).
- * @return <code>this.transform(new AddConverter(offset))</code>
+ * @return this unit offset by the specified value.
*/
Unit<Q> add(double offset);
/**
* Returns the result of multiplying this unit by the specified factor.
- * If the factor is an integer value, the multiplication is exact.
- * For example:<pre><code>
+ * If the factor is an integer value, the multiplication is exact
+ * (recommended). For example:<pre><code>
* FOOT = METRE.multiply(3048).divide(10000); // Exact definition.
* ELECTRON_MASS = KILOGRAM.multiply(9.10938188e-31); //
Approximation.
* </code></pre>
*
* @param factor the factor
- * @return <code>this.transform(new MultiplyConverter(factor))</code>
+ * @return this unit scaled by the specified factor.
*/
Unit<Q> multiply(double factor);
@@ -238,8 +232,8 @@
* For example:<pre><code>
* QUART = GALLON_LIQUID_US.divide(4); // Exact definition.
* </code></pre>
- * @param divisor the approximate divisor.
- * @return <code>this.transform(new MultiplyConverter(1.0 /
divisor))</code>
+ * @param divisor the divisor value.
+ * @return this unit divided by the specified divisor.
*/
Unit<Q> divide(double divisor);
@@ -267,5 +261,5 @@
* @param n the exponent.
* @return the result of raising this unit to the exponent.
*/
- Unit<?> pow(int n);
+ Unit<?> pow(int n);
}
Index:
jscience/src/main/java/org/unitsofmeasure/service/UnitFormatService.java
===================================================================
--- jscience/src/main/java/org/unitsofmeasure/service/UnitFormatService.java
(revision 0)
+++ jscience/src/main/java/org/unitsofmeasure/service/UnitFormatService.java
(revision 49)
@@ -0,0 +1,51 @@
+/*
+ * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
+ * Copyright (C) 2010 - JScience (http://jscience.org/)
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software is
+ * freely granted, provided that this notice is preserved.
+ */
+package org.unitsofmeasure.service;
+
+import java.io.IOException;
+import java.text.ParsePosition;
+import org.unitsofmeasure.Unit;
+
+/**
+ * <p> This interface provides methods for OSGi bundles to parse/format units
+ * as per the <a href="http://www.unitsofmeasure.org/">
+ * Unified Code for Units of Measure (UCUM)</a> specification.</p>
+ *
+ * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
+ * @see <a href="http://aurora.regenstrief.org/~ucum/ucum.html">UCUM Full
Specification</a>
+ * @version 1.0
+ */
+public interface UnitFormatService {
+
+ /**
+ * Formats the specified unit.
+ *
+ * @param unit the unit to format.
+ * @param appendable the appendable destination.
+ * @return the appendable destination passed in with formatted text
appended.
+ * @throws IOException if an error occurs.
+ */
+ Appendable format(Unit<?> unit, Appendable appendable)
+ throws IOException;
+
+ /**
+ * Parses a portion of the specified {@link CharSequence} from the
+ * specified position to produce a unit. If there is no unit to parse
+ * the unitary unit (dimensionless) is returned.
+ *
+ * @param csq the <code>CharSequence</code> to parse.
+ * @param cursor the cursor holding the current parsing index or <code>
+ * null</code> to parse the whole character sequence.
+ * @return the unit parsed from the specified character sub-sequence.
+ * @throws IllegalArgumentException if any problem occurs while parsing
the
+ * specified character sequence (e.g. illegal syntax).
+ */
+ Unit<?> parse(CharSequence csq, ParsePosition cursor)
+ throws IllegalArgumentException;
+}
Index: jscience/src/main/java/org/unitsofmeasure/util/Metric.java
===================================================================
--- jscience/src/main/java/org/unitsofmeasure/util/Metric.java (revision 0)
+++ jscience/src/main/java/org/unitsofmeasure/util/Metric.java (revision 49)
@@ -0,0 +1,636 @@
+/*
+ * JScience - Java(TM) Tools and Libraries for the Advancement of Sciences.
+ * Copyright (C) 2010 - JScience (http://jscience.org/)
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software is
+ * freely granted, provided that this notice is preserved.
+ */
+package org.unitsofmeasure.util;
+
+import org.unitsofmeasure.quantity.Quantity;
+import org.unitsofmeasure.Unit;
+import org.unitsofmeasure.quantity.Acceleration;
+import org.unitsofmeasure.quantity.AmountOfSubstance;
+import org.unitsofmeasure.quantity.Angle;
+import org.unitsofmeasure.quantity.Area;
+import org.unitsofmeasure.quantity.CatalyticActivity;
+import org.unitsofmeasure.quantity.DataAmount;
+import org.unitsofmeasure.quantity.Dimensionless;
+import org.unitsofmeasure.quantity.ElectricCapacitance;
+import org.unitsofmeasure.quantity.ElectricCharge;
+import org.unitsofmeasure.quantity.ElectricConductance;
+import org.unitsofmeasure.quantity.ElectricCurrent;
+import org.unitsofmeasure.quantity.ElectricInductance;
+import org.unitsofmeasure.quantity.ElectricPotential;
+import org.unitsofmeasure.quantity.ElectricResistance;
+import org.unitsofmeasure.quantity.Energy;
+import org.unitsofmeasure.quantity.Force;
+import org.unitsofmeasure.quantity.Frequency;
+import org.unitsofmeasure.quantity.Illuminance;
+import org.unitsofmeasure.quantity.Length;
+import org.unitsofmeasure.quantity.LuminousFlux;
+import org.unitsofmeasure.quantity.LuminousIntensity;
+import org.unitsofmeasure.quantity.MagneticFlux;
+import org.unitsofmeasure.quantity.MagneticFluxDensity;
+import org.unitsofmeasure.quantity.MagnetomotiveForce;
+import org.unitsofmeasure.quantity.Mass;
+import org.unitsofmeasure.quantity.Power;
+import org.unitsofmeasure.quantity.Pressure;
+import org.unitsofmeasure.quantity.RadiationDoseAbsorbed;
+import org.unitsofmeasure.quantity.RadiationDoseEffective;
+import org.unitsofmeasure.quantity.RadioactiveActivity;
+import org.unitsofmeasure.quantity.SolidAngle;
+import org.unitsofmeasure.quantity.Temperature;
+import org.unitsofmeasure.quantity.Time;
+import org.unitsofmeasure.quantity.Velocity;
+import org.unitsofmeasure.quantity.Volume;
+
+/**
+ * <p> This convenience class holds metric base units and derived units
+ * as specified by the "Système International d'Unités" (SI).</p>
+ *
+ * <p> All base units defined here are retrieved from their name using the
+ * {@link UnitFormat#getStandard() standard format} (UCUM) for units.
+ * For example:<code>METRE =
UnitFormat.getStandard().parse("m")</code></p>
+ *
+ * <p> This class provides also support for the 20 SI prefixes used in the
+ * metric system (decimal multiples and submultiples of SI units).
+ * For example:<pre><code>
+ * import org.unitsofmeasure.quantity.*;
+ * import static org.unitsofmeasure.Metric.*; // Static import.
+ * ...
+ * Unit<Pressure> HECTOPASCAL = HECTO(PASCAL);
+ * Unit<Length> KILOMETRE = KILO(METRE);
+ * </pre></code></p>
+ *
+ * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
+ * @see <a
href="http://en.wikipedia.org/wiki/International_System_of_Units">Wikipedia:
International System of Units</a>
+ * @version 1.0
+ */
+public final class Metric {
+
+ /**
+ * Holds the UCUM unit format instance.
+ */
+ private static final UnitFormat UCUM = UnitFormat.getStandard();
+
+ /**
+ * Private constructor (utility class, cannot be instantiated).
+ */
+ private Metric() {
+ }
+
+ /**
+ * Holds the dimensionless unit <code>ONE</code>.
+ */
+ public static Unit<Dimensionless> ONE =
UnitFormat.getStandard().parse("").asType(Dimensionless.class);
+
+ ////////////////
+ // BASE UNITS //
+ ////////////////
+ /**
+ * The base unit for electric current quantities (<code>A</code>).
+ * The Ampere is that constant current which, if maintained in two
straight
+ * parallel conductors of infinite length, of negligible circular
+ * cross-section, and placed 1 meter apart in vacuum, would produce
between
+ * these conductors a force equal to 2 * 10-7 newton per meter of length.
+ * It is named after the French physicist Andre Ampere (1775-1836).
+ */
+ public static final Unit<ElectricCurrent> AMPERE =
UCUM.parse("A").asType(ElectricCurrent.class);
+
+ /**
+ * The base unit for luminous intensity quantities (<code>cd</code>).
+ * The candela is the luminous intensity, in a given direction,
+ * of a source that emits monochromatic radiation of frequency
+ * 540 * 1012 hertz and that has a radiant intensity in that
+ * direction of 1/683 watt per steradian
+ * @see <a href="http://en.wikipedia.org/wiki/Candela">
+ * Wikipedia: Candela</a>
+ */
+ public static final Unit<LuminousIntensity> CANDELA =
UCUM.parse("cd").asType(LuminousIntensity.class);
+
+ /**
+ * The base unit for thermodynamic temperature quantities
(<code>K</code>).
+ * The kelvin is the 1/273.16th of the thermodynamic temperature of the
+ * triple point of water. It is named after the Scottish mathematician
and
+ * physicist William Thomson 1st Lord Kelvin (1824-1907)
+ */
+ public static final Unit<Temperature> KELVIN =
UCUM.parse("K").asType(Temperature.class);
+
+ /**
+ * The base unit for mass quantities (<code>kg</code>).
+ * It is the only SI unit with a prefix as part of its name and symbol.
+ * The kilogram is equal to the ma
[truncated due to length]
|
[jscience~subversion:49] Intermediate release for Martin/GeoAPI |
dautelle | 04/11/2010 |





