sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1755608 - in /sis/branches/JDK8/core: sis-feature/src/main/java/org/apache/sis/feature/builder/ sis-utility/src/main/java/org/apache/sis/math/ sis-utility/src/test/java/org/apache/sis/math/
Date Tue, 09 Aug 2016 14:42:17 GMT
Author: desruisseaux
Date: Tue Aug  9 14:42:17 2016
New Revision: 1755608

URL: http://svn.apache.org/viewvc?rev=1755608&view=rev
Log:
Fix corner cases (NullPointerException, etc.).

Modified:
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/ConcatenatedVector.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/math/VectorTest.java

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java?rev=1755608&r1=1755607&r2=1755608&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
[UTF-8] Tue Aug  9 14:42:17 2016
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Locale;
+import java.util.Set;
 import org.opengis.util.GenericName;
 import org.opengis.util.NameFactory;
 import org.opengis.util.FactoryException;
@@ -37,7 +38,6 @@ import org.apache.sis.util.ArraysExt;
 
 // Branch-dependent imports
 import java.util.Objects;
-import java.util.Set;
 import org.opengis.feature.AttributeType;
 import org.opengis.feature.Feature;
 import org.opengis.feature.FeatureType;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java?rev=1755608&r1=1755607&r2=1755608&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/ArrayVector.java
[UTF-8] Tue Aug  9 14:42:17 2016
@@ -45,6 +45,55 @@ abstract class ArrayVector<E extends Num
     }
 
     /**
+     * Creates a new instance.
+     *
+     * @throws IllegalArgumentException if the type of the given object is not recognized
by the method.
+     */
+    static Vector newInstance(final Object array, final boolean isUnsigned) throws IllegalArgumentException
{
+        if (array instanceof double[]) {
+            return new ArrayVector.Double((double[]) array);
+        }
+        if (array instanceof float[]) {
+            return new ArrayVector.Float((float[]) array);
+        }
+        if (array instanceof long[]) {
+            if (isUnsigned) {
+                return new ArrayVector.UnsignedLong((long[]) array);
+            } else {
+                return new ArrayVector.Long((long[]) array);
+            }
+        }
+        if (array instanceof int[]) {
+            if (isUnsigned) {
+                return new ArrayVector.UnsignedInteger((int[]) array);
+            } else {
+                return new ArrayVector.Integer((int[]) array);
+            }
+        }
+        if (array instanceof short[]) {
+            if (isUnsigned) {
+                return new ArrayVector.UnsignedShort((short[]) array);
+            } else {
+                return new ArrayVector.Short((short[]) array);
+            }
+        }
+        if (array instanceof byte[]) {
+            if (isUnsigned) {
+                return new ArrayVector.UnsignedByte((byte[]) array);
+            } else {
+                return new ArrayVector.Byte((byte[]) array);
+            }
+        }
+        if (array instanceof Number[]) {
+            return new ArrayVector.Raw((Number[]) array);
+        }
+        if (array instanceof String[]) {
+            return new ArrayVector.ASCII((String[]) array);
+        }
+        throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalParameterType_2,
"array", array.getClass()));
+    }
+
+    /**
      * Default implementation for the convenience of direct sub-types.
      */
     @Override
@@ -75,7 +124,7 @@ abstract class ArrayVector<E extends Num
     /**
      * A vector backed by an array of type {@code double[]}.
      */
