You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2014/05/21 22:11:07 UTC
svn commit: r1596668 - in /sis/trunk: ./
core/sis-feature/src/main/java/org/apache/sis/feature/
core/sis-feature/src/test/java/org/apache/sis/feature/
core/sis-feature/src/test/java/org/apache/sis/test/suite/
core/sis-referencing/src/main/java/org/apac...
Author: desruisseaux
Date: Wed May 21 20:11:06 2014
New Revision: 1596668
URL: http://svn.apache.org/r1596668
Log:
Merge from the JDK6 branch. The merge contains the split of DefaultFeature in two classes: DenseFeature and SparseFeature.
Added:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java (props changed)
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java (props changed)
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java (props changed)
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/CustomAttribute.java
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/CustomAttribute.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DenseFeatureTest.java
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/DenseFeatureTest.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureFormatTest.java
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureFormatTest.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureTestCase.java
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/FeatureTestCase.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/FeaturesTest.java
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/FeaturesTest.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/SparseFeatureTest.java
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/SparseFeatureTest.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/CorruptedObjectException.java
- copied unchanged from r1596667, sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/CorruptedObjectException.java
Removed:
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeature.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTest.java
Modified:
sis/trunk/ (props changed)
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FieldType.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAssociationTest.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTest.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
sis/trunk/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
sis/trunk/pom.xml
sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
Propchange: sis/trunk/
------------------------------------------------------------------------------
Merged /sis/branches/JDK8:r1595030-1596663
Merged /sis/branches/JDK7:r1595038-1596665
Merged /sis/branches/JDK6:r1595040-1596667
Propchange: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed May 21 20:11:06 2014
@@ -0,0 +1,8 @@
+/sis/branches/Android/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java:1430670-1480699
+/sis/branches/Android/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/Feature.java:1430670-1480699
+/sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java:1394364-1595039,1596667
+/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/Feature.java:1394364-1493762
+/sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java:1394913-1596665
+/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/Feature.java:1394913-1493760
+/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java:1584960-1596663
+/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java:1394364-1508466,1519089-1519674
Propchange: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java [UTF-8] Wed May 21 20:11:06 2014
@@ -55,7 +55,7 @@ public class DefaultAssociation extends
/**
* The associated feature.
*/
- private DefaultFeature value;
+ private AbstractFeature value;
/**
* Creates a new association of the given type.
@@ -73,10 +73,13 @@ public class DefaultAssociation extends
* @param role Information about the association.
* @param value The initial value.
*/
- public DefaultAssociation(final DefaultAssociationRole role, final DefaultFeature value) {
+ public DefaultAssociation(final DefaultAssociationRole role, final AbstractFeature value) {
ArgumentChecks.ensureNonNull("role", role);
this.role = role;
this.value = value;
+ if (value != null) {
+ ensureValid(role.getValueType(), value.getType());
+ }
}
/**
@@ -110,9 +113,9 @@ public class DefaultAssociation extends
*
* @return The associated feature (may be {@code null}).
*
- * @see DefaultFeature#getPropertyValue(String)
+ * @see AbstractFeature#getPropertyValue(String)
*/
- public DefaultFeature getValue() {
+ public AbstractFeature getValue() {
return value;
}
@@ -126,30 +129,37 @@ public class DefaultAssociation extends
* The amount of validation performed by this method is implementation dependent.
* Usually, only the most basic constraints are verified. This is so for performance reasons
* and also because some rules may be temporarily broken while constructing a feature.
- * A more exhaustive verification can be performed by invoking the {@link #validate()} method.
+ * A more exhaustive verification can be performed by invoking the {@link #quality()} method.
*
* @param value The new value, or {@code null}.
* @throws IllegalArgumentException If the given feature is not valid for this association.
*
- * @see DefaultFeature#setPropertyValue(String, Object)
+ * @see AbstractFeature#setPropertyValue(String, Object)
*/
- public void setValue(final DefaultFeature value) {
+ public void setValue(final AbstractFeature value) {
if (value != null) {
- final DefaultFeatureType base = role.getValueType();
- final DefaultFeatureType type = value.getType();
- if (base != type && !base.maybeAssignableFrom(type)) {
- throw new IllegalArgumentException(
- Errors.format(Errors.Keys.IllegalArgumentClass_3, getName(), base.getName(), type.getName()));
- }
+ ensureValid(role.getValueType(), value.getType());
}
this.value = value;
}
/**
+ * Ensures that storing a feature of the given type is valid for an association
+ * expecting the given base type.
+ */
+ private void ensureValid(final DefaultFeatureType base, final DefaultFeatureType type) {
+ if (base != type && !base.maybeAssignableFrom(type)) {
+ throw new IllegalArgumentException(
+ Errors.format(Errors.Keys.IllegalArgumentClass_3, getName(), base.getName(), type.getName()));
+ }
+ }
+
+ /**
* Verifies if the current association value mets the constraints defined by the association role.
- * This method returns {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports()
- * reports} for all constraint violations found, if any.
- * See {@link DefaultAttribute#validate()} for an example.
+ * This method returns at most one {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports()
+ * report} with a {@linkplain org.apache.sis.metadata.iso.quality.DefaultDomainConsistency#getResults() result} for
+ * each constraint violations found, if any.
+ * See {@link DefaultAttribute#quality()} for an example.
*
* <p>This association is valid if this method does not report any
* {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult conformance result} having a
@@ -157,33 +167,27 @@ public class DefaultAssociation extends
*
* @return Reports on all constraint violations found.
*
- * @see DefaultFeature#validate()
+ * @see AbstractFeature#quality()
*/
- /*
- * API NOTE: this method is final for now because if we allowed users to override it, users would
- * expect their method to be invoked by DefaultFeature.validate(). But this is not yet the case.
- */
- public final DataQuality validate() {
+ public DataQuality quality() {
final Validator v = new Validator(null);
v.validate(role, value);
return v.quality;
}
/**
- * Returns a shallow copy of this association.
- * The association {@linkplain #getValue() value} is <strong>not</strong> cloned.
+ * Returns a copy of this association.
+ * The default implementation returns a <em>shallow</em> copy:
+ * the association {@linkplain #getValue() value} is <strong>not</strong> cloned.
+ * However subclasses may choose to do otherwise.
*
* @return A clone of this association.
+ * @throws CloneNotSupportedException if this association can not be cloned.
+ * The default implementation never throw this exception. However subclasses may throw it.
*/
@Override
- public DefaultAssociation clone() {
- final DefaultAssociation clone;
- try {
- clone = (DefaultAssociation) super.clone();
- } catch (CloneNotSupportedException e) {
- throw new AssertionError(e); // Should never happen since we are cloneable.
- }
- return clone;
+ public DefaultAssociation clone() throws CloneNotSupportedException {
+ return (DefaultAssociation) super.clone();
}
/**
@@ -223,7 +227,7 @@ public class DefaultAssociation extends
@Debug
@Override
public String toString() {
- final StringBuilder buffer = role.toString("FeatureAssociation", role.getValueType().getName().toString());
+ final StringBuilder buffer = role.toString("FeatureAssociation", role.getValueType().getName());
if (value != null) {
final String pt = role.getTitleProperty();
if (pt != null) {
Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java [UTF-8] Wed May 21 20:11:06 2014
@@ -31,8 +31,8 @@ import static org.apache.sis.util.Argume
* <ul>
* <li><b>Aggregation</b> represents associations between features which can exist even if the aggregate is destroyed.</li>
* <li><b>Composition</b> represents relationships where the owned features are destroyed together with the composite.</li>
- * <li><b>Spatial</b> represents spatial or topological relationships that may exist between features (e.g. “east of”).</li>
- * <li><b>Temporal</b> may represent for example a sequence of changes over time involving the replacement of some
+ * <li><b>Spatial</b> association represents spatial or topological relationships that may exist between features (e.g. “<cite>east of</cite>”).</li>
+ * <li><b>Temporal</b> association may represent for example a sequence of changes over time involving the replacement of some
* feature instances by other feature instances.</li>
* </ul>
*
@@ -212,6 +212,6 @@ public class DefaultAssociationRole exte
@Debug
@Override
public String toString() {
- return toString("FeatureAssociationRole", valueType.getName().toString()).toString();
+ return toString("FeatureAssociationRole", valueType.getName()).toString();
}
}
Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java [UTF-8] Wed May 21 20:11:06 2014
@@ -121,7 +121,7 @@ public class DefaultAttribute<T> extends
*
* @return The attribute value (may be {@code null}).
*
- * @see DefaultFeature#getPropertyValue(String)
+ * @see AbstractFeature#getPropertyValue(String)
*/
public T getValue() {
return value;
@@ -134,23 +134,64 @@ public class DefaultAttribute<T> extends
* The amount of validation performed by this method is implementation dependent.
* Usually, only the most basic constraints are verified. This is so for performance reasons
* and also because some rules may be temporarily broken while constructing a feature.
- * A more exhaustive verification can be performed by invoking the {@link #validate()} method.
+ * A more exhaustive verification can be performed by invoking the {@link #quality()} method.
*
* @param value The new value.
*
- * @see DefaultFeature#setPropertyValue(String, Object)
+ * @see AbstractFeature#setPropertyValue(String, Object)
*/
public void setValue(final T value) {
this.value = value;
}
/**
- * Verifies if the current attribute value mets the constraints defined by the attribute type.
- * This method returns {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports()
- * reports} for all constraint violations found, if any.
+ * Evaluates the quality of this attribute at this method invocation time. The data quality reports
+ * may include information about whether the attribute value mets the constraints defined by the
+ * {@linkplain DefaultAttributeType attribute type}, or any other criterion at implementation choice.
+ *
+ * <p>The default implementation reports data quality with at least the following information:</p>
+ * <ul>
+ * <li>
+ * The {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getScope() scope}
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultScope#getLevel() level} is set to
+ * {@link org.opengis.metadata.maintenance.ScopeCode#ATTRIBUTE}.
+ * </li><li>
+ * At most one {@linkplain org.apache.sis.metadata.iso.quality.DefaultDomainConsistency domain consistency}
+ * element is added to the {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports()
+ * reports} list (implementations are free to omit that element if they have nothing to report).
+ * If a report is provided, then it will contain at least the following information:
+ * <ul>
+ * <li>
+ * The {@linkplain #getName() attribute name} as the data quality
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultDomainConsistency#getMeasureIdentification()
+ * measure identification}.
+ *
+ * <div class="note"><b>Note:</b> strictly speaking, {@code measureIdentification} identifies the
+ * <em>quality measurement</em>, not the “real” measurement itself. However this implementation
+ * uses the same set of identifiers for both for simplicity.</div>
+ * </li><li>
+ * If the attribute {@linkplain #getValue() value} is not an {@linkplain Class#isInstance instance}
+ * of the expected {@linkplain DefaultAttributeType#getValueClass() value class}, or if the number
+ * of occurrences is not inside the cardinality range, or if any other constraint is violated, then
+ * a {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult conformance result} is
+ * added for each violation with an
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult#getExplanation() explanation}
+ * set to the error message.
+ *
+ * <div class="warning"><b>Note:</b> this is a departure from ISO intend, since {@code explanation}
+ * should be a statement about what a successful conformance means. This point may be reformulated
+ * in a future SIS version.</div>
+ * </li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * This attribute is valid if this method does not report any
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult conformance result} having a
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult#pass() pass} value of {@code false}.
*
* <div class="note"><b>Example:</b> given an attribute named “population” with [1 … 1] cardinality,
- * if no value has been assigned to that attribute, then this {@code validate()} method will return
+ * if no value has been assigned to that attribute, then this {@code quality()} method will return
* the following data quality report:
*
* {@preformat text
@@ -167,40 +208,31 @@ public class DefaultAttribute<T> extends
* }
* </div>
*
- * This attribute is valid if this method does not report any
- * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult conformance result} having a
- * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult#pass() pass} value of {@code false}.
- *
* @return Reports on all constraint violations found.
*
- * @see DefaultFeature#validate()
+ * @see AbstractFeature#quality()
*/
- /*
- * API NOTE: this method is final for now because if we allowed users to override it, users would
- * expect their method to be invoked by DefaultFeature.validate(). But this is not yet the case.
- */
- public final DataQuality validate() {
+ public DataQuality quality() {
final Validator v = new Validator(ScopeCode.ATTRIBUTE);
v.validate(type, value);
return v.quality;
}
/**
- * Returns a shallow copy of this attribute.
- * The attribute {@linkplain #getValue() value} is <strong>not</strong> cloned.
+ * Returns a copy of this attribute.
+ * The default implementation returns a <em>shallow</em> copy:
+ * the attribute {@linkplain #getValue() value} is <strong>not</strong> cloned.
+ * However subclasses may choose to do otherwise.
*
* @return A clone of this attribute.
+ * @throws CloneNotSupportedException if this attribute can not be cloned.
+ * The default implementation never throw this exception. However subclasses may throw it,
+ * for example on attempt to clone the attribute value.
*/
@Override
@SuppressWarnings("unchecked")
- public DefaultAttribute<T> clone() {
- final DefaultAttribute<T> clone;
- try {
- clone = (DefaultAttribute<T>) super.clone();
- } catch (CloneNotSupportedException e) {
- throw new AssertionError(e); // Should never happen since we are cloneable.
- }
- return clone;
+ public DefaultAttribute<T> clone() throws CloneNotSupportedException {
+ return (DefaultAttribute<T>) super.clone();
}
/**
Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java [UTF-8] Wed May 21 20:11:06 2014
@@ -39,7 +39,7 @@ import org.apache.sis.internal.util.Unmo
/**
* Abstraction of a real-world phenomena. A {@code FeatureType} instance describes the class of all
- * {@link DefaultFeature} instances of that type.
+ * {@linkplain AbstractFeature feature} instances of that type.
*
* <div class="note"><b>Note:</b>
* Compared to the Java language, {@code FeatureType} is equivalent to {@link Class} while
@@ -56,7 +56,7 @@ import org.apache.sis.internal.util.Unmo
* Names can be {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped} for avoiding name collision.
*
* {@section Properties and inheritance}
- * Each feature type can provide descriptions for the following {@link #getProperties(boolean) properties}:
+ * Each feature type can provide descriptions for the following {@linkplain #getProperties(boolean) properties}:
*
* <ul>
* <li>{@linkplain DefaultAttributeType Attributes}</li>
@@ -85,7 +85,7 @@ import org.apache.sis.internal.util.Unmo
* @version 0.5
* @module
*
- * @see DefaultFeature
+ * @see AbstractFeature
*/
public class DefaultFeatureType extends AbstractIdentifiedType {
/**
@@ -109,6 +109,12 @@ public class DefaultFeatureType extends
private transient boolean isSimple;
/**
+ * {@code true} if the feature instances are expected to have lot of unset properties, or
+ * {@code false} if we expect most properties to be specified.
+ */
+ private transient boolean isSparse;
+
+ /**
* The direct parents of this feature type, or an empty set if none.
*
* @see #getSuperTypes()
@@ -132,6 +138,14 @@ public class DefaultFeatureType extends
private final List<PropertyType> properties;
/**
+ * All properties, including the ones declared in the super-types.
+ * This is an unmodifiable view of the {@link #byName} values.
+ *
+ * @see #getProperties(boolean)
+ */
+ private transient Collection<PropertyType> allProperties;
+
+ /**
* A lookup table for fetching properties by name, including the properties from super-types.
* This map shall not be modified after construction.
*
@@ -231,26 +245,82 @@ public class DefaultFeatureType extends
*/
private void computeTransientFields() {
final int capacity = Containers.hashMapCapacity(properties.size());
- isSimple = true;
byName = new LinkedHashMap<String,PropertyType>(capacity);
- indices = new HashMap<String,Integer>(capacity);
+ indices = new LinkedHashMap<String,Integer>(capacity);
assignableTo = new HashSet<GenericName>(4);
assignableTo.add(getName());
scanPropertiesFrom(this);
- byName = CollectionsExt.unmodifiableOrCopy(byName);
- indices = CollectionsExt.unmodifiableOrCopy(indices);
- assignableTo = CollectionsExt.unmodifiableOrCopy(assignableTo);
+ byName = compact(byName);
+ assignableTo = CollectionsExt.unmodifiableOrCopy(assignableTo);
+ allProperties = byName.values();
+ if (byName instanceof HashMap<?,?>) {
+ allProperties = Collections.unmodifiableCollection(allProperties);
+ }
+ /*
+ * Now check if the feature is simple/complex or dense/sparse. We perform this check after we finished
+ * to create the list of all properties, because some properties may be overridden and we want to take
+ * in account only the most specific ones.
+ */
+ isSimple = true;
+ int mandatory = 0; // Count of mandatory properties.
+ for (final Map.Entry<String,PropertyType> entry : byName.entrySet()) {
+ final int minimumOccurs, maximumOccurs;
+ final PropertyType property = entry.getValue();
+ if (property instanceof DefaultAttributeType<?>) { // TODO: check for AttributeType instead (after GeoAPI upgrade).
+ minimumOccurs = ((DefaultAttributeType<?>) property).getMinimumOccurs();
+ maximumOccurs = ((DefaultAttributeType<?>) property).getMaximumOccurs();
+ isSimple &= (minimumOccurs == maximumOccurs);
+ } else if (property instanceof FieldType) { // TODO: check for AssociationRole instead (after GeoAPI upgrade).
+ minimumOccurs = ((FieldType) property).getMinimumOccurs();
+ maximumOccurs = ((FieldType) property).getMaximumOccurs();
+ isSimple = false;
+ } else {
+ continue; // For feature operations, maximumOccurs is implicitly 0.
+ }
+ if (maximumOccurs != 0) {
+ isSimple &= (maximumOccurs == 1);
+ indices.put(entry.getKey(), indices.size());
+ if (minimumOccurs != 0) {
+ mandatory++;
+ }
+ }
+ }
+ indices = compact(indices);
+ /*
+ * Rational for choosing whether the feature is sparse: By default, java.util.HashMap implementation creates
+ * an internal array of length 16 (see HashMap.DEFAULT_INITIAL_CAPACITY). In addition, the HashMap instance
+ * itself consumes approximatively 8 "words" in memory. Consequently there is no advantage in using HashMap
+ * unless the number of properties is greater than 16 + 8 (note: we could specify a smaller initial capacity,
+ * but the memory consumed by each internal Map.Entry quickly exceed the few saved words). Next, the default
+ * HashMap threshold is 0.75, so there is again no advantage in using HashMap if we do not expect at least 25%
+ * of unused properties. Our current implementation arbitrarily sets the threshold to 50%.
+ */
+ final int n = indices.size();
+ isSparse = (n > 24) && (mandatory <= n/2);
+ }
+
+ /**
+ * Returns a more compact representation of the given map. This method is similar to
+ * {@link CollectionsExt#unmodifiableOrCopy(Map)}, except that it does not wrap the
+ * map in an unmodifiable view. The intend is to avoid one level of indirection for
+ * performance and memory reasons (keeping in mind that we will have lot of features).
+ * This is okay if we guaranteed that the map does not escape outside this class.
+ */
+ private static <K,V> Map<K,V> compact(final Map<K,V> map) {
+ switch (map.size()) {
+ case 0: return Collections.emptyMap();
+ case 1: final Map.Entry<K,V> entry = map.entrySet().iterator().next();
+ return Collections.singletonMap(entry.getKey(), entry.getValue());
+ default: return map;
+ }
}
/**
- * Computes the transient fields using the non-transient information in the given {@code source}.
+ * Fills the {@link #byName} map using the non-transient information in the given {@code source}.
* This method invokes itself recursively in order to use the information provided in super-types.
+ * This method also performs an opportunist verification of argument validity.
*/
private void scanPropertiesFrom(final DefaultFeatureType source) {
- /*
- * Process all super-types before to process the given type. The intend is to have the
- * super-types properties indexed before the sub-types ones in the 'indices' map.
- */
for (final DefaultFeatureType parent : source.getSuperTypes()) {
if (assignableTo.add(parent.getName())) {
scanPropertiesFrom(parent);
@@ -260,9 +330,6 @@ public class DefaultFeatureType extends
Map<DefaultFeatureType,Boolean> done = null;
for (final PropertyType property : source.properties) {
ArgumentChecks.ensureNonNullElement("properties", ++index, property);
- /*
- * Fill the (name, property) map with opportunist verification of argument validity.
- */
final String name = toString(property.getName(), source, index);
final PropertyType previous = byName.put(name, property);
if (previous != null) {
@@ -276,26 +343,6 @@ public class DefaultFeatureType extends
}
done.clear();
}
- /*
- * Fill the (name, indice) map. Values are indices that the property elements would have
- * in a flat array. This block also opportunistically check if the FeatureType is "simple".
- */
- final int maximumOccurs;
- if (property instanceof DefaultAttributeType<?>) { // TODO: check for AttributeType instead (after GeoAPI upgrade).
- maximumOccurs = ((DefaultAttributeType<?>) property).getMaximumOccurs();
- if (isSimple && ((DefaultAttributeType<?>) property).getMinimumOccurs() != maximumOccurs) {
- isSimple = false;
- }
- } else if (property instanceof FieldType) { // TODO: check for AssociationRole instead (after GeoAPI upgrade).
- maximumOccurs = ((FieldType) property).getMaximumOccurs();
- isSimple = false;
- } else {
- continue; // For feature operations, maximumOccurs is implicitly 0.
- }
- if (maximumOccurs != 0) {
- isSimple &= (maximumOccurs == 1);
- indices.put(name, indices.size());
- }
}
}
@@ -356,6 +403,14 @@ public class DefaultFeatureType extends
}
/**
+ * Returns {@code true} if the feature instances are expected to have lot of unset properties,
+ * or {@code false} if we expect most properties to be specified.
+ */
+ final boolean isSparse() {
+ return isSparse;
+ }
+
+ /**
* Returns {@code true} if this feature type contains only attributes constrained to the [1 … 1] cardinality,
* or operations. Such feature types can be handled as a {@link org.opengis.util.Record}s.
*
@@ -490,7 +545,7 @@ public class DefaultFeatureType extends
*/
public Collection<AbstractIdentifiedType> getProperties(final boolean includeSuperTypes) {
// TODO: temporary cast to be removed after we upgraded GeoAPI.
- return (Collection) (includeSuperTypes ? byName.values() : properties);
+ return (Collection) (includeSuperTypes ? allProperties : properties);
}
/**
@@ -504,11 +559,20 @@ public class DefaultFeatureType extends
}
/**
- * Returns the number of attributes and features (not operations) that instance will have
- * if all attributes are handled as simple attributes (maximum occurrences of 1).
+ * Returns the map from names to indices in an array of properties.
+ * This is used for {@link DenseFeature} implementation.
+ */
+ final Map<String,Integer> indices() {
+ return indices;
+ }
+
+ /**
+ * Creates a new feature instance of this type.
+ *
+ * @return A new feature instance.
*/
- final int getInstanceSize() {
- return indices.size();
+ public AbstractFeature newInstance() {
+ return isSparse ? new SparseFeature(this) : new DenseFeature(this);
}
/**
@@ -539,4 +603,16 @@ public class DefaultFeatureType extends
}
return false;
}
+
+ /**
+ * Formats this feature in a tabular format.
+ *
+ * @return A string representation of this feature in a tabular format.
+ *
+ * @see FeatureFormat
+ */
+ @Override
+ public String toString() {
+ return FeatureFormat.sharedFormat(this);
+ }
}
Propchange: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed May 21 20:11:06 2014
@@ -0,0 +1,8 @@
+/sis/branches/Android/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java:1430670-1480699
+/sis/branches/Android/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/Feature.java:1430670-1480699
+/sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java:1394364-1595039,1596667
+/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/Feature.java:1394364-1493762
+/sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java:1394913-1596665
+/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/Feature.java:1394913-1493760
+/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java:1584960-1596663
+/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java:1394364-1508466,1519089-1519674
Propchange: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FieldType.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FieldType.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FieldType.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/FieldType.java [UTF-8] Wed May 21 20:11:06 2014
@@ -116,7 +116,7 @@ abstract class FieldType extends Propert
/**
* Implementation of {@link #toString()} to be shared by subclasses and {@link DefaultAttribute#toString()}.
*/
- final StringBuilder toString(final String typeName, final String valueName) {
+ final StringBuilder toString(final String typeName, final Object valueName) {
final StringBuilder buffer = new StringBuilder(40).append(typeName).append('[');
final GenericName name = getName();
if (name != null) {
Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java [UTF-8] Wed May 21 20:11:06 2014
@@ -136,7 +136,7 @@ final class PropertySingleton<V> extends
*
* This method does not checks if the removal is allowed by the
* {@linkplain DefaultAttributeType#getMinimumOccurs() cardinality}.
- * Such check can be performed by {@link DefaultFeature#validate()}.
+ * Such check can be performed by {@link AbstractFeature#quality()}.
*/
@Override
public V remove(final int index) {
@@ -168,7 +168,7 @@ final class PropertySingleton<V> extends
*
* This method does not checks if the removal is allowed by the
* {@linkplain DefaultAttributeType#getMinimumOccurs() cardinality}.
- * Such check can be performed by {@link DefaultFeature#validate()}.
+ * Such check can be performed by {@link AbstractFeature#quality()}.
*/
@Override
public void clear() {
Propchange: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed May 21 20:11:06 2014
@@ -0,0 +1,8 @@
+/sis/branches/Android/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java:1430670-1480699
+/sis/branches/Android/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/Feature.java:1430670-1480699
+/sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java:1394364-1595039,1596667
+/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/Feature.java:1394364-1493762
+/sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java:1394913-1596665
+/sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/Feature.java:1394913-1493760
+/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java:1584960-1596663
+/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java:1394364-1508466,1519089-1519674
Propchange: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java [UTF-8] Wed May 21 20:11:06 2014
@@ -21,6 +21,7 @@ import org.opengis.util.InternationalStr
import org.opengis.metadata.Identifier;
import org.opengis.metadata.maintenance.ScopeCode;
import org.opengis.metadata.quality.EvaluationMethodType;
+import org.apache.sis.metadata.iso.quality.AbstractElement;
import org.apache.sis.metadata.iso.quality.DefaultDataQuality;
import org.apache.sis.metadata.iso.quality.DefaultDomainConsistency;
import org.apache.sis.metadata.iso.quality.DefaultConformanceResult;
@@ -57,19 +58,35 @@ final class Validator {
}
/**
- * Adds a report for a constraint violation.
+ * Adds a report for a constraint violation. If the given {@code report} is {@code null}, then this method creates
+ * a new {@link DefaultDomainConsistency} instance with the measure identification set to the property name.
*
- * @param type Description of the property for which a constraint violation has been found.
- * @param explanation Explanation of the constraint violation.
+ * <div class="note"><b>Note:</b>
+ * setting {@code measureIdentification} to the property name may look like a departure from ISO intend,
+ * since the former should be an identification of the <em>quality measurement</em> rather then the measure itself.
+ * (setting {@code measureDescription} to {@code type.getDescription()} would probably be wrong for that reason).
+ * However {@code measureIdentification} is only an identifier, not a full description of the quality measurement
+ * We are not strictly forbidden to use the same identifier for both the quality measurement than the measurement
+ * itself. However strictly speaking, maybe we should use a different scope.</div>
+ *
+ * @param report Where to add the result, or {@code null} if not yet created.
+ * @param type Description of the property for which a constraint violation has been found.
+ * @param explanation Explanation of the constraint violation.
+ * @return The {@code report}, or a new report if {@code report} was null.
*/
- void addViolationReport(final AbstractIdentifiedType type, final InternationalString explanation) {
- final DefaultDomainConsistency report = new DefaultDomainConsistency();
- final GenericName name = type.getName();
- report.setMeasureIdentification(name instanceof Identifier ? (Identifier) name : new NamedIdentifier(name));
- report.setMeasureDescription(type.getDescription());
- report.setEvaluationMethodType(EvaluationMethodType.DIRECT_INTERNAL);
+ private AbstractElement addViolationReport(AbstractElement report,
+ final AbstractIdentifiedType type, final InternationalString explanation)
+ {
+ if (report == null) {
+ final GenericName name = type.getName();
+ report = new DefaultDomainConsistency();
+ // Do not invoke report.setMeasureDescription(type.getDescription()) - see above javadoc.
+ report.setMeasureIdentification(name instanceof Identifier ? (Identifier) name : new NamedIdentifier(name));
+ report.setEvaluationMethodType(EvaluationMethodType.DIRECT_INTERNAL);
+ quality.getReports().add(report);
+ }
report.getResults().add(new DefaultConformanceResult(null, explanation, false));
- quality.getReports().add(report);
+ return report;
}
/**
@@ -81,7 +98,7 @@ final class Validator {
validate((DefaultAttributeType<?>) type, value);
}
if (type instanceof DefaultAssociationRole) {
- validate((DefaultAssociationRole) type, (DefaultFeature) value);
+ validate((DefaultAssociationRole) type, (AbstractFeature) value);
}
}
@@ -89,6 +106,7 @@ final class Validator {
* Verifies if the given value is valid for the given attribute type.
*/
void validate(final DefaultAttributeType<?> type, final Object value) {
+ AbstractElement report = null;
if (value != null) {
/*
* In theory, the following check is unnecessary since the type was constrained by the Attribute.setValue(T)
@@ -96,41 +114,44 @@ final class Validator {
* so we are better to check.
*/
if (!type.getValueClass().isInstance(value)) {
- addViolationReport(type, Errors.formatInternational(
+ report = addViolationReport(report, type, Errors.formatInternational(
Errors.Keys.IllegalPropertyClass_2, type.getName(), value.getClass()));
}
}
- verifyCardinality(type, type.getMinimumOccurs(), type.getMaximumOccurs(), value);
+ verifyCardinality(report, type, type.getMinimumOccurs(), type.getMaximumOccurs(), value);
}
/**
* Verifies if the given value is valid for the given association role.
*/
- void validate(final DefaultAssociationRole role, final DefaultFeature value) {
+ void validate(final DefaultAssociationRole role, final AbstractFeature value) {
+ AbstractElement report = null;
if (value != null) {
final DefaultFeatureType type = value.getType();
if (!role.getValueType().isAssignableFrom(type)) {
- addViolationReport(role, Errors.formatInternational(
+ report = addViolationReport(report, role, Errors.formatInternational(
Errors.Keys.IllegalPropertyClass_2, role.getName(), type.getName()));
}
}
- verifyCardinality(role, role.getMinimumOccurs(), role.getMaximumOccurs(), value);
+ verifyCardinality(report, role, role.getMinimumOccurs(), role.getMaximumOccurs(), value);
}
/**
* Verifies if the given value mets the cardinality constraint.
+ *
+ * @param report Where to add the result, or {@code null} if not yet created.
*/
- private void verifyCardinality(final AbstractIdentifiedType type,
+ private void verifyCardinality(final AbstractElement report, final AbstractIdentifiedType type,
final int minimumOccurs, final int maximumOccurs, final Object value)
{
if (value == null) {
if (minimumOccurs != 0) {
- addViolationReport(type, Errors.formatInternational(
+ addViolationReport(report, type, Errors.formatInternational(
Errors.Keys.MissingValueForProperty_1, type.getName()));
}
} else {
if (maximumOccurs == 0) {
- addViolationReport(type, Errors.formatInternational(
+ addViolationReport(report, type, Errors.formatInternational(
Errors.Keys.ForbiddenProperty_1, type.getName()));
}
}
Modified: sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/main/java/org/apache/sis/feature/package-info.java [UTF-8] Wed May 21 20:11:06 2014
@@ -33,7 +33,7 @@
* {@link java.lang.Class} in the Java language. By extension, {@code AttributeType} and {@code Operation} are
* equivalent to {@link java.lang.reflect.Field} and {@link java.lang.reflect.Method} respectively.</div></li>
*
- * <li><p><b>{@linkplain org.apache.sis.feature.DefaultFeature Feature instances}</b> (often called only Features)<br>
+ * <li><p><b>{@linkplain org.apache.sis.feature.AbstractFeature Feature instances}</b> (often called only Features)<br>
* Hold the <em>content</em> (or values) that describe one specific real-world object.</p>
*
* <div class="note"><b>Example:</b> the “Eiffel tower” is a <em>feature instance</em> belonging
@@ -72,7 +72,7 @@
* {@code ├─} {@linkplain org.apache.sis.feature.DefaultAssociationRole Feature association role}<br>
* {@code └─} {@linkplain org.apache.sis.feature.DefaultOperation Operation}<br>
* </td><td class="sep" style="width: 50%; white-space: nowrap">
- * {@linkplain org.apache.sis.feature.DefaultFeature Feature}<br>
+ * {@linkplain org.apache.sis.feature.AbstractFeature Feature}<br>
* Property<br>
* {@code ├─} {@linkplain org.apache.sis.feature.DefaultAttribute Attribute}<br>
* {@code └─} {@linkplain org.apache.sis.feature.DefaultAssociation Feature association}<br>
Modified: sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAssociationTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAssociationTest.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAssociationTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAssociationTest.java [UTF-8] Wed May 21 20:11:06 2014
@@ -34,7 +34,7 @@ import static org.apache.sis.test.Assert
*/
@DependsOn({
DefaultAssociationRoleTest.class,
- DefaultFeatureTest.class
+ DenseFeatureTest.class
})
public final strictfp class DefaultAssociationTest extends TestCase {
/**
@@ -44,9 +44,9 @@ public final strictfp class DefaultAssoc
* and Le Mans, France in 836.” — source: Wikipedia</blockquote>
*/
static DefaultAssociation twinTown() {
- final DefaultFeature twinTown = new DefaultFeature(DefaultFeatureTypeTest.city());
+ final AbstractFeature twinTown = DefaultFeatureTypeTest.city().newInstance();
twinTown.setPropertyValue("city", "Le Mans");
- twinTown.setPropertyValue("population", 148169);
+ twinTown.setPropertyValue("population", 143240); // In 2011.
final DefaultAssociation association = new DefaultAssociation(DefaultAssociationRoleTest.twinTown());
association.setValue(twinTown);
return association;
@@ -59,8 +59,8 @@ public final strictfp class DefaultAssoc
public void testWrongValue() {
final DefaultAssociation association = twinTown();
final PropertyType population = association.getRole().getValueType().getProperty("population");
- final DefaultFeature otherFeature = new DefaultFeature(new DefaultFeatureType(
- singletonMap(DefaultFeatureType.NAME_KEY, "Population"), false, null, population));
+ final AbstractFeature otherFeature = new DefaultFeatureType(
+ singletonMap(DefaultFeatureType.NAME_KEY, "Population"), false, null, population).newInstance();
try {
association.setValue(otherFeature);
} catch (IllegalArgumentException e) {
@@ -76,7 +76,8 @@ public final strictfp class DefaultAssoc
*/
@Test
public void testSerialization() {
- assertSerializedEquals(twinTown());
+ final DefaultAssociation twinTown = twinTown();
+ assertNotSame(twinTown, assertSerializedEquals(twinTown));
}
/**
Modified: sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTest.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTest.java [UTF-8] Wed May 21 20:11:06 2014
@@ -58,6 +58,14 @@ public final strictfp class DefaultAttri
}
/**
+ * Creates an attribute for a singleton value.
+ * This attribute has no default value.
+ */
+ static DefaultAttribute<String> parliament() {
+ return new DefaultAttribute<String>(DefaultAttributeTypeTest.parliament());
+ }
+
+ /**
* Tests getting and setting an attribute value.
*/
@Test
@@ -71,14 +79,14 @@ public final strictfp class DefaultAttri
}
/**
- * Tests {@link DefaultAttribute#validate()}.
+ * Tests {@link DefaultAttribute#quality()}.
*/
@Test
@DependsOnMethod("testValue")
@SuppressWarnings("unchecked")
- public void testValidate() {
+ public void testQuality() {
final DefaultAttribute<Integer> attribute = population();
- DataQuality quality = attribute.validate();
+ DataQuality quality = attribute.quality();
assertEquals("scope.level", ScopeCode.ATTRIBUTE, quality.getScope().getLevel());
assertDomainConsistencyEquals("population", "Missing value for “population” property.",
(DomainConsistency) getSingleton(quality.getReports()));
@@ -86,7 +94,7 @@ public final strictfp class DefaultAttri
* Intentionally store a value of the wrong type, and test again.
*/
((DefaultAttribute) attribute).setValue(4.5f);
- quality = attribute.validate();
+ quality = attribute.quality();
assertEquals("scope.level", ScopeCode.ATTRIBUTE, quality.getScope().getLevel());
assertDomainConsistencyEquals("population", "Property “population” does not accept instances of ‘Float’.",
(DomainConsistency) getSingleton(quality.getReports()));
@@ -132,10 +140,12 @@ public final strictfp class DefaultAttri
/**
* Tests {@link DefaultAttribute#clone()}.
+ *
+ * @throws CloneNotSupportedException Should never happen.
*/
@Test
@DependsOnMethod("testEquals")
- public void testClone() {
+ public void testClone() throws CloneNotSupportedException {
final DefaultAttribute<Integer> a1 = population();
final DefaultAttribute<Integer> a2 = a1.clone();
assertNotSame(a1, a2);
@@ -149,7 +159,7 @@ public final strictfp class DefaultAttri
@DependsOnMethod("testEquals")
public void testSerialization() {
final DefaultAttribute<String> attribute = city();
- assertSerializedEquals(attribute);
+ assertNotSame(attribute, assertSerializedEquals(attribute));
}
/**
Modified: sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTypeTest.java [UTF-8] Wed May 21 20:11:06 2014
@@ -26,6 +26,7 @@ import org.apache.sis.test.DependsOnMeth
import org.apache.sis.test.TestCase;
import org.junit.Test;
+import static java.util.Collections.singletonMap;
import static org.apache.sis.test.Assert.*;
@@ -72,6 +73,14 @@ public final strictfp class DefaultAttri
}
/**
+ * Creates an attribute type for a parliament name.
+ */
+ static DefaultAttributeType<String> parliament() {
+ return new DefaultAttributeType<String>(singletonMap(DefaultAttributeType.NAME_KEY, "parliament"),
+ String.class, 1, 1, null);
+ }
+
+ /**
* Tests the creation of a simple {@link DefaultAttributeType} instance for a mandatory singleton.
*/
@Test
Modified: sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java [UTF-8] Wed May 21 20:11:06 2014
@@ -76,9 +76,7 @@ public final strictfp class DefaultFeatu
*/
public static DefaultFeatureType capital() {
return new DefaultFeatureType(singletonMap(DefaultFeatureType.NAME_KEY, "Capital"), false,
- new DefaultFeatureType[] {city()},
- new DefaultAttributeType<String>(singletonMap(DefaultAttributeType.NAME_KEY, "parliament"),
- String.class, 1, 1, null));
+ new DefaultFeatureType[] {city()}, DefaultAttributeTypeTest.parliament());
}
/**
@@ -107,6 +105,14 @@ public final strictfp class DefaultFeatu
}
/**
+ * Creates a sub-type of the "metropolis" type with the "region" attribute overridden to
+ * {@link InternationalString}.
+ */
+ static DefaultFeatureType worldMetropolis() {
+ return worldMetropolis(metropolis(), InternationalString.class);
+ }
+
+ /**
* Creates a sub-type of the "metropolis" type with the "region" attribute overridden to the given type.
* The given type should be {@link InternationalString}, but we allow other type for testing argument checks.
*/
@@ -191,9 +197,10 @@ public final strictfp class DefaultFeatu
assertEquals("name", "City", simple.getName().toString());
assertTrue ("superTypes", simple.getSuperTypes().isEmpty());
assertFalse ("isAbstract", simple.isAbstract());
+ assertFalse ("isSparse", simple.isSparse());
assertTrue ("isSimple", simple.isSimple());
assertTrue ("isAssignableFrom", simple.isAssignableFrom(simple));
- assertEquals("instanceSize", 2, simple.getInstanceSize());
+ assertEquals("instanceSize", 2, simple.indices().size());
assertPropertiesEquals(simple, false, "city", "population");
}
@@ -239,8 +246,9 @@ public final strictfp class DefaultFeatu
assertTrue ("superTypes", complex.getSuperTypes().isEmpty());
assertTrue ("isAssignableFrom", complex.isAssignableFrom(complex));
assertFalse ("isAbstract", complex.isAbstract());
+ assertFalse ("isSparse", complex.isSparse());
assertEquals("isSimple", maximumOccurs == minimumOccurs, complex.isSimple());
- assertEquals("instanceSize", maximumOccurs == 0 ? 2 : 3, complex.getInstanceSize());
+ assertEquals("instanceSize", maximumOccurs == 0 ? 2 : 3, complex.indices().size());
assertEquals("minimumOccurs", minimumOccurs, festival.getMinimumOccurs());
assertEquals("maximumOccurs", maximumOccurs, festival.getMaximumOccurs());
assertEquals("properties.size", 3, properties.size());
@@ -288,8 +296,9 @@ public final strictfp class DefaultFeatu
assertEquals("name", "Capital", capital.getName().toString());
assertEquals("superTypes", city, getSingleton(capital.getSuperTypes()));
assertFalse ("isAbstract", capital.isAbstract());
+ assertFalse ("isSparse", capital.isSparse());
assertTrue ("isSimple", capital.isSimple());
- assertEquals("instanceSize", 3, capital.getInstanceSize());
+ assertEquals("instanceSize", 3, capital.indices().size());
assertPropertiesEquals(city, false, "city", "population");
assertPropertiesEquals(capital, false, "parliament");
@@ -322,8 +331,9 @@ public final strictfp class DefaultFeatu
assertEquals ("name", "Metropolis and capital", metroCapital.getName().toString());
assertArrayEquals("superTypes", new Object[] {metropolis, capital}, metroCapital.getSuperTypes().toArray());
assertFalse ("isAbstract", metroCapital.isAbstract());
+ assertFalse ("isSparse", metroCapital.isSparse());
assertTrue ("isSimple", metroCapital.isSimple());
- assertEquals ("instanceSize", 6, metroCapital.getInstanceSize());
+ assertEquals ("instanceSize", 6, metroCapital.indices().size());
assertPropertiesEquals(metroCapital, false, "country");
assertPropertiesEquals(metroCapital, true, "city", "population", "region", "isGlobal", "parliament", "country");
@@ -363,8 +373,9 @@ public final strictfp class DefaultFeatu
assertEquals ("name", "World metropolis", worldMetropolis.getName().toString());
assertArrayEquals("superTypes", new Object[] {metropolis}, worldMetropolis.getSuperTypes().toArray());
assertFalse ("isAbstract", worldMetropolis.isAbstract());
+ assertFalse ("isSparse", worldMetropolis.isSparse());
assertTrue ("isSimple", worldMetropolis.isSimple());
- assertEquals ("instanceSize", 4, worldMetropolis.getInstanceSize());
+ assertEquals ("instanceSize", 4, worldMetropolis.indices().size());
assertPropertiesEquals(worldMetropolis, false, "region");
assertPropertiesEquals(worldMetropolis, true, "city", "population", "region", "isGlobal");
Modified: sis/trunk/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java [UTF-8] (original)
+++ sis/trunk/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java [UTF-8] Wed May 21 20:11:06 2014
@@ -34,10 +34,13 @@ import org.junit.BeforeClass;
org.apache.sis.feature.DefaultFeatureTypeTest.class,
org.apache.sis.feature.DefaultAttributeTest.class,
org.apache.sis.feature.PropertySingletonTest.class,
- org.apache.sis.feature.DefaultFeatureTest.class,
+ org.apache.sis.feature.DenseFeatureTest.class,
+ org.apache.sis.feature.SparseFeatureTest.class,
org.apache.sis.feature.DefaultAssociationRoleTest.class,
org.apache.sis.feature.DefaultAssociationTest.class,
- org.apache.sis.feature.DefaultOperationTest.class
+ org.apache.sis.feature.DefaultOperationTest.class,
+ org.apache.sis.feature.FeatureFormatTest.class,
+ org.apache.sis.feature.FeaturesTest.class
})
public final strictfp class FeatureTestSuite extends TestSuite {
/**
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] Wed May 21 20:11:06 2014
@@ -156,6 +156,8 @@ public class DefaultParameterDescriptorG
* @param maximumOccurs The {@linkplain #getMaximumOccurs() maximum number of times}
* that values for this parameter group are required.
* @param parameters The {@linkplain #descriptors() parameter descriptors} for this group.
+ *
+ * @throws InvalidParameterNameException If a parameter name is duplicated.
*/
public DefaultParameterDescriptorGroup(final Map<String,?> properties,
final int minimumOccurs, final int maximumOccurs, GeneralParameterDescriptor... parameters)
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java [UTF-8] Wed May 21 20:11:06 2014
@@ -91,8 +91,8 @@ import static org.apache.sis.util.collec
* <caption>Formattable object types</caption>
* <tr><th>Class</th> <th>Remarks</th></tr>
* <tr><td>{@link ParameterValueGroup}</td><td><cite>Default values</cite> column is replaced by a column of the actual values.</td></tr>
- * <tr><td>{@link ParameterDescriptorGroup}</td><td>Table title is the parameter group name.</td></tr>
- * <tr><td>{@link OperationMethod}</td><td>Table title is the method name (not necessarily the same than parameter group name).</td></tr>
+ * <tr><td>{@link ParameterDescriptorGroup}</td><td>Table caption is the parameter group name.</td></tr>
+ * <tr><td>{@link OperationMethod}</td><td>Table caption is the method name (not necessarily the same than parameter group name).</td></tr>
* <tr><td><code>{@linkplain IdentifiedObject}[]</code></td><td>Accepted only for {@link ContentLevel#NAME_SUMMARY}.</td></tr>
* </table>
*
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java [UTF-8] Wed May 21 20:11:06 2014
@@ -43,25 +43,26 @@ public final class Parameters extends St
/**
* Casts the given parameter descriptor to the given type.
- * An exception is thrown immediately if the parameter does not have the expected value class.
+ * An exception is thrown immediately if the parameter does not have the expected
+ * {@linkplain DefaultParameterDescriptor#getValueClass() value class}.
*
- * @param <T> The expected value class.
+ * @param <T> The expected value class.
* @param descriptor The descriptor to cast, or {@code null}.
- * @param type The expected value class.
- * @return The descriptor casted to the given type, or {@code null} if the given descriptor was null.
- * @throws ClassCastException if the given descriptor doesn't have the expected value class.
+ * @param valueClass The expected value class.
+ * @return The descriptor casted to the given value class, or {@code null} if the given descriptor was null.
+ * @throws ClassCastException if the given descriptor does not have the expected value class.
*
* @category verification
*/
@SuppressWarnings("unchecked")
- public static <T> ParameterDescriptor<T> cast(final ParameterDescriptor<?> descriptor, final Class<T> type)
+ public static <T> ParameterDescriptor<T> cast(final ParameterDescriptor<?> descriptor, final Class<T> valueClass)
throws ClassCastException
{
if (descriptor != null) {
final Class<?> actual = descriptor.getValueClass();
// We require a strict equality - not type.isAssignableFrom(actual) - because in
// the later case we could have (to be strict) to return a <? extends T> type.
- if (!type.equals(actual)) {
+ if (!valueClass.equals(actual)) {
throw new ClassCastException(Errors.format(Errors.Keys.IllegalParameterType_2,
descriptor.getName().getCode(), actual));
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java [UTF-8] Wed May 21 20:11:06 2014
@@ -67,7 +67,7 @@
* }
* </div>
*
- * Calls to {@code parameter(…)} throw a {@link org.opengis.parameter.InvalidParameterNameException}
+ * Calls to {@code parameter(…)} throw a {@link org.opengis.parameter.ParameterNotFoundException}
* if the given name is unknown to the group.
* Calls to {@code setValue(…)} throw a {@link org.opengis.parameter.InvalidParameterValueException}
* if the given value is not assignable to the expected class or is not inside the value domain.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] Wed May 21 20:11:06 2014
@@ -330,7 +330,7 @@ public abstract class CompoundFormat<T>
* See {@link #createFormat(Class)} for the list of value types recognized by the default
* {@code CompoundFormat} implementation.
*
- * @param valueType The base type of values to parse or format.
+ * @param valueType The base type of values to parse or format, or {@code null} if unknown.
* @return The format to use for parsing and formatting values of the given type or any
* parent type, or {@code null} if none.
*/
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Wed May 21 20:11:06 2014
@@ -433,6 +433,11 @@ public final class Errors extends Indexe
public static final short MismatchedPropertyType_1 = 154;
/**
+ * Class of “{0}” values is ‘{2}’, but the requested type is ‘{1}’.
+ */
+ public static final short MismatchedValueClass_3 = 157;
+
+ /**
* No authority was specified for code “{0}”. The expected syntax is “AUTHORITY:CODE”.
*/
public static final short MissingAuthority_1 = 135;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Wed May 21 20:11:06 2014
@@ -97,6 +97,7 @@ MismatchedDimension_3 = Argu
MismatchedMatrixSize_4 = Mismatched matrix sizes: expected {0}\u00d7{1} but got {2}\u00d7{3}.
MismatchedParameterDescriptor_1 = Mismatched descriptor for \u201c{0}\u201d parameter.
MismatchedPropertyType_1 = Mismatched type for \u201c{0}\u201d property.
+MismatchedValueClass_3 = Class of \u201c{0}\u201d values is \u2018{2}\u2019, but the requested type is \u2018{1}\u2019.
MissingAuthority_1 = No authority was specified for code \u201c{0}\u201d. The expected syntax is \u201cAUTHORITY:CODE\u201d.
MissingRequiredModule_1 = This operation requires the \u201c{0}\u201d module.
MissingSchemeInURI = Missing scheme in URI.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Wed May 21 20:11:06 2014
@@ -87,6 +87,7 @@ MismatchedDimension_3 = L\u2
MismatchedMatrixSize_4 = Une matrice de taille de {0}\u00d7{1} \u00e9tait attendue mais la matrice donn\u00e9es est de taille {2}\u00d7{3}.
MismatchedParameterDescriptor_1 = Le descripteur du param\u00e8tre \u00ab\u202f{0}\u202f\u00bb ne correspond pas.
MismatchedPropertyType_1 = Le type de la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb ne correspond pas.
+MismatchedValueClass_3 = Les valeurs de \u00ab\u202f{0}\u202f\u00bb sont de la classe \u2018{2}\u2019, alors que le type demand\u00e9 \u00e9tait \u2018{1}\u2019.
MissingAuthority_1 = Aucune autorit\u00e9 n\u2019a \u00e9t\u00e9 sp\u00e9cifi\u00e9e pour le code \u00ab\u202f{0}\u202f\u00bb. Le format attendu est \u00ab\u202fAUTORIT\u00c9:CODE\u202f\u00bb.
MissingRequiredModule_1 = Cette op\u00e9ration requiert le module \u00ab\u202f{0}\u202f\u00bb.
MissingSchemeInURI = Il manque le sch\u00e9ma d\u2019URI.
Modified: sis/trunk/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/pom.xml?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/pom.xml (original)
+++ sis/trunk/pom.xml Wed May 21 20:11:06 2014
@@ -435,9 +435,6 @@ Apache SIS is a free software, Java lang
<source>${maven.compile.source}</source>
<target>${maven.compile.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
- <compilerArgs>
- <arg>-Xlint:all</arg>
- </compilerArgs>
</configuration>
</plugin>
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java?rev=1596668&r1=1596667&r2=1596668&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] Wed May 21 20:11:06 2014
@@ -29,7 +29,7 @@ import com.esri.core.geometry.Polygon;
import com.esri.core.geometry.Polyline;
import com.esri.core.geometry.Geometry;
-import org.apache.sis.feature.DefaultFeature;
+import org.apache.sis.feature.AbstractFeature;
import org.apache.sis.feature.DefaultFeatureType;
import org.apache.sis.feature.DefaultAttributeType;
import org.apache.sis.storage.DataStoreException;
@@ -74,7 +74,7 @@ public class ShapeFile {
// reserve 4 bytes
public ArrayList<FieldDescriptor> FDArray = new ArrayList<FieldDescriptor>();
- public Map<Integer, DefaultFeature> FeatureMap = new HashMap<Integer, DefaultFeature>();
+ public Map<Integer, AbstractFeature> FeatureMap = new HashMap<Integer, AbstractFeature>();
@@ -156,7 +156,7 @@ public class ShapeFile {
data = new byte[4];
rf.order(ByteOrder.LITTLE_ENDIAN);
int ShapeType = rf.getInt();
- final DefaultFeature f = new DefaultFeature(featureType);
+ final AbstractFeature f = featureType.newInstance();
if (ShapeType == ShapeTypeEnum.Point.getValue()) {
double x = rf.getDouble();