sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1592952 - in /sis/branches/JDK8: core/sis-feature/src/main/java/org/apache/sis/feature/ core/sis-feature/src/test/java/org/apache/sis/feature/ storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/
Date Wed, 07 May 2014 09:45:52 GMT
Author: desruisseaux
Date: Wed May  7 09:45:52 2014
New Revision: 1592952

URL: http://svn.apache.org/r1592952
Log:
Replaced the 'NumberRange<Integer>' cardinality by a pair of minimum/maximumOccurs as
int.
This is an anticipation for the GeoAPI interface which would not know about the Range type,
and also for performance reason since the maximumOccurs appear to be requested often.

Modified:
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonValue.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java
    sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java
    sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
    sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonValueTest.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java?rev=1592952&r1=1592951&r2=1592952&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
[UTF-8] Wed May  7 09:45:52 2014
@@ -19,7 +19,6 @@ package org.apache.sis.feature;
 import java.io.Serializable;
 import org.apache.sis.util.Debug;
 import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.util.resources.Errors;
 
 // Related to JDK7
 import java.util.Objects;
@@ -126,14 +125,7 @@ public class DefaultAttribute<T> impleme
      * @see DefaultFeature#validate()
      */
     public void validate() {
-        /*
-         * In theory, the following check is useless since the type was constrained by the
setValue(T) method signature.
-         * However in practice the call to setValue(…) is sometime done after type erasure,
so we are better to check.
-         */
-        if (value != null && !type.getValueClass().isInstance(value)) {
-            throw new RuntimeException( // TODO: IllegalAttributeException, pending GeoAPI
revision.
-                    Errors.format(Errors.Keys.IllegalPropertyClass_2, type.getName(), value.getClass()));
-        }
+        Validator.ensureValidValue(type, value);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java?rev=1592952&r1=1592951&r2=1592952&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
[UTF-8] Wed May  7 09:45:52 2014
@@ -23,7 +23,6 @@ import org.apache.sis.util.Debug;
 import org.apache.sis.util.Classes;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.Numerics;
-import org.apache.sis.measure.NumberRange;
 
 import static org.apache.sis.util.ArgumentChecks.*;
 
@@ -43,8 +42,8 @@ import java.util.Objects;
  *
  * <div class="warning"><b>Warning:</b>
  * This class is expected to implement a GeoAPI {@code AttributeType} interface in a future
version.
- * When such interface will be available, most references to {@code DefaultAttributeType}
in the API
- * will be replaced by references to the {@code AttributeType} interface.</div>
+ * When such interface will be available, most references to {@code DefaultAttributeType}
in current
+ * API will be replaced by references to the {@code AttributeType} interface.</div>
  *
  * {@section Value type}
  * Attributes can be used for both spatial and non-spatial properties.
@@ -60,7 +59,7 @@ import java.util.Objects;
  *
  * {@section Immutability and thread safety}
  * Instances of this class are immutable if all properties ({@link GenericName} and {@link
InternationalString}
- * instances) and all arguments (default value, cardinality) given to the constructor are
also immutable.
+ * instances) and all arguments (e.g. {@code defaultValue}) given to the constructor are
also immutable.
  * Such immutable instances can be shared by many objects and passed between threads without
