sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1449006 [1/2] - in /sis/trunk: ./ sis-utility/src/main/java/org/apache/sis/math/ sis-utility/src/main/java/org/apache/sis/measure/ sis-utility/src/main/java/org/apache/sis/util/ sis-utility/src/main/java/org/apache/sis/util/collection/ sis...
Date Fri, 22 Feb 2013 11:55:19 GMT
Author: desruisseaux
Date: Fri Feb 22 11:55:18 2013
New Revision: 1449006

URL: http://svn.apache.org/r1449006
Log:
Merge from the JDK6 branch.

Added:
    sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java
      - copied unchanged from r1449004, sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/test/Performance.java
      - copied unchanged from r1449004, sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/Performance.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/RangeSetTest.java
      - copied unchanged from r1449004, sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/RangeSetTest.java
    sis/trunk/src/main/docbook/fr/coverage.xml
      - copied unchanged from r1449004, sis/branches/JDK6/src/main/docbook/fr/coverage.xml
Removed:
    sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/DateRange.java
Modified:
    sis/trunk/   (props changed)
    sis/trunk/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/Range.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/package-info.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestConfiguration.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/test/TestUtilities.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/test/package-info.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/util/ArraysExtTest.java
    sis/trunk/sis-utility/src/test/java/org/apache/sis/util/collection/CacheTest.java
    sis/trunk/src/main/docbook/fr.xml

Propchange: sis/trunk/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1446209-1448999
  Merged /sis/branches/JDK6:r1446212-1449004

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java Fri Feb 22 11:55:18 2013
@@ -58,6 +58,8 @@ import static org.apache.sis.internal.ut
  * @since   0.3 (derived from geotk-1.0)
  * @version 0.3
  * @module
+ *
+ * @see org.apache.sis.util.Numbers
  */
 public final class MathFunctions extends Static {
     /**

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java Fri Feb 22 11:55:18 2013
@@ -49,6 +49,9 @@ import org.apache.sis.internal.util.Obje
  * @since   0.3 (derived from geotk-2.4)
  * @version 0.3
  * @module
+ *
+ * @see RangeFormat
+ * @see org.apache.sis.util.collection.RangeSet
  */
 @Immutable
 public class MeasurementRange<E extends Number & Comparable<? super E>> extends NumberRange<E> {
@@ -65,20 +68,6 @@ public class MeasurementRange<E extends 
     private final Unit<?> unit;
 
     /**
-     * Constructs an inclusive range of {@code float} values.
-     *
-     * @param  minValue The minimal value, inclusive, or {@link Float#NEGATIVE_INFINITY} if none..
-     * @param  maxValue The maximal value, <strong>inclusive</strong>, or {@link Float#POSITIVE_INFINITY} if none.
-     * @param  unit     The unit of measurement, or {@code null} if unknown.
-     * @return The new range of numeric values for the given bounds and unit of measurement.
-     */
-    public static MeasurementRange<Float> create(float minValue, float maxValue, Unit<?> unit) {
-        return new MeasurementRange<Float>(Float.class,
-                valueOf("minValue", minValue, Float.NEGATIVE_INFINITY),
-                valueOf("maxValue", maxValue, Float.POSITIVE_INFINITY), unit);
-    }
-
-    /**
      * Constructs a range of {@code float} values.
      *
      * @param  minValue       The minimal value, or {@link Float#NEGATIVE_INFINITY} if none.
@@ -86,7 +75,7 @@ public class MeasurementRange<E extends 
      * @param  maxValue       The maximal value, or {@link Float#POSITIVE_INFINITY} if none.
      * @param  isMaxIncluded  {@code true} if the maximal value is inclusive, or {@code false} if exclusive.
      * @param  unit           The unit of measurement, or {@code null} if unknown.
-     * @return The new range of numeric values for the given bounds and unit of measurement.
+     * @return The new range of numeric values for the given endpoints and unit of measurement.
      */
     public static MeasurementRange<Float> create(float minValue, boolean isMinIncluded,
                                                  float maxValue, boolean isMaxIncluded, Unit<?> unit)
@@ -97,20 +86,6 @@ public class MeasurementRange<E extends 
     }
 
     /**
-     * Constructs an inclusive range of {@code double} values.
-     *
-     * @param  minValue The minimal value, inclusive, or {@link Double#NEGATIVE_INFINITY} if none..
-     * @param  maxValue The maximal value, <strong>inclusive</strong>, or {@link Double#POSITIVE_INFINITY} if none.
-     * @param  unit     The unit of measurement, or {@code null} if unknown.
-     * @return The new range of numeric values for the given bounds and unit of measurement.
-     */
-    public static MeasurementRange<Double> create(double minValue, double maxValue, Unit<?> unit) {
-        return new MeasurementRange<Double>(Double.class,
-                valueOf("minValue", minValue, Double.NEGATIVE_INFINITY),
-                valueOf("maxValue", maxValue, Double.POSITIVE_INFINITY), unit);
-    }
-
-    /**
      * Constructs a range of {@code double} values.
      *
      * @param  minValue       The minimal value, or {@link Double#NEGATIVE_INFINITY} if none.
@@ -118,7 +93,7 @@ public class MeasurementRange<E extends 
      * @param  maxValue       The maximal value, or {@link Double#POSITIVE_INFINITY} if none.
      * @param  isMaxIncluded  {@code true} if the maximal value is inclusive, or {@code false} if exclusive.
      * @param  unit           The unit of measurement, or {@code null} if unknown.
-     * @return The new range of numeric values for the given bounds and unit of measurement.
+     * @return The new range of numeric values for the given endpoints and unit of measurement.
      */
     public static MeasurementRange<Double> create(double minValue, boolean isMinIncluded,
                                                   double maxValue, boolean isMaxIncluded, Unit<?> unit)
@@ -168,19 +143,6 @@ public class MeasurementRange<E extends 
     /**
      * Constructs a range of {@link Number} objects.
      *
-     * @param type     The element type, usually one of {@link Float} or {@link Double}.
-     * @param minValue The minimum value, inclusive, or {@code null} if none.
-     * @param maxValue The maximum value, <strong>inclusive</strong>, or {@code null} if none.
-     * @param unit     The unit of measurement, or {@code null} if unknown.
-     */
-    public MeasurementRange(final Class<E> type, final E minValue, final E maxValue, final Unit<?> unit) {
-        super(type, minValue, maxValue);
-        this.unit = unit;
-    }
-
-    /**
-     * Constructs a range of {@link Number} objects.
-     *
      * @param type          The element type, usually one of {@link Float} or {@link Double}.
      * @param minValue      The minimal value, or {@code null} if none.
      * @param isMinIncluded {@code true} if the minimal value is inclusive, or {@code false} if exclusive.

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java Fri Feb 22 11:55:18 2013
@@ -26,7 +26,9 @@ import org.apache.sis.util.resources.Err
  * {@code NumberRange} has no unit of measurement. For a range of physical measurements
  * with unit of measure, see {@link MeasurementRange}.
  *
- * <p>Most operations in this class are defined in two versions:</p>
+ * <p>{@code NumberRange} has some capability to convert different number types before to
+ * perform operations. In order to provide both this flexibility and the safety of generic
+ * types, most operations in this class are defined in two versions:</p>
  * <ul>
  *   <li>Methods inherited from the {@code Range} parent class
  *      ({@link #contains(Range) contains}, {@link #intersect(Range) intersect},
@@ -51,6 +53,14 @@ import org.apache.sis.util.resources.Err
  *   <li>{@link #castTo(Class)} for casting the range values to an other type.</li>
  * </ul>
  *
+ * {@section Relationship with standards}
+ * {@code NumberRange} is the SIS class closest to the
+ * <a href="http://en.wikipedia.org/wiki/Interval_%28mathematics%29">mathematical definition of interval</a>.
+ * It is closely related, while not identical, to the ISO 19123 (<cite>Coverage geometry and functions</cite>)
+ * definition of "ranges". At the difference of the parent {@link Range} class, which can be used only with
+ * {@linkplain org.opengis.coverage.DiscreteCoverage discrete coverages}, the {@code NumberRange} class can
+ * also be used with {@linkplain org.opengis.coverage.ContinuousCoverage continuous coverages}.
+ *
  * @param <E> The type of range elements as a subclass of {@link Number}.
  *
  * @author  Martin Desruisseaux (IRD)
@@ -60,6 +70,8 @@ import org.apache.sis.util.resources.Err
  * @module
  *
  * @see RangeFormat
+ * @see org.apache.sis.util.collection.RangeSet
+ * @see <a href="http://en.wikipedia.org/wiki/Interval_%28mathematics%29">Wikipedia: Interval</a>
  */
 @Immutable
 public class NumberRange<E extends Number & Comparable<? super E>> extends Range<E> {
@@ -69,24 +81,13 @@ public class NumberRange<E extends Numbe
     private static final long serialVersionUID = -818167965963008231L;
 
     /**
-     * Constructs an inclusive range of {@code byte} values.
-     *
-     * @param  minValue The minimal value, inclusive.
-     * @param  maxValue The maximal value, <strong>inclusive</strong>.
-     * @return The new range of numeric values for the given bounds.
-     */
-    public static NumberRange<Byte> create(final byte minValue, final byte maxValue) {
-        return new NumberRange<Byte>(Byte.class, Byte.valueOf(minValue), Byte.valueOf(maxValue));
-    }
-
-    /**
      * Constructs a range of {@code byte} values.
      *
      * @param  minValue       The minimal value.
      * @param  isMinIncluded  {@code true} if the minimal value is inclusive, or {@code false} if exclusive.
      * @param  maxValue       The maximal value.
      * @param  isMaxIncluded  {@code true} if the maximal value is inclusive, or {@code false} if exclusive.
-     * @return The new range of numeric values for the given bounds.
+     * @return The new range of numeric values for the given endpoints.
      */
     public static NumberRange<Byte> create(final byte minValue, final boolean isMinIncluded,
                                            final byte maxValue, final boolean isMaxIncluded)
@@ -97,24 +98,13 @@ public class NumberRange<E extends Numbe
     }
 
     /**
-     * Constructs an inclusive range of {@code short} values.
-     *
-     * @param  minValue The minimal value, inclusive.
-     * @param  maxValue The maximal value, <strong>inclusive</strong>.
-     * @return The new range of numeric values for the given bounds.
-     */
-    public static NumberRange<Short> create(final short minValue, final short maxValue) {
-        return new NumberRange<Short>(Short.class, Short.valueOf(minValue), Short.valueOf(maxValue));
-    }
-
-    /**
      * Constructs a range of {@code short} values.
      *
      * @param  minValue       The minimal value.
      * @param  isMinIncluded  {@code true} if the minimal value is inclusive, or {@code false} if exclusive.
      * @param  maxValue       The maximal value.
      * @param  isMaxIncluded  {@code true} if the maximal value is inclusive, or {@code false} if exclusive.
-     * @return The new range of numeric values for the given bounds.
+     * @return The new range of numeric values for the given endpoints.
      */
     public static NumberRange<Short> create(final short minValue, final boolean isMinIncluded,
                                             final short maxValue, final boolean isMaxIncluded)
@@ -125,24 +115,13 @@ public class NumberRange<E extends Numbe
     }
 
     /**
-     * Constructs an inclusive range of {@code int} values.
-     *
-     * @param  minValue The minimal value, inclusive.
-     * @param  maxValue The maximal value, <strong>inclusive</strong>.
-     * @return The new range of numeric values for the given bounds.
-     */
-    public static NumberRange<Integer> create(final int minValue, final int maxValue) {
-        return new NumberRange<Integer>(Integer.class, Integer.valueOf(minValue), Integer.valueOf(maxValue));
-    }
-
-    /**
      * Constructs a range of {@code int} values.
      *
      * @param  minValue       The minimal value.
      * @param  isMinIncluded  {@code true} if the minimal value is inclusive, or {@code false} if exclusive.
      * @param  maxValue       The maximal value.
      * @param  isMaxIncluded  {@code true} if the maximal value is inclusive, or {@code false} if exclusive.
-     * @return The new range of numeric values for the given bounds.
+     * @return The new range of numeric values for the given endpoints.
      */
     public static NumberRange<Integer> create(final int minValue, final boolean isMinIncluded,
                                               final int maxValue, final boolean isMaxIncluded)
