sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1764677 [8/9] - in /sis/branches/JDK7: ./ application/sis-console/src/main/java/org/apache/sis/console/ core/ core/sis-feature/src/main/java/org/apache/sis/feature/builder/ core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metad...
Date Thu, 13 Oct 2016 13:50:42 GMT
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/Measure.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -17,9 +17,8 @@
 package org.apache.sis.internal.jaxb.gml;
 
 import java.net.URISyntaxException;
-import javax.measure.unit.Unit;
-import javax.measure.unit.NonSI;
-import javax.measure.quantity.Quantity;
+import javax.measure.Unit;
+import javax.measure.Quantity;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlValue;
 import javax.xml.bind.annotation.XmlAttribute;
@@ -62,7 +61,7 @@ import org.apache.sis.measure.Units;
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  *
  * @see org.apache.sis.measure.Measure
@@ -150,12 +149,9 @@ public final class Measure {
                 return DefinitionURI.PREFIX + ":uom:" + Constants.EPSG + "::" + code;
             }
         }
-        if (unit == null || unit.equals(Unit.ONE)) {
+        if (unit == null || unit.equals(Units.ONE)) {
             return "";
         }
-        if (unit.equals(NonSI.PIXEL)) {
-            return "pixel"; // TODO: maybe not the most appropriate unit.
-        }
         return Context.schema(Context.current(), "gmd", Schemas.METADATA_ROOT).append(Schemas.UOM_PATH)
                 .append("#xpointer(//*[@gml:id='").append(unit).append("'])").toString();
     }