synchronization.
  *
  * <p>In particular, the {@link #getDefaultValue()} method does <strong>not</strong>
clone the returned value.
@@ -89,6 +88,17 @@ public class DefaultAttributeType<T> ext
     private final Class<T> valueClass;
 
     /**
+     * The minimum number of occurrences of the property within its containing entity.
+     */
+    private final int minimumOccurs;
+
+    /**
+     * The maximum number of occurrences of the property within its containing entity,
+     * or {@link Integer#MAX_VALUE} if there is no limit.
+     */
+    private final int maximumOccurs;
+
+    /**
      * The default value for the attribute, or {@code null} if none.
      *
      * @see #getDefaultValue()
@@ -96,11 +106,6 @@ public class DefaultAttributeType<T> ext
     private final T defaultValue;
 
     /**
-     * The minimum/maximum number of occurrences of the property within its containing entity.
-     */
-    private final NumberRange<Integer> cardinality;
-
-    /**
      * Constructs an attribute type from the given properties. The properties map is given
unchanged to
      * the {@linkplain AbstractIdentifiedType#AbstractIdentifiedType(Map) super-class constructor}.
      * The following table is a reminder of main (not all) properties:
@@ -136,28 +141,25 @@ public class DefaultAttributeType<T> ext
      *
      * @param properties    The name and other properties to be given to this attribute type.
      * @param valueClass    The type of attribute values.
+     * @param minimumOccurs The minimum number of occurrences of the property within its
containing entity.
+     * @param maximumOccurs The maximum number of occurrences of the property within its
containing entity,
+     *                      or {@link Integer#MAX_VALUE} if there is no restriction.
      * @param defaultValue  The default value for the attribute, or {@code null} if none.
-     * @param cardinality   The minimum and maximum number of occurrences of the property
within its containing entity,
-     *                      or {@code null} if there is no restriction.
      */
-    public DefaultAttributeType(final Map<String,?> properties, final Class<T>
valueClass, final T defaultValue,
-            NumberRange<Integer> cardinality)
+    public DefaultAttributeType(final Map<String,?> properties, final Class<T>
valueClass,
+            final int minimumOccurs, final int maximumOccurs, final T defaultValue)
     {
         super(properties);
         ensureNonNull("valueClass",   valueClass);
         ensureCanCast("defaultValue", valueClass, defaultValue);
-        if (cardinality == null) {
-            cardinality = NumberRange.createLeftBounded(0, true);
-        } else {
-            final Integer minValue = cardinality.getMinValue();
-            if (minValue == null || minValue < 0) {
-                throw new IllegalArgumentException(Errors.format(
-                        Errors.Keys.IllegalArgumentValue_2, "cardinality", cardinality));
-            }
+        if (minimumOccurs < 0 || maximumOccurs < minimumOccurs) {
+            throw new IllegalArgumentException(Errors.format(
+                    Errors.Keys.IllegalRange_2, minimumOccurs, maximumOccurs));
         }
-        this.valueClass   = valueClass;
-        this.defaultValue = Numerics.cached(defaultValue);
-        this.cardinality  = cardinality;
+        this.valueClass    = valueClass;
+        this.minimumOccurs = minimumOccurs;
+        this.maximumOccurs = maximumOccurs;
+        this.defaultValue  = Numerics.cached(defaultValue);
     }
 
     /**
@@ -169,16 +171,6 @@ public class DefaultAttributeType<T> ext
         return valueClass;
     }
 
-    /**
-     * Returns the default value for the attribute.
-     * This value is used when an attribute is created and no value for it is specified.
-     *
-     * @return The default value for the attribute, or {@code null} if none.
-     */
-    public T getDefaultValue() {
-        return defaultValue;
-    }
-
     /*
      * ISO 19109 properties omitted for now:
      *
@@ -192,14 +184,35 @@ public class DefaultAttributeType<T> ext
      */
 
     /**
-     * Returns the minimum and maximum number of occurrences of the property within its containing
entity.
-     * The bounds are always integer values greater than or equal to zero. The upper bounds
may be {@code null}
-     * if there is no maximum number of occurrences.
+     * Returns the minimum number of occurrences of the property within its containing entity.
+     * The returned value is greater than or equal to zero.
      *
-     * @return The minimum and maximum number of occurrences of the property within its containing
entity.
+     * @return The minimum number of occurrences of the property within its containing entity.
      */
-    public NumberRange<Integer> getCardinality() {
-        return cardinality;
+    public int getMinimumOccurs() {
+        return minimumOccurs;
+    }
+
+    /**
+     * Returns the maximum number of occurrences of the property within its containing entity.
+     * The returned value is greater than or equal to the {@link #getMinimumOccurs()} value.
+     * If there is no maximum, then this method returns {@link Integer#MAX_VALUE}.
+     *
+     * @return The maximum number of occurrences of the property within its containing entity,
+     *         or {@link Integer#MAX_VALUE} if none.
+     */
+    public int getMaximumOccurs() {
+        return maximumOccurs;
+    }
+
+    /**
+     * Returns the default value for the attribute.
+     * This value is used when an attribute is created and no value for it is specified.
+     *
+     * @return The default value for the attribute, or {@code null} if none.
+     */
+    public T getDefaultValue() {
+        return defaultValue;
     }
 
     /**
@@ -209,7 +222,8 @@ public class DefaultAttributeType<T> ext
      */
     @Override
     public int hashCode() {
-        return super.hashCode() + valueClass.hashCode() + Objects.hashCode(defaultValue)
+ 31*cardinality.hashCode();
+        return super.hashCode() + valueClass.hashCode() + 37*(minimumOccurs ^ maximumOccurs)
+
+               Objects.hashCode(defaultValue);
     }
 
     /**
@@ -224,9 +238,10 @@ public class DefaultAttributeType<T> ext
         }
         if (super.equals(obj)) {
             final DefaultAttributeType<?> that = (DefaultAttributeType<?>) obj;
-            return valueClass == that.valueClass &&
-                   Objects.equals(defaultValue, that.defaultValue) &&
-                   cardinality.equals(that.cardinality);
+            return valueClass    == that.valueClass    &&
+                   minimumOccurs == that.minimumOccurs &&
+                   maximumOccurs == that.maximumOccurs &&
+                   Objects.equals(defaultValue, that.defaultValue);
         }
         return false;
     }

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java?rev=1592952&r1=1592951&r2=1592952&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
[UTF-8] Wed May  7 09:45:52 2014
@@ -25,7 +25,6 @@ import org.apache.sis.util.Debug;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.collection.Containers;
-import org.apache.sis.measure.NumberRange;
 
 // Related to JDK7
 import java.util.Objects;
@@ -93,18 +92,6 @@ public class DefaultFeature implements S
     }
 
     /**
-     * Returns {@code true} if the given cardinality is for a singleton property.
-     */
-    private static boolean isSingleton(final NumberRange<Integer> cardinality) {
-        switch (cardinality.getMaxValue()) {
-            case 0:
-            case 1:  return true;
-            case 2:  return !cardinality.isMaxIncluded();
-            default: return false;
-        }
-    }
-
-    /**
      * Returns all properties (attributes, operations or associations) of the given name.
      * The returned list is <em>live</em>: change in that list will be immediately
reflected
      * in this {@code DefaultFeature}, and conversely.
@@ -128,7 +115,7 @@ public class DefaultFeature implements S
          * amount of features), we will not store the list in this DefaultFeature. Instead,
we use
          * a temporary object which will read and write the Attribute instance directly in
the map.
          */
-        if (isSingleton(at.getCardinality())) {
+        if (at.getMaximumOccurs() <= 1) {
             return new SingletonValue(at, properties, name);
         }
         /*
@@ -173,7 +160,7 @@ public class DefaultFeature implements S
             if (at == null) {
                 throw new IllegalArgumentException(propertyNotFound(name));
             }
-            if (isSingleton(at.getCardinality())) {
+            if (at.getMaximumOccurs() <= 1) {
                 return at.getDefaultValue();
             }
             // TODO

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonValue.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonValue.java?rev=1592952&r1=1592951&r2=1592952&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonValue.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonValue.java
[UTF-8] Wed May  7 09:45:52 2014
@@ -50,7 +50,7 @@ final class SingletonValue extends Abstr
     private static final DefaultAttribute<?>[] EMPTY = new DefaultAttribute<?>[0];
 
     /**
-     * The type of property elements in the list.
+     * The type of the property element in this list.
      */
     private final AbstractIdentifiedType type;
 

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java?rev=1592952&r1=1592951&r2=1592952&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
[UTF-8] Wed May  7 09:45:52 2014
@@ -44,4 +44,22 @@ final class Validator {
             throw new RuntimeException(Errors.format(Errors.Keys.MismatchedPropertyType_1,
type.getName()));
         }
     }
+
+    /**
+     * Ensures that the given value is valid for the given attribute type.
+     */
+    static void ensureValidValue(final DefaultAttributeType<?> type, final Object value)
{
+        if (value == null) {
+            return;
+        }
+        /*
+         * In theory, the following check is unnecessary since the type was constrained by
the Attribute.setValue(T)
+         * method signature. However in practice the call to Attribute.setValue(…) is sometime
done after type erasure,
+         * so we are better to check.
+         */
+        if (!type.getValueClass().isInstance(value)) {
+            throw new RuntimeException( // TODO: IllegalAttributeException, pending GeoAPI
revision.
+                    Errors.format(Errors.Keys.IllegalPropertyClass_2, type.getName(), value.getClass()));
+        }
+    }
 }

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java?rev=1592952&r1=1592951&r2=1592952&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java
[UTF-8] Wed May  7 09:45:52 2014
@@ -23,24 +23,26 @@
  * <ul>
  *   <li>{@linkplain org.apache.sis.feature.DefaultFeatureType Feature types} define
the <em>structure</em> of
  *       real-world representations. A feature type lists the attributes, operations, or
associations to other
- *       features (collectively called “properties”) that a feature can have.
- *
- *       <div class="note"><b>Note:</b> a {@code FeatureType} in a Spatial
Information System is equivalent to a
- *       {@link java.lang.Class} in the Java language. By extension, {@code AttributeType}
and {@code OperationType}
- *       are equivalent to {@link java.lang.reflect.Field} and {@link java.lang.reflect.Method}
respectively.</div></li>
+ *       features (collectively called “properties”) that a feature can have.</li>
  *
  *   <li>{@linkplain org.apache.sis.feature.DefaultFeature Feature instances} (often
called only {@code Feature}s)
- *       hold the <em>content</em> (or values) that describe one specific real-world
object.
- *
- *       <div class="note"><b>Example:</b> the “Eiffel tower” is a
feature <em>instance</em> belonging
- *       to the “Tower” feature <em>type</em>.</div></li>
+ *       hold the <em>content</em> (or values) that describe one specific real-world
object.</li>
  * </ul>
  *
+ * <div class="note"><b>Note:</b> a {@code FeatureType} in a Spatial Information
System is equivalent to a
+ * {@link java.lang.Class} in the Java language, while a {@code Feature} instance is equivalent
to a Java
+ * {@link java.lang.Object} of that class. By extension, {@code AttributeType} and {@code
Operation} are
+ * equivalent to {@link java.lang.reflect.Field} and {@link java.lang.reflect.Method} respectively.</div>
+ *
+ * <div class="note"><b>Example:</b> the “Eiffel tower” is a feature
<em>instance</em> belonging
+ * to the “Tower” feature <em>type</em>.</div>
+ *
  * {@section Class hierarchy}
- * The class hierarchy for features <cite>types</cite> and <cite>instances</cite>
are closely related:
+ * The class hierarchy for feature <cite>types</cite> is derived from ISO 19109
specification.
+ * The class hierarchy for feature <cite>instances</cite> is closely related:
  *
  * <table class="sis">
- * <caption>Class hierarchy</caption>
+ * <caption>Feature class hierarchy</caption>
  * <tr>
  *   <th>Types</th>
  *   <th class="sep">Instances</th>

Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java?rev=1592952&r1=1592951&r2=1592952&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java
[UTF-8] Wed May  7 09:45:52 2014
@@ -22,7 +22,6 @@ import java.util.Locale;
 import org.opengis.util.LocalName;
 import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
-import org.apache.sis.measure.NumberRange;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -54,7 +53,7 @@ public final strictfp class DefaultAttri
         assertNull(properties.put(DefaultAttributeType.DEFINITION_KEY  + "_ja", "都市の名前。"));
         assertNull(properties.put(DefaultAttributeType.DESCRIPTION_KEY, "Some verbose description."));
         final DefaultAttributeType<String> city = new DefaultAttributeType<>(properties,
-                String.class, "Utopia", NumberRange.create(1, true, 1, true));
+                String.class, 1, 1, "Utopia");
         properties.clear();
         return city;
     }
