sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1792913 - in /sis/branches/JDK8/core/sis-utility/src: main/java/org/apache/sis/measure/ main/resources/org/apache/sis/measure/ test/java/org/apache/sis/measure/
Date Thu, 27 Apr 2017 15:56:42 GMT
Author: desruisseaux
Date: Thu Apr 27 15:56:42 2017
New Revision: 1792913

URL: http://svn.apache.org/viewvc?rev=1792913&view=rev
Log:
Whether the unit symbol can have a prefix (UnitRegistry.PREFIXABLE) needs to be specified independently of whether the unit is an SystemUnit instance of SI (UnitRegistry.SI).
The reason is that not all SI SystemUnit instances can be prefixed: the main exception is "kg" where the unit to prefix is rather the ConventionalUnit instance "g".
An other exception is the ConventionalUnit instance "L" (litre), which is not a SI unit but for which usage of SI prefixes is allowed. 

Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/ConventionalUnit.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/SystemUnit.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitRegistry.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
    sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitAliases.properties
    sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames.properties
    sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_en_US.properties
    sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_fr.properties
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/SystemUnitTest.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/AbstractUnit.java [UTF-8] Thu Apr 27 15:56:42 2017
@@ -127,6 +127,13 @@ abstract class AbstractUnit<Q extends Qu
     }
 
     /**
+     * Returns {@code true} if the use of SI prefixes is allowed for this unit.
+     */
+    final boolean isPrefixable() {
+        return (scope & UnitRegistry.PREFIXABLE) != 0;
+    }
+
+    /**
      * Returns the symbol (if any) of this unit. A unit may have no symbol, in which case
      * the {@link #toString()} method is responsible for creating a string representation.
      *
@@ -173,6 +180,15 @@ abstract class AbstractUnit<Q extends Qu
     public abstract SystemUnit<Q> getSystemUnit();
 
     /**
+     * Returns the base units and their exponent whose product is the system unit,
+     * or {@code null} if the system unit is a base unit (not a product of existing units).
+     *
+     * @return the base units and their exponent making up the system unit.
+     */
+    @Override
+    public abstract Map<SystemUnit<?>, Integer> getBaseUnits();
+
+    /**
      * Returns the base units used by Apache SIS implementations.
      * Contrarily to {@link #getBaseUnits()}, this method never returns {@code null}.
      */
@@ -283,6 +299,14 @@ abstract class AbstractUnit<Q extends Qu
     }
 
     /**
+     * Returns units for the same quantity but with scale factors that are not the SI one, or {@code null} if none.
+     * This method returns a direct reference to the internal field; caller shall not modify.
+     */
+    ConventionalUnit<Q>[] related() {
+        return null;
+    }
+
+    /**
      * Compares this unit with the given object for equality.
      *
      * @param  other  the other object to compare with this unit, or {@code null}.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/ConventionalUnit.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/ConventionalUnit.java?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/ConventionalUnit.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/ConventionalUnit.java [UTF-8] Thu Apr 27 15:56:42 2017
@@ -62,9 +62,11 @@ final class ConventionalUnit<Q extends Q
 
     /**
      * The base, derived or alternate units to which this {@code ConventionalUnit} is related.
-     * This is called "preferred unit" in GML.
+     * This is called "preferred unit" in GML. This is usually an instance of {@link SystemUnit},
+     * but may also be another {@link ConventionalUnit} in some rare cases where this conventional
+     * unit can be prefixed like a SI units (e.g. litre: L, cl, mL, µL).
      */
-    final SystemUnit<Q> target;
+    private final AbstractUnit<Q> target;
 
     /**
      * The conversion from this unit to the {@linkplain #target} unit.
@@ -80,7 +82,7 @@ final class ConventionalUnit<Q extends Q
      * @param  scope     {@link UnitRegistry#SI}, {@link UnitRegistry#ACCEPTED}, other constants or 0 if unknown.
      * @param  epsg      the EPSG code, or 0 if this unit has no EPSG code.
      */
