sis-commits mailing list archives

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

URL: http://svn.apache.org/r1446208
Log:
Method renaming:
* getUnits() --> unit() for consistency with the method name in org.unitsofmeasurement
interfaces.
* getMinimum() --> getMinDouble() for consistency with getMinValue().
* getMaximum() --> getMaxDouble() for consistency with getMaxValue().

Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/DateRange.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/Range.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/DateRange.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/DateRange.java?rev=1446208&r1=1446207&r2=1446208&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/DateRange.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/DateRange.java Thu
Feb 14 14:38:42 2013
@@ -73,10 +73,10 @@ public class DateRange extends Range<Dat
      * @param  range The range to convert.
      * @param  origin The date to use as the origin.
      * @throws ConversionException if the given range doesn't have a
-     *         {@linkplain MeasurementRange#getUnits unit} compatible with milliseconds.
+     *         {@linkplain MeasurementRange#unit unit} compatible with milliseconds.
      */
     public DateRange(final MeasurementRange<?> range, final Date origin) throws ConversionException
{
-        this(range, getConverter(range.getUnits()), origin.getTime());
+        this(range, getConverter(range.unit()), origin.getTime());
     }
 
     /**
@@ -87,8 +87,8 @@ public class DateRange extends Range<Dat
             throws ConversionException
     {
         super(Date.class,
-              new Date(origin + Math.round(converter.convert(range.getMinimum()))), range.isMinIncluded(),
-              new Date(origin + Math.round(converter.convert(range.getMaximum()))), range.isMaxIncluded());
+              new Date(origin + Math.round(converter.convert(range.getMinDouble()))), range.isMinIncluded(),
+              new Date(origin + Math.round(converter.convert(range.getMaxDouble()))), range.isMaxIncluded());
     }
 
     /**

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java?rev=1446208&r1=1446207&r2=1446208&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
Thu Feb 14 14:38:42 2013
@@ -30,7 +30,7 @@ import java.util.Objects;
 /**
  * A range of numbers associated with a unit of measurement. All operations performed by
this
  * class ({@linkplain #union union}, {@linkplain #intersect intersection}, <i>etc.</i>)
are
- * performed in the units of measurement of {@code this} range object - values of the range
+ * performed in the unit of measurement of {@code this} range object - values of the range
  * object given in argument are converted if needed before an operation is applied.
  *
  * <p>Other methods defined in this class:</p>
@@ -39,7 +39,7 @@ import java.util.Objects;
  *       Usage of {@code MeasurementRange} with integer types is possible, but no convenience
  *       method is provided for integers because they are usually not representative of the
  *       nature of physical measurements.</li>
- *   <li>{@link #convertTo(Unit)} for converting the units of measurement.</li>
+ *   <li>{@link #convertTo(Unit)} for converting the unit of measurement.</li>
  *   <li>{@link #castTo(Class)} for casting the range values to an other type.</li>
  * </ul>
  *
@@ -58,24 +58,24 @@ public class MeasurementRange<E extends 
     private static final long serialVersionUID = 3980319420337513745L;
 
     /**
-     * The units of measurement, or {@code null} if unknown.
+     * The unit of measurement, or {@code null} if unknown.
      *
-     * @see #getUnits()
+     * @see #unit()
      */
-    private final Unit<?> units;
+    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  units    The units of measurement, or {@code null} if unknown.
+     * @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<?>
units) {
+    public static MeasurementRange<Float> create(float minValue, float maxValue, Unit<?>
unit) {
         return new MeasurementRange<>(Float.class,
                 valueOf("minValue", minValue, Float.NEGATIVE_INFINITY),
-                valueOf("maxValue", maxValue, Float.POSITIVE_INFINITY), units);
+                valueOf("maxValue", maxValue, Float.POSITIVE_INFINITY), unit);
     }
 
     /**
@@ -85,15 +85,15 @@ public class MeasurementRange<E extends 
      * @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.
-     * @param  units          The units of measurement, or {@code null} if unknown.
+     * @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, boolean isMinIncluded,
-                                                 float maxValue, boolean isMaxIncluded, Unit<?>
units)
+                                                 float maxValue, boolean isMaxIncluded, Unit<?>
unit)
     {
         return new MeasurementRange<>(Float.class,
                 valueOf("minValue", minValue, Float.NEGATIVE_INFINITY), isMinIncluded,
-                valueOf("maxValue", maxValue, Float.POSITIVE_INFINITY), isMaxIncluded, units);
+                valueOf("maxValue", maxValue, Float.POSITIVE_INFINITY), isMaxIncluded, unit);
     }
 
     /**
@@ -101,13 +101,13 @@ public class MeasurementRange<E extends 
      *
      * @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  units    The units of measurement, or {@code null} if unknown.
+     * @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<?> units) {
+    public static MeasurementRange<Double> create(double minValue, double maxValue,
Unit<?> unit) {
         return new MeasurementRange<>(Double.class,
                 valueOf("minValue", minValue, Double.NEGATIVE_INFINITY),
-                valueOf("maxValue", maxValue, Double.POSITIVE_INFINITY), units);
+                valueOf("maxValue", maxValue, Double.POSITIVE_INFINITY), unit);
     }
 
     /**
@@ -117,53 +117,52 @@ public class MeasurementRange<E extends 
      * @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.
-     * @param  units          The units of measurement, or {@code null} if unknown.
+     * @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, boolean isMinIncluded,
-                                                  double maxValue, boolean isMaxIncluded,
Unit<?> units)
+                                                  double maxValue, boolean isMaxIncluded,
Unit<?> unit)
     {
         return new MeasurementRange<>(Double.class,
                 valueOf("minValue", minValue, Double.NEGATIVE_INFINITY), isMinIncluded,
-                valueOf("maxValue", maxValue, Double.POSITIVE_INFINITY), isMaxIncluded, units);
+                valueOf("maxValue", maxValue, Double.POSITIVE_INFINITY), isMaxIncluded, unit);
     }
 
     /**
      * Constructs a range using the smallest type of {@link Number} that can hold the given
values.
      * This method performs the same work than {@link NumberRange#createBestFit
-     * NumberRange.createBestFit(…)} with an additional {@code units} argument.
+     * NumberRange.createBestFit(…)} with an additional {@code unit} argument.
      *
-     * @param  minimum        The minimum value, or {@code null} for negative infinity.
-     * @param  isMinIncluded  Defines whether the minimum value is included in the range.
-     * @param  maximum        The maximum value, or {@code null} for positive infinity.
-     * @param  isMaxIncluded  Defines whether the maximum value is included in the range.
-     * @param  units          The units of measurement, or {@code null} if unknown.
-     * @return The new range, or {@code null} if both {@code minimum} and {@code maximum}
-     *         are {@code null}.
+     * @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.
+     * @param  maxValue       The maximal value, or {@code null} 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, or {@code null} if both {@code minValue} and {@code maxValue}
are {@code null}.
      *
      * @see NumberRange#createBestFit(Number, boolean, Number, boolean)
      */
     @SuppressWarnings({"rawtypes","unchecked"})
-    public static MeasurementRange<?> createBestFit(final Number minimum, final boolean
isMinIncluded,
-            final Number maximum, final boolean isMaxIncluded, final Unit<?> units)
+    public static MeasurementRange<?> createBestFit(final Number minValue, final boolean
isMinIncluded,
+            final Number maxValue, final boolean isMaxIncluded, final Unit<?> unit)
     {
         final Class<? extends Number> type = Numbers.widestClass(
-                Numbers.narrowestClass(minimum), Numbers.narrowestClass(maximum));
+                Numbers.narrowestClass(minValue), Numbers.narrowestClass(maxValue));
         return (type == null) ? null :
-            new MeasurementRange(type, Numbers.cast(minimum, type), isMinIncluded,
-                                       Numbers.cast(maximum, type), isMaxIncluded, units);
+            new MeasurementRange(type, Numbers.cast(minValue, type), isMinIncluded,
+                                       Numbers.cast(maxValue, type), isMaxIncluded, unit);
     }
 
     /**
-     * Constructs a range with the same values than the specified range and the given units.
+     * Constructs a range with the same values than the specified range and the given unit.
      * This is a copy constructor, with the addition of a unit of measurement.
      *
      * @param range The range to copy. The elements must be {@link Number} instances.
-     * @param units The units of measurement, or {@code null} if unknown.
+     * @param unit  The unit of measurement, or {@code null} if unknown.
      */