@@ -67,7 +66,7 @@ public final strictfp class DefaultAttri
     static DefaultAttributeType<Integer> population(final Map<String,Object>
properties) {
         assertNull(properties.put(DefaultAttributeType.NAME_KEY, "population"));
         final DefaultAttributeType<Integer> population = new DefaultAttributeType<>(
-                properties, Integer.class, null, NumberRange.create(1, true, 1, true));
+                properties, Integer.class, 1, 1, null);
         properties.clear();
         return population;
     }
@@ -98,10 +97,8 @@ public final strictfp class DefaultAttri
         assertEquals("valueClass",   String.class, city.getValueClass());
         assertEquals("defaultValue", "Utopia",     city.getDefaultValue());
 
-        final NumberRange<Integer> cardinality = city.getCardinality();
-        assertNotNull("cardinality", cardinality);
-        assertEquals("cardinality.minValue", Integer.valueOf(1), cardinality.getMinValue());
-        assertEquals("cardinality.maxValue", Integer.valueOf(1), cardinality.getMaxValue());
+        assertEquals("minimumOccurs", 1, city.getMinimumOccurs());
+        assertEquals("axnimumOccurs", 1, city.getMaximumOccurs());
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java?rev=1592952&r1=1592951&r2=1592952&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
[UTF-8] Wed May  7 09:45:52 2014
@@ -80,13 +80,12 @@ public final strictfp class DefaultFeatu
     @Test
     @DependsOnMethod("testSimple")
     public void testNameCollision() {
-        final NumberRange<Integer> cardinality = NumberRange.create(1, true, 1, true);
         final DefaultAttributeType<String> city = new DefaultAttributeType<>(
-                singletonMap(DefaultAttributeType.NAME_KEY, "city"), String.class, null,
cardinality);
+                singletonMap(DefaultAttributeType.NAME_KEY, "city"), String.class, 1, 1,
null);
         final DefaultAttributeType<Integer> cityId = new DefaultAttributeType<>(
-                singletonMap(DefaultAttributeType.NAME_KEY, "city"), Integer.class, null,
cardinality);
+                singletonMap(DefaultAttributeType.NAME_KEY, "city"), Integer.class, 1, 1,
null);
         final DefaultAttributeType<Integer> population = new DefaultAttributeType<>(
-                singletonMap(DefaultAttributeType.NAME_KEY, "population"), Integer.class,
null, cardinality);
+                singletonMap(DefaultAttributeType.NAME_KEY, "population"), Integer.class,
1, 1, null);
 
         final Map<String,String> properties = singletonMap(DefaultAttributeType.NAME_KEY,
"City population");
         try {

Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonValueTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonValueTest.java?rev=1592952&r1=1592951&r2=1592952&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonValueTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonValueTest.java
[UTF-8] Wed May  7 09:45:52 2014
@@ -19,7 +19,6 @@ package org.apache.sis.feature;
 import java.util.Set;
 import java.util.Map;
 import java.util.HashMap;
-import org.apache.sis.measure.NumberRange;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -73,7 +72,7 @@ public final strictfp class SingletonVal
         otherValues   = singletonMap("other key", "other value");
         properties    = new HashMap<>(otherValues);
         attributeType = new DefaultAttributeType<>(singletonMap(DefaultAttributeType.NAME_KEY,
KEY),
-                                Integer.class, null, NumberRange.create(0, true, 1, true));
+                                Integer.class, 0, 1, null);
         singleton = new SingletonValue(attributeType, properties, KEY);
     }
 

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java?rev=1592952&r1=1592951&r2=1592952&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
[UTF-8] Wed May  7 09:45:52 2014
@@ -29,7 +29,6 @@ import com.esri.core.geometry.Polygon;
 import com.esri.core.geometry.Polyline;
 import com.esri.core.geometry.Geometry;
 
