sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1766833 [2/2] - in /sis/branches/JDK7: ./ core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/ core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ core/sis-utility/src/main/java/org/apache/sis/i...
Date Thu, 27 Oct 2016 14:15:19 GMT
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=1766833&r1=1766832&r2=1766833&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 27 14:15:18 2016
@@ -412,6 +412,17 @@ public final class Units extends Static
     public static final Unit<Time> TROPICAL_YEAR;
 
     /**
+     * The SI derived unit for frequency (Hz).
+     * One hertz is equal to one cycle per second.
+     * The unlocalized name is “hertz”.
+     *
+     * @since 0.8
+     *
+     * @see #SECOND
+     */
+    public static final Unit<Frequency> HERTZ;
+
+    /**
      * The SI derived unit for pressure (Pa).
      * One pascal is equal to 1 N/m².
      * Pressures are often used in {@linkplain org.apache.sis.referencing.crs.DefaultParametricCRS parametric CRS}
@@ -506,6 +517,14 @@ public final class Units extends Static
     public static final Unit<Mass> KILOGRAM;
 
     /**
+     * The SI base unit for electric current (A).
+     * The unlocalized name is “ampere”.
+     *
+     * @since 0.8
+     */
+    public static final Unit<ElectricCurrent> AMPERE;
+
+    /**
      * The SI derived unit for force (N).
      * One newton is the force required to give a mass of 1 kg an acceleration of 1 m/s².
      * The unlocalized name is “newton”.
@@ -556,15 +575,20 @@ public final class Units extends Static
     public static final Unit<Temperature> CELSIUS;
 
     /**
-     * The SI derived unit for frequency (Hz).
-     * One hertz is equal to one cycle per second.
-     * The unlocalized name is “hertz”.
+     * The SI base unit for luminous intensity (cd).
+     * The unlocalized name is “candela”.
      *
      * @since 0.8
+     */
+    public static final Unit<LuminousIntensity> CANDELA;
+
+    /**
+     * The SI base unit for amount of substance (mol).
+     * The unlocalized name is “mole”.
      *
-     * @see #SECOND
+     * @since 0.8
      */
-    public static final Unit<Frequency> HERTZ;
+    public static final Unit<AmountOfSubstance> MOLE;
 
     /**
      * The base dimensionless unit for scale measurements.
@@ -650,7 +674,10 @@ public final class Units extends Static
         final UnitDimension length        = new UnitDimension('L');
         final UnitDimension mass          = new UnitDimension('M');
         final UnitDimension time          = new UnitDimension('T');
+        final UnitDimension electric      = new UnitDimension('I');
         final UnitDimension temperature   = new UnitDimension('Θ');
+        final UnitDimension amount        = new UnitDimension('N');
+        final UnitDimension luminous      = new UnitDimension('J');
         final UnitDimension area          = length.pow(2);
         final UnitDimension speed         = length.divide(time);
         final UnitDimension force         = mass.multiply(speed).divide(time);
@@ -717,16 +744,19 @@ public final class Units extends Static
         PASCAL              = Pa;
         SQUARE_METRE        = m2;
         METRES_PER_SECOND   = mps;
-        KILOGRAM            = add(Mass.class,      mass,                  "kg",   UnitRegistry.SI,       (short) 0);
-        CUBIC_METRE         = add(Volume.class,    length.pow(3),         "m³",   UnitRegistry.SI,       (short) 0);
-        NEWTON              = add(Force.class,     force,                 "N",    UnitRegistry.SI,       (short) 0);
-        JOULE               = add(Energy.class,    energy,                "J",    UnitRegistry.SI,       (short) 0);
-        WATT                = add(Power.class,     energy.divide(time),   "W",    UnitRegistry.SI,       (short) 0);
-        HERTZ               = add(Frequency.class, time.pow(-1),          "Hz",   UnitRegistry.SI,       (short) 0);
-        HECTOPASCAL         = add(Pa, hecto,                              "hPa",  UnitRegistry.SI,       (short) 0);
-        HECTARE             = add(m2,  LinearConverter.scale(10000, 1),   "ha",   UnitRegistry.ACCEPTED, (short) 0);
-        KILOMETRES_PER_HOUR = add(mps, LinearConverter.scale(6, 100),     "km∕h", UnitRegistry.ACCEPTED, (short) 0);
-        CELSIUS             = add(K,   LinearConverter.create(1, 273.15), "°C",   UnitRegistry.SI,       (short) 0);
+        HERTZ               = add(Frequency.class,         time.pow(-1),           "Hz",   UnitRegistry.SI,       (short) 0);
+        KILOGRAM            = add(Mass.class,              mass,                   "kg",   UnitRegistry.SI,       (short) 0);
+        CUBIC_METRE         = add(Volume.class,            length.pow(3),          "m³",   UnitRegistry.SI,       (short) 0);
+        AMPERE              = add(ElectricCurrent.class,   electric,               "A",    UnitRegistry.SI,       (short) 0);
+        NEWTON              = add(Force.class,             force,                  "N",    UnitRegistry.SI,       (short) 0);
+        JOULE               = add(Energy.class,            energy,                 "J",    UnitRegistry.SI,       (short) 0);
+        WATT                = add(Power.class,             energy.divide(time),    "W",    UnitRegistry.SI,       (short) 0);
+        CANDELA             = add(LuminousIntensity.class, luminous,               "cd",   UnitRegistry.SI,       (short) 0);
+        MOLE                = add(AmountOfSubstance.class, amount,                 "mol",  UnitRegistry.SI,       (short) 0);
+        HECTOPASCAL         = add(Pa,  hecto,                                      "hPa",  UnitRegistry.SI,       (short) 0);
+        HECTARE             = add(m2,  LinearConverter.scale(10000, 1),            "ha",   UnitRegistry.ACCEPTED, (short) 0);
+        KILOMETRES_PER_HOUR = add(mps, LinearConverter.scale(6, 100),              "km∕h", UnitRegistry.ACCEPTED, (short) 0);
+        CELSIUS             = add(K,   LinearConverter.offset(27315, 100),         "°C",   UnitRegistry.SI,       (short) 0);
         /*
          * All Unit<Dimensionless>
          */
