ASSIGNED - bug 422300: Make all quantity amounts implement quantity type
updated to wrap ICU4J type rather than extend it.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=422300
diff --git a/bundles/org.eclipse.uomo.business/src/main/java/org/eclipse/uomo/business/money/MoneyAmount.java b/bundles/org.eclipse.uomo.business/src/main/java/org/eclipse/uomo/business/money/MoneyAmount.java
index 624bed7..56a1617 100644
--- a/bundles/org.eclipse.uomo.business/src/main/java/org/eclipse/uomo/business/money/MoneyAmount.java
+++ b/bundles/org.eclipse.uomo.business/src/main/java/org/eclipse/uomo/business/money/MoneyAmount.java
@@ -136,7 +136,7 @@
 	 */
 	public static MoneyAmount of(QuantityAmount<IMoney> amount) {
 		// MoneyAmount amountSI = amount.toSI();
-		return MoneyAmount.of(BigDecimal.valueOf(amount.getNumber()
+		return MoneyAmount.of(BigDecimal.valueOf(amount.getValue()
 				.doubleValue()), amount.unit().getSystemUnit());
 	}
 
diff --git a/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/QuantityAmount.java b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/QuantityAmount.java
index 0f5a02e..94f3dff 100644
--- a/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/QuantityAmount.java
+++ b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/QuantityAmount.java
@@ -13,6 +13,7 @@
 import java.math.BigDecimal;

 import java.math.MathContext;

 

+import org.eclipse.uomo.units.internal.MeasureAmount;

 import org.unitsofmeasurement.quantity.Dimensionless;

 import org.unitsofmeasurement.quantity.Quantity;

 import org.unitsofmeasurement.unit.IncommensurableException;

@@ -36,9 +37,11 @@
  *          Sep 2011) $ XXX rename to Amount, AbstractAmount or MeasureAmount?

  *          FIXME Bug 338334 overwrite equals()

  */

-public abstract class QuantityAmount<Q extends Quantity<Q>> extends Measure

+public abstract class QuantityAmount<Q extends Quantity<Q>>

 		implements IMeasure<Q> {

-

+	

+	private final Measure measure;

+	

 	/**

 	 * Holds a dimensionless measure of one (exact).

 	 */

@@ -99,9 +102,17 @@
 	// private double _maximum;

 

 	protected QuantityAmount(Number number, MeasureUnit unit) {

-		super(number, unit);

+		measure = MeasureAmount.of(number, unit);

 	}

 

+	/**

+	 * Returns the <b>ICU4J</b> <type>Measure</type> object.

+	 * @return the backing measure.

+	 */

+	public Measure getMeasure() {

+		return measure;

+	}

+	

 	/*

 	 * (non-Javadoc)

 	 * 

@@ -153,7 +164,7 @@
 	public Unit<Q> unit() {

 		return internalUnit();

 	}

-

+	

 	/*

 	 * (non-Javadoc)

 	 * 

@@ -176,6 +187,14 @@
 	public boolean isExact() {

 		return isExact;

 	}

+	

+	public Number getValue() {

+		return getNumber();

+	}

+	

+	public Unit<Q> getUnit() {

+		return internalUnit();

+	}

 

 	// ////////////////////

 	// Factory Creation //

@@ -203,6 +222,10 @@
 	 */

 	@SuppressWarnings("unchecked")

 	private final AbstractUnit<Q> internalUnit() {

-		return (AbstractUnit<Q>) super.getUnit();

+		return (AbstractUnit<Q>) measure.getUnit();

+	}

+	

+	protected final Number getNumber() {

+		return measure.getNumber();

 	}

 }

diff --git a/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/TimeAmount.java b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/TimeAmount.java
index 7883872..6f19a41 100644
--- a/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/TimeAmount.java
+++ b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/TimeAmount.java
@@ -97,13 +97,13 @@
 

 	public TimeAmount add(IMeasure<Time> that) {

 		return new TimeAmount(super.getNumber().doubleValue()

-				+ ((BaseAmount<Time>) that).getNumber().doubleValue(),

+				+ ((BaseAmount<Time>) that).getValue().doubleValue(),

 				that.unit());

 	}

 

 	public TimeAmount substract(IMeasure<Time> that) {

 		return new TimeAmount(super.getNumber().doubleValue()

-				- ((BaseAmount<Time>) that).getNumber().doubleValue(),

+				- ((BaseAmount<Time>) that).getValue().doubleValue(),

 				that.unit());

 	}

 	

diff --git a/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/internal/MeasureAmount.java b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/internal/MeasureAmount.java
new file mode 100644
index 0000000..8807532
--- /dev/null
+++ b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/internal/MeasureAmount.java
@@ -0,0 +1,36 @@
+/**

+ * Copyright (c) 2005, 2014, Werner Keil and others.

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *    Werner Keil - initial API and implementation

+ */

+package org.eclipse.uomo.units.internal;

+

+import com.ibm.icu.util.Measure;

+import com.ibm.icu.util.MeasureUnit;

+

+/**

+ * Wrapper for ICU4J Measure type

+ * @author Werner Keil

+ *

+ */

+public class MeasureAmount extends Measure {

+

+	protected MeasureAmount(Number number, MeasureUnit unit) {

+		super(number, unit);

+	}

+	

+	/**

+	 * Returns a new <type>MeasureAmount</type> with the given number and unit.

+	 * @param number the given number

+	 * @param unit the given unit

+	 * @return a new instance of <type>MeasureAmount</type>

+	 */

+	public static Measure of(Number number, MeasureUnit unit) {

+		return new MeasureAmount(number, unit);

+	}

+}

diff --git a/examples/units/org.eclipse.uomo.examples.units.console/src/main/java/org/eclipse/uomo/examples/units/console/HelloUnits.java b/examples/units/org.eclipse.uomo.examples.units.console/src/main/java/org/eclipse/uomo/examples/units/console/HelloUnits.java
index ae7faab..3d68c32 100644
--- a/examples/units/org.eclipse.uomo.examples.units.console/src/main/java/org/eclipse/uomo/examples/units/console/HelloUnits.java
+++ b/examples/units/org.eclipse.uomo.examples.units.console/src/main/java/org/eclipse/uomo/examples/units/console/HelloUnits.java
@@ -44,11 +44,11 @@
 		System.out.println(" " + USCustomary.FOOT);

 //		System.out.println(length.doubleValue(USCustomary.POUND)); // this won't work either.

 		UnitConverter inchConverter = lenUnit.getConverterTo(USCustomary.INCH);

-		System.out.print(inchConverter.convert(length.getNumber().doubleValue()));		

+		System.out.print(inchConverter.convert(length.getValue().doubleValue()));		

 		System.out.println(" " + USCustomary.INCH);

 		

 		@SuppressWarnings("unchecked")

-		AreaAmount area = new AreaAmount(length.getNumber().doubleValue() * length.getNumber().doubleValue(), 

+		AreaAmount area = new AreaAmount(length.getValue().doubleValue() * length.getValue().doubleValue(), 

 				(Unit<Area>) length.unit().multiply(SI.METRE));

 		System.out.println(area);

 		

diff --git a/examples/units/org.eclipse.uomo.examples.units.console/src/main/java/org/eclipse/uomo/examples/units/console/sandbox/SeismicExample.java b/examples/units/org.eclipse.uomo.examples.units.console/src/main/java/org/eclipse/uomo/examples/units/console/sandbox/SeismicExample.java
index 8550256..3f5430d 100644
--- a/examples/units/org.eclipse.uomo.examples.units.console/src/main/java/org/eclipse/uomo/examples/units/console/sandbox/SeismicExample.java
+++ b/examples/units/org.eclipse.uomo.examples.units.console/src/main/java/org/eclipse/uomo/examples/units/console/sandbox/SeismicExample.java
@@ -1,5 +1,5 @@
 /**

- * Copyright (c) 2005, 2011, Werner Keil, Ikayzo and others.

+ * Copyright (c) 2005, 2014, Werner Keil and others.

  * All rights reserved. This program and the accompanying materials

  * are made available under the terms of the Eclipse Public License v1.0

  * which accompanies this distribution, and is available at

@@ -11,8 +11,9 @@
 package org.eclipse.uomo.examples.units.console.sandbox;

 

 import org.eclipse.uomo.examples.units.types.Seismic;

+import org.eclipse.uomo.units.IMeasure;

 import org.eclipse.uomo.units.impl.quantity.EnergyAmount;

-import com.ibm.icu.util.Measure;

+import org.unitsofmeasurement.quantity.Energy;

 

 /**

  * @author Werner Keil

@@ -24,7 +25,7 @@
 	 * @param args

 	 */

 	public static void main(String[] args) {

-		Measure e = new EnergyAmount(8.3, Seismic.RICHTER_MAGNITUDE);

+		IMeasure<Energy> e = new EnergyAmount(8.3, Seismic.RICHTER_MAGNITUDE);

 		System.out.println(e);

 	}