-    static final class Double extends ArrayVector<java.lang.Double> {
+    private static final class Double extends ArrayVector<java.lang.Double> {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = -2900375382498345812L;
 
@@ -130,6 +179,7 @@ abstract class ArrayVector<E extends Num
         @Override public Number set(final int index, final Number value) {
             final double old = array[index];
             array[index] = value.doubleValue();
+            modCount++;
             return old;
         }
     }
@@ -137,7 +187,7 @@ abstract class ArrayVector<E extends Num
     /**
      * A vector backed by an array of type {@code float[]}.
      */
-    static class Float extends ArrayVector<java.lang.Float> {
+    private static class Float extends ArrayVector<java.lang.Float> {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = 5395284704294981455L;
 
@@ -178,6 +228,7 @@ abstract class ArrayVector<E extends Num
         @Override public final Number set(final int index, final Number value) {
             final float old = array[index];
             array[index] = value.floatValue();
+            modCount++;
             return old;
         }
     }
@@ -205,7 +256,7 @@ abstract class ArrayVector<E extends Num
     /**
      * A vector backed by an array of type {@code long[]}.
      */
-    static class Long extends ArrayVector<java.lang.Long> {
+    private static class Long extends ArrayVector<java.lang.Long> {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = 338413429037224587L;
 
@@ -236,6 +287,7 @@ abstract class ArrayVector<E extends Num
             verifyType(value.getClass(), Numbers.LONG);
             final long old = array[index];
             array[index] = value.longValue();
+            modCount++;
             return old;
         }
     }
@@ -243,7 +295,7 @@ abstract class ArrayVector<E extends Num
     /**
      * A vector backed by an array of type {@code int[]}.
      */
-    static class Integer extends ArrayVector<java.lang.Integer> {
+    private static class Integer extends ArrayVector<java.lang.Integer> {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = -1292641147544275801L;
 
@@ -275,6 +327,7 @@ abstract class ArrayVector<E extends Num
             verifyType(value.getClass(), Numbers.INTEGER);
             final int old = array[index];
             array[index] = value.intValue();
+            modCount++;
             return old;
         }
     }
@@ -282,7 +335,7 @@ abstract class ArrayVector<E extends Num
     /**
      * A vector backed by an array of type {@code short[]}.
      */
-    static class Short extends ArrayVector<java.lang.Short> {
+    private static class Short extends ArrayVector<java.lang.Short> {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = -126825963332296000L;
 
@@ -315,6 +368,7 @@ abstract class ArrayVector<E extends Num
             verifyType(value.getClass(), Numbers.SHORT);
             final short old = array[index];
             array[index] = value.shortValue();
+            modCount++;
             return old;
         }
     }
@@ -322,7 +376,7 @@ abstract class ArrayVector<E extends Num
     /**
      * A vector backed by an array of type {@code byte[]}.
      */
-    static class Byte extends ArrayVector<java.lang.Byte> {
+    private static class Byte extends ArrayVector<java.lang.Byte> {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = 7933568876180528548L;
 
@@ -356,6 +410,7 @@ abstract class ArrayVector<E extends Num
             verifyType(value.getClass(), Numbers.BYTE);
             final byte old = array[index];
             array[index] = value.byteValue();
+            modCount++;
             return old;
         }
     }
@@ -363,7 +418,7 @@ abstract class ArrayVector<E extends Num
     /**
      * A vector backed by an array of type {@code long[]} to be interpreted as unsigned values.
      */
-    static final class UnsignedLong extends Long {
+    private static final class UnsignedLong extends Long {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = 712968674526282882L;
 
@@ -401,7 +456,7 @@ abstract class ArrayVector<E extends Num
     /**
      * A vector backed by an array of type {@code int[]} to be interpreted as unsigned values.
      */
-    static final class UnsignedInteger extends Integer {
+    private static final class UnsignedInteger extends Integer {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = 8420585724189054050L;
 
@@ -430,14 +485,16 @@ abstract class ArrayVector<E extends Num
     /**
      * A vector backed by an array of type {@code short[]} to be interpreted as unsigned
values.
      */
-    static final class UnsignedShort extends Short {
+    private static final class UnsignedShort extends Short {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = 8219060080494444776L;
 
+        /** Creates a new vector for the given array. */
         UnsignedShort(final short[] array) {
             super(array);
         }
 
+        /** Declares this vector as unsigned. */
         @Override public boolean isUnsigned()          {return true;}
         @Override public double doubleValue(int index) {return intValue(index);}
         @Override public float   floatValue(int index) {return intValue(index);}
@@ -458,14 +515,16 @@ abstract class ArrayVector<E extends Num
     /**
      * A vector backed by an array of type {@code byte[]} to be interpreted as unsigned values.
      */
-    static final class UnsignedByte extends Byte {
+    private static final class UnsignedByte extends Byte {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = -2150064612523948331L;
 
+        /** Creates a new vector for the given array. */
         UnsignedByte(final byte[] array) {
             super(array);
         }
 
+        /** Declares this vector as unsigned. */
         @Override public boolean isUnsigned()          {return true;}
         @Override public double doubleValue(int index) {return intValue(index);}
         @Override public float   floatValue(int index) {return intValue(index);}
@@ -488,7 +547,7 @@ abstract class ArrayVector<E extends Num
      * A vector backed by an array of type {@code String[]}.
      * This is not recommended, but happen for example in GDAL extensions for GeoTIFF files.
      */
-    static class ASCII extends ArrayVector<java.lang.Double> {
+    private static final class ASCII extends ArrayVector<java.lang.Double> {
         /** For cross-version compatibility. */
         private static final long serialVersionUID = 2801615620517491573L;
 
@@ -505,7 +564,22 @@ abstract class ArrayVector<E extends Num
             return java.lang.Double.class;
         }
 
-        @Override public final int     size()          {return array.length;}
+        /** Returns {@code true} if the element at the given index is null or NaN. */
+        @Override public boolean isNaN(final int index) {
+            String value = array[index];
+            if (value == null) return true;
+            if (value.contains("NaN")) {
+                value = value.trim();
+                switch (value.length()) {
+                    case 3: return true;
+                    case 4: final char c = value.charAt(0);
+                            return (c == '+') || (c == '-');
+                }
+            }
+            return false;
+        }
+
+        @Override public int           size()          {return array.length;}
         @Override public String stringValue(int index) {return array[index];}
         @Override public double doubleValue(int index) {return java.lang.Double .parseDouble(array[index]);}
         @Override public float   floatValue(int index) {return java.lang.Float  .parseFloat
(array[index]);}
@@ -513,10 +587,68 @@ abstract class ArrayVector<E extends Num
         @Override public int       intValue(int index) {return java.lang.Integer.parseInt
  (array[index]);}
         @Override public short   shortValue(int index) {return java.lang.Short  .parseShort
(array[index]);}
         @Override public byte     byteValue(int index) {return java.lang.Byte   .parseByte
 (array[index]);}
-        @Override public final Number   get(int index) {return doubleValue(index);}
-        @Override public final Number   set(int index, final Number value) {
+        @Override public Number         get(int index) {
+            final String value = array[index];
+            return (value != null) ? java.lang.Double.parseDouble(value) : null;
+        }
+
+        /** Stores the given value in this vector and returns the previous value. */
+        @Override public final Number set(final int index, final Number value) {
             final Number old = get(index);
             array[index] = value.toString();
+            modCount++;
+            return old;
+        }
+    }
+
+    /**
+     * A vector backed by an array of type {@code Number[]}.
+     */
+    private static final class Raw extends ArrayVector<Number> {
+        /** For cross-version compatibility. */
+        private static final long serialVersionUID = 5444263017359778157L;
+
+        /** The backing array. */
+        private final Number[] array;
+
+        /** Creates a new vector for the given array. */
+        Raw(final Number[] array) {
+            this.array = array;
+        }
+
+        /** Returns the type of elements in the backing array. */
+        @SuppressWarnings({"unchecked", "rawtypes"})
+        @Override public final Class getElementType() {
+            return array.getClass().getComponentType();
+        }
+
+        /** Returns {@code true} if the element at the given index is null or NaN. */
+        @Override public boolean isNaN(final int index) {
+            Number value = array[index];
+            if (value == null) return true;
+            if (value instanceof java.lang.Float)  return ((java.lang.Float)  value).isNaN();
+            if (value instanceof java.lang.Double) return ((java.lang.Double) value).isNaN();
+            return false;
+        }
+
+        @Override public int           size()          {return array.length;}
+        @Override public Number         get(int index) {return array[index];}
+        @Override public double doubleValue(int index) {return array[index].doubleValue();}
+        @Override public float   floatValue(int index) {return array[index].floatValue();}
+        @Override public long     longValue(int index) {return array[index].longValue();}
+        @Override public int       intValue(int index) {return array[index].intValue();}
+        @Override public short   shortValue(int index) {return array[index].shortValue();}
+        @Override public byte     byteValue(int index) {return array[index].byteValue();}
+        @Override public String stringValue(int index) {
+            final Number value = array[index];
+            return (value != null) ? value.toString() : null;
+        }
+
+        /** Stores the given value in this vector and returns the previous value. */
+        @Override public final Number set(final int index, final Number value) {
+            final Number old = array[index];
+            array[index] = value;
+            modCount++;
             return old;
         }
     }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/ConcatenatedVector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/ConcatenatedVector.java?rev=1755608&r1=1755607&r2=1755608&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/ConcatenatedVector.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/ConcatenatedVector.java
[UTF-8] Tue Aug  9 14:42:17 2016
@@ -229,7 +229,9 @@ final class ConcatenatedVector extends V
             v = second;
             index -= limit;
         }
-        return v.set(index, value);
+        final Number old = v.set(index, value);
+        modCount++;
+        return old;
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java?rev=1755608&r1=1755607&r2=1755608&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java [UTF-8]
Tue Aug  9 14:42:17 2016
@@ -87,6 +87,7 @@ public abstract class Vector extends Abs
      *
      * <ul>
      *   <li>An array of a primitive type, like {@code float[]}.</li>
+     *   <li>A {@code Number[]} array.</li>
      *   <li>A {@code String[]} array (not recommended, but happen with some file formats).</li>
      *   <li>A {@code Vector}, in which case it is returned unchanged.</li>
      *   <li>The {@code null} value, in which case {@code null} is returned.</li>
@@ -109,44 +110,13 @@ public abstract class Vector extends Abs
      * @throws IllegalArgumentException if the type of the given object is not recognized
by the method.
      */
     public static Vector create(final Object array, final boolean isUnsigned) throws IllegalArgumentException
{
-        if (array instanceof double[]) {
-            return new ArrayVector.Double((double[]) array);
+        if (array == null) {
+            return null;
         }
-        if (array instanceof float[]) {
-            return new ArrayVector.Float((float[]) array);
+        if (array.getClass().isArray()) {
+            return ArrayVector.newInstance(array, isUnsigned);
         }
-        if (array instanceof long[]) {
-            if (isUnsigned) {
-                return new ArrayVector.UnsignedLong((long[]) array);
-            } else {
-                return new ArrayVector.Long((long[]) array);
-            }
-        }
-        if (array instanceof int[]) {
-            if (isUnsigned) {
-                return new ArrayVector.UnsignedInteger((int[]) array);
-            } else {
-                return new ArrayVector.Integer((int[]) array);
-            }
-        }
-        if (array instanceof short[]) {
-            if (isUnsigned) {
-                return new ArrayVector.UnsignedShort((short[]) array);
-            } else {
-                return new ArrayVector.Short((short[]) array);
-            }
-        }
-        if (array instanceof byte[]) {
-            if (isUnsigned) {
-                return new ArrayVector.UnsignedByte((byte[]) array);
-            } else {
-                return new ArrayVector.Byte((byte[]) array);
-            }
-        }
-        if (array instanceof String[]) {
-            return new ArrayVector.ASCII((String[]) array);
-        }
-        if (array == null || array instanceof Vector) {
+        if (array instanceof Vector) {
             return (Vector) array;
         }
         throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalParameterType_2,
"array", array.getClass()));
@@ -236,7 +206,7 @@ public abstract class Vector extends Abs
     public abstract int size();
 
     /**
-     * Returns {@code true} if the value at the given index is {@code NaN}.
+     * Returns {@code true} if the value at the given index is {@code null} or {@code NaN}.
      *
      * @param  index  the index in the [0 … {@linkplain #size() size}-1] range.
      * @return {@code true} if the value at the given index is {@code NaN}.
@@ -252,6 +222,7 @@ public abstract class Vector extends Abs
      * @param  index  the index in the [0 … {@linkplain #size() size}-1] range.
      * @return the value at the given index.
      * @throws IndexOutOfBoundsException if the given index is out of bounds.
+     * @throws NullPointerException if the value is {@code null} (never happen if this vector
wraps an array of primitive type).
      * @throws NumberFormatException if the value is stored as a {@code String} and can not
be parsed.
      */
     public abstract double doubleValue(int index);
@@ -264,6 +235,7 @@ public abstract class Vector extends Abs
      * @param  index  the index in the [0 … {@linkplain #size() size}-1] range.
      * @return the value at the given index.
      * @throws IndexOutOfBoundsException if the given index is out of bounds.
+     * @throws NullPointerException if the value is {@code null} (never happen if this vector
wraps an array of primitive type).
      * @throws NumberFormatException if the value is stored as a {@code String} and can not
be parsed.
      */
     public abstract float floatValue(int index);
@@ -279,6 +251,7 @@ public abstract class Vector extends Abs
      * @param  index  the index in the [0 … {@linkplain #size() size}-1] range.
      * @return the value at the given index.
      * @throws IndexOutOfBoundsException if the given index is out of bounds.
+     * @throws NullPointerException if the value is {@code null} (never happen if this vector
wraps an array of primitive type).
      * @throws NumberFormatException if the value is stored as a {@code String} and can not
be parsed.
      * @throws ArithmeticException if the value is too large for the capacity of the {@code
long} type.
      */
@@ -302,6 +275,7 @@ public abstract class Vector extends Abs
      * @param  index  the index in the [0 … {@linkplain #size() size}-1] range.
      * @return the value at the given index.
      * @throws IndexOutOfBoundsException if the given index is out of bounds.
+     * @throws NullPointerException if the value is {@code null} (never happen if this vector
wraps an array of primitive type).
      * @throws NumberFormatException if the value is stored as a {@code String} and can not
be parsed.
      * @throws ArithmeticException if the value is too large for the capacity of the {@code
int} type.
      */
@@ -324,6 +298,7 @@ public abstract class Vector extends Abs
      * @param  index  the index in the [0 … {@linkplain #size() size}-1] range.
      * @return the value at the given index.
      * @throws IndexOutOfBoundsException if the given index is out of bounds.
+     * @throws NullPointerException if the value is {@code null} (never happen if this vector
wraps an array of primitive type).
      * @throws NumberFormatException if the value is stored as a {@code String} and can not
be parsed.
      * @throws ArithmeticException if the value is too large for the capacity of the {@code
short} type.
      */
@@ -346,6 +321,7 @@ public abstract class Vector extends Abs
      * @param  index  the index in the [0 … {@linkplain #size() size}-1] range.
      * @return the value at the given index.
      * @throws IndexOutOfBoundsException if the given index is out of bounds.
+     * @throws NullPointerException if the value is {@code null} (never happen if this vector
wraps an array of primitive type).
      * @throws NumberFormatException if the value is stored as a {@code String} and can not
be parsed.
      * @throws ArithmeticException if the value is too large for the capacity of the {@code
byte} type.
      */
@@ -372,7 +348,7 @@ public abstract class Vector extends Abs
      * except if the values are {@linkplain #isUnsigned() unsigned integers}.
      *
      * @param  index  the index in the [0 … {@linkplain #size() size}-1] range.
-     * @return a string representation of the value at the given index.
+     * @return a string representation of the value at the given index (may be {@code null}).
      * @throws IndexOutOfBoundsException if the given index is out of bounds.
      */
     public abstract String stringValue(int index);
@@ -383,7 +359,7 @@ public abstract class Vector extends Abs
      * of the class returned by {@link #getElementType()} or a sub-class.
      *
      * @param  index  the index in the [0 … {@linkplain #size() size}-1] range.
-     * @return the value at the given index.
+     * @return the value at the given index (may be {@code null}).
      * @throws IndexOutOfBoundsException if the given index is out of bounds.
      * @throws NumberFormatException if the value is stored as a {@code String} and can not
be parsed.
      */
@@ -398,8 +374,9 @@ public abstract class Vector extends Abs
      * @param  value  the value to set at the given index.
      * @return the value previously stored at the given index.
      * @throws IndexOutOfBoundsException if the given index is out of bounds.
-     * @throws ClassCastException if the given value can not be stored in this vector.
      * @throws NumberFormatException if the previous value was stored as a {@code String}
and can not be parsed.
+     * @throws ClassCastException if the given value can not be converted to the type expected
by this vector.
+     * @throws ArrayStoreException if the given value can not be stored in this vector.
      */
     @Override
     public abstract Number set(int index, Number value);
@@ -522,7 +499,12 @@ public abstract class Vector extends Abs
         @Override public byte    byteValue  (int index)     {return Vector.this.byteValue
 (toBacking(index));}
         @Override public String  stringValue(int index)     {return Vector.this.stringValue(toBacking(index));}
         @Override public Number  get        (int index)     {return Vector.this.get     
  (toBacking(index));}
-        @Override public Number  set(int index, Number v)   {return Vector.this.set     
  (toBacking(index), v);}
+
+        @Override public Number set(final int index, final Number v) {
+            final Number old = Vector.this.set(toBacking(index), v);
+            modCount++;
+            return old;
+        }
 
         /** Delegates to the enclosing vector. */
         @Override Vector createSubSampling(int first, int step, final int length) {
@@ -666,7 +648,12 @@ public abstract class Vector extends Abs
         @Override public byte     byteValue  (int i)    {return Vector.this.byteValue  (indices[i]);}
         @Override public String   stringValue(int i)    {return Vector.this.stringValue(indices[i]);}
         @Override public Number   get        (int i)    {return Vector.this.get        (indices[i]);}
-        @Override public Number   set(int i, Number v)  {return Vector.this.set        (indices[i],
v);}
+
+        @Override public Number set(final int i, final Number v) {
+            final Number old = Vector.this.set(indices[i], v);
+            modCount++;
+            return old;
+        }
 
         /** Delegates to the enclosing vector. */
         @Override Vector createSubSampling(int first, final int step, final int length) {

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/math/VectorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/math/VectorTest.java?rev=1755608&r1=1755607&r2=1755608&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/math/VectorTest.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/math/VectorTest.java [UTF-8]
Tue Aug  9 14:42:17 2016
@@ -134,7 +134,7 @@ public final strictfp class VectorTest e
             array[i] = (i + 100) * 10;
         }
         vector = Vector.create(array, false);
-        assertTrue(vector instanceof ArrayVector.Float);
+        assertEquals("Float", vector.getClass().getSimpleName());
         assertSame(vector, Vector.create(vector, false));
         assertEquals(array.length, vector.size());
         assertEquals(Float.class, vector.getElementType());
@@ -157,7 +157,7 @@ public final strictfp class VectorTest e
             array[i] = (i + 100) * 10;
         }
         vector = Vector.create(array, false);
-        assertTrue(vector instanceof ArrayVector.Double);
+        assertEquals("Double", vector.getClass().getSimpleName());
         assertSame(vector, Vector.create(vector, false));
         assertEquals(array.length, vector.size());
         assertEquals(Double.class, vector.getElementType());



Mime
View raw message