-    ConventionalUnit(final SystemUnit<Q> target, final UnitConverter toTarget, final String symbol, final byte scope, final short epsg) {
+    ConventionalUnit(final AbstractUnit<Q> target, final UnitConverter toTarget, final String symbol, final byte scope, final short epsg) {
         super(symbol, scope, epsg);
         this.target   = target;
         this.toTarget = toTarget;
@@ -88,9 +90,12 @@ final class ConventionalUnit<Q extends Q
 
     /**
      * Creates a new unit with default name and symbol for the given converter.
+     *
+     * @param  target    the base or derived units to which the new unit will be related.
+     * @param  toTarget  the conversion from the new unit to the {@code target} unit.
      */
     @SuppressWarnings("unchecked")
-    static <Q extends Quantity<Q>> AbstractUnit<Q> create(final SystemUnit<Q> target, final UnitConverter toTarget) {
+    static <Q extends Quantity<Q>> AbstractUnit<Q> create(final AbstractUnit<Q> target, final UnitConverter toTarget) {
         if (toTarget.isIdentity()) {
             return target;
         }
@@ -115,7 +120,7 @@ final class ConventionalUnit<Q extends Q
          * unit instances.
          */
         String symbol = null;
-        if (target.scope == UnitRegistry.SI) {
+        if (target.isPrefixable()) {
             final String ts = target.getSymbol();
             if (ts != null && !ts.isEmpty() && toTarget.isLinear()) {
                 final int power = power(ts);
@@ -251,7 +256,7 @@ final class ConventionalUnit<Q extends Q
      */
     @Override
     public Dimension getDimension() {
-        return target.dimension;
+        return target.getDimension();
     }
 
     /**
@@ -259,7 +264,7 @@ final class ConventionalUnit<Q extends Q
      */
     @Override
     public SystemUnit<Q> getSystemUnit() {
-        return target;
+        return target.getSystemUnit();
     }
 
     /**
@@ -317,11 +322,12 @@ final class ConventionalUnit<Q extends Q
         UnitConverter c = toTarget;
         if (target != that) {                           // Optimization for a common case.
             final Unit<Q> step = that.getSystemUnit();
-            if (target != step && !target.equalsIgnoreMetadata(step)) {
+            if (target != step && !target.isCompatible(step)) {
                 // Should never occur unless parameterized type has been compromised.
                 throw new UnconvertibleException(incompatible(that));
             }
-            c = step.getConverterTo(that).concatenate(c);
+            c = target.getConverterTo(step).concatenate(c);         // Usually leave 'c' unchanged.
+            c =   step.getConverterTo(that).concatenate(c);
         }
         return c;
     }
@@ -349,7 +355,8 @@ final class ConventionalUnit<Q extends Q
             if (target != step && !target.isCompatible(step)) {
                 throw new IncommensurableException(incompatible(that));
             }
-            c = step.getConverterToAny(that).concatenate(c);
+            c = target.getConverterToAny(step).concatenate(c);      // Usually leave 'c' unchanged.
+            c =   step.getConverterToAny(that).concatenate(c);
         }
         return c;
     }
@@ -435,9 +442,14 @@ final class ConventionalUnit<Q extends Q
      * @return the unit after the specified transformation.
      */
     @Override
-    public Unit<Q> transform(final UnitConverter operation) {
+    public Unit<Q> transform(UnitConverter operation) {
         ArgumentChecks.ensureNonNull("operation", operation);
-        return create(target, toTarget.concatenate(operation));
+        AbstractUnit<Q> base = this;
+        if (!isPrefixable()) {
+            base = target;
+            operation = toTarget.concatenate(operation);
+        }
+        return create(base, operation);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/SystemUnit.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/SystemUnit.java?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/SystemUnit.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/SystemUnit.java [UTF-8] Thu Apr 27 15:56:42 2017
@@ -486,9 +486,10 @@ final class SystemUnit<Q extends Quantit
     }
 
     /**
-     * Returns units for the same quantity but with scale factors that are not the SI one.
+     * Returns units for the same quantity but with scale factors that are not the SI one, or {@code null} if none.
      * This method returns a direct reference to the internal field; caller shall not modify.
      */
+    @Override
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
     final ConventionalUnit<Q>[] related() {
         return related;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java [UTF-8] Thu Apr 27 15:56:42 2017
@@ -1246,7 +1246,7 @@ search:     while ((i = CharSequences.sk
                 s = 2;
             }
             unit = Units.get(uom.substring(s));
-            if (unit instanceof SystemUnit<?> && ((SystemUnit<?>) unit).scope == UnitRegistry.SI) {
+            if (unit instanceof AbstractUnit<?> && ((AbstractUnit<?>) unit).isPrefixable()) {
                 final LinearConverter c = LinearConverter.forPrefix(prefix);
                 if (c != null) {
                     String symbol = unit.getSymbol();
@@ -1255,7 +1255,7 @@ search:     while ((i = CharSequences.sk
                     } else {
                         symbol = prefix + symbol;
                     }
-                    return new ConventionalUnit<>((SystemUnit<?>) unit, c, symbol.intern(), (byte) 0, (short) 0);
+                    return new ConventionalUnit<>((AbstractUnit<?>) unit, c, symbol.intern(), (byte) 0, (short) 0);
                 }
             }
             unit = null;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitRegistry.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitRegistry.java?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitRegistry.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/UnitRegistry.java [UTF-8] Thu Apr 27 15:56:42 2017
@@ -48,25 +48,32 @@ final class UnitRegistry implements Syst
     private static final long serialVersionUID = -84557361079506390L;
 
     /**
+     * A bitmask specifying that the unit symbol can be combined with a SI prefix.
+     * This is usually combined only with {@link #SI}, not {@link #ACCEPTED} except
+     * the litre unit (cL, mL, etc).
+     */
+    static final byte PREFIXABLE = 1;
+
+    /**
      * Identifies units defined by the SI system.
      * All {@link SystemUnit} instances with this code can have a SI prefix.
      */
-    static final byte SI = 1;
+    static final byte SI = 2;
 
     /**
      * Identifies units defined outside the SI system but accepted for use with SI.
      */
-    static final byte ACCEPTED = 2;
+    static final byte ACCEPTED = 4;
 
     /**
      * Identifies units defined for use in British imperial system.
      */
-    static final byte IMPERIAL = 4;
+    static final byte IMPERIAL = 8;
 
     /**
      * Identifies units defined in another system than the above.
      */
-    static final byte OTHER = 8;
+    static final byte OTHER = 16;
 
     /**
      * All {@link UnitDimension}, {@link SystemUnit} or {@link ConventionalUnit} that are hard-coded in Apache SIS.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Thu Apr 27 15:56:42 2017
@@ -33,6 +33,11 @@ import org.apache.sis.internal.util.Cons
 
 import static java.lang.Math.PI;
 import static java.lang.Math.abs;
+import static org.apache.sis.measure.UnitRegistry.SI;
+import static org.apache.sis.measure.UnitRegistry.ACCEPTED;
+import static org.apache.sis.measure.UnitRegistry.IMPERIAL;
+import static org.apache.sis.measure.UnitRegistry.OTHER;
+import static org.apache.sis.measure.UnitRegistry.PREFIXABLE;
 import static org.apache.sis.measure.SexagesimalConverter.EPS;
 
 
@@ -324,6 +329,14 @@ public final class Units extends Static
     public static final Unit<Volume> CUBIC_METRE;
 
     /**
+     * The unit for litre volume (L, l or ℓ).
+     * The unlocalized name is “litre”.
+     *
+     * @since 0.8
+     */
+    public static final Unit<Volume> LITRE;
+
+    /**
      * The SI unit for solid angles (sr).
      * The unlocalized name is “steradian”.
      *
@@ -942,6 +955,14 @@ public final class Units extends Static
     public static final Unit<Illuminance> LUX;
 
     /**
+     * A SI conventional unit for mass (g).
+     * The unlocalized name is “gram”.
+     *
+     * @since 0.8
+     */
+    public static final Unit<Mass> GRAM;
+
+    /**
      * The SI base unit for mass (kg).
      * The unlocalized name is “kilogram”.
      *
@@ -1061,14 +1082,16 @@ public final class Units extends Static
         /*
          * Base, derived or alternate units that we need to reuse more than once in this static initializer.
          */
-        final SystemUnit<Length>        m   = add(Length.class,        Scalar.Length::new,        length,        "m",   UnitRegistry.SI, Constants.EPSG_METRE);
-        final SystemUnit<Area>          m2  = add(Area.class,          Scalar.Area::new,          area,          "m²",  UnitRegistry.SI, (short) 0);
-        final SystemUnit<Time>          s   = add(Time.class,          Scalar.Time::new,          time,          "s",   UnitRegistry.SI, (short) 1040);
-        final SystemUnit<Temperature>   K   = add(Temperature.class,   Scalar.Temperature::new,   temperature,   "K",   UnitRegistry.SI, (short) 0);
-        final SystemUnit<Speed>         mps = add(Speed.class,         Scalar.Speed::new,         speed,         "m∕s", UnitRegistry.SI, (short) 1026);
-        final SystemUnit<Pressure>      Pa  = add(Pressure.class,      Scalar.Pressure::new,      pressure,      "Pa",  UnitRegistry.SI, (short) 0);
-        final SystemUnit<Angle>         rad = add(Angle.class,         Scalar.Angle::new,         dimensionless, "rad", UnitRegistry.SI, (short) 9101);
-        final SystemUnit<Dimensionless> one = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "",    UnitRegistry.SI, (short) 9201);
+        final SystemUnit<Length>        m   = add(Length.class,        Scalar.Length::new,        length,        "m",   (byte) (SI | PREFIXABLE), Constants.EPSG_METRE);
+        final SystemUnit<Area>          m2  = add(Area.class,          Scalar.Area::new,          area,          "m²",  (byte) (SI | PREFIXABLE), (short) 0);
+        final SystemUnit<Volume>        m3  = add(Volume.class,        Scalar.Volume::new,        length.pow(3), "m³",  (byte) (SI | PREFIXABLE), (short) 0);
+        final SystemUnit<Time>          s   = add(Time.class,          Scalar.Time::new,          time,          "s",   (byte) (SI | PREFIXABLE), (short) 1040);
+        final SystemUnit<Temperature>   K   = add(Temperature.class,   Scalar.Temperature::new,   temperature,   "K",   (byte) (SI | PREFIXABLE), (short) 0);
+        final SystemUnit<Speed>         mps = add(Speed.class,         Scalar.Speed::new,         speed,         "m∕s", (byte) (SI | PREFIXABLE), (short) 1026);
+        final SystemUnit<Pressure>      Pa  = add(Pressure.class,      Scalar.Pressure::new,      pressure,      "Pa",  (byte) (SI | PREFIXABLE), (short) 0);
+        final SystemUnit<Angle>         rad = add(Angle.class,         Scalar.Angle::new,         dimensionless, "rad", (byte) (SI | PREFIXABLE), (short) 9101);
+        final SystemUnit<Dimensionless> one = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "",            SI,               (short) 9201);
+        final SystemUnit<Mass>          kg  = add(Mass.class,          Scalar.Mass::new,          mass,          "kg",          SI,               (short) 0);
         /*
          * All SI prefix to be used below, with additional converters to be used more than once.
          */
@@ -1087,96 +1110,98 @@ public final class Units extends Static
          */
         rad.related(4);
         RADIAN      = rad;
-        GRAD        = add(rad, LinearConverter.scale(Math.PI / 20, 200       / 20), "grad", UnitRegistry.OTHER,    (short) 9105);
-        DEGREE      = add(rad, LinearConverter.scale(Math.PI / 20, 180       / 20), "°",    UnitRegistry.ACCEPTED, Constants.EPSG_PARAM_DEGREES);
-        ARC_MINUTE  = add(rad, LinearConverter.scale(Math.PI / 20, 180*60    / 20), "′",    UnitRegistry.ACCEPTED, (short) 9103);
-        ARC_SECOND  = add(rad, LinearConverter.scale(Math.PI / 20, 180*60*60 / 20), "″",    UnitRegistry.ACCEPTED, (short) 9104);
-        MICRORADIAN = add(rad, micro,                                               "µrad", UnitRegistry.SI,       (short) 9109);
+        GRAD        = add(rad, LinearConverter.scale(Math.PI / 20, 200       / 20), "grad", OTHER,    (short) 9105);
+        DEGREE      = add(rad, LinearConverter.scale(Math.PI / 20, 180       / 20), "°",    ACCEPTED, Constants.EPSG_PARAM_DEGREES);
+        ARC_MINUTE  = add(rad, LinearConverter.scale(Math.PI / 20, 180*60    / 20), "′",    ACCEPTED, (short) 9103);
+        ARC_SECOND  = add(rad, LinearConverter.scale(Math.PI / 20, 180*60*60 / 20), "″",    ACCEPTED, (short) 9104);
+        MICRORADIAN = add(rad, micro,                                               "µrad", SI,       (short) 9109);
         /*
          * All Unit<Length>.
          */
         m.related(7);
         METRE          = m;
-        NANOMETRE      = add(m, nano,                                     "nm",    UnitRegistry.SI,       (short) 0);
-        MILLIMETRE     = add(m, milli,                                    "mm",    UnitRegistry.SI,       (short) 1025);
-        CENTIMETRE     = add(m, centi,                                    "cm",    UnitRegistry.SI,       (short) 1033);
-        KILOMETRE      = add(m, kilo,                                     "km",    UnitRegistry.SI,       (short) 9036);
-        NAUTICAL_MILE  = add(m, LinearConverter.scale(   1852,        1), "M",     UnitRegistry.OTHER,    (short) 9030);
-        STATUTE_MILE   = add(m, LinearConverter.scale(1609344,      100), "mi",    UnitRegistry.IMPERIAL, (short) 9093);
-        US_SURVEY_FOOT = add(m, LinearConverter.scale(   1200,     3937), "ftUS",  UnitRegistry.OTHER,    (short) 9003);
-        CLARKE_FOOT    = add(m, LinearConverter.scale(3047972654d, 1E10), "ftCla", UnitRegistry.OTHER,    (short) 9005);
-        FOOT           = add(m, LinearConverter.scale(   3048,    10000), "ft",    UnitRegistry.IMPERIAL, (short) 9002);
-        INCH           = add(m, LinearConverter.scale(    254,    10000), "in",    UnitRegistry.IMPERIAL, (short) 0);
-        POINT          = add(m, LinearConverter.scale( 996264, 72000000), "pt",    UnitRegistry.OTHER,    (short) 0);
+        NANOMETRE      = add(m, nano,                                     "nm",    SI,       (short) 0);
+        MILLIMETRE     = add(m, milli,                                    "mm",    SI,       (short) 1025);
+        CENTIMETRE     = add(m, centi,                                    "cm",    SI,       (short) 1033);
+        KILOMETRE      = add(m, kilo,                                     "km",    SI,       (short) 9036);
+        NAUTICAL_MILE  = add(m, LinearConverter.scale(   1852,        1), "M",     OTHER,    (short) 9030);
+        STATUTE_MILE   = add(m, LinearConverter.scale(1609344,      100), "mi",    IMPERIAL, (short) 9093);
+        US_SURVEY_FOOT = add(m, LinearConverter.scale(   1200,     3937), "ftUS",  OTHER,    (short) 9003);
+        CLARKE_FOOT    = add(m, LinearConverter.scale(3047972654d, 1E10), "ftCla", OTHER,    (short) 9005);
+        FOOT           = add(m, LinearConverter.scale(   3048,    10000), "ft",    IMPERIAL, (short) 9002);
+        INCH           = add(m, LinearConverter.scale(    254,    10000), "in",    IMPERIAL, (short) 0);
+        POINT          = add(m, LinearConverter.scale( 996264, 72000000), "pt",    OTHER,    (short) 0);
         /*
          * All Unit<Time>.
          */
         s.related(5);
         SECOND         = s;
-        MILLISECOND    = add(s, milli, "ms", UnitRegistry.SI, (short) 0);
-        MINUTE         = add(s, LinearConverter.scale(         60,      1), "min", UnitRegistry.ACCEPTED, (short) 0);
-        HOUR           = add(s, LinearConverter.scale(      60*60,      1), "h",   UnitRegistry.ACCEPTED, (short) 0);
-        DAY            = add(s, LinearConverter.scale(   24*60*60,      1), "d",   UnitRegistry.ACCEPTED, (short) 0);
-        WEEK           = add(s, LinearConverter.scale( 7*24*60*60,      1), "wk",  UnitRegistry.OTHER,    (short) 0);
-        TROPICAL_YEAR  = add(s, LinearConverter.scale(31556925445.0, 1000), "a",   UnitRegistry.OTHER,    (short) 1029);
+        MILLISECOND    = add(s, milli,                                      "ms",  SI,       (short) 0);
+        MINUTE         = add(s, LinearConverter.scale(         60,      1), "min", ACCEPTED, (short) 0);
+        HOUR           = add(s, LinearConverter.scale(      60*60,      1), "h",   ACCEPTED, (short) 0);
+        DAY            = add(s, LinearConverter.scale(   24*60*60,      1), "d",   ACCEPTED, (short) 0);
+        WEEK           = add(s, LinearConverter.scale( 7*24*60*60,      1), "wk",  OTHER,    (short) 0);
+        TROPICAL_YEAR  = add(s, LinearConverter.scale(31556925445.0, 1000), "a",   OTHER,    (short) 1029);
         /*
          * All Unit<Speed>.
          */
         mps.related(1);
         METRES_PER_SECOND   = mps;
-        KILOMETRES_PER_HOUR = add(mps, LinearConverter.scale(6, 100), "km∕h", UnitRegistry.ACCEPTED, (short) 0);
+        KILOMETRES_PER_HOUR = add(mps, LinearConverter.scale(6, 100), "km∕h", ACCEPTED, (short) 0);
         /*
          * All Unit<Pressure>.
          */
         Pa.related(3);
         PASCAL      = Pa;
-        HECTOPASCAL = add(Pa,  hecto,                            "hPa",  UnitRegistry.SI,    (short) 0);
-        DECIBAR     = add(Pa,  ten4,                             "dbar", UnitRegistry.OTHER, (short) 0);
-        BAR         = add(Pa,  LinearConverter.scale(100000, 1), "bar",  UnitRegistry.OTHER, (short) 0);
-        ATMOSPHERE  = add(Pa,  LinearConverter.scale(101325, 1), "atm",  UnitRegistry.OTHER, (short) 0);
+        HECTOPASCAL = add(Pa,  hecto,                            "hPa",  SI,    (short) 0);
+        DECIBAR     = add(Pa,  ten4,                             "dbar", OTHER, (short) 0);
+        BAR         = add(Pa,  LinearConverter.scale(100000, 1), "bar",  OTHER, (short) 0);
+        ATMOSPHERE  = add(Pa,  LinearConverter.scale(101325, 1), "atm",  OTHER, (short) 0);
         /*
          * All Unit<Temperature>.
          */
         K.related(1);
         KELVIN     = K;
-        CELSIUS    = add(K, LinearConverter.offset(  27315, 100), "°C", UnitRegistry.SI,    (short) 0);
-        FAHRENHEIT = add(K, new LinearConverter(100, 45967, 180), "°F", UnitRegistry.OTHER, (short) 0);
+        CELSIUS    = add(K, LinearConverter.offset(  27315, 100), "°C", SI,    (short) 0);
+        FAHRENHEIT = add(K, new LinearConverter(100, 45967, 180), "°F", OTHER, (short) 0);
         /*
          * Electricity and magnetism.
          */
-        AMPERE  = add(ElectricCurrent.class,     null, current,                      "A",  UnitRegistry.SI, (short) 0);
-        COULOMB = add(ElectricCharge.class,      null, charge,                       "C",  UnitRegistry.SI, (short) 0);
-        VOLT    = add(ElectricPotential.class,   null, potential,                    "V",  UnitRegistry.SI, (short) 0);
-        FARAD   = add(ElectricCapacitance.class, null, charge.divide(potential),     "F",  UnitRegistry.SI, (short) 0);
-        SIEMENS = add(ElectricConductance.class, null, current.divide(potential),    "S",  UnitRegistry.SI, (short) 0);
-        OHM     = add(ElectricResistance.class,  null, potential.divide(current),    "Ω",  UnitRegistry.SI, (short) 0);
-        WEBER   = add(MagneticFlux.class,        null, magneticFlux,                 "Wb", UnitRegistry.SI, (short) 0);
-        TESLA   = add(MagneticFluxDensity.class, null, magneticFlux.divide(area),    "T",  UnitRegistry.SI, (short) 0);
-        HENRY   = add(ElectricInductance.class,  null, magneticFlux.divide(current), "H",  UnitRegistry.SI, (short) 0);
+        AMPERE  = add(ElectricCurrent.class,     null, current,                      "A",  (byte) (SI | PREFIXABLE), (short) 0);
+        COULOMB = add(ElectricCharge.class,      null, charge,                       "C",  (byte) (SI | PREFIXABLE), (short) 0);
+        VOLT    = add(ElectricPotential.class,   null, potential,                    "V",  (byte) (SI | PREFIXABLE), (short) 0);
+        FARAD   = add(ElectricCapacitance.class, null, charge.divide(potential),     "F",  (byte) (SI | PREFIXABLE), (short) 0);
+        SIEMENS = add(ElectricConductance.class, null, current.divide(potential),    "S",  (byte) (SI | PREFIXABLE), (short) 0);
+        OHM     = add(ElectricResistance.class,  null, potential.divide(current),    "Ω",  (byte) (SI | PREFIXABLE), (short) 0);
+        WEBER   = add(MagneticFlux.class,        null, magneticFlux,                 "Wb", (byte) (SI | PREFIXABLE), (short) 0);
+        TESLA   = add(MagneticFluxDensity.class, null, magneticFlux.divide(area),    "T",  (byte) (SI | PREFIXABLE), (short) 0);
+        HENRY   = add(ElectricInductance.class,  null, magneticFlux.divide(current), "H",  (byte) (SI | PREFIXABLE), (short) 0);
         /*
          * Other units.
          */
         SQUARE_METRE = m2;
-        HECTARE      = add(m2,  ten4,                                                             "ha",  UnitRegistry.ACCEPTED, (short) 0);
-        CUBIC_METRE  = add(Volume.class,            Scalar.Volume::new,    length.pow(3),         "m³",  UnitRegistry.SI,       (short) 0);
-        HERTZ        = add(Frequency.class,         Scalar.Frequency::new, time.pow(-1),          "Hz",  UnitRegistry.SI,       (short) 0);
-        KILOGRAM     = add(Mass.class,              Scalar.Mass::new,      mass,                  "kg",  UnitRegistry.SI,       (short) 0);
-        NEWTON       = add(Force.class,             Scalar.Force::new,     force,                 "N",   UnitRegistry.SI,       (short) 0);
-        JOULE        = add(Energy.class,            Scalar.Energy::new,    energy,                "J",   UnitRegistry.SI,       (short) 0);
-        WATT         = add(Power.class,             Scalar.Power::new,     power,                 "W",   UnitRegistry.SI,       (short) 0);
-        LUX          = add(Illuminance.class,       null,                  luminous.divide(area), "lx",  UnitRegistry.SI,       (short) 0);
-        LUMEN        = add(LuminousFlux.class,      null,                  luminous,              "lm",  UnitRegistry.SI,       (short) 0);
-        CANDELA      = add(LuminousIntensity.class, null,                  luminous,              "cd",  UnitRegistry.SI,       (short) 0);    // Must be after Lumen.
-        MOLE         = add(AmountOfSubstance.class, null,                  amount,                "mol", UnitRegistry.SI,       (short) 0);
-        STERADIAN    = add(SolidAngle.class,        null,                  dimensionless,         "sr",  UnitRegistry.SI,       (short) 0);
+        CUBIC_METRE  = m3;
+        KILOGRAM     = kg;
+        HECTARE      = add(m2,                      ten4,                                         "ha",          ACCEPTED,               (short) 0);
+        LITRE        = add(m3,                      milli,                                        "L",   (byte) (ACCEPTED | PREFIXABLE), (short) 0);
+        GRAM         = add(kg,                      milli,                                        "g",   (byte) (ACCEPTED | PREFIXABLE), (short) 0);
+        HERTZ        = add(Frequency.class,         Scalar.Frequency::new, time.pow(-1),          "Hz",  (byte) (SI       | PREFIXABLE), (short) 0);
+        NEWTON       = add(Force.class,             Scalar.Force::new,     force,                 "N",   (byte) (SI       | PREFIXABLE), (short) 0);
+        JOULE        = add(Energy.class,            Scalar.Energy::new,    energy,                "J",   (byte) (SI       | PREFIXABLE), (short) 0);
+        WATT         = add(Power.class,             Scalar.Power::new,     power,                 "W",   (byte) (SI       | PREFIXABLE), (short) 0);
+        LUX          = add(Illuminance.class,       null,                  luminous.divide(area), "lx",  (byte) (SI       | PREFIXABLE), (short) 0);
+        LUMEN        = add(LuminousFlux.class,      null,                  luminous,              "lm",  (byte) (SI       | PREFIXABLE), (short) 0);
+        CANDELA      = add(LuminousIntensity.class, null,                  luminous,              "cd",  (byte) (SI       | PREFIXABLE), (short) 0);    // Must be after Lumen.
+        MOLE         = add(AmountOfSubstance.class, null,                  amount,                "mol", (byte) (SI       | PREFIXABLE), (short) 0);
+        STERADIAN    = add(SolidAngle.class,        null,                  dimensionless,         "sr",  (byte) (SI       | PREFIXABLE), (short) 0);
         /*
          * All Unit<Dimensionless>.
          */
-        PERCENT = add(one, centi,                                                    "%",     UnitRegistry.OTHER, (short) 0);
-        PPM     = add(one, micro,                                                    "ppm",   UnitRegistry.OTHER, (short) 9202);
-        PSU     = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "psu",   UnitRegistry.OTHER, (short) 0);
-        SIGMA   = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "sigma", UnitRegistry.OTHER, (short) 0);
-        PIXEL   = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "px",    UnitRegistry.OTHER, (short) 0);
+        PERCENT = add(one, centi,                                                    "%",     OTHER, (short) 0);
+        PPM     = add(one, micro,                                                    "ppm",   OTHER, (short) 9202);
+        PSU     = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "psu",   OTHER, (short) 0);
+        SIGMA   = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "sigma", OTHER, (short) 0);
+        PIXEL   = add(Dimensionless.class, Scalar.Dimensionless::new, dimensionless, "px",    OTHER, (short) 0);
         UNITY   = UnitRegistry.init(one);  // Must be last in order to take precedence over all other units associated to UnitDimension.NONE.
 
         UnitRegistry.alias(UNITY,       Short.valueOf((short) 9203));

Modified: sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitAliases.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitAliases.properties?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitAliases.properties [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitAliases.properties [UTF-8] Thu Apr 27 15:56:42 2017
@@ -12,12 +12,17 @@ degree\ north=�
 degree\ south=�
 degree\ west=�
 feet=ft
+kilograms=kg
 grade=grad
 grades=grad
 gradian=grad
 gradians=grad
 grads=grad
+grams=g
 hours=h
+l=L
+liters=L
+litres=L
 mbar=hPa
 millibar=hPa
 millibars=hPa

Modified: sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames.properties?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames.properties [ISO-8859-1] Thu Apr 27 15:56:42 2017
@@ -11,6 +11,7 @@ F=farad
 ft=foot
 ftCla=Clarke\u2019s foot
 ftUS=US survey foot
+g=gram
 grad=grad
 h=hour
 ha=hectare
@@ -23,12 +24,13 @@ J=joule
 kg=kilogram
 km=kilometre
 km\u2215h=kilometres per hour
+L=litre
 lm=lumen
 lx=lux
 M=nautical mile
 m=metre
-m\u00b2=square metre
-m\u00b3=cubic metre
+m²=square metre
+m³=cubic metre
 m\u2215s=metres per second
 mi=statute mile
 min=minute
@@ -52,11 +54,11 @@ V=volt
 W=watt
 Wb=weber
 wk=week
-\u00b5rad=microradian
+µrad=microradian
 \u03a9=ohm
 %=percentage
-\u00b0=degree
+°=degree
 \u2032=arc-minute
 \u2033=arc-second
-\u00b0C=Celsius
-\u00b0F=Fahrenheit
+°C=Celsius
+°F=Fahrenheit

Modified: sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_en_US.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_en_US.properties?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_en_US.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_en_US.properties [ISO-8859-1] Thu Apr 27 15:56:42 2017
@@ -1,6 +1,7 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
 cm=centimeter
 km=kilometer
+L=liter
 m=meter
 m²=square meter
 m³=cubic meter

Modified: sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_fr.properties?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_fr.properties [ISO-8859-1] Thu Apr 27 15:56:42 2017
@@ -1,33 +1,34 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
-A=amp\u00e8re
-a=ann\u00e9e
-atm=atmosph\u00e8re
-cm=centim\u00e8tre
+A=ampère
+a=année
+atm=atmosphère
+cm=centimètre
 d=jour
 ft=pied
 ftCla=pied de Clarke
-ftUS=pied am\u00e9ricain
+ftUS=pied américain
+g=gramme
 grad=grade
 h=heure
 in=pouce
 kg=kilogramme
-km=kilom\u00e8tre
-km\u2215h=kilom\u00e8tres par heure
+km=kilomètre
+km\u2215h=kilomètres par heure
 M=mille marin international
-m=m\u00e8tre
-m\u00b2=m\u00e8tre carr\u00e9
-m\u00b3=m\u00e8tre cube
-m\u2215s=m\u00e8tres par seconde
+m=mètre
+m²=mètre carré
+m³=mètre cube
+m\u2215s=mètres par seconde
 mi=mille terrestre international
-mm=millim\u00e8tre
+mm=millimètre
 ms=milliseconde
-nm=nanom\u00e8tre
+nm=nanomètre
 ppm=parties par million
 s=seconde
-sr=st\u00e9radian
-unity=unit\u00e9
+sr=stéradian
+unity=unité
 wk=semaine
 %=pourcentage
-\u00b0=degr\u00e9e
+°=degrée
 \u2032=arc-minute
 \u2033=arc-seconde

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java [UTF-8] Thu Apr 27 15:56:42 2017
@@ -17,8 +17,10 @@
 package org.apache.sis.measure;
 
 import java.lang.reflect.Field;
+import javax.measure.IncommensurableException;
 import javax.measure.Unit;
 import javax.measure.UnitConverter;
+import javax.measure.quantity.Volume;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
@@ -30,7 +32,7 @@ import static org.apache.sis.test.Assert
 /**
  * Tests the {@link ConventionalUnit} class. This class tests also the {@link SystemUnit#multiply(double)} and
  * {@link SystemUnit#divide(double)} methods since they are used for creating {@code ConventionalUnit} instances,
- * but those methods just delegate to {@link ConventionalUnit#create(SystemUnit, UnitConverter)}.
+ * but those methods just delegate to {@link ConventionalUnit#create(AbstractUnit, UnitConverter)}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 0.8
@@ -70,7 +72,9 @@ public final strictfp class Conventional
         verify(Units.PASCAL,            Units.PASCAL,                "Pa",     1);
         verify(Units.PASCAL,            Units.HECTOPASCAL,          "hPa",   100);
         verify(Units.METRES_PER_SECOND, Units.KILOMETRES_PER_HOUR, "km∕h",  0.06);
+        verify(Units.CUBIC_METRE,       Units.LITRE,                  "L",  1E-3);
         verify(Units.KILOGRAM,          Units.KILOGRAM,              "kg",     1);
+        verify(Units.KILOGRAM,          Units.GRAM,                   "g",  1E-3);
         verify(Units.UNITY,             Units.UNITY,                   "",     1);
         verify(Units.UNITY,             Units.PERCENT,                "%",  1E-2);
         verify(Units.UNITY,             Units.PPM,                  "ppm",  1E-6);
@@ -240,6 +244,68 @@ public final strictfp class Conventional
     }
 
     /**
+     * Verifies that the given units derived from litres ({@code u1}) is equivalent to the given units derived
+     * from cubic metres ({@code u2}). The conversion between those two units is expected to be identity.
+     */
+    private static void assertEquivalent(final String s1, final Unit<Volume> u1,
+                                         final String s2, final Unit<Volume> u2)
+            throws IncommensurableException
+    {
+        assertEquals("unit1.symbol", s1, u1.getSymbol());
+        assertEquals("unit2.symbol", s2, u2.getSymbol());
+        assertTrue("getConverterTo(…).isIdentity", u1.getConverterTo(u2).isIdentity());
+        assertTrue("getConverterTo(…).isIdentity", u2.getConverterTo(u1).isIdentity());
+        assertTrue("getConverterTo(…).isIdentity", u1.getConverterToAny(u2).isIdentity());
+        assertTrue("getConverterTo(…).isIdentity", u2.getConverterToAny(u1).isIdentity());
+    }
+
+    /**
+     * Tests the equivalence between litres and cubic metres.
+     * The litre unit is handled as a special case, since it is not a SI unit but can have SI prefix.
+     *
+     * @throws IncommensurableException if {@link Unit#getConverterToAny(Unit)} failed.
+     */
+    @Test
+    @DependsOnMethod("verifyPrefixes")
+    public void testVolumeEquivalences() throws IncommensurableException {
+        assertEquivalent(  "L", Units.LITRE.divide  (1E+00),  "dm³", Units.CUBIC_METRE.divide  (1E+03));
+        assertEquivalent( "mL", Units.LITRE.divide  (1E+03),  "cm³", Units.CUBIC_METRE.divide  (1E+06));
+        assertEquivalent( "µL", Units.LITRE.divide  (1E+06),  "mm³", Units.CUBIC_METRE.divide  (1E+09));
+        assertEquivalent( "fL", Units.LITRE.divide  (1E+15),  "µm³", Units.CUBIC_METRE.divide  (1E+18));
+        assertEquivalent( "yL", Units.LITRE.divide  (1E+24),  "nm³", Units.CUBIC_METRE.divide  (1E+27));
+        assertEquivalent( "kL", Units.LITRE.multiply(1E+03),   "m³", Units.CUBIC_METRE.divide  (1E+00));
+        assertEquivalent( "ML", Units.LITRE.multiply(1E+06), "dam³", Units.CUBIC_METRE.multiply(1E+03));
+        assertEquivalent( "GL", Units.LITRE.multiply(1E+09),  "hm³", Units.CUBIC_METRE.multiply(1E+06));
+        assertEquivalent( "TL", Units.LITRE.multiply(1E+12),  "km³", Units.CUBIC_METRE.multiply(1E+09));
+        assertEquivalent( "ZL", Units.LITRE.multiply(1E+21),  "Mm³", Units.CUBIC_METRE.multiply(1E+18));
+        assertEquals    ( "dL", Units.LITRE.divide  (1E+01).getSymbol());
+        assertEquals    ( "cL", Units.LITRE.divide  (1E+02).getSymbol());
+        assertEquals    ( "nL", Units.LITRE.divide  (1E+09).getSymbol());
+        assertEquals    ( "pL", Units.LITRE.divide  (1E+12).getSymbol());
+        assertEquals    ( "aL", Units.LITRE.divide  (1E+18).getSymbol());
+        assertEquals    ( "zL", Units.LITRE.divide  (1E+21).getSymbol());
+        assertEquals    ("daL", Units.LITRE.multiply(1E+01).getSymbol());
+        assertEquals    ( "hL", Units.LITRE.multiply(1E+02).getSymbol());
+        assertEquals    ( "PL", Units.LITRE.multiply(1E+15).getSymbol());
+        assertEquals    ( "EL", Units.LITRE.multiply(1E+18).getSymbol());
+        assertEquals    ( "YL", Units.LITRE.multiply(1E+24).getSymbol());
+    }
+
+    /**
+     * Tests conversion between litres and cubic metres.
+     */
+    @Test
+    @DependsOnMethod("testVolumeEquivalences")
+    public void testVolumeConversions() {
+        final Unit<Volume>  l  = Units.LITRE;
+        final Unit<Volume> cl  = Units.LITRE.divide(100);
+        final Unit<Volume> ml  = Units.LITRE.divide(1000);
+        final Unit<Volume> cm3 = Units.CUBIC_METRE.divide(1E+06);
+        assertEquals("4 L to ml", 4000,  l.getConverterTo(ml) .convert(4), STRICT);
+        assertEquals("4 cL to cm³", 40, cl.getConverterTo(cm3).convert(4), STRICT);
+    }
+
+    /**
      * Serializes some units, deserializes them and verifies that we get the same instance.
      */
     @Test

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/SystemUnitTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/SystemUnitTest.java?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/SystemUnitTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/SystemUnitTest.java [UTF-8] Thu Apr 27 15:56:42 2017
@@ -53,7 +53,7 @@ public final strictfp class SystemUnitTe
      *
      * @throws ReflectiveOperationException if an error occurred while iterating over the field values.
      *
-     * @see ConventionalUnit#create(SystemUnit, UnitConverter)
+     * @see ConventionalUnit#create(AbstractUnit, UnitConverter)
      */
     @Test
     public void verifyRelatedUnits() throws ReflectiveOperationException {

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java?rev=1792913&r1=1792912&r2=1792913&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java [UTF-8] Thu Apr 27 15:56:42 2017
@@ -74,6 +74,7 @@ public final strictfp class UnitFormatTe
         verify(declared, "SQUARE_METRE",        "L²",           "m²",    "square metre",            Units.SQUARE_METRE);
         verify(declared, "HECTARE",             "L²",           "ha",    "hectare",                 Units.HECTARE);
         verify(declared, "CUBIC_METRE",         "L³",           "m³",    "cubic metre",             Units.CUBIC_METRE);
+        verify(declared, "LITRE",               "L³",           "L",     "litre",                   Units.LITRE);
         verify(declared, "STERADIAN",           "",             "sr",    "steradian",               Units.STERADIAN);
         verify(declared, "MICRORADIAN",         "",             "µrad",  "microradian",             Units.MICRORADIAN);
         verify(declared, "RADIAN",              "",             "rad",   "radian",                  Units.RADIAN);
@@ -115,6 +116,7 @@ public final strictfp class UnitFormatTe
         verify(declared, "LUMEN",               "J",            "lm",    "lumen",                   Units.LUMEN);
         verify(declared, "LUX",                 "J∕L²",         "lx",    "lux",                     Units.LUX);
         verify(declared, "KILOGRAM",            "M",            "kg",    "kilogram",                Units.KILOGRAM);
+        verify(declared, "GRAM",                "M",            "g",     "gram",                    Units.GRAM);
         verify(declared, "MOLE",                "N",            "mol",   "mole",                    Units.MOLE);
         verify(declared, "UNITY",               "",             "",       null,                     Units.UNITY);
         verify(declared, "PERCENT",             "",             "%",     "percentage",              Units.PERCENT);
@@ -209,9 +211,13 @@ public final strictfp class UnitFormatTe
         f.setStyle(UnitFormat.Style.UCUM);
         assertEquals("m",   f.format(Units.METRE));
         assertEquals("km",  f.format(Units.KILOMETRE));
+        assertEquals("g",   f.format(Units.GRAM));
+        assertEquals("kg",  f.format(Units.KILOGRAM));
         assertEquals("s",   f.format(Units.SECOND));
         assertEquals("min", f.format(Units.MINUTE));
         assertEquals("m2",  f.format(Units.SQUARE_METRE));
+        assertEquals("m3",  f.format(Units.CUBIC_METRE));
+        assertEquals("L",   f.format(Units.LITRE));
         assertEquals("Cel", f.format(Units.CELSIUS));
         assertEquals("K",   f.format(Units.KELVIN));
     }
@@ -225,9 +231,13 @@ public final strictfp class UnitFormatTe
         f.setStyle(UnitFormat.Style.NAME);
         assertEquals("metre",        f.format(Units.METRE));
         assertEquals("kilometre",    f.format(Units.KILOMETRE));
+        assertEquals("gram",         f.format(Units.GRAM));
+        assertEquals("kilogram",     f.format(Units.KILOGRAM));
         assertEquals("second",       f.format(Units.SECOND));
         assertEquals("minute",       f.format(Units.MINUTE));
         assertEquals("square metre", f.format(Units.SQUARE_METRE));
+        assertEquals("cubic metre",  f.format(Units.CUBIC_METRE));
+        assertEquals("litre",        f.format(Units.LITRE));
         assertEquals("Celsius",      f.format(Units.CELSIUS));          // Really upper-case "C" - this is a SI exception.
 
         f.setLocale(Locale.US);
@@ -235,6 +245,8 @@ public final strictfp class UnitFormatTe
         assertEquals("kilometer",    f.format(Units.KILOMETRE));
         assertEquals("second",       f.format(Units.SECOND));
         assertEquals("square meter", f.format(Units.SQUARE_METRE));
+        assertEquals("cubic meter",  f.format(Units.CUBIC_METRE));
+        assertEquals("liter",        f.format(Units.LITRE));
         assertEquals("Celsius",      f.format(Units.CELSIUS));
 
         f.setLocale(Locale.FRANCE);
@@ -242,6 +254,8 @@ public final strictfp class UnitFormatTe
         assertEquals("kilomètre",    f.format(Units.KILOMETRE));
         assertEquals("seconde",      f.format(Units.SECOND));
         assertEquals("mètre carré",  f.format(Units.SQUARE_METRE));
+        assertEquals("mètre cube",   f.format(Units.CUBIC_METRE));
+        assertEquals("litre",        f.format(Units.LITRE));
         assertEquals("Celsius",      f.format(Units.CELSIUS));
     }
 
@@ -262,6 +276,13 @@ public final strictfp class UnitFormatTe
         assertSame(Units.KILOMETRE,     f.parse("kilometers"));
         assertSame(Units.SQUARE_METRE,  f.parse("square metre"));
         assertSame(Units.SQUARE_METRE,  f.parse("square_meters"));
+        assertSame(Units.CUBIC_METRE,   f.parse("cubic_metres"));
+        assertSame(Units.LITRE,         f.parse("litre"));
+        assertSame(Units.LITRE,         f.parse("liters"));
+        assertSame(Units.GRAM,          f.parse("gram"));
+        assertSame(Units.GRAM,          f.parse("grams"));
+        assertSame(Units.KILOGRAM,      f.parse("kilogram"));
+        assertSame(Units.KILOGRAM,      f.parse("kilograms"));
         assertSame(Units.DEGREE,        f.parse("degree"));
         assertSame(Units.DEGREE,        f.parse("degrees"));
         assertSame(Units.DEGREE,        f.parse("decimal degrees"));
@@ -326,6 +347,9 @@ public final strictfp class UnitFormatTe
         assertSame(Units.METRE,         f.parse("m01"));
         assertSame(Units.SQUARE_METRE,  f.parse("m2"));
         assertSame(Units.CUBIC_METRE,   f.parse("m3"));
+        assertSame(Units.LITRE,         f.parse("L"));
+        assertSame(Units.LITRE,         f.parse("l"));
+        assertSame(Units.LITRE,         f.parse("ℓ"));
         assertSame(Units.HERTZ,         f.parse("s-1"));
     }
 
@@ -337,9 +361,13 @@ public final strictfp class UnitFormatTe
     @DependsOnMethod("testParseSymbol")
     public void testParsePrefix() {
         final UnitFormat f = new UnitFormat(Locale.UK);
-        ConventionalUnitTest.verify(Units.JOULE,  f.parse("kJ"),   "kJ",  1E+3);
-        ConventionalUnitTest.verify(Units.HERTZ,  f.parse("MHz"),  "MHz", 1E+6);
-        ConventionalUnitTest.verify(Units.PASCAL, f.parse("daPa"), "daPa",  10);
+        ConventionalUnitTest.verify(Units.JOULE,       f.parse("kJ"),   "kJ",   1E+3);
+        ConventionalUnitTest.verify(Units.HERTZ,       f.parse("MHz"),  "MHz",  1E+6);
+        ConventionalUnitTest.verify(Units.PASCAL,      f.parse("daPa"), "daPa", 1E+1);
+        ConventionalUnitTest.verify(Units.CUBIC_METRE, f.parse("mL"),   "mL",   1E-6);
+        ConventionalUnitTest.verify(Units.KILOGRAM,    f.parse("kg"),   "kg",   1E+0);
+        ConventionalUnitTest.verify(Units.KILOGRAM,    f.parse("g"),    "g",    1E-3);
+        ConventionalUnitTest.verify(Units.KILOGRAM,    f.parse("mg"),   "mg",   1E-6);
         /*
          * Verify that prefix are not accepted for conventional units. It would either be illegal prefix duplication
          * (for example we should not accept "kkm" as if it was "k" + "km") or confusing (for example "a" stands for



Mime
View raw message