-import org.apache.sis.measure.NumberRange;
 import org.apache.sis.feature.DefaultFeature;
 import org.apache.sis.feature.DefaultFeatureType;
 import org.apache.sis.feature.DefaultAttributeType;
@@ -259,14 +258,13 @@ public class ShapeFile {
     private DefaultFeatureType getFeatureType(final String name) {
         final int n = FDArray.size();
         final DefaultAttributeType<?>[] attributes = new DefaultAttributeType<?>[n
+ 1];
-        final NumberRange<Integer> cardinality = NumberRange.create(1, true, 1, true);
         final Map<String,Object> properties = new HashMap<>(4);
         for (int i=0; i<n; i++) {
             properties.put(DefaultAttributeType.NAME_KEY, FDArray.get(i).getName());
-            attributes[i] = new DefaultAttributeType<>(properties, String.class, null,
cardinality);
+            attributes[i] = new DefaultAttributeType<>(properties, String.class, 1,
1, null);
         }
         properties.put(DefaultAttributeType.NAME_KEY, GEOMETRY_NAME);
-        attributes[n] = new DefaultAttributeType<>(properties, Geometry.class, null,
cardinality);
+        attributes[n] = new DefaultAttributeType<>(properties, Geometry.class, 1, 1,
null);
         properties.put(DefaultAttributeType.NAME_KEY, name);
         return new DefaultFeatureType(properties, false, null, attributes);
     }



Mime
View raw message