@@ -153,24 +132,13 @@ public class NumberRange<E extends Numbe
     }
 
     /**
-     * Constructs an inclusive range of {@code long} values.
-     *
-     * @param  minValue The minimal value, inclusive.
-     * @param  maxValue The maximal value, <strong>inclusive</strong>.
-     * @return The new range of numeric values for the given bounds.
-     */
-    public static NumberRange<Long> create(final long minValue, final long maxValue) {
-        return new NumberRange<Long>(Long.class, Long.valueOf(minValue), Long.valueOf(maxValue));
-    }
-
-    /**
      * Constructs a range of {@code long} values.
      *
      * @param  minValue       The minimal value.
      * @param  isMinIncluded  {@code true} if the minimal value is inclusive, or {@code false} if exclusive.
      * @param  maxValue       The maximal value.
      * @param  isMaxIncluded  {@code true} if the maximal value is inclusive, or {@code false} if exclusive.
-     * @return The new range of numeric values for the given bounds.
+     * @return The new range of numeric values for the given endpoints.
      */
     public static NumberRange<Long> create(final long minValue, final boolean isMinIncluded,
                                            final long maxValue, final boolean isMaxIncluded)
@@ -181,20 +149,6 @@ public class NumberRange<E extends Numbe
     }
 
     /**
-     * Constructs an inclusive range of {@code float} values.
-     * The values can not be {@link Float#NaN}.
-     *
-     * @param  minValue The minimal value, inclusive, or {@link Float#NEGATIVE_INFINITY} if none..
-     * @param  maxValue The maximal value, <strong>inclusive</strong>, or {@link Float#POSITIVE_INFINITY} if none.
-     * @return The new range of numeric values for the given bounds.
-     */
-    public static NumberRange<Float> create(final float minValue, final float maxValue) {
-        return new NumberRange<Float>(Float.class,
-                valueOf("minValue", minValue, Float.NEGATIVE_INFINITY),
-                valueOf("maxValue", maxValue, Float.POSITIVE_INFINITY));
-    }
-
-    /**
      * Constructs a range of {@code float} values.
      * The values can not be {@link Float#NaN}.
      *
@@ -202,7 +156,7 @@ public class NumberRange<E extends Numbe
      * @param  isMinIncluded  {@code true} if the minimal value is inclusive, or {@code false} if exclusive.
      * @param  maxValue       The maximal value, or {@link Float#POSITIVE_INFINITY} if none.
      * @param  isMaxIncluded  {@code true} if the maximal value is inclusive, or {@code false} if exclusive.
-     * @return The new range of numeric values for the given bounds.
+     * @return The new range of numeric values for the given endpoints.
      */
     public static NumberRange<Float> create(final float minValue, final boolean isMinIncluded,
                                             final float maxValue, final boolean isMaxIncluded)
@@ -224,20 +178,6 @@ public class NumberRange<E extends Numbe
     }
 
     /**
-     * Constructs an inclusive range of {@code double} values.
-     * The values can not be {@link Double#NaN}.
-     *
-     * @param  minValue The minimal value, inclusive, or {@link Double#NEGATIVE_INFINITY} if none..
-     * @param  maxValue The maximal value, <strong>inclusive</strong>, or {@link Double#POSITIVE_INFINITY} if none.
-     * @return The new range of numeric values for the given bounds.
-     */
-    public static NumberRange<Double> create(final double minValue, final double maxValue) {
-        return new NumberRange<Double>(Double.class,
-                valueOf("minValue", minValue, Double.NEGATIVE_INFINITY),
-                valueOf("maxValue", maxValue, Double.POSITIVE_INFINITY));
-    }
-
-    /**
      * Constructs a range of {@code double} values.
      * The values can not be {@link Double#NaN}.
      *
@@ -245,7 +185,7 @@ public class NumberRange<E extends Numbe
      * @param  isMinIncluded  {@code true} if the minimal value is inclusive, or {@code false} if exclusive.
      * @param  maxValue       The maximal value, or {@link Double#POSITIVE_INFINITY} if none.
      * @param  isMaxIncluded  {@code true} if the maximal value is inclusive, or {@code false} if exclusive.
-     * @return The new range of numeric values for the given bounds.
+     * @return The new range of numeric values for the given endpoints.
      */
     public static NumberRange<Double> create(final double minValue, final boolean isMinIncluded,
                                              final double maxValue, final boolean isMaxIncluded)
