sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1446224 - in /sis/branches/JDK7/sis-utility/src: main/java/org/apache/sis/measure/ test/java/org/apache/sis/measure/
Date Thu, 14 Feb 2013 15:00:05 GMT
Author: desruisseaux
Date: Thu Feb 14 15:00:05 2013
New Revision: 1446224

URL: http://svn.apache.org/r1446224
Log:
Removal of the DateRange subclass, because it provides few added value compared to Range<Date>
and
because usage of java.util.Date will probably be abandonned in favor of ISO 19108 (temporal
schema) types.

Removed:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/DateRange.java
Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/package-info.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java?rev=1446224&r1=1446223&r2=1446224&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java Thu
Feb 14 15:00:05 2013
@@ -43,7 +43,7 @@ import org.apache.sis.util.resources.Err
  *
  * <ul>
  *   <li>If the elements type is assignable to {@link Date}, then the {@code parse}
method
- *       will create {@link DateRange} objects.</li>
+ *       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
@@ -59,7 +59,6 @@ import org.apache.sis.util.resources.Err
  * @module
  *
  * @see Range
- * @see DateRange
  * @see NumberRange
  * @see MeasurementRange
  */
@@ -209,8 +208,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 +253,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.
@@ -858,7 +857,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.class, min, isMinIncluded, max, isMaxIncluded);
         } else {
             @SuppressWarnings({"unchecked","rawtypes"})
             final Class<? extends Comparable<?>> type = (Class) elementType;

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/package-info.java?rev=1446224&r1=1446223&r2=1446224&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/package-info.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/package-info.java Thu
Feb 14 15:00:05 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/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java?rev=1446224&r1=1446223&r2=1446224&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java
(original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/DateRangeTest.java
Thu Feb 14 15:00:05 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.class, min, in2);
+        final Range<Date> r2 = new Range<>(Date.class, in1, max);
+        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.class, min, max);
+        final Range<Date> inner = new Range<>(Date.class, in1, in2);
         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.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.class, min, in2);
+        final Range<Date> r2 = new Range<>(Date.class, in1, max);
+        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.class, min, max);
+        final Range<Date> inner = new Range<>(Date.class, in1, in2);
         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.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.class, min, max);
+        final Range<Date> inner = new Range<>(Date.class, in1, in2);
+        final Range<Date>[] rt = outer.subtract(inner);
         assertEquals(2, rt.length);
         assertEquals(min, rt[0].getMinValue());
         assertEquals(in1, rt[0].getMaxValue());

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java?rev=1446224&r1=1446223&r2=1446224&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java
(original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java
Thu Feb 14 15:00:05 2013
@@ -290,7 +290,7 @@ public final strictfp class RangeFormatT
         final long DAY  = 24L * HOUR;
         final long YEAR = round(365.25 * DAY);
 
-        DateRange range = new DateRange(new Date(15*DAY + 18*HOUR), new Date(20*YEAR + 15*DAY
+ 9*HOUR));
+        Range<Date> range = new Range<>(Date.class, new Date(15*DAY + 18*HOUR),
new Date(20*YEAR + 15*DAY + 9*HOUR));
         AttributedCharacterIterator it = format.formatToCharacterIterator(range);
         String text = it.toString();
         findYears(it, RangeFormat.Field.MIN_VALUE, minPos);
@@ -304,7 +304,7 @@ public final strictfp class RangeFormatT
         /*
          * Try again with the infinity symbol in one bounds.
          */
-        range = new DateRange((Date) null, new Date(20*YEAR));
+        range = new Range<>(Date.class, (Date) null, new Date(20*YEAR));
         it    = format.formatToCharacterIterator(range);
         text  = it.toString();
         findYears(it, RangeFormat.Field.MAX_VALUE, maxPos);
@@ -313,7 +313,7 @@ public final strictfp class RangeFormatT
         assertEquals(14, maxPos.getEndIndex());
         assertEquals(range, parse(text));
 
-        range = new DateRange(new Date(20*YEAR), (Date) null);
+        range = new Range<>(Date.class, new Date(20*YEAR), (Date) null);
         it    = format.formatToCharacterIterator(range);
         text  = it.toString();
         findYears(it, RangeFormat.Field.MIN_VALUE, minPos);



Mime
View raw message