@@ -745,6 +775,8 @@ public final class Units extends Static
         UnitRegistry.alias(CELSIUS,     "℃");
         UnitRegistry.alias(CELSIUS,   "Cel");
         UnitRegistry.alias(GRAD,      "gon");
+        UnitRegistry.alias(HECTARE,   "hm²");
+        UnitRegistry.alias(UNITY,       "1");
 
         initialized = true;
     }

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] Thu Oct 27 14:15:18 2016
@@ -1621,7 +1621,7 @@ cmp:    while (ia < lga) {
      * @param  s1          the first characters sequence to compare, or {@code null}.
      * @param  s2          the second characters sequence to compare, or {@code null}.
      * @param  filter      the subset of characters to compare, or {@code null} for comparing all characters.
-     * @param  ignoreCase  {@code true} for comparing cases, or {@code false} for requiring exact match.
+     * @param  ignoreCase  {@code true} for ignoring cases, or {@code false} for requiring exact match.
      * @return {@code true} if both arguments are {@code null} or if the two given texts are equal,
      *         optionally ignoring case and filtered-out characters.
      */

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakEntry.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakEntry.java?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakEntry.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakEntry.java [UTF-8] Thu Oct 27 14:15:18 2016
@@ -35,7 +35,7 @@ import org.apache.sis.math.MathFunctions
  * This is an element in a linked list. When the reference is disposed, it is removed
  * from the enclosing collection.
  *
- * @param <E> The type of elements in the collection.
+ * @param  <E>  the type of elements in the collection.
  *
  * @author  Martin Desruisseaux (MPO, IRD, Geomatys)
  * @since   0.3
@@ -90,9 +90,9 @@ abstract class WeakEntry<E> extends Weak
      * Counts the number of entries in the given table.
      * This method does not verify if the referenced object has been garbage collected.
      *
-     * @param  <E>   The type of elements in the collection.
-     * @param  table The table in which to count the number of entries.
-     * @return Number of entries in the given table.
+     * @param  <E>    the type of elements in the collection.
+     * @param  table  the table in which to count the number of entries.
+     * @return number of entries in the given table.
      */
     static <E> int count(final WeakEntry<E>[] table) {
         int n = 0;
@@ -108,8 +108,8 @@ abstract class WeakEntry<E> extends Weak
     /**
      * Removes this entry from the given table of entries.
      *
-     * @param  table    The table from which to remove this entry.
-     * @param  removeAt The index of this entry in the given table.
+     * @param  table     the table from which to remove this entry.
+     * @param  removeAt  the index of this entry in the given table.
      * @return {@code true} if this entry has been found and removed, or {@code false} otherwise.
      */
     final boolean removeFrom(final WeakEntry<E>[] table, final int removeAt) {
@@ -134,12 +134,12 @@ abstract class WeakEntry<E> extends Weak
     /**
      * Rehashes the given table.
      *
-     * @param  oldTable     The table to rehash.
-     * @param  count        Number of elements in the table (including chained elements).
-     * @param  callerMethod The method invoking this one, for logging purpose only. The caller class
+     * @param  oldTable      the table to rehash.
+     * @param  count         number of elements in the table (including chained elements).
+     * @param  callerMethod  the method invoking this one, for logging purpose only. The caller class
      *         will be inferred from the enclosing class of the {@code oldTable} component type. This
      *         uses the knowledge that all our implementations of {@code WeakEntry} are inner classes.
-     * @return The new table array, or {@code oldTable} if no rehash were needed.
+     * @return the new table array, or {@code oldTable} if no rehash were needed.
      */
     static <E> WeakEntry<E>[] rehash(final WeakEntry<E>[] oldTable, final int count, final String callerMethod) {
         /*
@@ -188,8 +188,8 @@ abstract class WeakEntry<E> extends Weak
      * If the number of elements is lower than this threshold, then the table should be
      * rehashed for saving space.
      *
-     * @param  capacity The table capacity.
-     * @return Minimal number of elements for not rehashing.
+     * @param  capacity  the table capacity.
+     * @return minimal number of elements for not rehashing.
      */
     static int lowerCapacityThreshold(final int capacity) {
         return capacity >>> 2;
@@ -199,8 +199,8 @@ abstract class WeakEntry<E> extends Weak
      * If the number of elements is upper than this threshold, then the table should be
      * rehashed for better performance.
      *
-     * @param  capacity The table capacity.
-     * @return Maximal number of elements for not rehashing.
+     * @param  capacity  the table capacity.
+     * @return maximal number of elements for not rehashing.
      */
     static int upperCapacityThreshold(final int capacity) {
         return capacity - (capacity >>> 2);

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java [UTF-8] Thu Oct 27 14:15:18 2016
@@ -69,7 +69,7 @@ import java.util.Objects;
  * the caller. But if a sequence of two or more method calls need to appear atomic from other threads perspective,
  * then the caller can synchronize on {@code this}.
  *
- * @param <E> The type of elements in the set.
+ * @param  <E>  the type of elements in the set.
  *
  * @author  Martin Desruisseaux (MPO, IRD, Geomatys)
  * @since   0.3
@@ -134,7 +134,7 @@ public class WeakHashSet<E> extends Abst
     /**
      * Creates a {@code WeakHashSet} for elements of the specified type.
      *
-     * @param type The type of the element to be included in this set.
+     * @param  type  the type of the element to be included in this set.
      */
     public WeakHashSet(final Class<E> type) {
         elementType            = type;
@@ -198,7 +198,7 @@ public class WeakHashSet<E> extends Abst
     /**
      * Returns the count of element in this set.
      *
-     * @return Number of elements in this set.
+     * @return number of elements in this set.
      */
     @Override
     public synchronized int size() {
@@ -211,9 +211,9 @@ public class WeakHashSet<E> extends Abst
      * If this set already contains the specified element, the call leaves
      * this set unchanged and returns {@code false}.
      *
-     * @param  element Element to be added to this set.
+     * @param  element  element to be added to this set.
      * @return {@code true} if this set did not already contain the specified element.
-     * @throws NullArgumentException If the given object is {@code null}.
+     * @throws NullArgumentException if the given object is {@code null}.
      */
     @Override
     public synchronized boolean add(final E element) throws NullArgumentException {
@@ -225,7 +225,7 @@ public class WeakHashSet<E> extends Abst
      * Removes a single instance of the specified element from this set, if it is present
      * Null values are considered never present.
      *
-     * @param  element element to be removed from this set, if present. Can be {@code null}.
+     * @param  element  element to be removed from this set, if present. Can be {@code null}.
      * @return {@code true} if the set contained the specified element.
      */
     @Override
@@ -238,8 +238,8 @@ public class WeakHashSet<E> extends Abst
      * contain any object equals to {@code element}, then this method returns {@code null}.
      * Null values are considered never present.
      *
-     * @param  element The element to get.
-     * @return An element equals to the given one if already presents in the set,
+     * @param  element  the element to get.
+     * @return an element equals to the given one if already presents in the set,
      *         or {@code null} otherwise.
      *
      * @see #unique(Object)
@@ -252,7 +252,7 @@ public class WeakHashSet<E> extends Abst
      * Returns {@code true} if this set contains the specified element.
      * Null values are considered never present.
      *
-     * @param  element Object to be checked for containment in this set. Can be {@code null}.
+     * @param  element  object to be checked for containment in this set. Can be {@code null}.
      * @return {@code true} if this set contains the specified element.
      */
     @Override
@@ -277,10 +277,10 @@ public class WeakHashSet<E> extends Abst
      *     return element;
      * }
      *
-     * @param  <T> The type of the element to get. Can be {@code null}.
-     * @param  element The element to get or to add in the set if not already presents,
-     *         or {@code null} if the given element was null.
-     * @return An element equals to the given one if already presents in the set,
+     * @param  <T>      the type of the element to get. Can be {@code null}.
+     * @param  element  the element to get or to add in the set if not already presents,
+     *                  or {@code null} if the given element was null.
+     * @return an element equals to the given one if already presents in the set,
      *         or the given {@code object} otherwise.
      */
     public synchronized <T extends E> T unique(final T element) {
@@ -357,7 +357,7 @@ public class WeakHashSet<E> extends Abst
      * order. Note that this array contains strong references. Consequently, no
      * object reclamation will occur as long as a reference to this array is hold.
      *
-     * @return All elements in this set.
+     * @return all elements in this set.
      */
     @Override
     public synchronized E[] toArray() {
@@ -381,7 +381,7 @@ public class WeakHashSet<E> extends Abst
      * No element from this set will be garbage collected as long as a
      * reference to the iterator is hold.
      *
-     * @return An iterator over all elements in this set.
+     * @return an iterator over all elements in this set.
      */
     @Override
     public Iterator<E> iterator() {

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java [UTF-8] Thu Oct 27 14:15:18 2016
@@ -56,7 +56,7 @@ import java.util.Objects;
  *     V value;
  *     synchronized (map) {
  *         value = map.get(key);
- *         if (value != null) {
+ *         if (value == null) {
  *             value = ...; // Create the value here.
  *             map.put(key, value);
  *         }
@@ -75,8 +75,8 @@ import java.util.Objects;
  * of the caller. But if a sequence of two or more method calls need to appear atomic from other threads perspective,
  * then the caller can synchronize on {@code this}.
  *
- * @param <K> The class of key elements.
- * @param <V> The class of value elements.
+ * @param  <K>  the class of key elements.
+ * @param  <V>  the class of value elements.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
@@ -233,7 +233,7 @@ public class WeakValueHashMap<K,V> exten
     /**
      * Creates a new {@code WeakValueHashMap}.
      *
-     * @param keyType The type of keys in the map.
+     * @param  keyType  the type of keys in the map.
      */
     public WeakValueHashMap(final Class<K> keyType) {
         this(keyType, false);
@@ -247,9 +247,9 @@ public class WeakValueHashMap<K,V> exten
      * <p>Reference-equality semantic is rarely used. See the {@link java.util.IdentityHashMap} class javadoc
      * for a discussion about drawbacks and use cases when reference-equality semantic is useful.</p>
      *
-     * @param keyType  The type of keys in the map.
-     * @param identity {@code true} if the map shall use reference-equality in place of object-equality
-     *                 when comparing keys, or {@code false} for the standard behavior.
+     * @param  keyType   the type of keys in the map.
+     * @param  identity  {@code true} if the map shall use reference-equality in place of object-equality
+     *                   when comparing keys, or {@code false} for the standard behavior.
      *
      * @since 0.4
      */
@@ -309,7 +309,7 @@ public class WeakValueHashMap<K,V> exten
     /**
      * Returns the number of key-value mappings in this map.
      *
-     * @return The number of entries in this map.
+     * @return the number of entries in this map.
      */
     @Override
     public synchronized int size() {
@@ -320,7 +320,7 @@ public class WeakValueHashMap<K,V> exten
     /**
      * Returns the hash code value for the given key.
      *
-     * @param key The key (can not be null).
+     * @param  key  the key (can not be null).
      */
     final int keyHashCode(final Object key) {
         switch (comparisonMode) {
@@ -334,8 +334,8 @@ public class WeakValueHashMap<K,V> exten
     /**
      * Returns {@code true} if the two given keys are equal.
      *
-     * @param k1 The first key (can not be null).
-     * @paral k2 The second key.
+     * @param  k1  the first key (can not be null).
+     * @paral  k2  the second key.
      */
     final boolean keyEquals(final Object k1, final Object k2) {
         switch (comparisonMode) {
@@ -350,7 +350,7 @@ public class WeakValueHashMap<K,V> exten
      * Returns {@code true} if this map contains a mapping for the specified key.
      * Null keys are considered never present.
      *
-     * @param  key key whose presence in this map is to be tested.
+     * @param  key  key whose presence in this map is to be tested.
      * @return {@code true} if this map contains a mapping for the specified key.
      */
     @Override
@@ -362,7 +362,7 @@ public class WeakValueHashMap<K,V> exten
      * Returns {@code true} if this map maps one or more keys to this value.
      * Null values are considered never present.
      *
-     * @param  value value whose presence in this map is to be tested.
+     * @param  value  value whose presence in this map is to be tested.
      * @return {@code true} if this map maps one or more keys to this value.
      */
     @Override
@@ -375,8 +375,8 @@ public class WeakValueHashMap<K,V> exten
      * Returns {@code null} if the map contains no mapping for this key.
      * Null keys are considered never present.
      *
-     * @param  key Key whose associated value is to be returned.
-     * @return The value to which this map maps the specified key.
+     * @param  key  key whose associated value is to be returned.
+     * @return the value to which this map maps the specified key.
      */
     @Override
     @SuppressWarnings("unchecked")
@@ -436,9 +436,9 @@ public class WeakValueHashMap<K,V> exten
      * Associates the specified value with the specified key in this map.
      * The value is associated using a {@link WeakReference}.
      *
-     * @param  key key with which the specified value is to be associated.
-     * @param  value value to be associated with the specified key.
-     * @return The previous value associated with specified key, or {@code null} if there was no mapping for key.
+     * @param  key    key with which the specified value is to be associated.
+     * @param  value  value to be associated with the specified key.
+     * @return the previous value associated with specified key, or {@code null} if there was no mapping for key.
      *
      * @throws NullArgumentException if the key or the value is {@code null}.
      */
@@ -457,9 +457,9 @@ public class WeakValueHashMap<K,V> exten
      * value is returned. Otherwise the specified value is associated to the key using a {@link WeakReference}
      * and {@code null} is returned.
      *
-     * @param  key key with which the specified value is to be associated.
-     * @param  value value to be associated with the specified key.
-     * @return The current value associated with specified key, or {@code null} if there was no mapping for key.
+     * @param  key    key with which the specified value is to be associated.
+     * @param  value  value to be associated with the specified key.
+     * @return the current value associated with specified key, or {@code null} if there was no mapping for key.
      *
      * @throws NullArgumentException if the key or the value is {@code null}.
      *
@@ -476,7 +476,7 @@ public class WeakValueHashMap<K,V> exten
     /**
      * Removes the mapping for this key from this map if present.
      *
-     * @param key key whose mapping is to be removed from the map.
+     * @param  key  key whose mapping is to be removed from the map.
      * @return previous value associated with specified key, or {@code null} if there was no entry for key.
      */
     @Override
@@ -527,8 +527,7 @@ public class WeakValueHashMap<K,V> exten
 
         /**
          * Returns a view of this set as an array. Note that this array contains strong references.
-         * Consequently, no object reclamation will occur as long as a reference to this array is
-         * hold.
+         * Consequently, no object reclamation will occur as long as a reference to this array is hold.
          */
         @Override
         @SuppressWarnings("unchecked")

Modified: sis/branches/JDK7/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames.properties?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames.properties [ISO-8859-1] Thu Oct 27 14:15:18 2016
@@ -1,5 +1,7 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
+A=ampere
 a=year
+cd=candela
 cm=centimetre
 d=day
 ft=foot
@@ -21,6 +23,7 @@ m³=cubic metre
 mi=statute mile
 min=minute
 mm=millimetre
+mol=mole
 ms=millisecond
 N=newton
 nm=nanometre

Modified: sis/branches/JDK7/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_fr.properties?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/resources/org/apache/sis/measure/UnitNames_fr.properties [ISO-8859-1] Thu Oct 27 14:15:18 2016
@@ -1,4 +1,5 @@
 # Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
+A=ampère
 a=année
 cm=centimètre
 d=jour

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=1766833&r1=1766832&r2=1766833&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 27 14:15:18 2016
@@ -51,7 +51,7 @@ public final strictfp class MeasureTest
     /**
      * Tests the {@link Measure#setUOM(String)}.
      *
-     * @throws URISyntaxException Should not happen.
+     * @throws URISyntaxException if the URI used by the test is invalid.
      */
     @Test
     @DependsOnMethod("testGetUOM")
@@ -73,7 +73,7 @@ public final strictfp class MeasureTest
 
         measure.unit = null;
         measure.asXPointer = true;
-        measure.setUOM("gmxUom.xml#kg"); // Not really an existing unit in 'gmxUom'.
+        measure.setUOM("gmxUom.xml#kg");                        // Not really an existing unit in 'gmxUom'.
         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/ConventionalUnitTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/ConventionalUnitTest.java [UTF-8] Thu Oct 27 14:15:18 2016
@@ -16,16 +16,21 @@
  */
 package org.apache.sis.measure;
 
+import java.lang.reflect.Field;
 import javax.measure.Unit;
+import javax.measure.UnitConverter;
 import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.test.Assert.*;
 
 
 /**
- * Tests the {@link ConventionalUnit} class.
+ * 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)}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.8
@@ -45,7 +50,7 @@ public final strictfp class Conventional
     static void verify(final Unit<?> system, final Unit<?> unit, final String symbol, final double scale) {
         assertSame  ("getSystemUnit()", system, unit.getSystemUnit());
         assertEquals("getSymbol()",     symbol, unit.getSymbol());
-        assertEquals("UnitConverter", scale, Units.toStandardUnit(unit), STRICT);
+        assertEquals("UnitConverter",   scale,  Units.toStandardUnit(unit), STRICT);
     }
 
     /**
@@ -70,4 +75,137 @@ public final strictfp class Conventional
         verify(Units.UNITY,             Units.PERCENT,                "%",  1E-2);
         verify(Units.UNITY,             Units.PPM,                  "ppm",  1E-6);
     }
+
+    /**
+     * Tests {@link ConventionalUnit#prefix(double)}.
+     */
+    @Test
+    public void testPrefix() {
+        assertEquals( 0 , ConventionalUnit.prefix(1E-27));
+        assertEquals( 0 , ConventionalUnit.prefix(1E-25));
+        assertEquals('y', ConventionalUnit.prefix(1E-24));
+        assertEquals( 0 , ConventionalUnit.prefix(1E-23));
+        assertEquals('n', ConventionalUnit.prefix(1E-09));
+        assertEquals( 0 , ConventionalUnit.prefix(1E-08));
+        assertEquals( 0 , ConventionalUnit.prefix(1E-04));
+        assertEquals('m', ConventionalUnit.prefix(1E-03));
+        assertEquals('c', ConventionalUnit.prefix(1E-02));
+        assertEquals('d', ConventionalUnit.prefix(1E-01));
+        assertEquals( 0 , ConventionalUnit.prefix(    1));
+        assertEquals( 0 , ConventionalUnit.prefix(    0));
+        assertEquals( 0 , ConventionalUnit.prefix(  -10));
+        assertEquals('㍲', ConventionalUnit.prefix(   10));
+        assertEquals('h', ConventionalUnit.prefix(  100));
+        assertEquals('k', ConventionalUnit.prefix( 1000));
+        assertEquals( 0 , ConventionalUnit.prefix(1E+04));
+        assertEquals('G', ConventionalUnit.prefix(1E+09));
+        assertEquals('Y', ConventionalUnit.prefix(1E+24));
+        assertEquals( 0 , ConventionalUnit.prefix(1E+25));
+        assertEquals( 0 , ConventionalUnit.prefix(1E+27));
+        assertEquals( 0 , ConventionalUnit.prefix(1E+25));
+    }
+
+    /**
+     * Tests {@link ConventionalUnit#power(String)}.
+     */
+    @Test
+    public void testPower() {
+        assertEquals("m",    1, ConventionalUnit.power("m"));
+        assertEquals("m²",   2, ConventionalUnit.power("m²"));
+        assertEquals("m2",   2, ConventionalUnit.power("m2"));
+        assertEquals("m₂",   1, ConventionalUnit.power("m₂"));      // Because the "2" is in indice.
+        assertEquals("m³",   3, ConventionalUnit.power("m³"));
+        assertEquals("m/s²", 1, ConventionalUnit.power("m/s²"));
+        assertEquals("km/h", 1, ConventionalUnit.power("km/h"));
+        assertEquals("m³/s", 3, ConventionalUnit.power("m³/s"));
+        assertEquals("m³s",  0, ConventionalUnit.power("m³s"));     // Illegal symbol.
+    }
+
+    /**
+     * Ensures that the characters in the {@link ConventionalUnit#PREFIXES} array match
+     * the prefixes recognized by {@link LinearConverter#forPrefix(char)}.
+     *
+     * @throws ReflectiveOperationException if this test can not access the private fields of {@link LinearConverter}.
+     *
+     * @see LinearConverterTest#verifyPrefixes()
+     */
+    @Test
+    @DependsOnMethod("testPrefix")
+    public void verifyPrefixes() throws ReflectiveOperationException {
+        Field f = ConventionalUnit.class.getDeclaredField("PREFIXES");
+        f.setAccessible(true);
+        double previousScale = StrictMath.pow(1000, -(ConventionalUnit.MAX_POWER + 1));
+        for (final char prefix : (char[]) f.get(null)) {
+            final LinearConverter lc = LinearConverter.forPrefix(prefix);
+            final String asString = String.valueOf(prefix);
+            assertNotNull(asString, lc);
+            /*
+             * Ratio of previous scale with current scale shall be a power of 10.
+             */
+            final double scale = lc.derivative(0);
+            final double power = StrictMath.log10(scale / previousScale);
+            assertTrue  (asString,    power >= 1);
+            assertEquals(asString, 0, power % 1, STRICT);
+            /*
+             * At this point we got the LinearConverter to use for the test,
+             * and we know the expected prefix. Verify that we get that value.
+             */
+            assertEquals("ConventionalUnit.prefix(double)", asString, String.valueOf(ConventionalUnit.prefix(scale)));
+            previousScale = scale;
+        }
+    }
+
+    /**
+     * Tests {@link SystemUnit#multiply(double)} and {@link SystemUnit#divide(double)}.
+     * Both are implemented by calls to {@link SystemUnit#transform(UnitConverter)}.
+     */
+    @Test
+    @DependsOnMethod({"verifyPrefixes","testPower"})
+    public void testTransformSystemUnit() {
+        assertSame(Units.METRE,      Units.METRE.multiply(   1));
+        assertSame(Units.KILOMETRE,  Units.METRE.multiply(1000));
+        assertSame(Units.MILLIMETRE, Units.METRE.divide  (1000));
+        assertSame(Units.CENTIMETRE, Units.METRE.divide  ( 100));
+        assertSame(Units.NANOMETRE,  Units.METRE.divide  (1E+9));
+        assertSame(Units.NANOMETRE,  Units.METRE.multiply(1E-9));
+        verify    (Units.METRE,      Units.METRE.multiply( 100), "hm", 100);
+        verify    (Units.METRE,      Units.METRE.multiply(  10), "dam", 10);
+
+        assertSame(Units.METRES_PER_SECOND, Units.METRES_PER_SECOND.multiply(   1));
+        verify    (Units.METRES_PER_SECOND, Units.METRES_PER_SECOND.multiply(1000), "km∕s", 1E+3);
+        verify    (Units.METRES_PER_SECOND, Units.METRES_PER_SECOND.divide  (1000), "mm∕s", 1E-3);
+
+        assertSame(Units.SQUARE_METRE, Units.SQUARE_METRE.multiply(   1));
+        assertSame(Units.HECTARE,      Units.SQUARE_METRE.multiply(1E+4));
+        assertSame(Units.CUBIC_METRE,  Units.CUBIC_METRE .multiply(   1));
+        verify    (Units.CUBIC_METRE,  Units.CUBIC_METRE .multiply(1E+9), "km³", 1E+9);
+        verify    (Units.CUBIC_METRE,  Units.CUBIC_METRE .divide  (1E+9), "mm³", 1E-9);
+    }
+
+    /**
+     * Tests {@link ConventionalUnit#multiply(double)} and {@link ConventionalUnit#divide(double)}.
+     * Both are implemented by calls to {@link ConventionalUnit#transform(UnitConverter)}.
+     */
+    @Test
+    @DependsOnMethod("testTransformSystemUnit")
+    public void testTransformConventionalUnit() {
+        assertSame(Units.MILLIMETRE, Units.MILLIMETRE.multiply(   1));
+        assertSame(Units.CENTIMETRE, Units.MILLIMETRE.multiply(  10));
+        assertSame(Units.MILLIMETRE, Units.CENTIMETRE.divide  (  10));
+        assertSame(Units.MILLIMETRE, Units.CENTIMETRE.multiply( 0.1));
+        assertSame(Units.KILOMETRE,  Units.MILLIMETRE.multiply(1E+6));
+        assertSame(Units.NANOMETRE,  Units.KILOMETRE .divide  (1E+12));
+        assertSame(Units.NANOMETRE,  Units.KILOMETRE .multiply(1E-12));
+
+        verify(Units.SQUARE_METRE, Units.HECTARE.divide(1E+10), "mm²", 1E-6);
+    }
+
+    /**
+     * Serializes some units, deserializes them and verifies that we get the same instance.
+     */
+    @Test
+    public void testSerialization() {
+        assertSame(Units.KILOMETRE, assertSerializedEquals(Units.KILOMETRE));
+        assertSame(Units.HECTARE,   assertSerializedEquals(Units.HECTARE));
+    }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/LinearConverterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/LinearConverterTest.java?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/LinearConverterTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/LinearConverterTest.java [UTF-8] Thu Oct 27 14:15:18 2016
@@ -16,12 +16,16 @@
  */
 package org.apache.sis.measure;
 
+import java.math.BigDecimal;
 import java.lang.reflect.Field;
-import org.apache.sis.test.TestCase;
+import javax.measure.UnitConverter;
+import org.apache.sis.math.Fraction;
 import org.apache.sis.util.ArraysExt;
+import org.apache.sis.test.TestCase;
+import org.apache.sis.test.DependsOnMethod;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.test.Assert.*;
 
 
 /**
@@ -34,10 +38,35 @@ import static org.junit.Assert.*;
  */
 public final strictfp class LinearConverterTest extends TestCase {
     /**
+     * Asserts that the given converter is a linear converter with the given scale factor and no offset.
+     * The scale factor is given by the ratio of the given numerator and denominator.
+     *
+     * @param  numerator    the expected numerator in the conversion factor.
+     * @param  denominator  the expected denominator in the conversion factor.
+     * @param  converter    the converter to verify.
+     */
+    private static void assertScale(final int numerator, final int denominator, final LinearConverter converter) {
+        final double derivative = numerator / (double) denominator;
+        final Number[] coefficients = converter.coefficients();
+        assertEquals("coefficients.length", 2, coefficients.length);
+        assertEquals("offset", 0, coefficients[0].doubleValue(), STRICT);
+        assertEquals("scale", derivative, coefficients[1].doubleValue(), STRICT);
+        if (denominator != 1) {
+            assertInstanceOf("coefficients[1]", Fraction.class, coefficients[1]);
+            final Fraction f = (Fraction) coefficients[1];
+            assertEquals("numerator",   numerator,   f.numerator);
+            assertEquals("denominator", denominator, f.denominator);
+        }
+        assertEquals("derivative", derivative, converter.derivative(0), STRICT);
+    }
+
+    /**
      * Ensures that the characters in the {@link LinearConverter#PREFIXES} array are in strictly increasing order,
      * and that {@link LinearConverter#POWERS} has the same length.
      *
      * @throws ReflectiveOperationException if this test can not access the private fields of {@link LinearConverter}.
+     *
+     * @see ConventionalUnitTest#verifyPrefixes()
      */
     @Test
     public void verifyPrefixes() throws ReflectiveOperationException {
@@ -50,4 +79,184 @@ public final strictfp class LinearConver
         f.setAccessible(true);
         assertEquals("length", prefixes.length, ((byte[]) f.get(null)).length);
     }
+
+    /**
+     * Tests the {@link LinearConverter#forPrefix(char)} method. This also indirectly tests the
+     * {@link LinearConverter#scale(double, double)} and {@link LinearConverter#coefficients()}
+     * methods.
+     */
+    @Test
+    public void testForPrefix() {
+        assertScale(1000000,    1, LinearConverter.forPrefix('M'));
+        assertScale(   1000,    1, LinearConverter.forPrefix('k'));
+        assertScale(      1,  100, LinearConverter.forPrefix('c'));
+        assertScale(      1, 1000, LinearConverter.forPrefix('m'));
+    }
+
+    /**
+     * Tests {@link LinearConverter#pow(UnitConverter, int, boolean)}.
+     */
+    @Test
+    public void testPow() {
+        LinearConverter c = LinearConverter.scale(10, 3);
+        assertScale( 100,  9, LinearConverter.pow(c, 2, false));
+        assertScale(1000, 27, LinearConverter.pow(c, 3, false));
+
+        c = LinearConverter.scale(1000, 27);
+        assertScale(10, 3, LinearConverter.pow(c, 3, true));
+    }
+
+    /**
+     * Tests the {@link LinearConverter#isIdentity()} and {@link LinearConverter#isLinear()} methods.
+     * This also indirectly test the {@link LinearConverter#offset(double, double)} and
+     * {@link LinearConverter#coefficients()} methods.
+     */
+    @Test
+    public void testIsIdentityAndLinear() {
+        LinearConverter c = LinearConverter.IDENTITY;
+        assertTrue(c.isIdentity());
+        assertTrue(c.isLinear());
+        assertEquals("coefficients.length", 0, c.coefficients().length);
+
+        c = LinearConverter.scale(100, 100);
+        assertTrue(c.isIdentity());
+        assertTrue(c.isLinear());
+        assertEquals("coefficients.length", 0, c.coefficients().length);
+
+        c = LinearConverter.scale(254, 100);
+        assertFalse(c.isIdentity());
+        assertTrue (c.isLinear());
+        assertScale(254, 100, c);
+    }
+
+    /**
+     * Tests {@link LinearConverter#convert(double)}. This method tests also the pertinence of
+     * representing the conversion factor by a ratio instead than a single {@code double} value.
+     */
+    @Test
+    public void testConvertDouble() {
+        LinearConverter c = LinearConverter.scale(254, 100);            // inches to centimetres
+        assertEquals(1143, c.convert(450), STRICT);
+        /*
+         * Below is an example of case giving a different result depending on whether we use the straightforward
+         * y = (x⋅scale + offset)  equation or the longer  y = (x⋅scale + offset) ∕ divisor  equation.  This test
+         * uses the US survey foot, which is defined as exactly 1200∕3937 metres.  That conversion factor has no
+         * exact representation in the 'double' type. Converting 200 metres to US survey foot gives 656.1666666…
+         * Converting that value back to US survey foot with (x⋅scale + offset) gives 199.99999999999997 metres,
+         * but the longer equation used by UnitConverter gives exactly 200 metres as expected.
+         *
+         * Reminder: we usually don't care much about those rounding errors as they are unavoidable when doing
+         * floating point arithmetic and the scale factor are usually no more accurate in base 10 than base 2.
+         * But unit conversions are special cases since the conversion factors are exact in base 10 by definition.
+         */
+        c = LinearConverter.scale(1200, 3937);                          // US survey feet to metres
+        assertEquals(200, c.convert(656.16666666666667), STRICT);       // Really want STRICT; see above comment
+        /*
+         * Test conversion from degrees Celsius to Kelvin. The straightforward equation gives 300.15999999999997
+         * while the longer equation used by UnitConverter gives 300.16 as expected.
+         */
+        c = LinearConverter.offset(27315, 100);                         // Celsius to kelvin
+        assertEquals(300.16, c.convert(27.01), STRICT);                 // Really want STRICT; see above comment
+    }
+
+    /**
+     * Tests {@link LinearConverter#convert(Number)} with a value of type {@link Float}.
+     * This method indirectly tests {@link org.apache.sis.math.DecimalFunctions#floatToDouble(float)}.
+     */
+    @Test
+    @DependsOnMethod("testConvertDouble")
+    public void testConvertFloat() {
+        LinearConverter c = LinearConverter.offset(27315, 100);
+        final Number n = c.convert(Float.valueOf(27.01f));
+        assertInstanceOf("convert(Float)", Double.class, n);
+        assertEquals(300.16, n.doubleValue(), STRICT);                  // Really want STRICT; see testConvertDouble()
+    }
+
+    /**
+     * Tests {@link LinearConverter#convert(Number)} with a value of type {@link BigDecimal}.
+     */
+    @Test
+    @DependsOnMethod("testConvertDouble")
+    public void testConvertBigDecimal() {
+        LinearConverter c = LinearConverter.offset(27315, 100);
+        final Number n = c.convert(new BigDecimal("27.01"));
+        assertInstanceOf("convert(BigDecimal)", BigDecimal.class, n);
+        assertEquals(new BigDecimal("300.16"), n);
+    }
+
+    /**
+     * Tests {@link LinearConverter#inverse()}.
+     */
+    @Test
+    public void testInverse() {
+        LinearConverter c = LinearConverter.scale(254, 100);
+        LinearConverter inv = (LinearConverter) c.inverse();
+        assertScale(254, 100, c);
+        assertScale(100, 254, inv);
+        assertEquals(12.3, c.convert(inv.convert(12.3)), STRICT);
+        /*
+         * Following is an example of case where our effort regarding preserving accuracy in base 10 does not work.
+         * However the concatenation of those two UnitConverter gives the identity converter, as expected.
+         * That concatenation is not verified here because it is not the purpose of this test case.
+         */
+        c = LinearConverter.offset(27315, 100);
+        inv = (LinearConverter) c.inverse();
+        assertEquals(12.3, c.convert(inv.convert(12.3)), 1E-13);
+        // TODO: use JDK9' Math.fma(…) in LinearConverter.convert(double) and verify if it solve the accuracy issue.
+    }
+
+    /**
+     * Tests {@link LinearConverter#concatenate(UnitConverter)}.
+     */
+    @Test
+    public void testConcatenate() {
+        LinearConverter c = LinearConverter.scale(254, 100);                        // inches to centimetres
+        assertScale(254, 100, c);
+        c = (LinearConverter) c.concatenate(LinearConverter.scale(10, 1));          // centimetres to millimetres
+        assertScale(254, 10, c);
+        c = (LinearConverter) c.concatenate(LinearConverter.scale(1, 1000));        // millimetres to metres
+        assertScale(254, 10000, c);
+
+        c = LinearConverter.offset(27315, 100);                                     // Celsius to kelvin
+        c = (LinearConverter) c.concatenate(LinearConverter.offset(-54630, 200));
+        assertTrue(c.isIdentity());
+    }
+
+    /**
+     * Tests {@link LinearConverter#equals(Object)} and {@link LinearConverter#hashCode()}.
+     */
+    @Test
+    public void testEquals() {
+        final LinearConverter c1 = LinearConverter.scale(254, 100);
+        final LinearConverter c2 = LinearConverter.scale( 25, 100);
+        final LinearConverter c3 = LinearConverter.scale(254, 100);
+        assertFalse(c1.equals(c2));
+        assertTrue (c1.equals(c3));
+        assertFalse(c2.equals(c3));
+        assertFalse(c1.hashCode() == c2.hashCode());
+        assertTrue (c1.hashCode() == c3.hashCode());
+        assertFalse(c2.hashCode() == c3.hashCode());
+    }
+
+    /**
+     * Tests serialization of a {@link UnitConverter}.
+     */
+    @Test
+    @DependsOnMethod("testEquals")
+    public void testSerialization() {
+        LinearConverter c = LinearConverter.scale(254, 100);
+        assertNotSame(c, assertSerializedEquals(c));
+    }
+
+    /**
+     * Tests {@link LinearConverter#toString()}, mostly for debugging purpose.
+     */
+    @Test
+    public void testToString() {
+        assertEquals("y = x",                   LinearConverter.IDENTITY          .toString());
+        assertEquals("y = 100⋅x",               LinearConverter.scale (  100,   1).toString());
+        assertEquals("y = x∕100",               LinearConverter.scale (    1, 100).toString());
+        assertEquals("y = 254⋅x∕100",           LinearConverter.scale (  254, 100).toString());
+        assertEquals("y = (100⋅x + 27315)∕100", LinearConverter.offset(27315, 100).toString());
+    }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitFormatTest.java [UTF-8] Thu Oct 27 14:15:18 2016
@@ -81,6 +81,7 @@ public final strictfp class UnitFormatTe
         verify(declared, "DAY",                 "T",        "d",     Units.DAY);
         verify(declared, "WEEK",                "T",        "wk",    Units.WEEK);
         verify(declared, "TROPICAL_YEAR",       "T",        "a",     Units.TROPICAL_YEAR);
+        verify(declared, "HERTZ",               "∕T",       "Hz",    Units.HERTZ);
         verify(declared, "PASCAL",              "M∕(L⋅T²)", "Pa",    Units.PASCAL);
         verify(declared, "HECTOPASCAL",         "M∕(L⋅T²)", "hPa",   Units.HECTOPASCAL);
         verify(declared, "HECTARE",             "L²",       "ha",    Units.HECTARE);
@@ -89,12 +90,14 @@ public final strictfp class UnitFormatTe
         verify(declared, "METRES_PER_SECOND",   "L∕T",      "m∕s",   Units.METRES_PER_SECOND);
         verify(declared, "KILOMETRES_PER_HOUR", "L∕T",      "km∕h",  Units.KILOMETRES_PER_HOUR);
         verify(declared, "KILOGRAM",            "M",        "kg",    Units.KILOGRAM);
+        verify(declared, "AMPERE",              "I",        "A",     Units.AMPERE);
         verify(declared, "NEWTON",              "M⋅L∕T²",   "N",     Units.NEWTON);
         verify(declared, "JOULE",               "M⋅L²∕T²",  "J",     Units.JOULE);
         verify(declared, "WATT",                "M⋅L²∕T³",  "W",     Units.WATT);
         verify(declared, "KELVIN",              "Θ",        "K",     Units.KELVIN);
         verify(declared, "CELSIUS",             "Θ",        "°C",    Units.CELSIUS);
-        verify(declared, "HERTZ",               "∕T",       "Hz",    Units.HERTZ);
+        verify(declared, "CANDELA",             "J",        "cd",    Units.CANDELA);
+        verify(declared, "MOLE",                "N",        "mol",   Units.MOLE);
         verify(declared, "UNITY",               "",         "",      Units.UNITY);
         verify(declared, "PERCENT",             "",         "%",     Units.PERCENT);
         verify(declared, "PPM",                 "",         "ppm",   Units.PPM);
@@ -281,4 +284,19 @@ public final strictfp class UnitFormatTe
             assertTrue(message, message.contains("ka"));
         }
     }
+
+    /**
+     * Tests parsing of symbols composed of terms combined by arithmetic operations (e.g. "m/s").
+     */
+    @Test
+    @DependsOnMethod("testPrefixParsing")
+    public void testTermsParsing() {
+        final UnitFormat f = new UnitFormat(Locale.UK);
+        assertSame(Units.SQUARE_METRE,      f.parse("m⋅m"));
+        assertSame(Units.CUBIC_METRE,       f.parse("m⋅m⋅m"));
+        assertSame(Units.CUBIC_METRE,       f.parse("m²⋅m"));
+        assertSame(Units.CUBIC_METRE,       f.parse("m2.m"));
+        assertSame(Units.METRES_PER_SECOND, f.parse("m∕s"));
+        assertSame(Units.HERTZ,             f.parse("1/s"));
+    }
 }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/measure/UnitsTest.java [UTF-8] Thu Oct 27 14:15:18 2016
@@ -35,6 +35,7 @@ import static org.apache.sis.test.Assert
  * @module
  */
 @DependsOn({
+    UnitFormatTest.class,
     SexagesimalConverterTest.class,
     org.apache.sis.internal.util.DefinitionURITest.class,
     org.apache.sis.internal.util.XPathsTest.class
@@ -293,7 +294,7 @@ public final strictfp class UnitsTest ex
         assertEquals(Integer.valueOf(9122), getEpsgCode(DEGREE,         true));
         assertEquals(Integer.valueOf(9110), getEpsgCode(DMS,            false));
         assertEquals(Integer.valueOf(9110), getEpsgCode(DMS,            true));
-        assertEquals(Integer.valueOf(9108), getEpsgCode(DMS_SCALED,     false));
+        assertEquals(Integer.valueOf(9107), getEpsgCode(DMS_SCALED,     false));
         assertEquals(Integer.valueOf(9111), getEpsgCode(DM,             false));
         assertEquals(Integer.valueOf(1029), getEpsgCode(TROPICAL_YEAR,  false));
         assertEquals(Integer.valueOf(1040), getEpsgCode(SECOND,         false));

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] Thu Oct 27 14:15:18 2016
@@ -51,7 +51,7 @@ import org.junit.BeforeClass;
     org.apache.sis.util.LocalesTest.class,
     org.apache.sis.util.resources.LoaderTest.class,
     org.apache.sis.util.resources.IndexedResourceBundleTest.class,
-    org.apache.sis.util.ArgumentChecksTest.class, // Uses resources.
+    org.apache.sis.util.ArgumentChecksTest.class,                       // Uses resources.
     org.apache.sis.util.logging.PerformanceLevelTest.class,
     org.apache.sis.util.logging.WarningListenersTest.class,
     org.apache.sis.util.logging.MonolineFormatterTest.class,
@@ -109,6 +109,7 @@ import org.junit.BeforeClass;
     org.apache.sis.measure.ConventionalUnitTest.class,
     org.apache.sis.measure.UnitFormatTest.class,
     org.apache.sis.measure.UnitsTest.class,
+    org.apache.sis.measure.UnitServicesTest.class,
     org.apache.sis.measure.RangeTest.class,
     org.apache.sis.measure.DateRangeTest.class,
     org.apache.sis.measure.NumberRangeTest.class,
@@ -138,7 +139,7 @@ import org.junit.BeforeClass;
     org.apache.sis.internal.converter.ArrayConverterTest.class,
     org.apache.sis.internal.converter.ConverterRegistryTest.class,
     org.apache.sis.internal.converter.SystemRegistryTest.class,
-    org.apache.sis.internal.converter.NumberConverterTest.class, // Shall be after SystemRegistryTest.
+    org.apache.sis.internal.converter.NumberConverterTest.class,        // Shall be after SystemRegistryTest.
 
     // XML most basic types.
     org.apache.sis.xml.XLinkTest.class,

Modified: sis/branches/JDK7/ide-project/NetBeans/build.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/build.xml?rev=1766833&r1=1766832&r2=1766833&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/build.xml (original)
+++ sis/branches/JDK7/ide-project/NetBeans/build.xml Thu Oct 27 14:15:18 2016
@@ -77,6 +77,13 @@
       </fileset>
     </concat>
 
+    <!-- Units of Measurement implementations to be loaded by ServiceLoader. -->
+    <concat destfile="${build.classes.dir}/META-INF/services/javax.measure.spi.ServiceProvider" encoding="UTF-8" fixlastline="yes">
+      <fileset dir="${project.root}">
+        <include name="*/*/src/main/resources/META-INF/services/javax.measure.spi.ServiceProvider"/>
+      </fileset>
+    </concat>
+
 
 
     <!-- ==== GeoAPI service providers ============================================================================= -->



Mime
View raw message