@@ -330,18 +270,6 @@ public class NumberRange<E extends Numbe
     }
 
     /**
-     * Constructs an inclusive range of {@link Number} objects.
-     *
-     * @param  type     The element type, usually one of {@link Byte}, {@link Short},
-     *                  {@link Integer}, {@link Long}, {@link Float} or {@link Double}.
-     * @param  minValue The minimum value, inclusive, or {@code null} if none.
-     * @param  maxValue The maximum value, <strong>inclusive</strong>, or {@code null} if none.
-     */
-    public NumberRange(final Class<E> type, final E minValue, final E maxValue) {
-        super(type, minValue, maxValue);
-    }
-
-    /**
      * Constructs a range of {@link Number} objects.
      *
      * @param type           The element type, usually one of {@link Byte}, {@link Short},

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/Range.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/Range.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/Range.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/Range.java Fri Feb 22 11:55:18 2013
@@ -32,24 +32,43 @@ import org.apache.sis.internal.util.Obje
  * a user to determine if a value of the same class is contained inside the range.
  * The minimum and maximum values do not have to be included in the range, and
  * can be null.  If the minimum or maximum values are null, the range is said to
- * be unbounded on that extreme. If both the minimum and maximum are null,
+ * be unbounded on that endpoint. If both the minimum and maximum are null,
  * the range is completely unbounded and all values of that class are contained
  * within the range. Null values are always considered <em>exclusive</em>,
- * since iterations over the values will never reach the infinite bound.
+ * since iterations over the values will never reach the infinite endpoint.
+ *
+ * <p>The minimal and maximal values (the <cite>endpoints</cite>) may be inclusive or exclusive.
+ * Numeric ranges where both endpoints are inclusive are called <cite>closed intervals</cite>
+ * and are represented by square brackets, for example "{@code [0 … 255]}".
+ * Numeric ranges where both endpoints are exclusive are called <cite>open intervals</cite>
+ * and are represented by parenthesis, for example "{@code (0 … 256)}".</p>
  *
  * {@section Type and value of range elements}
  * To be a member of a {@code Range}, the {@code <E>} type defining the range must implement the
  * {@link Comparable} interface. All argument values given to the methods of this class shall be
- * or contain instances of the same {@code <E>} type. The type is enforced by parameterized type,
+ * or contain instances of that {@code <E>} type. The type is enforced by parameterized type,
  * but some subclasses may put additional constraints. For example {@link MeasurementRange} will
- * additionally checks the units of measurement. Every methods defined in this class may throw
- * an {@link IllegalArgumentException} if a given argument does not meet a constraint other than
- * the type.
+ * additionally checks the units of measurement. Consequently every methods defined in this class
+ * may throw an {@link IllegalArgumentException} if a given argument does not meet some constraint
+ * beyond the type.
+ *
+ * {@section Relationship with ISO 19123 definition of range}
+ * The ISO 19123 standard (<cite>Coverage geometry and functions</cite>) defines the range as the set
+ * (either finite or {@linkplain org.opengis.geometry.TransfiniteSet transfinite}) of feature attribute
+ * values associated by a function (the {@linkplain org.opengis.coverage.Coverage coverage}) with the
+ * elements of the coverage domain. In other words, if we see a coverage as a function, then a range
+ * is the set of possible return values.
  *
- * {@section String representation}
- * The {@linkplain #toString() string representation} of a {@code Range} is defined
- * in a locale-insensitive way. In order to format a range using a different locale,
- * or for parsing a range, use {@link RangeFormat}.
+ * <p>The characteristics of the spatial domain are defined by the ISO 19123 standard whereas the
+ * characteristics of the attribute range are not part of that standard. In Apache SIS, those
+ * characteristics are described by the {@link org.apache.sis.coverage.SampleDimension} class,
+ * which may contain one or many {@code Range} instances. Consequently this {@code Range} class
+ * is closely related, but not identical, to the ISO 19123 definition or range.</p>
+ *
+ * <p>Ranges are not necessarily numeric. Numeric and non-numeric ranges can be associated to
+ * {@linkplain org.opengis.coverage.DiscreteCoverage discrete coverages}, while typically only
+ * numeric ranges can be associated to {@linkplain org.opengis.coverage.ContinuousCoverage
+ * continuous coverages}.</p>
  *
  * @param <E> The type of range elements, typically a {@link Number} subclass or {@link java.util.Date}.
  *
@@ -61,6 +80,7 @@ import org.apache.sis.internal.util.Obje
  * @module
  *
  * @see RangeFormat
+ * @see org.apache.sis.util.collection.RangeSet
  */
 @Immutable
 public class Range<E extends Comparable<? super E>> implements CheckedContainer<E>, Serializable {
@@ -102,24 +122,7 @@ public class Range<E extends Comparable<
     }
 
     /**
-     * Creates a new range bounded by the given inclusive values.
-     *
-     * @param elementType  The class of the range elements.
-     * @param minValue     The minimal value (inclusive), or {@code null} if none.
-     * @param maxValue     The maximal value (inclusive), or {@code null} if none.
-     */
-    public Range(final Class<E> elementType, final E minValue, final E maxValue) {
-        ArgumentChecks.ensureNonNull("elementType", elementType);
-        this.elementType   = elementType;
-        this.minValue      = minValue;
-        this.isMinIncluded = (minValue != null);
-        this.maxValue      = maxValue;
-        this.isMaxIncluded = (maxValue != null);
-        assert validate();
-    }
-
-    /**
-     * Creates a new range bounded by the given values.
+     * Creates a new range bounded by the given endpoint values.
      *
      * @param elementType    The base type of the range elements.
      * @param minValue       The minimal value, or {@code null} if none.
@@ -213,7 +216,7 @@ public class Range<E extends Comparable<
 
     /**
      * Returns {@code true} if the {@linkplain #getMinValue() minimal value} is inclusive,
-     * or {@code false} is exclusive. Note that {@code null} values are always considered
+     * or {@code false} if exclusive. Note that {@code null} values are always considered
      * exclusive.
      *
      * @return {@code true} if the minimal value is inclusive, or {@code false} if exclusive.
@@ -235,7 +238,7 @@ public class Range<E extends Comparable<
 
     /**
      * Returns {@code true} if the {@linkplain #getMaxValue() maximal value} is inclusive,
-     * or {@code false} is exclusive. Note that {@code null} values are always considered
+     * or {@code false} if exclusive. Note that {@code null} values are always considered
      * exclusive.
      *
      * @return {@code true} if the maximal value is inclusive, or {@code false} if exclusive.
@@ -461,7 +464,7 @@ public class Range<E extends Comparable<
     }
 
     /**
-     * Compares the {@linkplain #getMinValue() minimum value} of this range with the given bound of
+     * Compares the {@linkplain #getMinValue() minimum value} of this range with the given endpoint of
      * another range. Since the given value is either the minimal or maximal value of another range,
      * it may be inclusive or exclusive. The later is specified by {@code position} as below:
      *
@@ -473,11 +476,11 @@ public class Range<E extends Comparable<
      *
      * Note that the non-zero position shall be exactly -1 or +1, not arbitrary negative or positive.
      *
-     * @param  value    A bound value of the other range to be compared to the minimal value of this range.
+     * @param  value    An endpoint value of the other range to be compared to the minimal value of this range.
      * @param  position The position of {@code value} relative to the inclusive values of the other range.
      * @return Position (-, + or 0) of the inclusive values of this range compared to the other range.
      *
-     * @see #containsNC(Range)
+     * @see #contains(Range)
      */
     private int compareMinTo(final E value, int position) {
         /*
@@ -519,8 +522,8 @@ public class Range<E extends Comparable<
     }
 
     /**
-     * Compares the {@linkplain #getMaxValue() maximum value} of this range with the given bound of
-     * another range. See the comment in {@link #compareMinTo(Comparable, int)} for more details.
+     * Compares the {@linkplain #getMaxValue() maximum value} of this range with the given endpoint
+     * of another range. See the comment in {@link #compareMinTo(Comparable, int)} for more details.
      */
     private int compareMaxTo(final E value, int position) {
         if (maxValue == null) {
@@ -595,57 +598,55 @@ public class Range<E extends Comparable<
     }
 
     /**
-     * Returns a string representation of this range.
-     * The string representation is defined as below:
+     * Returns a unlocalized string representation of this range. This method complies to the format
+     * described in the <a href="http://en.wikipedia.org/wiki/ISO_31-11">ISO 31-11</a> standard,
+     * except that the minimal and maximal values are separated by the "{@code …}" character
+     * instead than coma. More specifically, the string representation is defined as below:
      *
      * <ul>
-     *   <li>If the range is empty, then this method returns {@code "[]"}.</li>
-     *   <li>Otherwise if the minimal value is equals to the maximal value, then
-     *       the string representation of that value is returned directly.</li>
-     *   <li>Otherwise the string representation of the minimal and maximal values
-     *       are formatted like {@code [min … max]} for inclusive bounds or
-     *       {@code (min … max)} for exclusive bounds, or a mix of both styles.
-     *       The ∞ symbol is used in place of {@code min} or {@code max} for
-     *       unbounded ranges.</li>
+     *   <li>If the range {@linkplain #isEmpty() is empty}, then this method returns "{@code {}}".</li>
+     *   <li>Otherwise if the minimal value is equals to the maximal value, then the string
+     *       representation of that value is returned inside braces as in "{@code {value}}".</li>
+     *   <li>Otherwise the string representation of the minimal and maximal values are formatted
+     *       like "{@code [min … max]}" for inclusive endpoints or "{@code (min … max)}" for exclusive
+     *       endpoints, or a mix of both styles. The "{@code ∞}" symbol is used in place of
+     *       {@code min} or {@code max} for unbounded ranges.</li>
      * </ul>
      *
-     * If this range is a {@link MeasurementRange}, then the unit of measurement is
-     * appended to the above string representation.
+     * If this range is a {@link MeasurementRange}, then the {@linkplain Unit unit of measurement}
+     * is appended to the above string representation except for empty ranges.
      *
      * @see RangeFormat
+     * @see <a href="http://en.wikipedia.org/wiki/ISO_31-11">Wikipedia: ISO 31-11</a>
      */
     @Override
     public String toString() {
         if (isEmpty()) {
-            return "[]";
-        }
-        if (minValue != null && minValue.equals(maxValue)) {
-            String value = minValue.toString();
-            final Unit<?> unit = unit();
-            if (unit != null) {
-                value = value + ' ' + unit;
-            }
-            return value;
+            return "{}";
         }
         final StringBuilder buffer = new StringBuilder(20);
-        buffer.append(isMinIncluded ? '[' : '(');
-        if (minValue == null) {
-            buffer.append("−∞");
-        } else {
-            buffer.append(minValue);
-        }
-        // Compact representation for integers, more space for real numbers.
-        if (Numbers.isInteger(elementType) && isCompact(minValue, false) && isCompact(maxValue, true)) {
-            buffer.append('…');
-        } else {
-            buffer.append(" … ");
-        }
-        if (maxValue == null) {
-            buffer.append('∞');
+        if (minValue != null && minValue.equals(maxValue)) {
+            buffer.append('{').append(minValue).append('}');
         } else {
-            buffer.append(maxValue);
+            buffer.append(isMinIncluded ? '[' : '(');
+            if (minValue == null) {
+                buffer.append("−∞");
+            } else {
+                buffer.append(minValue);
+            }
+            // Compact representation for integers, more space for real numbers.
+            if (Numbers.isInteger(elementType) && isCompact(minValue, false) && isCompact(maxValue, true)) {
+                buffer.append('…');
+            } else {
+                buffer.append(" … ");
+            }
+            if (maxValue == null) {
+                buffer.append('∞');
+            } else {
+                buffer.append(maxValue);
+            }
+            buffer.append(isMaxIncluded ? ']' : ')');
         }
-        buffer.append(isMaxIncluded ? ']' : ')');
         final Unit<?> unit = unit();
         if (unit != null) {
             buffer.append(' ').append(unit);

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java Fri Feb 22 11:55:18 2013
@@ -38,17 +38,51 @@ import org.apache.sis.util.resources.Err
 
 
 /**
- * Parses and formats {@linkplain Range ranges} of the given type. The kind of ranges created
- * by the {@code parse} method is determined by the class of range elements:
+ * Parses and formats {@link Range} instances according the given locale.
+ * This class complies to the format described in the <a href="http://en.wikipedia.org/wiki/ISO_31-11">ISO 31-11</a>
+ * standard, except that the minimal and maximal values are separated by the "{@code …}" character
+ * instead than coma. More specifically, the format is defined as below:
  *
  * <ul>
- *   <li>If the elements type is assignable to {@link Date}, then the {@code parse} method
- *       will create {@link DateRange} objects.</li>
+ *   <li>If the range {@linkplain Range#isEmpty() is empty}, then the range is represented by "{@code {}}".</li>
+ *   <li>Otherwise if the {@linkplain Range#getMinValue() minimal value} is equals to the
+ *       {@linkplain Range#getMaxValue() maximal value}, then that single value is formatted
+ *       inside braces as in "{@code {value}}".</li>
+ *   <li>Otherwise the minimal and maximal values are formatted inside bracket or parenthesis,
+ *       depending on whether each endpoint is inclusive or exclusive:
+ *     <ul>
+ *       <li>"{@code [min … max]}" if both endpoints are inclusive (<cite>closed interval</cite>);</li>
+ *       <li>"{@code (min … max)}" if both endpoints are exclusive (<cite>open interval</cite>);</li>
+ *       <li>or a mix of both styles if an endpoint is inclusive while the other is exclusive.</li>
+ *     </ul>
+ *     The "{@code ∞}" symbol is used in place of {@code min} or {@code max} for unbounded ranges.</li>
+ * </ul>
+ *
+ * If the range to format is an instance of {@link MeasurementRange}, then the
+ * {@linkplain Unit unit of measurement} is appended except for empty ranges.
+ *
+ * {@section Lenient parsing}
+ * At parsing time, the above formatting rules are relaxed as below:
+ *
+ * <ul>
+ *   <li>Empty ranges can be represented by "{@code []}"or "{@code ()}" in addition to the
+ *       standard "{@code {}}".</li>
+ *   <li>The braces are optional for singleton values, i.e. "{@code value}" is accepted
+ *       as well as "{@code {value}}".</li>
+ * </ul>
+ *
+ * {@section Range type and type of range elements}
+ * The kind of ranges created by the {@link #parse(String) parse(…)} methods is determined
+ * by the type of range elements:
+ *
+ * <ul>
+ *   <li>If the elements type is assignable to {@link Date}, then the {@code parse(…)} methods
+ *       will create {@code Range<Date>} objects.</li>
  *   <li>If the elements type is assignable to {@link Number}, then:
  *     <ul>
- *       <li>If the text to parse contains a {@linkplain Unit unit} of measure, then
- *           the {@code parse} method will create {@link MeasurementRange} objects.</li>
- *       <li>Otherwise the {@code parse} method will create {@link NumberRange} objects.</li>
+ *       <li>If the text to parse contains a {@linkplain Unit unit of measurement}, then
+ *           the {@code parse(…)} methods will create {@link MeasurementRange} objects.</li>
+ *       <li>Otherwise the {@code parse(…)} methods will create {@link NumberRange} objects.</li>
  *     </ul>
  *   </li>
  * </ul>
@@ -58,10 +92,8 @@ import org.apache.sis.util.resources.Err
  * @version 0.3
  * @module
  *
- * @see Range
- * @see DateRange
- * @see NumberRange
- * @see MeasurementRange
+ * @see Range#toString()
+ * @see <a href="http://en.wikipedia.org/wiki/ISO_31-11">Wikipedia: ISO 31-11</a>
  */
 public class RangeFormat extends Format {
     /**
@@ -147,45 +179,58 @@ public class RangeFormat extends Format 
         }
     }
 
+    // All "character" fields below are code point values.
+    /**
+     * The character opening an empty range or a range containing only one element.
+     * The default value is {@code '{'}.
+     */
+    private final int openSet;
+
     /**
      * The character opening a range in which the minimal value is inclusive.
      * The default value is {@code '['}.
      */
-    private final char openInclusive;
+    private final int openInclusive;
 
     /**
      * The character opening a range in which the minimal value is exclusive.
      * The default value is {@code '('}. Note that the {@code ']'} character
      * is also sometime used.
      */
-    private final char openExclusive;
+    private final int openExclusive;
 
     /**
      * An alternative character opening a range in which the minimal value is exclusive.
      * This character is not used for formatting (only {@link #openExclusive} is used),
      * but is accepted during parsing. The default value is {@code ']'}.
      */
-    private final char openExclusiveAlt;
+    private final int openExclusiveAlt;
+
+    /**
+     * The character closing an empty range or a range containing only one element.
+     * The default value is {@code '}'}.
+     */
+    private final int closeSet;
 
     /**
      * The character closing a range in which the maximal value is inclusive.
      * The default value is {@code ']'}.
      */
-    private final char closeInclusive;
+    private final int closeInclusive;
 
     /**
      * The character closing a range in which the maximal value is exclusive.
      * The default value is {@code ')'}. Note that the {@code '['} character
      * is also sometime used.
      */
-    private final char closeExclusive;
+    private final int closeExclusive;
 
     /**
      * An alternative character closing a range in which the maximal value is exclusive.
      * This character is not used for formatting (only {@link #closeExclusive} is used),
      * but is accepted during parsing. The default value is {@code '['}.
      */
-    private final char closeExclusiveAlt;
+    private final int closeExclusiveAlt;
 
     /**
      * The string to use as a separator between minimal and maximal value, not including
@@ -209,8 +254,8 @@ public class RangeFormat extends Format 
      * to be created by the parse method:
      *
      * <ul>
-     *   <li>{@link NumberRange} if the element type is assignable to {@link Number} or {@link Angle}.</li>
-     *   <li>{@link DateRange}   if the element type is assignable to {@link Date}.</li>
+     *   <li>{@code NumberRange<?>} if the element type is assignable to {@link Number} or {@link Angle}.</li>
+     *   <li>{@code Range<Date>} if the element type is assignable to {@link Date}.</li>
      * </ul>
      *
      * @see Range#getElementType()
@@ -254,7 +299,7 @@ public class RangeFormat extends Format 
     }
 
     /**
-     * Creates a new format for parsing and formatting {@linkplain DateRange date ranges}
+     * Creates a new format for parsing and formatting {@code Range<Date>}
      * using the given locale and timezone.
      *
      * @param locale   The locale for parsing and formatting range components.
@@ -296,9 +341,11 @@ public class RangeFormat extends Format 
         }
         minusSign         = ds.getMinusSign();
         infinity          = ds.getInfinity();
+        openSet           = '{';
         openInclusive     = '['; // Future SIS version may determine those characters from the locale.
         openExclusive     = '('; // We may also provide an 'applyPattern(String)' method for setting those char.
         openExclusiveAlt  = ']';
+        closeSet          = '}';
         closeInclusive    = ']';
         closeExclusive    = ')';
         closeExclusiveAlt = '[';
@@ -415,19 +462,7 @@ public class RangeFormat extends Format 
 
     /**
      * Formats a {@link Range} and appends the resulting text to a given string buffer.
-     * This method formats then given range as below:
-     *
-     * <ul>
-     *   <li>If the range is empty, then this method appends {@code "[]"}.</li>
-     *   <li>Otherwise if the minimal value is equals to the maximal value, then
-     *       that value is formatted alone.</li>
-     *   <li>Otherwise the minimal and maximal values are formatted like {@code [min … max]} for
-     *       inclusive bounds or {@code (min … max)} for exclusive bounds, or a mix of both styles.
-     *       The ∞ symbol is used in place of {@code min} or {@code max} for unbounded ranges.</li>
-     * </ul>
-     *
-     * If the given range is a {@link MeasurementRange}, then the unit of measurement is
-     * appended to the above string representation.
+     * See the <a href="#skip-navbar_top">class javadoc</a> for a description of the format.
      *
      * @param  range      The {@link Range} object to format.
      * @param  toAppendTo Where the text is to be appended.
@@ -456,18 +491,18 @@ public class RangeFormat extends Format 
             final AttributedCharacterIterator characterIterator)
     {
         /*
-         * Special case for an empty range. This is typically formatted as "[]". The field
+         * Special case for an empty range. This is typically formatted as "{}". The field
          * position is unconditionally set to the empty substring inside the brackets.
          */
         int fieldPos = getField(pos);
         if (range.isEmpty()) {
-            toAppendTo.append(openInclusive);
+            toAppendTo.appendCodePoint(openSet);
             if (fieldPos >= MIN_VALUE_FIELD && fieldPos <= UNIT_FIELD) {
                 final int p = toAppendTo.length();
                 pos.setBeginIndex(p); // First index, inclusive.
                 pos.setEndIndex  (p); // Last index, exclusive
             }
-            toAppendTo.append(closeInclusive);
+            toAppendTo.appendCodePoint(closeSet);
             return;
         }
         /*
@@ -479,16 +514,15 @@ public class RangeFormat extends Format 
         final Comparable<?> minValue = range.getMinValue();
         final Comparable<?> maxValue = range.getMaxValue();
         final boolean isSingleton = (minValue != null) && minValue.equals(maxValue);
-        int field;
+        int field = MIN_VALUE_FIELD;
         if (isSingleton) {
             if (fieldPos == MIN_VALUE_FIELD) {
                 fieldPos = MAX_VALUE_FIELD;
             }
             field = MAX_VALUE_FIELD;
-        } else {
-            field = MIN_VALUE_FIELD;
-            toAppendTo.append(range.isMinIncluded() ? openInclusive : openExclusive);
         }
+        toAppendTo.appendCodePoint(isSingleton ? openSet :
+                range.isMinIncluded() ? openInclusive : openExclusive);
         for (; field <= UNIT_FIELD; field++) {
             final Object value;
             switch (field) {
@@ -536,9 +570,8 @@ public class RangeFormat extends Format 
                     break;
                 }
                 case MAX_VALUE_FIELD: {
-                    if (!isSingleton) {
-                        toAppendTo.append(range.isMaxIncluded() ? closeInclusive : closeExclusive);
-                    }
+                    toAppendTo.appendCodePoint(isSingleton ? closeSet :
+                            range.isMaxIncluded() ? closeInclusive : closeExclusive);
                     break;
                 }
             }
@@ -691,31 +724,68 @@ public class RangeFormat extends Format 
             c = source.codePointAt(index);
             if (!Character.isWhitespace(c)) break;
         }
-        /*
-         * Get the minimal and maximal values, and whatever they are inclusive or exclusive.
-         */
         final Object minValue, maxValue;
         final boolean isMinIncluded, isMaxIncluded;
         if (!isOpen(c)) {
             /*
-             * No bracket. Assume that we have a single value for the range.
+             * No bracket, or curly bracket. We have eigher an empty range (as in "{}")
+             * or a single value for the range. The braces are optional for single value.
+             * In other words, this block parses all of the following cases:
+             *
+             *  - {}
+             *  - {value}
+             *  - value         (not standard, but accepted by this parser)
              */
-            pos.setIndex(index);
-            final Object value = elementFormat.parseObject(source, pos);
-            if (value == null) {
-                return null;
+            final boolean hasBraces = (c == openSet);
+            if (hasBraces) {
+                // Skip the opening brace and following whitespaces.
+                while ((index += Character.charCount(c)) < length) {
+                    c = source.codePointAt(index);
+                    if (!Character.isWhitespace(c)) break;
+                }
+            }
+            if (hasBraces && c == closeSet) {
+                // Empty range represented by {}
+                minValue = maxValue = valueOfNil();
+                isMinIncluded = isMaxIncluded = false;
+            } else {
+                // Singleton value, with or without braces.
+                pos.setIndex(index);
+                final Object value = elementFormat.parseObject(source, pos);
+                if (value == null) {
+                    return null;
+                }
+                pos.setErrorIndex(index); // In case of failure during the conversion.
+                minValue = maxValue = convert(value);
+                index = pos.getIndex();
+                isMinIncluded = isMaxIncluded = true;
+            }
+            if (hasBraces) {
+                // Skip whitespaces, then skip the closing brace.
+                // Absence of closing brace is considered an error.
+                do {
+                    if (index >= length) {
+                        pos.setErrorIndex(length);
+                        return null;
+                    }
+                    c = source.codePointAt(index);
+                    index += Character.charCount(c);
+                } while (Character.isWhitespace(c));
+                if (c != closeSet) {
+                    pos.setErrorIndex(index - Character.charCount(c));
+                    return null;
+                }
+                pos.setIndex(index);
             }
-            pos.setErrorIndex(index); // In case of failure during the conversion.
-            minValue = maxValue = convert(value);
-            isMinIncluded = isMaxIncluded = true;
-            index = pos.getIndex();
         } else {
             /*
              * We found an opening bracket. Skip the whitespaces. If the next
              * character is a closing bracket, then we have an empty range.
+             * The later case is an extension to the standard format, since
+             * empty ranges are usually represented by {} instead than [].
              */
             isMinIncluded = (c == openInclusive);
-            do {
+            do { // Skip whitespaces.
                 index += Character.charCount(c);
                 if (index >= length) {
                     pos.setErrorIndex(length);
@@ -725,7 +795,7 @@ public class RangeFormat extends Format 
             } while (Character.isWhitespace(c));
             if (isClose(c)) {
                 pos.setErrorIndex(index);  // In case of failure during the conversion.
-                minValue = maxValue = convert(0);
+                minValue = maxValue = valueOfNil();
                 isMaxIncluded = false;
                 index += Character.charCount(c);
             } else {
@@ -792,7 +862,7 @@ public class RangeFormat extends Format 
                      */
                     for (index = pos.getIndex(); ; index += Character.charCount(c)) {
                         if (index >= length) {
-                           pos.setErrorIndex(length);
+                            pos.setErrorIndex(length);
                             return null;
                         }
                         c = source.charAt(index);
@@ -858,7 +928,7 @@ public class RangeFormat extends Format 
         } else if (Date.class.isAssignableFrom(elementType)) {
             final Date min = (Date) minValue;
             final Date max = (Date) maxValue;
-            return new DateRange(min, isMinIncluded, max, isMaxIncluded);
+            return new Range<Date>(Date.class, min, isMinIncluded, max, isMaxIncluded);
         } else {
             @SuppressWarnings({"unchecked","rawtypes"})
             final Class<? extends Comparable<?>> type = (Class) elementType;
@@ -884,4 +954,19 @@ public class RangeFormat extends Format 
         throw new UnconvertibleObjectException(Errors.format(
                 Errors.Keys.IllegalClass_2, elementType, value.getClass()));
     }
+
+    /**
+     * Returns a "nil" value. This is used for creating empty ranges.
+     */
+    private Object valueOfNil() {
+        Object value = Numbers.valueOfNil(elementType);
+        if (value == null) {
+            if (Date.class.isAssignableFrom(elementType)) {
+                value = new Date();
+            } else {
+                value = 0;
+            }
+        }
+        return convert(value);
+    }
 }

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/package-info.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/package-info.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/measure/package-info.java Fri Feb 22 11:55:18 2013
@@ -25,8 +25,7 @@
  *      ({@link org.apache.sis.measure.Longitude},
  *       {@link org.apache.sis.measure.Latitude})</li>
  *   <li>{@link org.apache.sis.measure.Range} and its subclasses
- *      ({@link org.apache.sis.measure.DateRange},
- *       {@link org.apache.sis.measure.NumberRange},
+ *      ({@link org.apache.sis.measure.NumberRange},
  *       {@link org.apache.sis.measure.MeasurementRange})</li>
  *   <li>Formatters
  *      ({@link org.apache.sis.measure.AngleFormat},

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java Fri Feb 22 11:55:18 2013
@@ -1424,7 +1424,15 @@ public final class ArraysExt extends Sta
 
     /**
      * Returns {@code true} if all elements in the specified array are in increasing order.
-     * Null and empty arrays are considered as sorted.
+     * Special cases:
+     *
+     * <ul>
+     *   <li>Empty arrays are considered as sorted.</li>
+     *   <li>Null arrays are considered as unknown content and cause a {@code NullPointerException}
+     *       to be thrown.</li>
+     *   <li>{@code null} elements are considered unordered and may appear anywhere in the array;
+     *       they will be silently ignored.</li>
+     * </ul>
      *
      * @param <E>         The type of array elements.
      * @param array       The array to test for order.
@@ -1434,10 +1442,58 @@ public final class ArraysExt extends Sta
      * @return {@code true} if all elements in the given array are sorted in increasing order.
      */
     public static <E> boolean isSorted(final E[] array, final Comparator<? super E> comparator, final boolean strict) {
-        for (int i=1; i<array.length; i++) {
-            final int c = comparator.compare(array[i], array[i-1]);
-            if (strict ? c <= 0 : c < 0) {
-                return false;
+        for (int i=0; i<array.length; i++) {
+            E p = array[i];
+            if (p != null) {
+                while (++i < array.length) {
+                    final E e = array[i];
+                    if (e != null) {
+                        final int c = comparator.compare(e, p);
+                        if (strict ? c <= 0 : c < 0) {
+                            return false;
+                        }
+                        p = e;
+                    }
+                }
+                break;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Returns {@code true} if all elements in the specified array are in increasing order.
+     * Special cases:
+     *
+     * <ul>
+     *   <li>Empty arrays are considered as sorted.</li>
+     *   <li>Null arrays are considered as unknown content and cause a {@code NullPointerException}
+     *       to be thrown.</li>
+     *   <li>{@code null} elements are considered unordered and may appear anywhere in the array;
+     *       they will be silently ignored.</li>
+     * </ul>
+     *
+     * @param <E>         The type of array elements.
+     * @param array       The array to test for order.
+     * @param strict      {@code true} if elements should be strictly sorted (i.e. equal
+     *                    elements are not allowed), or {@code false} otherwise.
+     * @return {@code true} if all elements in the given array are sorted in increasing order.
+     */
+    public static <E extends Comparable<? super E>> boolean isSorted(final E[] array, final boolean strict) {
+        for (int i=0; i<array.length; i++) {
+            E p = array[i];
+            if (p != null) {
+                while (++i < array.length) {
+                    final E e = array[i];
+                    if (e != null) {
+                        final int c = e.compareTo(p);
+                        if (strict ? c <= 0 : c < 0) {
+                            return false;
+                        }
+                        p = e;
+                    }
+                }
+                break;
             }
         }
         return true;
@@ -1445,11 +1501,15 @@ public final class ArraysExt extends Sta
 
     /**
      * Returns {@code true} if all elements in the specified array are in increasing order.
-     * Null and empty arrays are considered as sorted.
+     * Special cases:
      *
-     * {@section Handling of NaN values}
-     * Since {@code NaN} values are unordered, they may appears anywhere in the array;
-     * they will be ignored.
+     * <ul>
+     *   <li>Empty arrays are considered as sorted.</li>
+     *   <li>Null arrays are considered as unknown content and cause a {@code NullPointerException}
+     *       to be thrown.</li>
+     *   <li>{@link Double#NaN NaN} elements are considered unordered and may appear anywhere
+     *       in the array; they will be silently ignored.</li>
+     * </ul>
      *
      * @param array  The array to test for order.
      * @param strict {@code true} if elements should be strictly sorted (i.e. equal elements
@@ -1457,15 +1517,19 @@ public final class ArraysExt extends Sta
      * @return {@code true} if all elements in the given array are sorted in increasing order.
      */
     public static boolean isSorted(final double[] array, final boolean strict) {
-        int previous = 0;
-        for (int i=1; i<array.length; i++) {
-            final double e = array[i];
-            final double p = array[previous];
-            if (strict ? e <= p : e < p) {
-                return false;
-            }
-            if (!Double.isNaN(e)) {
-                previous = i;
+        for (int i=0; i<array.length; i++) {
+            double p = array[i];
+            if (!Double.isNaN(p)) {
+                while (++i < array.length) {
+                    final double e = array[i];
+                    if (strict ? e <= p : e < p) {
+                        return false;
+                    }
+                    if (!Double.isNaN(e)) {
+                        p = e;
+                    }
+                }
+                break;
             }
         }
         return true;
@@ -1473,11 +1537,15 @@ public final class ArraysExt extends Sta
 
     /**
      * Returns {@code true} if all elements in the specified array are in increasing order.
-     * Null and empty arrays are considered as sorted.
+     * Special cases:
      *
-     * {@section Handling of NaN values}
-     * Since {@code NaN} values are unordered, they may appears anywhere in the array;
-     * they will be ignored.
+     * <ul>
+     *   <li>Empty arrays are considered as sorted.</li>
+     *   <li>Null arrays are considered as unknown content and cause a {@code NullPointerException}
+     *       to be thrown.</li>
+     *   <li>{@link Float#NaN NaN} elements are considered unordered and may appear anywhere
+     *       in the array; they will be silently ignored.</li>
+     * </ul>
      *
      * @param array  The array to test for order.
      * @param strict {@code true} if elements should be strictly sorted (i.e. equal elements
@@ -1485,15 +1553,19 @@ public final class ArraysExt extends Sta
      * @return {@code true} if all elements in the given array are sorted in increasing order.
      */
     public static boolean isSorted(final float[] array, final boolean strict) {
-        int previous = 0;
-        for (int i=1; i<array.length; i++) {
-            final float e = array[i];
-            final float p = array[previous];
-            if (strict ? e <= p : e < p) {
-                return false;
-            }
-            if (!Float.isNaN(e)) {
-                previous = i;
+        for (int i=0; i<array.length; i++) {
+            float p = array[i];
+            if (!Float.isNaN(p)) {
+                while (++i < array.length) {
+                    final float e = array[i];
+                    if (strict ? e <= p : e < p) {
+                        return false;
+                    }
+                    if (!Float.isNaN(e)) {
+                        p = e;
+                    }
+                }
+                break;
             }
         }
         return true;
@@ -1501,7 +1573,13 @@ public final class ArraysExt extends Sta
 
     /**
      * Returns {@code true} if all elements in the specified array are in increasing order.
-     * Null and empty arrays are considered as sorted.
+     * Special cases:
+     *
+     * <ul>
+     *   <li>Empty arrays are considered as sorted.</li>
+     *   <li>Null arrays are considered as unknown content and cause a {@code NullPointerException}
+     *       to be thrown.</li>
+     * </ul>
      *
      * @param array  The array to test for order.
      * @param strict {@code true} if elements should be strictly sorted (i.e. equal elements
@@ -1509,11 +1587,14 @@ public final class ArraysExt extends Sta
      * @return {@code true} if all elements in the given array are sorted in increasing order.
      */
     public static boolean isSorted(final long[] array, final boolean strict) {
-        for (int i=1; i<array.length; i++) {
-            final long e = array[i];
-            final long p = array[i-1];
-            if (strict ? e <= p : e < p) {
-                return false;
+        if (array.length != 0) {
+            long p = array[0];
+            for (int i=1; i<array.length; i++) {
+                final long e = array[i];
+                if (strict ? e <= p : e < p) {
+                    return false;
+                }
+                p = e;
             }
         }
         return true;
@@ -1521,7 +1602,13 @@ public final class ArraysExt extends Sta
 
     /**
      * Returns {@code true} if all elements in the specified array are in increasing order.
-     * Null and empty arrays are considered as sorted.
+     * Special cases:
+     *
+     * <ul>
+     *   <li>Empty arrays are considered as sorted.</li>
+     *   <li>Null arrays are considered as unknown content and cause a {@code NullPointerException}
+     *       to be thrown.</li>
+     * </ul>
      *
      * @param array  The array to test for order.
      * @param strict {@code true} if elements should be strictly sorted (i.e. equal elements
@@ -1529,11 +1616,14 @@ public final class ArraysExt extends Sta
      * @return {@code true} if all elements in the given array are sorted in increasing order.
      */
     public static boolean isSorted(final int[] array, final boolean strict) {
-        for (int i=1; i<array.length; i++) {
-            final int e = array[i];
-            final int p = array[i-1];
-            if (strict ? e <= p : e < p) {
-                return false;
+        if (array.length != 0) {
+            int p = array[0];
+            for (int i=1; i<array.length; i++) {
+                final int e = array[i];
+                if (strict ? e <= p : e < p) {
+                    return false;
+                }
+                p = e;
             }
         }
         return true;
@@ -1541,7 +1631,13 @@ public final class ArraysExt extends Sta
 
     /**
      * Returns {@code true} if all elements in the specified array are in increasing order.
-     * Null and empty arrays are considered as sorted.
+     * Special cases:
+     *
+     * <ul>
+     *   <li>Empty arrays are considered as sorted.</li>
+     *   <li>Null arrays are considered as unknown content and cause a {@code NullPointerException}
+     *       to be thrown.</li>
+     * </ul>
      *
      * @param array  The array to test for order.
      * @param strict {@code true} if elements should be strictly sorted (i.e. equal elements
@@ -1549,11 +1645,14 @@ public final class ArraysExt extends Sta
      * @return {@code true} if all elements in the given array are sorted in increasing order.
      */
     public static boolean isSorted(final short[] array, final boolean strict) {
-        for (int i=1; i<array.length; i++) {
-            final short e = array[i];
-            final short p = array[i-1];
-            if (strict ? e <= p : e < p) {
-                return false;
+        if (array.length != 0) {
+            short p = array[0];
+            for (int i=1; i<array.length; i++) {
+                final short e = array[i];
+                if (strict ? e <= p : e < p) {
+                    return false;
+                }
+                p = e;
             }
         }
         return true;
@@ -1561,7 +1660,13 @@ public final class ArraysExt extends Sta
 
     /**
      * Returns {@code true} if all elements in the specified array are in increasing order.
-     * Null and empty arrays are considered as sorted.
+     * Special cases:
+     *
+     * <ul>
+     *   <li>Empty arrays are considered as sorted.</li>
+     *   <li>Null arrays are considered as unknown content and cause a {@code NullPointerException}
+     *       to be thrown.</li>
+     * </ul>
      *
      * @param array  The array to test for order.
      * @param strict {@code true} if elements should be strictly sorted (i.e. equal elements
@@ -1569,11 +1674,14 @@ public final class ArraysExt extends Sta
      * @return {@code true} if all elements in the given array are sorted in increasing order.
      */
     public static boolean isSorted(final byte[] array, final boolean strict) {
-        for (int i=1; i<array.length; i++) {
-            final byte e = array[i];
-            final byte p = array[i-1];
-            if (strict ? e <= p : e < p) {
-                return false;
+        if (array.length != 0) {
+            byte p = array[0];
+            for (int i=1; i<array.length; i++) {
+                final byte e = array[i];
+                if (strict ? e <= p : e < p) {
+                    return false;
+                }
+                p = e;
             }
         }
         return true;
@@ -1581,7 +1689,13 @@ public final class ArraysExt extends Sta
 
     /**
      * Returns {@code true} if all elements in the specified array are in increasing order.
-     * Null and empty arrays are considered as sorted.
+     * Special cases:
+     *
+     * <ul>
+     *   <li>Empty arrays are considered as sorted.</li>
+     *   <li>Null arrays are considered as unknown content and cause a {@code NullPointerException}
+     *       to be thrown.</li>
+     * </ul>
      *
      * @param array  The array to test for order.
      * @param strict {@code true} if elements should be strictly sorted (i.e. equal elements
@@ -1589,11 +1703,14 @@ public final class ArraysExt extends Sta
      * @return {@code true} if all elements in the given array are sorted in increasing order.
      */
     public static boolean isSorted(final char[] array, final boolean strict) {
-        for (int i=1; i<array.length; i++) {
-            final char e = array[i];
-            final char p = array[i-1];
-            if (strict ? e <= p : e < p) {
-                return false;
+        if (array.length != 0) {
+            char p = array[0];
+            for (int i=1; i<array.length; i++) {
+                final char e = array[i];
+                if (strict ? e <= p : e < p) {
+                    return false;
+                }
+                p = e;
             }
         }
         return true;

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Numbers.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Numbers.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Numbers.java Fri Feb 22 11:55:18 2013
@@ -38,6 +38,8 @@ import org.apache.sis.util.collection.Co
  * @since   0.3 (derived from geotk-2.5)
  * @version 0.3
  * @module
+ *
+ * @see org.apache.sis.math.MathFunctions
  */
 public final class Numbers extends Static {
     /**

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java Fri Feb 22 11:55:18 2013
@@ -340,6 +340,11 @@ public final class Errors extends Indexe
         public static final int StalledThread_1 = 63;
 
         /**
+         * Ordering between “{0}” and “{1}” elements is undefined.
+         */
+        public static final int UndefinedOrderingForElements_2 = 70;
+
+        /**
          * Unexpected change in ‘{0}’.
          */
         public static final int UnexpectedChange_1 = 56;

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties Fri Feb 22 11:55:18 2013
@@ -81,6 +81,7 @@ OddArrayLength_1                = Array 
 RecursiveCreateCallForKey_1     = Recursive call while creating an object for the \u201c{0}\u201d key.
 RequireDecimalSeparator         = A decimal separator is required.
 StalledThread_1                 = Thread \u201c{0}\u201d seems stalled.
+UndefinedOrderingForElements_2  = Ordering between \u201c{0}\u201d and \u201c{1}\u201d elements is undefined.
 UnexpectedChange_1              = Unexpected change in \u2018{0}\u2019.
 UnexpectedEndOfString_1         = More characters were expected at the end of \u201c{0}\u201d.
 UnmodifiableAffineTransform     = This affine transform is unmodifiable.

Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties Fri Feb 22 11:55:18 2013
@@ -69,6 +69,7 @@ OddArrayLength_1                = La lon
 RecursiveCreateCallForKey_1     = Appel r\u00e9cursif lors de la cr\u00e9ation d\u2019un objet pour la cl\u00e9 \u201c{0}\u201d.
 RequireDecimalSeparator         = Un s\u00e9parateur d\u00e9cimal est requis.
 StalledThread_1                 = La t\u00e2che \u201c{0}\u201d semble bloqu\u00e9e.
+UndefinedOrderingForElements_2  = L\u2019ordre entre les \u00e9l\u00e9ments \u201c{0}\u201d et \u201c{1}\u201d n\u2019est pas d\u00e9fini.
 UnexpectedChange_1              = Changement inattendu dans \u2018{0}\u2019.
 UnexpectedEndOfString_1         = D\u2019autres caract\u00e8res \u00e9taient attendus \u00e0 la fin du texte \u201c{0}\u201d.
 UnmodifiableAffineTransform     = Cette transformation affine n\u2019est pas modifiable.

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java Fri Feb 22 11:55:18 2013
@@ -30,6 +30,16 @@ import static org.apache.sis.test.Assert
 /**
  * Tests {@link Statistics}.
  *
+ * <p>This class uses {@link Random} numbers generator with hard-coded seeds. We do not allow
+ * random seeds because the tests invoke the {@link Random#nextGaussian()} method, then check
+ * if the statistical values are within some range. Because Gaussian distributions have non-null
+ * probability to contain arbitrary large values (infinity is the only limit), testing with random
+ * seeds could produce statistical values out of the expected range no matter how large is this range.
+ * We could only reduce the probability, but never make it null. This is not a flaw in the code,
+ * but a consequence of the probabilistic nature of those statistical distributions.
+ * Consequently, in order to keep the build stable, the random seeds are fixed to values
+ * that are known to produce results inside the range expected by this test class.</p>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
  * @version 0.3
@@ -63,7 +73,7 @@ public final strictfp class StatisticsTe
      */
     @Test
     public void testGaussian() {
-        final Random random = new Random(317780561);
+        final Random random = new Random(317780561); // See class javadoc.
         final Statistics statistics = new Statistics(null);
         for (int i=0; i<10000; i++) {
             statistics.add(random.nextGaussian());
@@ -182,7 +192,7 @@ public final strictfp class StatisticsTe
      */
     @Test
     public void testConcatenation() {
-        final Random random = new Random(429323868);
+        final Random random = new Random(429323868); // See class javadoc.
         final Statistics global = new Statistics(null);
         final Statistics byBlock = new Statistics(null);
         for (int i=0; i<10; i++) {

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java Fri Feb 22 11:55:18 2013
@@ -26,7 +26,9 @@ import static org.apache.sis.test.TestUt
 
 
 /**
- * Tests the {@link DateRange} class.
+ * Tests the {@link Range} class with date values. A previous version was using a dedicated
+ * {@code DateRange} for this purpose. However the specialized class has been removed because
+ * usage of {@code java.util.Date} is replaced by usage of ISO 19108 (temporal schema) types.
  *
  * @author  Martin Desruisseaux (IRD)
  * @since   0.3 (derived from geotk-2.4)
@@ -36,7 +38,7 @@ import static org.apache.sis.test.TestUt
 @DependsOn(RangeTest.class)
 public final strictfp class DateRangeTest extends TestCase {
     /**
-     * Tests {@link DateRange#union(Range)}.
+     * Tests {@link Range#union(Range)}.
      */
     @Test
     public void testUnion() {
@@ -44,29 +46,23 @@ public final strictfp class DateRangeTes
         final Date in1 = date("1998-05-12 11:00:00");
         final Date in2 = date("1998-06-08 14:00:00");
         final Date max = date("1998-07-01 19:00:00");
-        final DateRange r1 = new DateRange(min, in2);
-        final DateRange r2 = new DateRange(in1, max);
-        final DateRange rt = r1.union(r2);
+        final Range<Date> r1 = new Range<Date>(Date.class, min, true, in2, true);
+        final Range<Date> r2 = new Range<Date>(Date.class, in1, true, max, true);
+        final Range<Date> rt = r1.union(r2);
         assertEquals(min, rt.getMinValue());
         assertEquals(max, rt.getMaxValue());
         assertEquals(rt, r2.union(r1));
         /*
          * Test a range fully included in the other range.
          */
-        final DateRange outer = new DateRange(min, max);
-        final DateRange inner = new DateRange(in1, in2);
+        final Range<Date> outer = new Range<Date>(Date.class, min, true, max, true);
+        final Range<Date> inner = new Range<Date>(Date.class, in1, true, in2, true);
         assertSame(outer, outer.union(inner));
         assertSame(outer, inner.union(outer));
-        /*
-         * Same test than above, but with a cast from Range to DateRange.
-         */
-        final Range<Date> outerAsRange = new Range<Date>(Date.class, min, max);
-        assertSame(outerAsRange, outerAsRange.union(inner));
-        assertEquals(outer, inner.union(outerAsRange));
     }
 
     /**
-     * Tests {@link DateRange#intersect(Range)}.
+     * Tests {@link Range#intersect(Range)}.
      */
     @Test
     public void testIntersect() {
@@ -74,29 +70,23 @@ public final strictfp class DateRangeTes
         final Date in1 = date("1998-05-12 11:00:00");
         final Date in2 = date("1998-06-08 14:00:00");
         final Date max = date("1998-07-01 19:00:00");
-        final DateRange r1 = new DateRange(min, in2);
-        final DateRange r2 = new DateRange(in1, max);
-        final DateRange rt = r1.intersect(r2);
+        final Range<Date> r1 = new Range<Date>(Date.class, min, true, in2, true);
+        final Range<Date> r2 = new Range<Date>(Date.class, in1, true, max, true);
+        final Range<Date> rt = r1.intersect(r2);
         assertEquals(in1, rt.getMinValue());
         assertEquals(in2, rt.getMaxValue());
         assertEquals(rt, r2.intersect(r1));
         /*
          * Test a range fully included in the other range.
          */
-        final DateRange outer = new DateRange(min, max);
-        final DateRange inner = new DateRange(in1, in2);
+        final Range<Date> outer = new Range<Date>(Date.class, min, true, max, true);
+        final Range<Date> inner = new Range<Date>(Date.class, in1, true, in2, true);
         assertSame(inner, outer.intersect(inner));
         assertSame(inner, inner.intersect(outer));
-        /*
-         * Same test than above, but with a cast from Range to DateRange.
-         */
-        final Range<Date> innerAsRange = new Range<Date>(Date.class, in1, in2);
-        assertSame(innerAsRange, innerAsRange.intersect(outer));
-        assertEquals(inner, outer.intersect(innerAsRange));
     }
 
     /**
-     * Tests {@link DateRange#subtract(Range)}.
+     * Tests {@link Range#subtract(Range)}.
      */
     @Test
     public void testSubtract() {
@@ -104,9 +94,9 @@ public final strictfp class DateRangeTes
         final Date in1 = date("1998-05-12 11:00:00");
         final Date in2 = date("1998-06-08 14:00:00");
         final Date max = date("1998-07-01 19:00:00");
-        final DateRange outer = new DateRange(min, max);
-        final DateRange inner = new DateRange(in1, in2);
-        final DateRange[] rt = outer.subtract(inner);
+        final Range<Date> outer = new Range<Date>(Date.class, min, true, max, true);
+        final Range<Date> inner = new Range<Date>(Date.class, in1, true, in2, true);
+        final Range<Date>[] rt = outer.subtract(inner);
         assertEquals(2, rt.length);
         assertEquals(min, rt[0].getMinValue());
         assertEquals(in1, rt[0].getMaxValue());

Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java?rev=1449006&r1=1449005&r2=1449006&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/MeasurementRangeTest.java Fri Feb 22 11:55:18 2013
@@ -42,9 +42,9 @@ public final strictfp class MeasurementR
      */
     @Test
     public void testConvertTo() throws ConversionException {
-        final MeasurementRange<Float> range = MeasurementRange.create(1000f, 2000f, SI.METRE);
+        final MeasurementRange<Float> range = MeasurementRange.create(1000f, true, 2000f, true, SI.METRE);
         assertSame(range, range.convertTo(SI.METRE));
-        assertEquals(MeasurementRange.create(1f, 2f, SI.KILOMETRE), range.convertTo(SI.KILOMETRE));
+        assertEquals(MeasurementRange.create(1f, true, 2f, true, SI.KILOMETRE), range.convertTo(SI.KILOMETRE));
     }
 
     /**
@@ -52,14 +52,14 @@ public final strictfp class MeasurementR
      */
     @Test
     public void testAutoConversions() {
-        final MeasurementRange<Float> r1 = MeasurementRange.create(1000f, 2000f, SI.METRE);
-        final MeasurementRange<Float> r2 = MeasurementRange.create(1.5f, 3f, SI.KILOMETRE);
+        final MeasurementRange<Float> r1 = MeasurementRange.create(1000f, true, 2000f, true, SI.METRE);
+        final MeasurementRange<Float> r2 = MeasurementRange.create(1.5f, true, 3f, true, SI.KILOMETRE);
         assertEquals(Float.class, r1.getElementType());
         assertEquals(Float.class, r2.getElementType());
-        assertEquals(MeasurementRange.create(1000f, 3000f, SI.METRE ),    r1.union    (r2));
-        assertEquals(MeasurementRange.create(1f,    3f,    SI.KILOMETRE), r2.union    (r1));
-        assertEquals(MeasurementRange.create(1500f, 2000f, SI.METRE ),    r1.intersect(r2));
-        assertEquals(MeasurementRange.create(1.5f,  2f,    SI.KILOMETRE), r2.intersect(r1));
+        assertEquals(MeasurementRange.create(1000f, true, 3000f, true, SI.METRE ),    r1.union    (r2));
+        assertEquals(MeasurementRange.create(   1f, true,    3f, true, SI.KILOMETRE), r2.union    (r1));
+        assertEquals(MeasurementRange.create(1500f, true, 2000f, true, SI.METRE ),    r1.intersect(r2));
+        assertEquals(MeasurementRange.create( 1.5f, true,    2f, true, SI.KILOMETRE), r2.intersect(r1));
     }
 
     /**
@@ -67,12 +67,12 @@ public final strictfp class MeasurementR
      */
     @Test
     public void testAutoConversionsOfAny() {
-        final MeasurementRange<?> r1 = MeasurementRange.create(1000f, 2000f, SI.METRE);
-        final MeasurementRange<?> r2 = MeasurementRange.create(1.5f, 3f, SI.KILOMETRE);
-        assertEquals(MeasurementRange.create(1000f, 3000f, SI.METRE ),    r1.unionAny    (r2));
-        assertEquals(MeasurementRange.create(1f,    3f,    SI.KILOMETRE), r2.unionAny    (r1));
-        assertEquals(MeasurementRange.create(1500f, 2000f, SI.METRE ),    r1.intersectAny(r2));
-        assertEquals(MeasurementRange.create(1.5f,  2f,    SI.KILOMETRE), r2.intersectAny(r1));
+        final MeasurementRange<?> r1 = MeasurementRange.create(1000f, true, 2000f, true, SI.METRE);
+        final MeasurementRange<?> r2 = MeasurementRange.create(1.5f, true, 3f, true, SI.KILOMETRE);
+        assertEquals(MeasurementRange.create(1000f, true, 3000f, true, SI.METRE ),    r1.unionAny    (r2));
+        assertEquals(MeasurementRange.create(   1f, true,    3f, true, SI.KILOMETRE), r2.unionAny    (r1));
+        assertEquals(MeasurementRange.create(1500f, true, 2000f, true, SI.METRE ),    r1.intersectAny(r2));
+        assertEquals(MeasurementRange.create( 1.5f, true,    2f, true, SI.KILOMETRE), r2.intersectAny(r1));
     }
 
     /**
@@ -80,8 +80,8 @@ public final strictfp class MeasurementR
      */
     @Test
     public void testToString() {
-        final MeasurementRange<Float> range = MeasurementRange.create(10f, 20f, SI.KILOMETRE);
-        assertEquals("[10.0 … 20.0] km", range.toString());
+        final MeasurementRange<Float> range = MeasurementRange.create(10f, true, 20f, true, SI.KILOMETRE);
+        assertEquals("[10.0 … 20.0] km", range.toString());
     }
 
     /**
@@ -89,8 +89,8 @@ public final strictfp class MeasurementR
      */
     @Test
     public void testSerialization() {
-        NumberRange<Float> r1 = MeasurementRange.create(1000f, 2000f, SI.METRE);
-        NumberRange<Float> r2 = MeasurementRange.create(1.5f, 3f, SI.KILOMETRE);
+        NumberRange<Float> r1 = MeasurementRange.create(1000f, true, 2000f, true, SI.METRE);
+        NumberRange<Float> r2 = MeasurementRange.create(1.5f, true, 3f, true, SI.KILOMETRE);
         assertNotSame(r1, assertSerializedEquals(r1));
         assertNotSame(r2, assertSerializedEquals(r2));
     }



Mime
View raw message