-    public MeasurementRange(final Range<E> range, final Unit<?> units) {
+    public MeasurementRange(final Range<E> range, final Unit<?> unit) {
         super(range);
-        this.units = units;
+        this.unit = unit;
     }
 
     /**
@@ -172,11 +171,11 @@ public class MeasurementRange<E extends 
      * @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 units         The units of measurement, or {@code null} if unknown.
+     * @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<?> units) {
+    public MeasurementRange(final Class<E> type, final E minValue, final E maxValue,
final Unit<?> unit) {
         super(type, minValue, maxValue);
-        this.units = units;
+        this.unit = unit;
     }
 
     /**
@@ -187,15 +186,15 @@ public class MeasurementRange<E extends 
      * @param isMinIncluded {@code true} if the minimal value is inclusive, or {@code false}
if exclusive.
      * @param maxValue      The maximal value, or {@code null} if none.
      * @param isMaxIncluded {@code true} if the maximal value is inclusive, or {@code false}
if exclusive.
-     * @param units         The units of measurement, or {@code null} if unknown.
+     * @param unit          The unit of measurement, or {@code null} if unknown.
      */
     public MeasurementRange(final Class<E> type,
                             final E minValue, final boolean isMinIncluded,
                             final E maxValue, final boolean isMaxIncluded,
-                            final Unit<?> units)
+                            final Unit<?> unit)
     {
         super(type, minValue, isMinIncluded, maxValue, isMaxIncluded);
-        this.units = units;
+        this.unit = unit;
     }
 
     /**
@@ -205,45 +204,45 @@ public class MeasurementRange<E extends 
      * @param type  The element type, usually one of {@link Byte}, {@link Short},
      *              {@link Integer}, {@link Long}, {@link Float} or {@link Double}.
      * @param range The range to copy. The elements must be {@link Number} instances.
-     * @param units The units of measurement, or {@code null} if unknown.
+     * @param unit  The unit of measurement, or {@code null} if unknown.
      */