@@ -181,7 +177,7 @@ public final class Measure {
      * @param  type The quantity for the desired unit.
      * @return A unit compatible with the given type, or {@code null} if none.
      */
-    public <Q extends Quantity> Unit<Q> getUnit(final Class<Q> type) {
+    public <Q extends Quantity<Q>> Unit<Q> getUnit(final Class<Q> type) {
         return (unit != null) ? unit.asType(type) : null;
     }
 

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/MeasureList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/MeasureList.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/MeasureList.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/MeasureList.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -23,7 +23,7 @@ import java.net.URISyntaxException;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlValue;
 import javax.xml.bind.annotation.XmlAttribute;
-import javax.measure.unit.Unit;
+import javax.measure.Unit;
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.util.ObjectConverter;
 import org.apache.sis.util.ObjectConverters;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -18,14 +18,8 @@ package org.apache.sis.internal.util;
 
 import java.util.Map;
 import java.util.HashMap;
-import java.text.Format;
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import javax.measure.unit.NonSI;
-import javax.measure.unit.SI;
-import javax.measure.unit.Unit;
-import javax.measure.unit.UnitFormat;
-import javax.measure.quantity.Quantity;
+import javax.measure.Unit;
+import javax.measure.Quantity;
 import org.apache.sis.measure.Units;
 import org.apache.sis.util.Workaround;
 
@@ -39,12 +33,7 @@ import org.apache.sis.util.Workaround;
  * @module
  */
 @Workaround(library="JSR-275", version="0.9.3")
-public final class PatchedUnitFormat extends Format {
-    /**
-     * For cross-version compatibility (even if this class is hopefully temporary).
-     */
-    private static final long serialVersionUID = -3064428584419360693L;
-
+public final class PatchedUnitFormat {
     /**
      * The symbols for some units defined by Apache SIS. We store here the symbols that we were not able
      * to set in the units created by {@link org.apache.sis.measure.SexagesimalConverter} because of
@@ -77,23 +66,9 @@ public final class PatchedUnitFormat ext
     }
 
     /**
-     * The {@link UnitFormat} to patch.
-     */
-    private final UnitFormat format;
-
-    /**
-     * {@code true} for formatting the unit names using US spelling.
-     * Example: "meter" instead of "metre".
-     */
-    public boolean isLocaleUS;
-
-    /**
-     * Creates a new {@code PatchedUnitFormat} instance wrapping the given format.
-     *
-     * @param format the format to wrap.
+     * Do not allow instantiation of this class.
      */
-    public PatchedUnitFormat(final UnitFormat format) {
-        this.format = format;
+    private PatchedUnitFormat() {
     }
 
     /**
@@ -105,11 +80,11 @@ public final class PatchedUnitFormat ext
      * @return The replacement to format, or {@code unit} if not needed.
      */
     @SuppressWarnings("unchecked")
-    public static <Q extends Quantity> Unit<Q> toFormattable(Unit<Q> unit) {
+    public static <Q extends Quantity<Q>> Unit<Q> toFormattable(Unit<Q> unit) {
         final Map<Unit<?>,String> symbols = SYMBOLS;
         if (symbols != null && symbols.containsKey(unit)) {
             assert Units.isAngular(unit);
-            unit = (Unit<Q>) NonSI.DEGREE_ANGLE;
+            unit = (Unit<Q>) Units.DEGREE;
         }
         return unit;
     }
@@ -147,48 +122,14 @@ public final class PatchedUnitFormat ext
     }
 
     /**
-     * Formats the given unit.
+     * Returns the "special-case" symbol of the given unit, or {@code null} if none.
      *
-     * @param  unit The unit to format.
-     * @param  toAppendTo where to append to unit.
-     * @param  pos Ignored.
-     * @return The given {@code toAppendTo} argument.
+     * @param  unit  the unit to format.
+     * @return the "special-case" symbol of given unit, or {@code null}.
      */
-    @Override
-    public StringBuffer format(final Object unit, final StringBuffer toAppendTo, final FieldPosition pos) {
+    @Workaround(library="JSR-275", version="0.9.3")
+    public static String getSymbol(final Object unit) {
         final Map<Unit<?>,String> symbols = SYMBOLS;
-        if (symbols != null) {
-            final String symbol = symbols.get(unit);
-            if (symbol != null) {
-                return toAppendTo.append(symbol);
-            }
-        }
-        /*
-         * Following are specific to the WKT format, which is currently the only user of this method.
-         * If we invoke this method for other purposes, then we would need to provide more control on
-         * what kind of formatting is desired.
-         */
-        if (Unit.ONE.equals(unit)) {
-            return toAppendTo.append("unity");
-        } else if (NonSI.DEGREE_ANGLE.equals(unit)) {
-            return toAppendTo.append("degree");
-        } else if (SI.METRE.equals(unit)) {
-            return toAppendTo.append(isLocaleUS ? "meter" : "metre");
-        } else if (NonSI.FOOT_SURVEY_US.equals(unit)) {
-            return toAppendTo.append("US survey foot");
-        } else if (Units.PPM.equals(unit)) {
-            return toAppendTo.append("parts per million");
-        }
-        return format.format(unit, toAppendTo, pos);
-    }
-
-    /**
-     * Delegates to the wrapped {@link UnitFormat}.
-     *
-     * @return The parsed unit, or {@code null}.
-     */
-    @Override
-    public Object parseObject(final String source, final ParsePosition pos) {
-        return format.parseObject(source, pos);
+        return (symbols != null) ? symbols.get(unit) : null;
     }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/XPaths.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/XPaths.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/XPaths.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/XPaths.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -46,9 +46,9 @@ public final class XPaths extends Static
      *       {@code "http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])"})</li>
      * </ul>
      *
-     * @param  type The object type.
-     * @param  url  The URL to parse.
-     * @return The reference, or {@code null} if none.
+     * @param  type  the object type.
+     * @param  url   the URL to parse.
+     * @return the reference, or {@code null} if none.
      */
     public static String xpointer(final String type, final String url) {
         if (type.equals("uom")) {

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -29,14 +29,14 @@ import java.text.ParsePosition;
 import java.text.NumberFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import javax.measure.unit.Unit;
-import javax.measure.unit.UnitFormat;
+import javax.measure.Unit;
 
 import org.opengis.referencing.IdentifiedObject;
 import org.apache.sis.measure.Angle;
 import org.apache.sis.measure.AngleFormat;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.RangeFormat;
+import org.apache.sis.measure.UnitFormat;
 import org.apache.sis.util.Localized;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.ArgumentChecks;
@@ -77,7 +77,7 @@ import static org.apache.sis.internal.ut
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.8
  * @module
  */
 public abstract class CompoundFormat<T> extends Format implements Localized {

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -16,9 +16,9 @@
  */
 package org.apache.sis.measure;
 
-import javax.measure.unit.Unit;
-import javax.measure.converter.UnitConverter;
-import javax.measure.converter.ConversionException;
+import javax.measure.Unit;
+import javax.measure.UnitConverter;
+import javax.measure.IncommensurableException;
 import org.apache.sis.util.Numbers;
 import org.apache.sis.util.resources.Errors;
 
@@ -243,9 +243,9 @@ public class MeasurementRange<E extends
      *
      * @param  targetUnit  the target unit, or {@code null} for keeping the unit unchanged.
      * @return the converted range, or {@code this} if no conversion is needed.
-     * @throws ConversionException if the target unit are not compatible with this {@linkplain #unit() range unit}.
+     * @throws IncommensurableException if the target unit are not compatible with this {@linkplain #unit() range unit}.
      */
-    public MeasurementRange<E> convertTo(final Unit<?> targetUnit) throws ConversionException {
+    public MeasurementRange<E> convertTo(final Unit<?> targetUnit) throws IncommensurableException {
         return convertAndCast(elementType, targetUnit);
     }
 
@@ -275,7 +275,7 @@ public class MeasurementRange<E extends
     private <N extends E> Range<N> convert(final Range<N> range) throws IllegalArgumentException {
         if (range instanceof MeasurementRange<?>) try {
             return ((MeasurementRange<N>) range).convertAndCast(range.elementType, unit);
-        } catch (ConversionException e) {
+        } catch (IncommensurableException e) {
             throw new IllegalArgumentException(Errors.format(Errors.Keys.IncompatibleUnits_2,
                     ((MeasurementRange<?>) range).unit, unit), e);
         }
@@ -298,7 +298,7 @@ public class MeasurementRange<E extends
     {
         if (range instanceof MeasurementRange<?>) try {
             return ((MeasurementRange<?>) range).convertAndCast(type, unit);
-        } catch (ConversionException e) {
+        } catch (IncommensurableException e) {
             throw new IllegalArgumentException(Errors.format(Errors.Keys.IncompatibleUnits_2,
                     ((MeasurementRange<?>) range).unit, unit), e);
         }
@@ -314,11 +314,11 @@ public class MeasurementRange<E extends
      *               {@link Integer}, {@link Long}, {@link Float} or {@link Double}.
      * @param  targetUnit the target unit, or {@code null} for no change.
      * @return the casted range, or {@code this}.
-     * @throws ConversionException if the given target unit is not compatible with the unit of this range.
+     * @throws IncommensurableException if the given target unit is not compatible with the unit of this range.
      */
     @SuppressWarnings("unchecked")
     private <N extends Number & Comparable<? super N>> MeasurementRange<N>
-            convertAndCast(final Class<N> type, Unit<?> targetUnit) throws ConversionException
+            convertAndCast(final Class<N> type, Unit<?> targetUnit) throws IncommensurableException
     {
         if (targetUnit == null || targetUnit.equals(unit)) {
             if (elementType == type) {
@@ -327,7 +327,7 @@ public class MeasurementRange<E extends
             targetUnit = unit;
         } else if (unit != null) {
             final UnitConverter converter = unit.getConverterToAny(targetUnit);
-            if (!converter.equals(UnitConverter.IDENTITY)) {
+            if (!converter.isIdentity()) {
                 boolean minInc = isMinIncluded;
                 boolean maxInc = isMaxIncluded;
                 double minimum = converter.convert(getMinDouble());

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -20,7 +20,7 @@ import java.util.Formatter;
 import java.util.Formattable;
 import java.util.FormattableFlags;
 import java.io.Serializable;
-import javax.measure.unit.Unit;
+import javax.measure.Unit;
 import org.apache.sis.internal.util.Utilities;
 import org.apache.sis.internal.util.PatchedUnitFormat;
 import org.apache.sis.util.collection.CheckedContainer;
@@ -86,7 +86,7 @@ import java.util.Objects;
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Jody Garnett (for parameterized type inspiration)
  * @since   0.3
- * @version 0.3
+ * @version 0.8
  * @module
  *
  * @see RangeFormat

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -31,8 +31,7 @@ import java.text.AttributedCharacterIter
 import java.text.FieldPosition;
 import java.text.ParseException;
 import java.text.ParsePosition;
-import javax.measure.unit.Unit;
-import javax.measure.unit.UnitFormat;
+import javax.measure.Unit;
 import org.apache.sis.util.Numbers;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.UnconvertibleObjectException;
@@ -91,7 +90,7 @@ import org.apache.sis.util.resources.Err
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  *
  * @see Range#toString()
@@ -578,7 +577,7 @@ public class RangeFormat extends Format
             }
             field = MAX_VALUE_FIELD;
         }
-        toAppendTo.appendCodePoint( // Select the char for the first condition to be true below:
+        toAppendTo.appendCodePoint(                     // Select the char for the first condition to be true below:
                 isSingleton           ? openSet :
                 range.isMinIncluded() ? openInclusive :
                 alternateForm         ? openExclusiveAlt :
@@ -594,7 +593,7 @@ public class RangeFormat extends Format
             int startPosition = toAppendTo.length();
             if (value == null) {
                 switch (field) {
-                    case MIN_VALUE_FIELD: toAppendTo.append(minusSign); // Fall through
+                    case MIN_VALUE_FIELD: toAppendTo.append(minusSign);             // Fall through
                     case MAX_VALUE_FIELD: toAppendTo.append(infinity); break;
                 }
             } else {
@@ -631,7 +630,7 @@ public class RangeFormat extends Format
                     toAppendTo.append(' ').append(separator).append(' ');
                     break;
                 }
-                case MAX_VALUE_FIELD: { // Select the char for the first condition to be true below:
+                case MAX_VALUE_FIELD: {                 // Select the char for the first condition to be true below:
                     toAppendTo.appendCodePoint(
                             isSingleton           ? closeSet :
                             range.isMaxIncluded() ? closeInclusive :

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/SexagesimalConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/SexagesimalConverter.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/SexagesimalConverter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/SexagesimalConverter.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -16,12 +16,12 @@
  */
 package org.apache.sis.measure;
 
-import java.math.BigDecimal;
-import java.math.MathContext;
-import javax.measure.unit.Unit;
-import javax.measure.unit.NonSI;
+import java.util.List;
+import java.util.Collections;
+import java.io.Serializable;
+import javax.measure.Unit;
 import javax.measure.quantity.Angle;
-import javax.measure.converter.UnitConverter;
+import javax.measure.UnitConverter;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.internal.util.PatchedUnitFormat;
@@ -47,7 +47,7 @@ import static org.apache.sis.math.MathFu
  * @version 0.6
  * @module
  */
-class SexagesimalConverter extends UnitConverter { // Intentionally not final.
+class SexagesimalConverter implements UnitConverter, Serializable {
     /**
      * Serial number for compatibility with different versions.
      */
@@ -74,7 +74,7 @@ class SexagesimalConverter extends UnitC
      * <p>This unit does not have an easily readable symbol because of the
      * <a href="http://kenai.com/jira/browse/JSR_275-41">JSR-275 bug</a>.</p>
      */
-    static final Unit<Angle> DM = NonSI.DEGREE_ANGLE.transform(
+    static final Unit<Angle> DM = Units.DEGREE.transform(
             new SexagesimalConverter(false, 100).inverse()).asType(Angle.class);//.alternate("D.M");
 
     /**
@@ -93,7 +93,7 @@ class SexagesimalConverter extends UnitC
      * <p>This unit does not have an easily readable symbol because of the
      * <a href="http://kenai.com/jira/browse/JSR_275-41">JSR-275 bug</a>.</p>
      */
-    static final Unit<Angle> DMS = NonSI.DEGREE_ANGLE.transform(
+    static final Unit<Angle> DMS = Units.DEGREE.transform(
             new SexagesimalConverter(true, 10000).inverse()).asType(Angle.class);//.alternate("D.MS");
 
     /**
@@ -113,7 +113,7 @@ class SexagesimalConverter extends UnitC
      * <p>This unit does not have an easily readable symbol because of the
      * <a href="http://kenai.com/jira/browse/JSR_275-41">JSR-275 bug</a>.</p>
      */
-    static final Unit<Angle> DMS_SCALED = NonSI.DEGREE_ANGLE.transform(
+    static final Unit<Angle> DMS_SCALED = Units.DEGREE.transform(
             new SexagesimalConverter(true, 1).inverse()).asType(Angle.class);//.alternate("DMS");
 
     /*
@@ -143,8 +143,8 @@ class SexagesimalConverter extends UnitC
     /**
      * Constructs a converter for sexagesimal units.
      *
-     * @param hasSeconds {@code true} if the seconds field is present.
-     * @param divider The value to divide DMS unit by.
+     * @param hasSeconds  {@code true} if the seconds field is present.
+     * @param divider     the value to divide DMS unit by.
      *        For "degree minute second" (EPSG code 9107), this is 1.
      *        For "sexagesimal degree" (EPSG code 9110), this is 10000.
      */
@@ -165,6 +165,31 @@ class SexagesimalConverter extends UnitC
     }
 
     /**
+     * Returns {@code false} since this converter is not an identity function.
+     */
+    @Override
+    public boolean isIdentity() {
+        return false;
+    }
+
+    /**
+     * Returns {@code false} since the conversion is non-linear.
+     */
+    @Override
+    public boolean isLinear() {
+        return false;
+    }
+
+    /**
+     * Returns a collection containing only {@code this} since this conversion is not
+     * a concatenation of other converters.
+     */
+    @Override
+    public List<? extends UnitConverter> getConversionSteps() {
+        return Collections.singletonList(this);
+    }
+
+    /**
      * Returns the inverse of this converter.
      */
     @Override
@@ -181,7 +206,7 @@ class SexagesimalConverter extends UnitC
         angle = (angle - deg) * 60;
         if (hasSeconds) {
             final double min = truncate(angle);
-            angle  = (angle - min) * 60; // Secondes
+            angle  = (angle - min) * 60;                // Secondes
             angle += (deg*100 + min)*100;
         } else {
             angle += deg * 100;
@@ -192,11 +217,19 @@ class SexagesimalConverter extends UnitC
     /**
      * Performs a conversion from fractional degrees to sexagesimal degrees.
      * This method delegates to the version working on {@code double} primitive type,
-     * so it does not provide the accuracy normally required by this method contract.
+     * so it may not provide the accuracy normally required by this method contract.
+     */
+    @Override
+    public final Number convert(final Number value) {
+        return convert(value.doubleValue());
+    }
+
+    /**
+     * @todo not yet supported.
      */
     @Override
-    public final BigDecimal convert(final BigDecimal value, final MathContext context) {
-        return new BigDecimal(convert(value.doubleValue()), context);
+    public UnitConverter concatenate(UnitConverter uc) {
+        throw new UnsupportedOperationException("Not supported yet.");
     }
 
     /**
@@ -250,7 +283,7 @@ class SexagesimalConverter extends UnitC
                 deg = truncate(min / 100);
                 min -= deg * 100;
             }
-            if (min <= -60 || min >= 60) {  // Do not enter for NaN
+            if (min <= -60 || min >= 60) {                              // Do not enter for NaN
                 if (Math.abs(Math.abs(min) - 100) <= (EPS * 100)) {
                     if (min >= 0) deg++; else deg--;
                     min = 0;
@@ -258,7 +291,7 @@ class SexagesimalConverter extends UnitC
                     throw illegalField(angle, min, Vocabulary.Keys.AngularMinutes);
                 }
             }
-            if (sec <= -60 || sec >= 60) { // Do not enter for NaN
+            if (sec <= -60 || sec >= 60) {                              // Do not enter for NaN
                 if (Math.abs(Math.abs(sec) - 100) <= (EPS * 100)) {
                     if (sec >= 0) min++; else min--;
                     sec = 0;
@@ -272,10 +305,10 @@ class SexagesimalConverter extends UnitC
         /**
          * Creates an exception for an illegal field.
          *
-         * @param  value The user-supplied angle value.
-         * @param  field The value of the illegal field.
-         * @param  unit  The vocabulary key for the field (minutes or seconds).
-         * @return The exception to throw.
+         * @param  value  the user-supplied angle value.
+         * @param  field  the value of the illegal field.
+         * @param  unit   the vocabulary key for the field (minutes or seconds).
+         * @return the exception to throw.
          */
         private static IllegalArgumentException illegalField(final double value, final double field, final short unit) {
             return new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentField_4,

Copied: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java (from r1764673, sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java?p2=sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java&p1=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java&r1=1764673&r2=1764677&rev=1764677&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -21,12 +21,12 @@ import java.text.Format;
 import java.text.FieldPosition;
 import java.text.ParsePosition;
 import java.io.IOException;
-import java.io.UncheckedIOException;
 import javax.measure.Unit;
 import javax.measure.format.ParserException;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.util.DefinitionURI;
 import org.apache.sis.internal.util.XPaths;
+import org.apache.sis.internal.jdk8.UncheckedIOException;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.Exceptions;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -16,157 +16,518 @@
  */
 package org.apache.sis.measure;
 
-import javax.measure.unit.SI;
-import javax.measure.unit.NonSI;
-import javax.measure.unit.Unit;
+import javax.measure.Unit;
+import javax.measure.UnitConverter;
+import javax.measure.format.ParserException;
+import javax.measure.Quantity;
 import javax.measure.quantity.Angle;
-import javax.measure.quantity.Length;
-import javax.measure.quantity.Duration;
+import javax.measure.quantity.Area;
 import javax.measure.quantity.Dimensionless;
-import javax.measure.quantity.Quantity;
-import javax.measure.converter.UnitConverter;
+import javax.measure.quantity.Energy;
+import javax.measure.quantity.Force;
+import javax.measure.quantity.Frequency;
+import javax.measure.quantity.Length;
+import javax.measure.quantity.Mass;
+import javax.measure.quantity.Power;
+import javax.measure.quantity.Pressure;
+import javax.measure.quantity.Speed;
+import javax.measure.quantity.Temperature;
+import javax.measure.quantity.Time;
+import javax.measure.quantity.Volume;
+
 import org.apache.sis.util.Static;
 import org.apache.sis.util.Workaround;
-import org.apache.sis.util.ArraysExt;
-import org.apache.sis.util.Exceptions;
-import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.internal.util.DefinitionURI;
 import org.apache.sis.internal.util.Constants;
-import org.apache.sis.internal.util.XPaths;
 
 import static java.lang.Math.PI;
 import static java.lang.Math.abs;
 import static org.apache.sis.measure.SexagesimalConverter.EPS;
-import static org.apache.sis.util.CharSequences.trimWhitespaces;
 
 
 /**
- * Static methods working on {@link Unit} instances, and some constants in addition to the
- * {@link SI} and {@link NonSI} ones.
+ * Provides constants for various Units of Measurement together with static methods working on {@link Unit} instances.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public final class Units extends Static {
     /**
-     * The suffixes that NetCDF files sometime put after the "degrees" unit.
-     * Suffix at even index are for axes having the standard geometric direction,
-     * while suffix at odd index are for axes having the reverse direction.
+     * The SI base unit for distances (symbol “m”).
+     *
+     * @see #NANOMETRE
+     * @see #MILLIMETRE
+     * @see #CENTIMETRE
+     * @see #KILOMETRE
+     * @see #NAUTICAL_MILE
+     * @see #FOOT
+     * @see #FOOT_SURVEY_US
+     *
+     * @since 0.8
      */
-    private static final String[] CARDINAL_DIRECTIONS = {"east", "west", "north", "south"};
+    public static final Unit<Length> METRE = tec.units.ri.unit.Units.METRE;
 
     /**
-     * Do not allows instantiation of this class.
+     * Unit of measurement defined as 10<sup>-9</sup> metres.
+     * This unit is often used in wavelength measurements.
+     *
+     * @see #METRE
+     * @see #CENTIMETRE
+     * @see #MILLIMETRE
+     *
+     * @since 0.8
      */
-    private Units() {
-    }
+    public static final Unit<Length> NANOMETRE = METRE.divide(1E9);
+
+    /**
+     * Unit of measurement defined as 0.001 metres.
+     *
+     * @see #METRE
+     * @see #NANOMETRE
+     * @see #CENTIMETRE
+     * @see #KILOMETRE
+     *
+     * @since 0.8
+     */
+    public static final Unit<Length> MILLIMETRE = METRE.divide(1000);
+
+    /**
+     * Unit of measurement defined as 0.01 metres.
+     *
+     * @see #METRE
+     * @see #NANOMETRE
+     * @see #MILLIMETRE
+     * @see #KILOMETRE
+     *
+     * @since 0.8
+     */
+    public static final Unit<Length> CENTIMETRE = METRE.divide(100);
+
+    /**
+     * Unit of measurement defined as 1000 metres.
+     *
+     * @see #METRE
+     * @see #NAUTICAL_MILE
+     *
+     * @since 0.8
+     */
+    public static final Unit<Length> KILOMETRE = METRE.multiply(1000);
+
+    /**
+     * Unit of measurement defined as 1852 metres.
+     * This is approximatively the distance between two parallels of latitude separated by one arc-minute.
+     *
+     * @see #METRE
+     * @see #KILOMETRE
+     *
+     * @since 0.8
+     */
+    public static final Unit<Length> NAUTICAL_MILE = METRE.multiply(1852);
+
+    /**
+     * Unit of measurement defined as 0.3048 metres.
+     *
+     * @see #METRE
+     * @see #FOOT_SURVEY_US
+     *
+     * @since 0.8
+     */
+    public static final Unit<Length> FOOT = METRE.multiply(0.3048);
+
+    /**
+     * Unit of measurement defined as 12/39.37 metres.
+     * This is approximatively 0.3048006096… metres.
+     *
+     * @see #METRE
+     * @see #FOOT
+     *
+     * @since 0.8
+     */
+    public static final Unit<Length> FOOT_SURVEY_US = METRE.multiply(12 / 39.37);
+
+    /**
+     * The SI unit for plane angles.
+     * There is 2π radians in a circle.
+     *
+     * @see #DEGREE
+     * @see #GRAD
+     * @see #ARC_MINUTE
+     * @see #ARC_SECOND
+     * @see #MICRORADIAN
+     *
+     * @since 0.8
+     */
+    public static final Unit<Angle> RADIAN = tec.units.ri.unit.Units.RADIAN;
+
+    /**
+     * Unit of measurement defined as π/180 radians.
+     * There is 360° in a circle.
+     *
+     * @see #RADIAN
+     * @see #ARC_MINUTE
+     * @see #ARC_SECOND
+     *
+     * @since 0.8
+     */
+    public static final Unit<Angle> DEGREE = RADIAN.multiply(Math.PI/180);
+
+    /**
+     * Unit of measurement defined as π/200 radians.
+     * There is 400 grads in a circle.
+     *
+     * @see #RADIAN
+     * @see #DEGREE
+     *
+     * @since 0.8
+     */
+    public static final Unit<Angle> GRAD = RADIAN.multiply(Math.PI/200);
+
+    /**
+     * Unit of measurement defined as 1/60 degree.
+     *
+     * @see #RADIAN
+     * @see #DEGREE
+     *
+     * @since 0.8
+     */
+    public static final Unit<Angle> ARC_MINUTE = RADIAN.multiply(Math.PI / (180*60));
+
+    /**
+     * Unit of measurement defined as 1/(60×60) degree.
+     *
+     * @see #RADIAN
+     * @see #DEGREE
+     *
+     * @since 0.8
+     */
+    public static final Unit<Angle> ARC_SECOND = RADIAN.multiply(Math.PI / (180*60*60));
+
+    /**
+     * Unit of measurement defined as 10<sup>-6</sup> radians.
+     *
+     * @see #RADIAN
+     *
+     * @since 0.8
+     */
+    public static final Unit<Angle> MICRORADIAN = RADIAN.divide(1E+6);
+
+    /**
+     * The SI base unit for durations (symbol “s”).
+     *
+     * @see #MILLISECOND
+     * @see #MINUTE
+     * @see #HOUR
+     * @see #DAY
+     * @see #WEEK
+     * @see #YEAR
+     *
+     * @since 0.8
+     */
+    public static final Unit<Time> SECOND = tec.units.ri.unit.Units.SECOND;
+
+    /**
+     * Unit of measurement defined as 10<sup>-3</sup> seconds.
+     * Useful for conversions from and to {@link java.util.Date} objects.
+     *
+     * @see #SECOND
+     */
+    public static final Unit<Time> MILLISECOND = SECOND.divide(1000);
+
+    /**
+     * Unit of measurement defined as 60 seconds.
+     *
+     * @see #SECOND
+     * @see #HOUR
+     *
+     * @since 0.8
+     */
+    public static final Unit<Time> MINUTE = tec.units.ri.unit.Units.MINUTE;
+
+    /**
+     * Unit of measurement defined as 60×60 seconds.
+     *
+     * @see #SECOND
+     * @see #MINUTE
+     *
+     * @since 0.8
+     */
+    public static final Unit<Time> HOUR = tec.units.ri.unit.Units.HOUR;
+
+    /**
+     * Unit of measurement defined as 24×60×60 seconds.
+     *
+     * @see #SECOND
+     * @see #WEEK
+     *
+     * @since 0.8
+     */
+    public static final Unit<Time> DAY = tec.units.ri.unit.Units.DAY;
 
     /**
-     * Unit for milliseconds. Useful for conversion from and to {@link java.util.Date} objects.
+     * Unit of measurement defined as 7 days.
+     *
+     * @see #SECOND
+     * @see #DAY
+     * @see #YEAR
+     *
+     * @since 0.8
      */
-    public static final Unit<Duration> MILLISECOND = SI.MetricPrefix.MILLI(SI.SECOND);
+    public static final Unit<Time> WEEK = tec.units.ri.unit.Units.WEEK;
 
     /**
      * The EPSG:1029 definition of year.
+     *
+     * @see #SECOND
+     * @see #WEEK
+     * @see #DAY
+     *
+     * @since 0.8
+     */
+    private static final Unit<Time> YEAR = SECOND.divide(31556925.445);
+
+    /**
+     * The SI unit for frequency (symbol “Hz”).
+     * A unit of frequency equal to one cycle per second.
+     *
+     * @since 0.8
+     */
+    public static final Unit<Frequency> HERTZ = tec.units.ri.unit.Units.HERTZ;
+
+    /**
+     * The SI unit for pressure (symbol “Pa”).
+     * One pascal is equal to 1 N/m².
+     * Pressures are often used in {@linkplain org.apache.sis.referencing.crs.DefaultParametricCRS parametric CRS}
+     * for height measurements.
+     *
+     * @see #HECTOPASCAL
+     *
+     * @since 0.8
+     */
+    public static final Unit<Pressure> PASCAL = tec.units.ri.unit.Units.PASCAL;
+
+    /**
+     * Unit of measurement defined as 100 pascals.
+     *
+     * @see #PASCAL
+     *
+     * @since 0.8
+     */
+    public static final Unit<Pressure> HECTOPASCAL = PASCAL.multiply(100);
+
+    /**
+     * The SI base unit for mass (symbol “kg”).
+     *
+     * @since 0.8
+     */
+    public static final Unit<Mass> KILOGRAM = tec.units.ri.unit.Units.KILOGRAM;
+
+    /**
+     * The SI unit for force (symbol “N”).
+     * One newton is the force required to give a mass of 1 kg an acceleration of 1 m/s².
+     *
+     * @since 0.8
+     */
+    public static final Unit<Force> NEWTON = tec.units.ri.unit.Units.NEWTON;
+
+    /**
+     * The SI unit for energy (symbol “J”).
+     *
+     * @since 0.8
+     */
+    public static final Unit<Energy> JOULE = tec.units.ri.unit.Units.JOULE;
+
+    /**
+     * The SI unit for power (symbol “W”).
+     * One watt is equal to one joule per second.
+     *
+     * @since 0.8
+     */
+    public static final Unit<Power> WATT = tec.units.ri.unit.Units.WATT;
+
+    /**
+     * The SI base unit for thermodynamic temperature (symbol “K”).
+     *
+     * @see #CELSIUS
+     *
+     * @since 0.8
+     */
+    public static final Unit<Temperature> KELVIN = tec.units.ri.unit.Units.KELVIN;
+
+    /**
+     * Unit of measurement defined as the temperature in Kelvin minus 273.15.
+     *
+     * @see #KELVIN
+     *
+     * @since 0.8
+     */
+    public static final Unit<Temperature> CELSIUS = tec.units.ri.unit.Units.CELSIUS;
+
+    /**
+     * Derived unit of measurement for speed (symbol “m/s”).
+     *
+     * @see #KILOMETRES_PER_HOUR
+     *
+     * @since 0.8
+     */
+    public static final Unit<Speed> METRES_PER_SECOND = tec.units.ri.unit.Units.METRES_PER_SECOND;
+
+    /**
+     * Derived unit of measurement for speed (symbol “km/h”).
+     *
+     * @see #METRES_PER_SECOND
+     *
+     * @since 0.8
+     */
+    public static final Unit<Speed> KILOMETRES_PER_HOUR = tec.units.ri.unit.Units.KILOMETRES_PER_HOUR;
+
+    /**
+     * Derived unit of measurement for area (symbol “m²”).
+     *
+     * @since 0.8
+     */
+    public static final Unit<Area> SQUARE_METRE = tec.units.ri.unit.Units.SQUARE_METRE;
+
+    /**
+     * Derived unit of measurement for area (symbol “m²”).
+     *
+     * @since 0.8
      */
-    private static final Unit<Duration> YEAR = SI.SECOND.divide(31556925.445);
+    public static final Unit<Volume> CUBIC_METRE = tec.units.ri.unit.Units.CUBIC_METRE;
 
     /**
-     * Parts per million.
+     * Dimensionless unit for scale measurements.
      *
-     * <p>This unit does not have an easily readable symbol because of the
-     * <a href="http://kenai.com/jira/browse/JSR_275-41">JSR-275 bug</a>.</p>
+     * @see #PERCENT
+     * @see #PPM
+     *
+     * @since 0.8
      */
-    public static final Unit<Dimensionless> PPM = Unit.ONE.times(1E-6);//.alternate("ppm");
+    public static final Unit<Dimensionless> ONE = tec.units.ri.AbstractUnit.ONE;
+
+    /**
+     * Dimensionless unit for percentages.
+     *
+     * @see #ONE
+     * @see #PPM
+     *
+     * @since 0.8
+     */
+    public static final Unit<Dimensionless> PERCENT = tec.units.ri.unit.Units.PERCENT;
+
+    /**
+     * Dimensionless unit for parts per million.
+     *
+     * @see #ONE
+     * @see #PERCENT
+     */
+    public static final Unit<Dimensionless> PPM = ONE.divide(1E+6);
 
     /**
      * Salinity measured using PSS-78. While this is a dimensionless measurement, the {@code "psu"} symbol
      * is sometime added to PSS-78 measurement. However this is officially discouraged.
      */
-    static final Unit<Dimensionless> PSU = Unit.ONE.alternate("psu");
+    static final Unit<Dimensionless> PSU = ONE.alternate("psu");
 
     /**
      * Sigma-level, used in oceanography. This is a way to measure a depth as a fraction of the sea floor depth.
      */
-    static final Unit<Dimensionless> SIGMA = Unit.ONE.alternate("sigma");
+    static final Unit<Dimensionless> SIGMA = ONE.alternate("sigma");
+
+    /**
+     * Dimensionless unit for pixels.
+     */
+    public static final Unit<Dimensionless> PIXEL = ONE.alternate("pixel");
+
+    static {
+        final javax.measure.format.UnitFormat format = tec.units.ri.format.SimpleUnitFormat.getInstance();
+        format.label(METRE,  "m");
+        format.label(FOOT,  "ft");
+        format.label(DEGREE, "°");
+        format.label(GRAD, "grad");
+    }
+
+    /**
+     * Do not allows instantiation of this class.
+     */
+    private Units() {
+    }
 
     /**
      * Returns {@code true} if the given unit is a linear unit.
-     * Linear units are convertible to {@link NonSI#DEGREE_ANGLE}.
+     * Linear units are convertible to {@link #DEGREE}.
      *
      * <p>Angular units are dimensionless, which may be a cause of confusion with other
-     * dimensionless units like {@link Unit#ONE} or {@link #PPM}. This method take care
+     * dimensionless units like {@link #ONE} or {@link #PPM}. This method take care
      * of differentiating angular units from other dimensionless units.</p>
      *
-     * @param unit The unit to check (may be {@code null}).
+     * @param  unit  the unit to check (may be {@code null}).
      * @return {@code true} if the given unit is non-null and angular.
      *
      * @see #ensureAngular(Unit)
      */
     public static boolean isAngular(final Unit<?> unit) {
-        return (unit != null) && unit.toSI().equals(SI.RADIAN);
+        return (unit != null) && unit.getSystemUnit().equals(RADIAN);
     }
 
     /**
      * Returns {@code true} if the given unit is a linear unit.
-     * Linear units are convertible to {@link SI#METRE}.
+     * Linear units are convertible to {@link #METRE}.
      *
-     * @param unit The unit to check (may be {@code null}).
+     * @param  unit  the unit to check (may be {@code null}).
      * @return {@code true} if the given unit is non-null and linear.
      *
      * @see #ensureLinear(Unit)
      */
     public static boolean isLinear(final Unit<?> unit) {
-        return (unit != null) && unit.toSI().equals(SI.METRE);
+        return (unit != null) && unit.getSystemUnit().equals(METRE);
     }
 
     /**
      * Returns {@code true} if the given unit is a pressure unit.
-     * Pressure units are convertible to {@link SI#PASCAL}.
+     * Pressure units are convertible to {@link #PASCAL}.
      * Those units are sometime used instead of linear units for altitude measurements.
      *
-     * @param unit The unit to check (may be {@code null}).
+     * @param  unit  the unit to check (may be {@code null}).
      * @return {@code true} if the given unit is non-null and a pressure unit.
      */
     public static boolean isPressure(final Unit<?> unit) {
-        return (unit != null) && unit.toSI().equals(SI.PASCAL);
+        return (unit != null) && unit.getSystemUnit().equals(PASCAL);
     }
 
     /**
      * Returns {@code true} if the given unit is a temporal unit.
-     * Temporal units are convertible to {@link SI#SECOND}.
+     * Temporal units are convertible to {@link #SECOND}.
      *
-     * @param unit The unit to check (may be {@code null}).
+     * @param  unit  the unit to check (may be {@code null}).
      * @return {@code true} if the given unit is non-null and temporal.
      *
      * @see #ensureTemporal(Unit)
      */
     public static boolean isTemporal(final Unit<?> unit) {
-        return (unit != null) && unit.toSI().equals(SI.SECOND);
+        return (unit != null) && unit.getSystemUnit().equals(SECOND);
     }
 
     /**
      * Returns {@code true} if the given unit is a dimensionless scale unit.
      * This include {@link Unit#ONE} and {@link #PPM}.
      *
-     * @param unit The unit to check (may be {@code null}).
+     * @param  unit  the unit to check (may be {@code null}).
      * @return {@code true} if the given unit is non-null and a dimensionless scale.
      *
      * @see #ensureScale(Unit)
      */
     public static boolean isScale(final Unit<?> unit) {
-        return (unit != null) && unit.toSI().equals(Unit.ONE);
+        return (unit != null) && unit.getSystemUnit().equals(ONE);
     }
 
     /**
      * Makes sure that the specified unit is either null or an angular unit.
      * This method is used for argument checks in constructors and setter methods.
      *
-     * @param  unit The unit to check, or {@code null} if none.
-     * @return The given {@code unit} argument, which may be null.
+     * @param  unit  the unit to check, or {@code null} if none.
+     * @return the given {@code unit} argument, which may be null.
      * @throws IllegalArgumentException if {@code unit} is non-null and not an angular unit.
      *
      * @see #isAngular(Unit)
@@ -183,8 +544,8 @@ public final class Units extends Static
      * Makes sure that the specified unit is either null or a linear unit.
      * This method is used for argument checks in constructors and setter methods.
      *
-     * @param  unit The unit to check, or {@code null} if none.
-     * @return The given {@code unit} argument, which may be null.
+     * @param  unit  the unit to check, or {@code null} if none.
+     * @return the given {@code unit} argument, which may be null.
      * @throws IllegalArgumentException if {@code unit} is non-null and not a linear unit.
      *
      * @see #isLinear(Unit)
@@ -201,26 +562,26 @@ public final class Units extends Static
      * Makes sure that the specified unit is either null or a temporal unit.
      * This method is used for argument checks in constructors and setter methods.
      *
-     * @param  unit The unit to check, or {@code null} if none.
-     * @return The given {@code unit} argument, which may be null.
+     * @param  unit  the unit to check, or {@code null} if none.
+     * @return the given {@code unit} argument, which may be null.
      * @throws IllegalArgumentException if {@code unit} is non-null and not a temporal unit.
      *
      * @see #isTemporal(Unit)
      */
     @SuppressWarnings("unchecked")
-    public static Unit<Duration> ensureTemporal(final Unit<?> unit) throws IllegalArgumentException {
+    public static Unit<Time> ensureTemporal(final Unit<?> unit) throws IllegalArgumentException {
         if (unit != null && !isTemporal(unit)) {
             throw new IllegalArgumentException(Errors.format(Errors.Keys.NonTemporalUnit_1, unit));
         }
-        return (Unit<Duration>) unit;
+        return (Unit<Time>) unit;
     }
 
     /**
      * Makes sure that the specified unit is either null or a scale unit.
      * This method is used for argument checks in constructors and setter methods.
      *
-     * @param  unit The unit to check, or {@code null} if none.
-     * @return The given {@code unit} argument, which may be null.
+     * @param  unit  the unit to check, or {@code null} if none.
+     * @return the given {@code unit} argument, which may be null.
      * @throws IllegalArgumentException if {@code unit} is non-null and not a scale unit.
      *
      * @see #isScale(Unit)
@@ -234,54 +595,43 @@ public final class Units extends Static
     }
 
     /**
-     * Multiplies the given unit by the given factor. For example multiplying {@link SI#METRE}
-     * by 1000 gives {@link SI#KILOMETRE}. Invoking this method is equivalent to invoking
-     * {@link Unit#times(double)} except for the following:
+     * Multiplies the given unit by the given factor. For example multiplying {@link #METRE}
+     * by 1000 gives {@link #KILOMETRE}. Invoking this method is equivalent to invoking
+     * {@link Unit#multiply(double)} except for the following:
      *
      * <ul>
      *   <li>A small tolerance factor is applied for a few factors commonly used in GIS.
-     *       For example {@code multiply(SI.RADIANS, 0.0174532925199...)} will return
-     *       {@link NonSI#DEGREE_ANGLE} even if the given numerical value is slightly
-     *       different than {@linkplain Math#PI pi}/180. The tolerance factor and the
-     *       set of units handled especially may change in future SIS versions.</li>
+     *       For example {@code multiply(RADIANS, 0.0174532925199...)} will return {@link #DEGREE}
+     *       even if the given numerical value is slightly different than {@linkplain Math#PI π}/180.
+     *       The tolerance factor and the set of units handled especially may change in future SIS versions.</li>
      *   <li>This method tries to returns unique instances for some common units.</li>
      * </ul>
      *
-     * @param  <Q>    The quantity measured by the unit.
-     * @param  unit   The unit to multiply.
-     * @param  factor The multiplication factor.
-     * @return The unit multiplied by the given factor.
+     * @param  <Q>     the quantity measured by the unit.
+     * @param  unit    the unit to multiply.
+     * @param  factor  the multiplication factor.
+     * @return the unit multiplied by the given factor.
      */
     @Workaround(library="JSR-275", version="0.9.3")
     @SuppressWarnings("unchecked")
-    public static <Q extends Quantity> Unit<Q> multiply(Unit<Q> unit, final double factor) {
-        if (SI.RADIAN.equals(unit)) {
+    public static <Q extends Quantity<Q>> Unit<Q> multiply(Unit<Q> unit, final double factor) {
+        if (RADIAN.equals(unit)) {
             if (abs(factor - (PI / 180)) <= (EPS * PI/180)) {
-                return (Unit<Q>) NonSI.DEGREE_ANGLE;
+                return (Unit<Q>) DEGREE;
             }
             if (abs(factor - (PI / 200)) <= (EPS * PI/200)) {
-                return (Unit<Q>) NonSI.GRADE;
+                return (Unit<Q>) GRAD;
             }
-        } else if (SI.METRE.equals(unit)) {
+        } else if (METRE.equals(unit)) {
             if (abs(factor - 0.3048) <= (EPS * 0.3048)) {
-                return (Unit<Q>) NonSI.FOOT;
+                return (Unit<Q>) FOOT;
             }
             if (abs(factor - (1200.0/3937)) <= (EPS * (1200.0/3937))) {
-                return (Unit<Q>) NonSI.FOOT_SURVEY_US;
+                return (Unit<Q>) FOOT_SURVEY_US;
             }
         }
         if (abs(factor - 1) > EPS) {
-            final long fl = (long) factor;
-            if (fl == factor) {
-                /*
-                 * Invoke the Unit.times(long) overloaded method, not Unit.scale(double),
-                 * because as of JSR-275 0.9.3 the method with the long argument seems to
-                 * do a better work of detecting when the result is an existing unit.
-                 */
-                unit = unit.times(fl);
-            } else {
-                unit = unit.times(factor);
-            }
+            unit = unit.multiply(factor);
         }
         return UnitsMap.canonicalize(unit);
     }
@@ -290,25 +640,24 @@ public final class Units extends Static
      * Returns the factor by which to multiply the standard unit in order to get the given unit.
      * The "standard" unit is usually the SI unit on which the given unit is based.
      *
-     * <p><b>Example:</b> If the given unit is <var>kilometre</var>, then this method returns 1000
+     * <p><b>Example:</b> if the given unit is <var>kilometre</var>, then this method returns 1000
      * since a measurement in kilometres must be multiplied by 1000 in order to give the equivalent
      * measurement in the "standard" units (here <var>metres</var>).</p>
      *
-     * @param  <Q>  The quantity measured by the unit.
-     * @param  unit The unit for which we want the multiplication factor to standard unit.
-     * @return The factor by which to multiply a measurement in the given unit in order to
+     * @param  <Q>   the quantity measured by the unit.
+     * @param  unit  the unit for which we want the multiplication factor to standard unit.
+     * @return the factor by which to multiply a measurement in the given unit in order to
      *         get an equivalent measurement in the standard unit.
      */
     @Workaround(library="JSR-275", version="0.9.3")
-    public static <Q extends Quantity> double toStandardUnit(final Unit<Q> unit) {
-        return derivative(unit.getConverterTo(unit.toSI()), 0);
+    public static <Q extends Quantity<Q>> double toStandardUnit(final Unit<Q> unit) {
+        return derivative(unit.getConverterTo(unit.getSystemUnit()), 0);
     }
 
     /**
      * Returns an estimation of the derivative of the given converter at the given value.
      * This method is a workaround for a method which existed in previous JSR-275 API but
-     * have been removed in more recent releases. This method will be deprecated if the
-     * removed API is reinserted in future JSR-275 release.
+     * have been removed in more recent releases.
      *
      * <p>Current implementation computes the derivative as below:</p>
      *
@@ -316,13 +665,12 @@ public final class Units extends Static
      *     return converter.convert(value + 1) - converter.convert(value);
      * }
      *
-     * The above is exact for {@linkplain javax.measure.converter.LinearConverter linear converters},
-     * which is the case of the vast majority of unit converters in use. It may not be exact for a
-     * few unusual converter like the one from sexagesimal degrees to decimal degrees for example.
-     *
-     * @param  converter The converter for which we want the derivative at a given point.
-     * @param  value The point at which to compute the derivative.
-     * @return The derivative at the given point.
+     * The above is exact for linear converters, which is the case of the vast majority of unit converters in use.
+     * It may not be exact for a few unusual converter like the one from sexagesimal degrees to decimal degrees.
+     *
+     * @param  converter  the converter for which we want the derivative at a given point.
+     * @param  value      the point at which to compute the derivative.
+     * @return the derivative at the given point.
      */
     @Workaround(library="JSR-275", version="0.9.3")
     public static double derivative(final UnitConverter converter, final double value) {
@@ -330,9 +678,11 @@ public final class Units extends Static
     }
 
     /**
-     * Parses the given symbol. This method is similar to {@link Unit#valueOf(CharSequence)}, but
-     * hands especially a few symbols found in WKT parsing or in XML files. The list of symbols
-     * handled especially is implementation-dependent and may change in future SIS versions.
+     * Parses the given symbol. Invoking this method is equivalent to invoking
+     * {@link UnitFormat#parse(CharSequence)} on a shared locale-independent instance.
+     * This method is capable to handle some symbols found during WKT parsing or in XML files.
+     * The list of symbols supported by this method is implementation-dependent
+     * and may change in future SIS versions.
      *
      * <div class="section">Parsing authority codes</div>
      * As a special case, if the given {@code uom} arguments is of the form {@code "EPSG:####"}
@@ -342,158 +692,25 @@ public final class Units extends Static
      * <div class="section">NetCDF unit symbols</div>
      * The attributes in NetCDF files often merge the axis direction with the angular unit,
      * as in {@code "degrees_east"} or {@code "degrees_north"}. This {@code valueOf} method
-     * ignores those suffixes and unconditionally returns {@link NonSI#DEGREE_ANGLE} for all
-     * axis directions. In particular, the units for {@code "degrees_west"} and {@code "degrees_east"}
-     * do <strong>not</strong> have opposite sign. It is caller responsibility to handle the
-     * direction of axes associated to NetCDF units.
-     *
-     * @param  uom The symbol to parse, or {@code null}.
-     * @return The parsed symbol, or {@code null} if {@code uom} was null.
-     * @throws IllegalArgumentException if the given symbol can not be parsed.
-     */
-    public static Unit<?> valueOf(String uom) throws IllegalArgumentException {
-        if (uom == null) {
-            return null;
-        }
-        uom = trimWhitespaces(CharSequences.toASCII(uom)).toString();
-        final int length = uom.length();
-        /*
-         * Check for authority codes (currently only EPSG, but more could be added later).
-         * If the unit is not an authority code (which is the most common case), then we
-         * will check for hard-coded unit symbols.
-         *
-         * DefinitionURI.codeOf(…) returns 'uom' directly (provided that whitespaces were already trimmed)
-         * if no ':' character were found, in which case the string is assumed to be the code directly.
-         * This is the intended behavior for AuthorityFactory, but in the particular case of this method
-         * we want to try to parse as a xpointer before to give up.
-         */
-        if (isURI(uom)) {
-            String code = DefinitionURI.codeOf("uom", Constants.EPSG, uom);
-            if (code != null && code != uom) try {              // Really identity check, see above comment.
-                return valueOfEPSG(Integer.parseInt(code));
-            } catch (NumberFormatException e) {
-                throw new IllegalArgumentException(Errors.format(
-                        Errors.Keys.IllegalArgumentValue_2, "uom", uom), e);
-            }
-            code = XPaths.xpointer("uom", uom);
-            if (code != null) {
-                uom = code;
-            }
-        }
-        /*
-         * Check for degrees units. Note that "deg" could be both angular and Celsius degrees.
-         * We try to resolve this ambiguity in the code below by looking for the "Celsius" suffix.
-         * Other suffixes commonly found in NetCDF files are "west", "east", "north" or "south".
-         * Those suffixes are ignored.
-         */
-        if (uom.regionMatches(true, 0, "deg", 0, 3)) {
-            switch (length) {
-                case 3: return NonSI.DEGREE_ANGLE; // Exactly "deg"
-                case 4: {
-                    if (uom.charAt(3) == 'K') {
-                        return SI.KELVIN; // Exactly "degK".
-                    }
-                    break;
-                }
-            }
-            String prefix = uom;
-            boolean isTemperature = false;
-            final int s = Math.max(uom.lastIndexOf(' '), uom.lastIndexOf('_'));
-            if (s >= 1) {
-                final String suffix = (String) trimWhitespaces(uom, s+1, length);
-                if (ArraysExt.containsIgnoreCase(CARDINAL_DIRECTIONS, suffix) || (isTemperature = isCelsius(suffix))) {
-                    prefix = (String) trimWhitespaces(uom, 0, s); // Remove the suffix only if we recognized it.
-                }
-            }
-            if (equalsIgnorePlural(prefix, "degree")) {
-                return isTemperature ? SI.CELSIUS : NonSI.DEGREE_ANGLE;
-            }
-        } else {
-            /*
-             * Check for unit symbols that do not begin with "deg". If a symbol begins
-             * with "deg", then the check should be put in the above block instead.
-             */
-            if (uom.equals("°")                      || equalsIgnorePlural(uom, "decimal_degree")) return NonSI.DEGREE_ANGLE;
-            if (uom.equalsIgnoreCase("arcsec"))                                                    return NonSI.SECOND_ANGLE;
-            if (uom.equalsIgnoreCase("rad")          || equalsIgnorePlural(uom, "radian"))         return SI.RADIAN;
-            if (equalsIgnorePlural(uom, "meter")     || equalsIgnorePlural(uom, "metre"))          return SI.METRE;
-            if (equalsIgnorePlural(uom, "kilometer") || equalsIgnorePlural(uom, "kilometre"))      return SI.KILOMETRE;
-            if (equalsIgnorePlural(uom, "week"))        return NonSI.WEEK;
-            if (equalsIgnorePlural(uom, "day"))         return NonSI.DAY;
-            if (equalsIgnorePlural(uom, "hour"))        return NonSI.HOUR;
-            if (equalsIgnorePlural(uom, "minute"))      return NonSI.MINUTE;
-            if (equalsIgnorePlural(uom, "second"))      return SI   .SECOND;
-            if (equalsIgnorePlural(uom, "pixel"))       return NonSI.PIXEL;
-            if (equalsIgnorePlural(uom, "grade"))       return NonSI.GRADE;
-            if (isCelsius(uom))                         return SI.CELSIUS;
-            if (uom.isEmpty())                          return Unit.ONE;
-            if (uom.equalsIgnoreCase("US survey foot")) return NonSI.FOOT_SURVEY_US;
-            if (uom.equalsIgnoreCase("ppm"))            return PPM;
-            if (uom.equalsIgnoreCase("psu"))            return PSU;
-            if (uom.equalsIgnoreCase("sigma"))          return SIGMA;
-        }
-        final Unit<?> unit;
-        try {
-            unit = Unit.valueOf(uom);
-        } catch (IllegalArgumentException e) {
-            // Provides a better error message than the default JSR-275 0.9.4 implementation.
-            throw Exceptions.setMessage(e, Errors.format(Errors.Keys.IllegalArgumentValue_2, "uom", uom), true);
-        }
-        /*
-         * Special case: JSR-275 version 0.6.1 parses "1/s" and "s-1" as "Baud", which is not what
-         * we use in geoscience. Replace "Baud" by "Hertz" if the symbol was not explicitely "Bd".
-         */
-        if (unit.isCompatible(SI.HERTZ) && !uom.equals("Bd")) {
-            return SI.HERTZ;
-        }
-        return UnitsMap.canonicalize(unit);
-    }
-
-    /**
-     * Returns {@code true} if the given {@code uom} is equals to the given expected string,
-     * ignoring trailing {@code 's'} character (if any).
-     */
-    @SuppressWarnings("fallthrough")
-    private static boolean equalsIgnorePlural(final String uom, final String expected) {
-        final int length = expected.length();
-        switch (uom.length() - length) {
-            case 0:  break; // uom has exactly the expected length.
-            case 1:  if (Character.toLowerCase(uom.charAt(length)) == 's') break; // else fallthrough.
-            default: return false;
-        }
-        return uom.regionMatches(true, 0, expected, 0, length);
-    }
-
-    /**
-     * Returns {@code true} if the given {@code uom} is equals to {@code "Celsius"} or
-     * {@code "Celcius"}. The later is a common misspelling.
-     */
-    private static boolean isCelsius(final String uom) {
-        return uom.equalsIgnoreCase("Celsius") || uom.equalsIgnoreCase("Celcius");
-    }
-
-    /**
-     * Returns {@code true} if the given unit seems to be an URI. Example:
-     * <ul>
-     *   <li>{@code "urn:ogc:def:uom:EPSG::9001"}</li>
-     *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])"}</li>
-     * </ul>
+     * ignores those suffixes and unconditionally returns {@link #DEGREE} for all axis directions.
+     * In particular, the units for {@code "degrees_west"} and {@code "degrees_east"}
+     * do <strong>not</strong> have opposite sign.
+     * It is caller responsibility to handle the direction of axes associated to NetCDF units.
+     *
+     * @param  uom  the symbol to parse, or {@code null}.
+     * @return the parsed symbol, or {@code null} if {@code uom} was null.
+     * @throws ParserException if the given symbol can not be parsed.
+     *
+     * @see UnitFormat#parse(CharSequence)
      */
-    private static boolean isURI(final String uom) {
-        for (int i=uom.length(); --i>=0;) {
-            final char c = uom.charAt(i);
-            if (c == ':' || c == '#') {
-                return true;
-            }
-        }
-        return false;
+    public static Unit<?> valueOf(String uom) throws ParserException {
+        return (uom != null) ? UnitFormat.INSTANCE.parse(uom) : null;
     }
 
     /**
-     * Returns a hard-coded unit from an EPSG code. The {@code code} argument given to this
-     * method shall be a code identifying a record in the {@code "Unit of Measure"} table of
-     * the EPSG database. If this method does not recognize the given code, then it returns
-     * {@code null}.
+     * Returns a hard-coded unit from an EPSG code. The {@code code} argument given to this method shall
+     * be a code identifying a record in the {@code "Unit of Measure"} table of the EPSG geodetic dataset.
+     * If this method does not recognize the given code, then it returns {@code null}.
      *
      * <p>The list of units recognized by this method is not exhaustive. This method recognizes
      * the base units declared in the {@code TARGET_UOM_CODE} column of the above-cited table,
@@ -521,7 +738,7 @@ public final class Units extends Static
      *       <tr><td>9102</td><td>decimal degree</td></tr>
      *       <tr><td>9103</td><td>minute</td></tr>
      *       <tr><td>9104</td><td>second</td></tr>
-     *       <tr><td>9105</td><td>grade</td></tr>
+     *       <tr><td>9105</td><td>grad</td></tr>
      *       <tr><td>9107</td><td>degree-minute-second</td></tr>
      *       <tr><td>9108</td><td>degree-minute-second</td></tr>
      *       <tr><td>9109</td><td>microradian</td></tr>
@@ -556,35 +773,35 @@ public final class Units extends Static
      * and code 9122 (<cite>degree (supplier to define representation)</cite>) for coordinate system axes.
      * But Apache SIS considers those two codes as synonymous.</div>
      *
-     * @param  code The EPSG code for a unit of measurement.
-     * @return The unit, or {@code null} if the code is unrecognized.
+     * @param  code  the EPSG code for a unit of measurement.
+     * @return the unit, or {@code null} if the code is unrecognized.
      *
      * @see org.apache.sis.referencing.factory.GeodeticAuthorityFactory#createUnit(String)
      */
     public static Unit<?> valueOfEPSG(final int code) {
         switch (code) {
             case Constants.EPSG_PARAM_DEGREES:  // Fall through
-            case Constants.EPSG_AXIS_DEGREES:   return NonSI.DEGREE_ANGLE;
-            case Constants.EPSG_METRE:          return SI.METRE;
+            case Constants.EPSG_AXIS_DEGREES:   return DEGREE;
+            case Constants.EPSG_METRE:          return METRE;
 
-            case 1029: return       YEAR;
-            case 1040: return SI   .SECOND;
-            case 9002: return NonSI.FOOT;
-            case 9003: return NonSI.FOOT_SURVEY_US;
-            case 9030: return NonSI.NAUTICAL_MILE;
-            case 9036: return SI   .KILOMETRE;
-            case 9101: return SI   .RADIAN;
-            case 9103: return NonSI.MINUTE_ANGLE;
-            case 9104: return NonSI.SECOND_ANGLE;
-            case 9105: return NonSI.GRADE;
-            case 9109: return SI.MetricPrefix.MICRO(SI.RADIAN);
+            case 1029: return YEAR;
+            case 1040: return SECOND;
+            case 9002: return FOOT;
+            case 9003: return FOOT_SURVEY_US;
+            case 9030: return NAUTICAL_MILE;
+            case 9036: return KILOMETRE;
+            case 9101: return RADIAN;
+            case 9103: return ARC_MINUTE;
+            case 9104: return ARC_SECOND;
+            case 9105: return GRAD;
+            case 9109: return MICRORADIAN;
             case 9107: // Fall through
             case 9108: return SexagesimalConverter.DMS_SCALED;
             case 9110: return SexagesimalConverter.DMS;
             case 9111: return SexagesimalConverter.DM;
             case 9203: // Fall through
-            case 9201: return Unit .ONE;
-            case 9202: return Units.PPM;
+            case 9201: return ONE;
+            case 9202: return PPM;
             default:   return null;
         }
     }
@@ -602,9 +819,9 @@ public final class Units extends Static
      * When such choice exists, the code to return is determined by the {@code inAxis} argument,
      * which specifies whether the code will be used for axis definition or in other context.
      *
-     * @param  unit The unit for which to get the EPSG code.
+     * @param  unit   the unit for which to get the EPSG code.
      * @param  inAxis {@code true} for a unit used in Coordinate System Axis definition.
-     * @return The EPSG code of the given units, or {@code null} if unknown.
+     * @return the EPSG code of the given units, or {@code null} if unknown.
      *
      * @since 0.4
      */

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -20,10 +20,8 @@ import java.util.Map;
 import java.util.HashMap;
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import javax.measure.unit.SI;
-import javax.measure.unit.NonSI;
-import javax.measure.unit.Unit;
-import javax.measure.quantity.Quantity;
+import javax.measure.Unit;
+import javax.measure.Quantity;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.util.Static;
 
@@ -31,12 +29,12 @@ import static org.apache.sis.measure.Uni
 
 
 /**
- * Map of units, defined in a separated class in order to avoid too-early class loading.
+ * Map of units, defined in a separated class in order to avoid too early class loading.
  * This class may be removed in a future SIS version if we provide our own units framework.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  */
 final class UnitsMap extends Static {
@@ -73,8 +71,8 @@ final class UnitsMap extends Static {
     private static final Map<Unit<?>,Unit<?>> COMMONS = new HashMap<>(48);
     static {
         COMMONS.put(MILLISECOND, MILLISECOND);
-        boolean nonSI = false;
-        do for (final Field field : (nonSI ? NonSI.class : SI.class).getFields()) {
+        COMMONS.put(tec.units.ri.AbstractUnit.ONE, tec.units.ri.AbstractUnit.ONE);
+        for (final Field field : tec.units.ri.unit.Units.class.getFields()) {
             final int modifiers = field.getModifiers();
             if (Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers)) {
                 final Object value;
@@ -91,18 +89,18 @@ final class UnitsMap extends Static {
                     }
                 }
             }
-        } while ((nonSI = !nonSI) == true);
+        }
     }
 
     /**
      * Returns a unique instance of the given units if possible, or the units unchanged otherwise.
      *
-     * @param  <A>    The quantity measured by the unit.
-     * @param  unit   The unit to canonicalize.
-     * @return A unit equivalents to the given unit, canonicalized if possible.
+     * @param  <A>   the quantity measured by the unit.
+     * @param  unit  the unit to canonicalize.
+     * @return a unit equivalents to the given unit, canonicalized if possible.
      */
     @SuppressWarnings({"unchecked","rawtypes"})
-    static <A extends Quantity> Unit<A> canonicalize(final Unit<A> unit) {
+    static <A extends Quantity<A>> Unit<A> canonicalize(final Unit<A> unit) {
         final Unit<?> candidate = COMMONS.get(unit);
         if (candidate != null) {
             return (Unit) candidate;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/package-info.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/measure/package-info.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -36,7 +36,7 @@
  *
  * @author  Martin Desruisseaux (MPO, IRD, Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.8
  * @module
  */
 package org.apache.sis.measure;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Static.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Static.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Static.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Static.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -49,7 +49,7 @@ package org.apache.sis.util;
  * <tr><td>{@link org.apache.sis.referencing.operation.matrix.Matrices}</td>
  *     <td>Create and compare {@link org.opengis.referencing.operation.Matrix} objects</td></tr>
  * <tr><td>{@link org.apache.sis.measure.Units}</td>
- *     <td>Get a {@linkplain javax.measure.unit.Unit unit} from a symbol or EPSG code,
+ *     <td>Get a {@linkplain javax.measure.Unit unit} from a symbol or EPSG code,
  *         and test if a unit is angular, linear or temporal.</td></tr>
  *
  * <tr><th colspan="2" class="hsep">OGC/ISO objects (metadata, referencing, geometries)</th></tr>

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -30,7 +30,7 @@ import java.util.ResourceBundle;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.lang.reflect.Modifier;
-import javax.measure.unit.Unit;
+import javax.measure.Unit;
 import org.opengis.util.CodeList;
 import org.opengis.util.ControlledVocabulary;
 import org.opengis.util.InternationalString;

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/package-info.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -84,7 +84,7 @@
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  *
  * @see java.util.ResourceBundle

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/ValueConverter.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -26,7 +26,8 @@ import java.util.Locale;
 import java.util.UUID;
 import java.nio.charset.Charset;
 import java.nio.charset.IllegalCharsetNameException;
-import javax.measure.unit.Unit;
+import javax.measure.Unit;
+import javax.measure.format.ParserException;
 import org.apache.sis.measure.Units;
 import org.apache.sis.util.Locales;
 
@@ -321,7 +322,7 @@ public class ValueConverter {
         value = trimWhitespaces(value);
         if (value != null && !value.isEmpty()) try {
             return Units.valueOf(value);
-        } catch (IllegalArgumentException e) {
+        } catch (ParserException e) {
             if (!exceptionOccured(context, value, String.class, Unit.class, e)) {
                 throw e;
             }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/converter/StringConverterTest.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -26,11 +26,11 @@ import java.net.URISyntaxException;
 import java.net.MalformedURLException;
 import java.nio.charset.Charset;
 import java.lang.annotation.ElementType;
-import javax.measure.unit.SI;
-import javax.measure.unit.Unit;
+import javax.measure.Unit;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.citation.OnLineFunction;
 import org.apache.sis.measure.Angle;
+import org.apache.sis.measure.Units;
 import org.apache.sis.math.FunctionProperty;
 import org.apache.sis.util.ObjectConverter;
 import org.apache.sis.util.UnconvertibleObjectException;
@@ -52,7 +52,7 @@ import java.nio.charset.StandardCharsets
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.5
+ * @version 0.8
  * @module
  */
 @DependsOn(org.apache.sis.measure.AngleTest.class)
@@ -300,7 +300,7 @@ public final strictfp class StringConver
     @Test
     public void testUnit() {
         final ObjectConverter<String,Unit<?>> c = new StringConverter.Unit();
-        runInvertibleConversion(c, "km", SI.KILOMETRE);
+        runInvertibleConversion(c, "km", Units.KILOMETRE);
         assertSerializedEquals(c);
     }
 

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/MeasureTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/MeasureTest.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/MeasureTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/MeasureTest.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -17,9 +17,7 @@
 package org.apache.sis.internal.jaxb.gml;
 
 import java.net.URISyntaxException;
-import javax.measure.unit.Unit;
-import javax.measure.unit.SI;
-import javax.measure.unit.NonSI;
+import org.apache.sis.measure.Units;
 import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
@@ -42,11 +40,11 @@ public final strictfp class MeasureTest
      */
     @Test
     public void testGetUOM() {
-        final Measure measure = new Measure(10, SI.METRE);
+        final Measure measure = new Measure(10, Units.METRE);
         assertEquals("urn:ogc:def:uom:EPSG::9001", measure.getUOM());
-        measure.unit = NonSI.DEGREE_ANGLE;
+        measure.unit = Units.DEGREE;
         assertEquals("urn:ogc:def:uom:EPSG::9102", measure.getUOM());
-        measure.unit = Unit.ONE;
+        measure.unit = Units.ONE;
         assertEquals("urn:ogc:def:uom:EPSG::9201", measure.getUOM());
     }
 
@@ -60,7 +58,7 @@ public final strictfp class MeasureTest
     public void testSetUOM() throws URISyntaxException {
         final Measure measure = new Measure();
         measure.setUOM("http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#m");
-        assertEquals(SI.METRE, measure.unit);
+        assertEquals(Units.METRE, measure.unit);
         assertEquals("urn:ogc:def:uom:EPSG::9001", measure.getUOM());
         measure.asXPointer = true;
         assertEquals(Schemas.METADATA_ROOT + Schemas.UOM_PATH + "#xpointer(//*[@gml:id='m'])", measure.getUOM());
@@ -68,7 +66,7 @@ public final strictfp class MeasureTest
         measure.unit = null;
         measure.asXPointer = false;
         measure.setUOM("../uom/ML_gmxUom.xml#xpointer(//*[@gml:id='deg'])");
-        assertEquals(NonSI.DEGREE_ANGLE, measure.unit);
+        assertEquals(Units.DEGREE, measure.unit);
         assertEquals("urn:ogc:def:uom:EPSG::9102", measure.getUOM());
         measure.asXPointer = true;
         assertEquals(Schemas.METADATA_ROOT + Schemas.UOM_PATH + "#xpointer(//*[@gml:id='deg'])", measure.getUOM());
@@ -76,7 +74,7 @@ public final strictfp class MeasureTest
         measure.unit = null;
         measure.asXPointer = true;
         measure.setUOM("gmxUom.xml#kg"); // Not really an existing unit in 'gmxUom'.
-        assertEquals(SI.KILOGRAM, measure.unit);
+        assertEquals(Units.KILOGRAM, measure.unit);
         assertEquals(Schemas.METADATA_ROOT + Schemas.UOM_PATH + "#xpointer(//*[@gml:id='kg'])", measure.getUOM());
     }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java?rev=1764677&r1=1764676&r2=1764677&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java [UTF-8] Thu Oct 13 13:50:40 2016
@@ -16,9 +16,7 @@
  */
 package org.apache.sis.measure;
 
-import javax.measure.unit.SI;
-import javax.measure.unit.NonSI;
-import javax.measure.converter.ConversionException;
+import javax.measure.IncommensurableException;
 import org.junit.Test;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.DependsOn;
@@ -31,7 +29,7 @@ import static org.apache.sis.test.Assert
  *
  * @author  Martin Desruisseaux (IRD)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  */
 @DependsOn(NumberRangeTest.class)
@@ -39,13 +37,13 @@ public final strictfp class MeasurementR
     /**
      * Tests unit conversions by the {@link MeasurementRange#convertTo(Unit)} method.
      *
-     * @throws ConversionException Should not happen.
+     * @throws IncommensurableException if a conversion between incompatible units were attempted.
      */
     @Test
-    public void testConvertTo() throws ConversionException {
-        final MeasurementRange<Float> range = MeasurementRange.create(1000f, true, 2000f, true, SI.METRE);
-        assertSame(range, range.convertTo(SI.METRE));
-        assertEquals(MeasurementRange.create(1f, true, 2f, true, SI.KILOMETRE), range.convertTo(SI.KILOMETRE));
+    public void testConvertTo() throws IncommensurableException {
+        final MeasurementRange<Float> range = MeasurementRange.create(1000f, true, 2000f, true, Units.METRE);
+        assertSame(range, range.convertTo(Units.METRE));
+        assertEquals(MeasurementRange.create(1f, true, 2f, true, Units.KILOMETRE), range.convertTo(Units.KILOMETRE));
     }
 
     /**
@@ -53,14 +51,14 @@ public final strictfp class MeasurementR
      */
     @Test
     public void testAutoConversions() {
-        final MeasurementRange<Float> r1 = MeasurementRange.create(1000f, true, 2000f, true, SI.METRE);
-        final MeasurementRange<Float> r2 = MeasurementRange.create(1.5f, true, 3f, true, SI.KILOMETRE);
+        final MeasurementRange<Float> r1 = MeasurementRange.create(1000f, true, 2000f, true, Units.METRE);
+        final MeasurementRange<Float> r2 = MeasurementRange.create(1.5f, true, 3f, true, Units.KILOMETRE);
         assertEquals(Float.class, r1.getElementType());
         assertEquals(Float.class, r2.getElementType());
-        assertEquals(MeasurementRange.create(1000f, true, 3000f, true, SI.METRE ),    r1.union    (r2));
-        assertEquals(MeasurementRange.create(   1f, true,    3f, true, SI.KILOMETRE), r2.union    (r1));
-        assertEquals(MeasurementRange.create(1500f, true, 2000f, true, SI.METRE ),    r1.intersect(r2));
-        assertEquals(MeasurementRange.create( 1.5f, true,    2f, true, SI.KILOMETRE), r2.intersect(r1));
+        assertEquals(MeasurementRange.create(1000f, true, 3000f, true, Units.METRE ),    r1.union    (r2));
+        assertEquals(MeasurementRange.create(   1f, true,    3f, true, Units.KILOMETRE), r2.union    (r1));
+        assertEquals(MeasurementRange.create(1500f, true, 2000f, true, Units.METRE ),    r1.intersect(r2));
+        assertEquals(MeasurementRange.create( 1.5f, true,    2f, true, Units.KILOMETRE), r2.intersect(r1));
     }
 
     /**
@@ -68,12 +66,12 @@ public final strictfp class MeasurementR
      */
     @Test
     public void testAutoConversionsOfAny() {
-        final MeasurementRange<?> r1 = MeasurementRange.create(1000f, true, 2000f, true, SI.METRE);
-        final MeasurementRange<?> r2 = MeasurementRange.create(1.5f, true, 3f, true, SI.KILOMETRE);
-        assertEquals(MeasurementRange.create(1000f, true, 3000f, true, SI.METRE ),    r1.unionAny    (r2));
-        assertEquals(MeasurementRange.create(   1f, true,    3f, true, SI.KILOMETRE), r2.unionAny    (r1));
-        assertEquals(MeasurementRange.create(1500f, true, 2000f, true, SI.METRE ),    r1.intersectAny(r2));
-        assertEquals(MeasurementRange.create( 1.5f, true,    2f, true, SI.KILOMETRE), r2.intersectAny(r1));
+        final MeasurementRange<?> r1 = MeasurementRange.create(1000f, true, 2000f, true, Units.METRE);
+        final MeasurementRange<?> r2 = MeasurementRange.create(1.5f, true, 3f, true, Units.KILOMETRE);
+        assertEquals(MeasurementRange.create(1000f, true, 3000f, true, Units.METRE ),    r1.unionAny    (r2));
+        assertEquals(MeasurementRange.create(   1f, true,    3f, true, Units.KILOMETRE), r2.unionAny    (r1));
+        assertEquals(MeasurementRange.create(1500f, true, 2000f, true, Units.METRE ),    r1.intersectAny(r2));
+        assertEquals(MeasurementRange.create( 1.5f, true,    2f, true, Units.KILOMETRE), r2.intersectAny(r1));
     }
 
     /**
@@ -81,9 +79,9 @@ public final strictfp class MeasurementR
      */
     @Test
     public void testToString() {
-        MeasurementRange<Float> range = MeasurementRange.create(10f, true, 20f, true, SI.KILOMETRE);
+        MeasurementRange<Float> range = MeasurementRange.create(10f, true, 20f, true, Units.KILOMETRE);
         assertEquals("[10.0 … 20.0] km", range.toString());
-        range = MeasurementRange.create(10f, true, 20f, true, NonSI.DEGREE_ANGLE);
+        range = MeasurementRange.create(10f, true, 20f, true, Units.DEGREE);
         assertEquals("[10.0 … 20.0]°", range.toString());
     }
 
@@ -92,8 +90,8 @@ public final strictfp class MeasurementR
      */
     @Test
     public void testSerialization() {
-        NumberRange<Float> r1 = MeasurementRange.create(1000f, true, 2000f, true, SI.METRE);
-        NumberRange<Float> r2 = MeasurementRange.create(1.5f, true, 3f, true, SI.KILOMETRE);
+        NumberRange<Float> r1 = MeasurementRange.create(1000f, true, 2000f, true, Units.METRE);
+        NumberRange<Float> r2 = MeasurementRange.create(1.5f, true, 3f, true, Units.KILOMETRE);
         assertNotSame(r1, assertSerializedEquals(r1));
         assertNotSame(r2, assertSerializedEquals(r2));
     }




Mime
View raw message