-    private MeasurementRange(final Class<E> type, final Range<? extends Number>
range, final Unit<?> units) {
+    private MeasurementRange(final Class<E> type, final Range<? extends Number>
range, final Unit<?> unit) {
         super(type, range);
-        this.units = units;
+        this.unit = unit;
     }
 
     /**
-     * Creates a new range using the same element type and the same units than this range.
+     * Creates a new range using the same element type and the same unit than this range.
      */
     @Override
     Range<E> create(final E minValue, final boolean isMinIncluded,
                     final E maxValue, final boolean isMaxIncluded)
     {
-        return new MeasurementRange<>(elementType, minValue, isMinIncluded, maxValue,
isMaxIncluded, units);
+        return new MeasurementRange<>(elementType, minValue, isMinIncluded, maxValue,
isMaxIncluded, unit);
     }
 
     /**
-     * Returns the units of measurement, or {@code null} if unknown.
+     * Returns the unit of measurement, or {@code null} if unknown.
      *
-     * @return The units of measurement, or {@code null}.
+     * @return The unit of measurement, or {@code null}.
      */
     @Override
-    public Unit<?> getUnits() {
-        return units;
+    public Unit<?> unit() {
+        return unit;
     }
 
     /**
-     * Converts this range to the specified units. If this measurement range has null units,
-     * then the specified target units are simply assigned to the returned range with no
+     * Converts this range to the specified unit. If this measurement range has null unit,
+     * then the specified target unit are simply assigned to the returned range with no
      * other changes.
      *
-     * @param  targetUnits the target units, or {@code null} for keeping the units unchanged.
+     * @param  targetUnit the target unit, or {@code null} for keeping the unit unchanged.
      * @return The converted range, or {@code this} if no conversion is needed.
-     * @throws ConversionException if the target units are not compatible with
-     *         this {@linkplain #getUnits() range units}.
+     * @throws ConversionException if the target unit are not compatible with
+     *         this {@linkplain #unit() range unit}.
      */
-    public MeasurementRange<E> convertTo(final Unit<?> targetUnits) throws ConversionException
{
-        return convertAndCast(elementType, targetUnits);
+    public MeasurementRange<E> convertTo(final Unit<?> targetUnit) throws ConversionException
{
+        return convertAndCast(elementType, targetUnit);
     }
 
     /**
@@ -255,13 +254,13 @@ public class MeasurementRange<E extends 
         if (elementType == type) {
             return (MeasurementRange<N>) this;
         } else {
-            return new MeasurementRange<>(type, this, units);
+            return new MeasurementRange<>(type, this, unit);
         }
     }
 
     /**
      * If the given range is an instance of {@code MeasurementRange}, converts that
-     * range to the units of this range. Otherwise returns the given range unchanged.
+     * range to the unit of this range. Otherwise returns the given range unchanged.
      *
      * @param  range The range to convert.
      * @return The converted range.
@@ -270,17 +269,17 @@ public class MeasurementRange<E extends 
      */
     private <N extends E> Range<N> convert(final Range<N> range) throws
IllegalArgumentException {
         if (range instanceof MeasurementRange<?>) try {
-            return ((MeasurementRange<N>) range).convertAndCast(range.elementType,
units);
+            return ((MeasurementRange<N>) range).convertAndCast(range.elementType,
unit);
         } catch (ConversionException e) {
             throw new IllegalArgumentException(Errors.format(Errors.Keys.IncompatibleUnits_2,
-                    ((MeasurementRange<?>) range).units, units), e);
+                    ((MeasurementRange<?>) range).unit, unit), e);
         }
         return range;
     }
 
     /**
      * Casts the specified range to the specified type. If this class is associated to a
unit of
-     * measurement, then this method convert the {@code range} units to the same units than
this
+     * measurement, then this method convert the {@code range} unit to the same unit than
this
      * instance.
      *
      * @param type The class to cast to. Must be one of {@link Byte}, {@link Short},
@@ -293,42 +292,42 @@ public class MeasurementRange<E extends 
             throws IllegalArgumentException
     {
         if (range instanceof MeasurementRange<?>) try {
-            return ((MeasurementRange<?>) range).convertAndCast(type, units);
+            return ((MeasurementRange<?>) range).convertAndCast(type, unit);
         } catch (ConversionException e) {
             throw new IllegalArgumentException(Errors.format(Errors.Keys.IncompatibleUnits_2,
-                    ((MeasurementRange<?>) range).units, units), e);
+                    ((MeasurementRange<?>) range).unit, unit), e);
         }
-        return new MeasurementRange<>(type, range, units);
+        return new MeasurementRange<>(type, range, unit);
     }
 
     /**
-     * Casts this range to the specified type and converts to the specified units.
+     * Casts this range to the specified type and converts to the specified unit.
      * This method is invoked on the {@code other} instance in expressions like
      * {@code this.operation(other)}.
      *
      * @param  type The class to cast to. Must be one of {@link Byte}, {@link Short},
      *             {@link Integer}, {@link Long}, {@link Float} or {@link Double}.
-     * @param  targetUnit the target units, or {@code null} for no change.
+     * @param  targetUnit the target unit, or {@code null} for no change.
      * @return The casted range, or {@code this}.
      * @throws ConversionException if the given target unit is not compatible with
      *         the unit of this range.
      */
     @SuppressWarnings("unchecked")
     private <N extends Number & Comparable<? super N>> MeasurementRange<N>
-            convertAndCast(final Class<N> type, Unit<?> targetUnits) throws ConversionException
+            convertAndCast(final Class<N> type, Unit<?> targetUnit) throws ConversionException
     {
-        if (targetUnits == null || targetUnits.equals(units)) {
+        if (targetUnit == null || targetUnit.equals(unit)) {
             if (elementType == type) {
                 return (MeasurementRange<N>) this;
             }
-            targetUnits = units;
-        } else if (units != null) {
-            final UnitConverter converter = units.getConverterToAny(targetUnits);
+            targetUnit = unit;
+        } else if (unit != null) {
+            final UnitConverter converter = unit.getConverterToAny(targetUnit);
             if (!converter.equals(UnitConverter.IDENTITY)) {
                 boolean minInc = isMinIncluded;
                 boolean maxInc = isMaxIncluded;
-                double minimum = converter.convert(getMinimum());
-                double maximum = converter.convert(getMaximum());
+                double minimum = converter.convert(getMinDouble());
+                double maximum = converter.convert(getMaxDouble());
                 if (minimum > maximum) {
                     final double  td = minimum; minimum = maximum; maximum = td;
                     final boolean tb = minInc;  minInc  = maxInc;  maxInc  = tb;
@@ -339,10 +338,10 @@ public class MeasurementRange<E extends 
                 }
                 return new MeasurementRange<>(type,
                         Numbers.cast(minimum, type), minInc,
-                        Numbers.cast(maximum, type), maxInc, targetUnits);
+                        Numbers.cast(maximum, type), maxInc, targetUnit);
             }
         }
-        return new MeasurementRange<>(type, this, targetUnits);
+        return new MeasurementRange<>(type, this, targetUnit);
     }
 
     /**
@@ -361,7 +360,7 @@ public class MeasurementRange<E extends 
      * the operation.
      *
      * @throws IllegalArgumentException is the given range is an instance of
-     *         {@code MeasurementRange} using incommensurable units of measurement.
+     *         {@code MeasurementRange} using incommensurable unit of measurement.
      */
     @Override
     public boolean contains(final Range<? extends E> range) throws IllegalArgumentException
{
@@ -375,7 +374,7 @@ public class MeasurementRange<E extends 
      * the operation.
      *
      * @throws IllegalArgumentException is the given range is an instance of
-     *         {@code MeasurementRange} using incommensurable units of measurement.
+     *         {@code MeasurementRange} using incommensurable unit of measurement.
      */
     @Override
     public boolean intersects(final Range<? extends E> range) throws IllegalArgumentException
{
@@ -389,7 +388,7 @@ public class MeasurementRange<E extends 
      * the operation.
      *
      * @throws IllegalArgumentException is the given range is an instance of
-     *         {@code MeasurementRange} using incommensurable units of measurement.
+     *         {@code MeasurementRange} using incommensurable unit of measurement.
      */
     @Override
     public Range<E> intersect(final Range<E> range) throws IllegalArgumentException
{
@@ -403,7 +402,7 @@ public class MeasurementRange<E extends 
      * the operation.
      *
      * @throws IllegalArgumentException is the given range is an instance of
-     *         {@code MeasurementRange} using incommensurable units of measurement.
+     *         {@code MeasurementRange} using incommensurable unit of measurement.
      */
     @Override
     public Range<E> union(final Range<E> range) throws IllegalArgumentException
{
@@ -417,7 +416,7 @@ public class MeasurementRange<E extends 
      * the operation.
      *
      * @throws IllegalArgumentException is the given range is an instance of
-     *         {@code MeasurementRange} using incommensurable units of measurement.
+     *         {@code MeasurementRange} using incommensurable unit of measurement.
      */
     @Override
     public Range<E>[] subtract(final Range<E> range) throws IllegalArgumentException
{
@@ -431,7 +430,7 @@ public class MeasurementRange<E extends 
     public boolean equals(final Object object) {
         if (super.equals(object)) {
             if (object instanceof MeasurementRange<?>) {
-                return Objects.equals(units, ((MeasurementRange<?>) object).units);
+                return Objects.equals(unit, ((MeasurementRange<?>) object).unit);
             }
             return true;
         }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java?rev=1446208&r1=1446207&r2=1446208&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java Thu
Feb 14 14:38:42 2013
@@ -23,8 +23,8 @@ import org.apache.sis.util.resources.Err
 
 /**
  * A range of numbers capable of widening conversions when performing range operations.
- * {@code NumberRange} has no units. For a range of physical measurements with units of
- * measure, see {@link MeasurementRange}.
+ * {@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>
  * <ul>
@@ -388,8 +388,8 @@ public class NumberRange<E extends Numbe
 
     /**
      * Casts the specified range to the specified type.  If this class is associated to a
unit of
-     * measurement, then this method converts the {@code range} units to the same units than
this
-     * instance.  This method is overridden by {@link MeasurementRange} only in the way described
+     * measurement, then this method converts the {@code range} unit to the same unit than
this
+     * instance. This method is overridden by {@link MeasurementRange} only in the way described
      * above.
      *
      * @param  type The class to cast to. Must be one of {@link Byte}, {@link Short},
@@ -447,13 +447,13 @@ public class NumberRange<E extends Numbe
      * @return The minimum value.
      */
     @SuppressWarnings("unchecked")
-    public double getMinimum() {
+    public double getMinDouble() {
         final Number value = (Number) getMinValue();
         return (value != null) ? value.doubleValue() : Double.NEGATIVE_INFINITY;
     }
 
     /**
-     * Returns the {@linkplain #getMinimum() minimum value} with the specified inclusive
or
+     * Returns the {@linkplain #getMinDouble() minimum value} with the specified inclusive
or
      * exclusive state. If this range is unbounded, then {@link Double#NEGATIVE_INFINITY}
is
      * returned.
      *
@@ -461,8 +461,8 @@ public class NumberRange<E extends Numbe
      *         or {@code false} for the minimum value exclusive.
      * @return The minimum value, inclusive or exclusive as requested.
      */
-    public double getMinimum(final boolean inclusive) {
-        double value = getMinimum();
+    public double getMinDouble(final boolean inclusive) {
+        double value = getMinDouble();
         if (inclusive != isMinIncluded()) {
             value = next(getElementType(), value, inclusive);
         }
@@ -476,13 +476,13 @@ public class NumberRange<E extends Numbe
      * @return The maximum value.
      */
     @SuppressWarnings("unchecked")
-    public double getMaximum() {
+    public double getMaxDouble() {
         final Number value = (Number) getMaxValue();
         return (value != null) ? value.doubleValue() : Double.POSITIVE_INFINITY;
     }
 
     /**
-     * Returns the {@linkplain #getMaximum() maximum value} with the specified inclusive
or
+     * Returns the {@linkplain #getMaxDouble() maximum value} with the specified inclusive
or
      * exclusive state. If this range is unbounded, then {@link Double#POSITIVE_INFINITY}
is
      * returned.
      *
@@ -490,8 +490,8 @@ public class NumberRange<E extends Numbe
      *         or {@code false} for the maximum value exclusive.
      * @return The maximum value, inclusive or exclusive as requested.
      */
-    public double getMaximum(final boolean inclusive) {
-        double value = getMaximum();
+    public double getMaxDouble(final boolean inclusive) {
+        double value = getMaxDouble();
         if (inclusive != isMaxIncluded()) {
             value = next(getElementType(), value, !inclusive);
         }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/Range.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/Range.java?rev=1446208&r1=1446207&r2=1446208&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/Range.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/Range.java Thu Feb
14 14:38:42 2013
@@ -176,7 +176,7 @@ public class Range<E extends Comparable<
     /**
      * To be overridden by {@link MeasurementRange} only.
      */
-    Unit<?> getUnits() {
+    Unit<?> unit() {
         return null;
     }
 
@@ -621,9 +621,9 @@ public class Range<E extends Comparable<
         }
         if (minValue != null && minValue.equals(maxValue)) {
             String value = minValue.toString();
-            final Unit<?> units = getUnits();
-            if (units != null) {
-                value = value + ' ' + units;
+            final Unit<?> unit = unit();
+            if (unit != null) {
+                value = value + ' ' + unit;
             }
             return value;
         }
@@ -646,9 +646,9 @@ public class Range<E extends Comparable<
             buffer.append(maxValue);
         }
         buffer.append(isMaxIncluded ? ']' : ')');
-        final Unit<?> units = getUnits();
-        if (units != null) {
-            buffer.append(' ').append(units);
+        final Unit<?> unit = unit();
+        if (unit != null) {
+            buffer.append(' ').append(unit);
         }
         return buffer.toString();
     }

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=1446208&r1=1446207&r2=1446208&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 14:38:42 2013
@@ -84,7 +84,7 @@ public class RangeFormat extends Format 
     private static final int MAX_VALUE_FIELD = 1;
 
     /**
-     * The constant value for {@link FieldPosition} which designate the units of measurement.
+     * The constant value for {@link FieldPosition} which designate the unit of measurement.
      *
      * @see Field#UNIT
      */
@@ -230,7 +230,7 @@ public class RangeFormat extends Format 
     protected final Format elementFormat;
 
     /**
-     * The format for units of measurement, or {@code null} if none. This is non-null if
and
+     * The format for unit of measurement, or {@code null} if none. This is non-null if and
      * only if {@link #elementType} is assignable to {@link Number} but not to {@link Angle}.
      */
     protected final UnitFormat unitFormat;
@@ -494,7 +494,7 @@ public class RangeFormat extends Format 
             switch (field) {
                 case MIN_VALUE_FIELD: value = minValue; break;
                 case MAX_VALUE_FIELD: value = maxValue; break;
-                case UNIT_FIELD:      value = range.getUnits(); break;
+                case UNIT_FIELD:      value = range.unit(); break;
                 default: throw new AssertionError(field);
             }
             int startPosition = toAppendTo.length();
@@ -812,7 +812,7 @@ public class RangeFormat extends Format 
         }
         /*
          * Parses the unit, if any. The units are always optional: if we can not parse
-         * them, then we will consider that the parsing stopped before the units.
+         * them, then we will consider that the parsing stopped before the unit.
          */
         Unit<?> unit = null;
         if (unitFormat != null) {

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java?rev=1446208&r1=1446207&r2=1446208&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
(original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/NumberRangeTest.java
Thu Feb 14 14:38:42 2013
@@ -39,12 +39,12 @@ public final strictfp class NumberRangeT
     @Test
     public void testIntegerBounds() {
         final NumberRange<Integer> range = NumberRange.create(10, 20);
-        assertEquals(10, range.getMinimum(     ), 0);
-        assertEquals(10, range.getMinimum(true ), 0);
-        assertEquals( 9, range.getMinimum(false), 0);
-        assertEquals(20, range.getMaximum(     ), 0);
-        assertEquals(20, range.getMaximum(true ), 0);
-        assertEquals(21, range.getMaximum(false), 0);
+        assertEquals(10, range.getMinDouble(     ), 0);
+        assertEquals(10, range.getMinDouble(true ), 0);
+        assertEquals( 9, range.getMinDouble(false), 0);
+        assertEquals(20, range.getMaxDouble(     ), 0);
+        assertEquals(20, range.getMaxDouble(true ), 0);
+        assertEquals(21, range.getMaxDouble(false), 0);
     }
 
     /**



Mime
View raw message