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/27 12:09:59 UTC
svn commit: r1597732 - in /sis/branches/JDK8/core/sis-feature/src:
main/java/org/apache/sis/feature/ test/java/org/apache/sis/feature/
Author: desruisseaux
Date: Tue May 27 10:09:58 2014
New Revision: 1597732
URL: http://svn.apache.org/r1597732
Log:
Use the GeoAPI PropertyType interface. This is a branch-specific change; the trunk will need to use the current hacks,
since those feature interfaces are not part of GeoAPI 3.0 (the will be submitted for next GeoAPI version).
Removed:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertyType.java
Modified:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultOperation.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FieldType.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.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/SingletonAssociationTest.java
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java?rev=1597732&r1=1597731&r2=1597732&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java [UTF-8] Tue May 27 10:09:58 2014
@@ -28,6 +28,9 @@ import org.apache.sis.util.resources.Err
import org.apache.sis.util.CorruptedObjectException;
import org.apache.sis.internal.util.CheckedArrayList;
+// Branch-dependent imports
+import org.opengis.feature.PropertyType;
+
/**
* An instance of a {@linkplain DefaultFeatureType feature type} containing values for a real-world phenomena.
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java?rev=1597732&r1=1597731&r2=1597732&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java [UTF-8] Tue May 27 10:09:58 2014
@@ -21,15 +21,15 @@ import java.util.Locale;
import java.io.Serializable;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
-import org.opengis.feature.IdentifiedType;
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.iso.Types;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-// Related to JDK7
+// Branch-dependent imports
import java.util.Objects;
+import org.opengis.feature.IdentifiedType;
/**
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java?rev=1597732&r1=1597731&r2=1597732&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociationRole.java [UTF-8] Tue May 27 10:09:58 2014
@@ -19,11 +19,13 @@ package org.apache.sis.feature;
import java.util.Map;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
-import org.opengis.feature.IdentifiedType;
import org.apache.sis.util.Debug;
import static org.apache.sis.util.ArgumentChecks.*;
+// Branch-dependent imports
+import org.opengis.feature.PropertyType;
+
/**
* Indicates the role played by the association between two features.
@@ -139,7 +141,7 @@ public class DefaultAssociationRole exte
String p = titleProperty; // No synchronization - not a big deal if computed twice.
if (p == null) {
p = "";
- for (final IdentifiedType type : valueType.getProperties(true)) {
+ for (final PropertyType type : valueType.getProperties(true)) {
if (type instanceof DefaultAttributeType<?>) {
final DefaultAttributeType<?> pt = (DefaultAttributeType<?>) type;
if (pt.getMaximumOccurs() != 0 && CharSequence.class.isAssignableFrom(pt.getValueClass())) {
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java?rev=1597732&r1=1597731&r2=1597732&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java [UTF-8] Tue May 27 10:09:58 2014
@@ -30,13 +30,15 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
-import org.opengis.feature.IdentifiedType;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.collection.Containers;
import org.apache.sis.internal.util.CollectionsExt;
import org.apache.sis.internal.util.UnmodifiableArrayList;
+// Branch-dependent imports
+import org.opengis.feature.PropertyType;
+
/**
* Abstraction of a real-world phenomena. A {@code FeatureType} instance describes the class of all
@@ -197,12 +199,6 @@ public class DefaultFeatureType extends
* </tr>
* </table>
*
- * <div class="warning"><b>Warning:</b> In a future SIS version, the type of array elements may be
- * changed to {@code org.opengis.feature.FeatureType} and {@code org.opengis.feature.PropertyType}.
- * This change is pending GeoAPI revision. In the meantime, make sure that the {@code properties}
- * array contains only attribute types, association roles or operations, <strong>not</strong> other
- * feature types since the later are not properties in the ISO sense.</div>
- *
* @param identification The name and other information to be given to this feature type.
* @param isAbstract If {@code true}, the feature type acts as an abstract super-type.
* @param superTypes The parents of this feature type, or {@code null} or empty if none.
@@ -210,7 +206,7 @@ public class DefaultFeatureType extends
* association role that carries characteristics of a feature type.
*/
public DefaultFeatureType(final Map<String,?> identification, final boolean isAbstract,
- final DefaultFeatureType[] superTypes, final IdentifiedType... properties)
+ final DefaultFeatureType[] superTypes, final PropertyType... properties)
{
super(identification);
ArgumentChecks.ensureNonNull("properties", properties);
@@ -219,7 +215,7 @@ public class DefaultFeatureType extends
CollectionsExt.<DefaultFeatureType>immutableSet(true, superTypes);
switch (properties.length) {
case 0: this.properties = Collections.emptyList(); break;
- case 1: this.properties = Collections.singletonList((PropertyType) properties[0]); break;
+ case 1: this.properties = Collections.singletonList(properties[0]); break;
default: this.properties = UnmodifiableArrayList.wrap(Arrays.copyOf(properties, properties.length, PropertyType[].class)); break;
}
computeTransientFields();
@@ -535,18 +531,13 @@ public class DefaultFeatureType extends
* inherited from the {@link #getSuperTypes() super-types} only if {@code includeSuperTypes} is
* {@code true}.
*
- * <div class="warning"><b>Warning:</b>
- * The type of list elements will be changed to {@code PropertyType} if and when such interface
- * will be defined in GeoAPI.</div>
- *
* @param includeSuperTypes {@code true} for including the properties inherited from the super-types,
* or {@code false} for returning only the properties defined explicitely in this type.
* @return Feature operation, attribute type and association role that carries characteristics of this
* feature type (not including parent types).
*/
- public Collection<IdentifiedType> getProperties(final boolean includeSuperTypes) {
- // TODO: temporary cast to be removed after we upgraded GeoAPI.
- return (Collection) (includeSuperTypes ? allProperties : properties);
+ public Collection<PropertyType> getProperties(final boolean includeSuperTypes) {
+ return includeSuperTypes ? allProperties : properties;
}
/**
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultOperation.java?rev=1597732&r1=1597731&r2=1597732&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultOperation.java [UTF-8] Tue May 27 10:09:58 2014
@@ -24,8 +24,9 @@ import org.apache.sis.referencing.Identi
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.Debug;
-// Related to JDK7
+// Branch-dependent imports
import java.util.Objects;
+import org.opengis.feature.PropertyType;
/**
@@ -48,7 +49,7 @@ import java.util.Objects;
* @version 0.5
* @module
*/
-public class DefaultOperation extends PropertyType {
+public class DefaultOperation extends AbstractIdentifiedType implements PropertyType {
/**
* For cross-version compatibility.
*/
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java?rev=1597732&r1=1597731&r2=1597732&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java [UTF-8] Tue May 27 10:09:58 2014
@@ -24,7 +24,6 @@ import java.text.FieldPosition;
import java.text.ParsePosition;
import java.text.ParseException;
import java.util.concurrent.atomic.AtomicReference;
-import org.opengis.feature.IdentifiedType;
import org.opengis.util.InternationalString;
import org.opengis.util.GenericName;
import org.apache.sis.io.TableAppender;
@@ -33,6 +32,9 @@ import org.apache.sis.util.ArgumentCheck
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.resources.Vocabulary;
+// Branch-dependent imports
+import org.opengis.feature.PropertyType;
+
/**
* Formats {@link AbstractFeature features} or {@linkplain DefaultFeatureType feature types} in a tabular format.
@@ -185,7 +187,7 @@ header: for (int i=0; ; i++) {
* Done writing the header. Now write all property rows.
* Rows without value will be skipped only if optional.
*/
- for (final IdentifiedType propertyType : featureType.getProperties(true)) {
+ for (final PropertyType propertyType : featureType.getProperties(true)) {
Object value;
if (feature != null) {
value = feature.getPropertyValue(propertyType.getName().toString());
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FieldType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FieldType.java?rev=1597732&r1=1597731&r2=1597732&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FieldType.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FieldType.java [UTF-8] Tue May 27 10:09:58 2014
@@ -21,6 +21,9 @@ import java.util.Iterator;
import org.opengis.util.GenericName;
import org.apache.sis.util.resources.Errors;
+// Branch-dependent imports
+import org.opengis.feature.PropertyType;
+
/**
* Base class of property types having a value and a cardinality.
@@ -36,7 +39,7 @@ import org.apache.sis.util.resources.Err
* @version 0.5
* @module
*/
-abstract class FieldType extends PropertyType {
+abstract class FieldType extends AbstractIdentifiedType implements PropertyType {
/**
* For cross-version compatibility.
*/
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=1597732&r1=1597731&r2=1597732&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] Tue May 27 10:09:58 2014
@@ -20,7 +20,6 @@ import java.util.Collection;
import java.util.Collections;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
-import org.opengis.feature.IdentifiedType;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.maintenance.ScopeCode;
import org.opengis.metadata.quality.EvaluationMethodType;
@@ -32,6 +31,9 @@ import org.apache.sis.metadata.iso.quali
import org.apache.sis.referencing.NamedIdentifier;
import org.apache.sis.util.resources.Errors;
+// Branch-dependent imports
+import org.opengis.feature.PropertyType;
+
/**
* Provides validation methods to be shared by different implementations.
@@ -78,7 +80,7 @@ final class Validator {
* @return The {@code report}, or a new report if {@code report} was null.
*/
private AbstractElement addViolationReport(AbstractElement report,
- final IdentifiedType type, final InternationalString explanation)
+ final PropertyType type, final InternationalString explanation)
{
if (report == null) {
final GenericName name = type.getName();
@@ -159,7 +161,7 @@ final class Validator {
*
* @param report Where to add the result, or {@code null} if not yet created.
*/
- private void verifyCardinality(final AbstractElement report, final IdentifiedType type,
+ private void verifyCardinality(final AbstractElement report, final PropertyType type,
final int minimumOccurs, final int maximumOccurs, final int count)
{
if (count < minimumOccurs) {
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=1597732&r1=1597731&r2=1597732&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] Tue May 27 10:09:58 2014
@@ -21,7 +21,6 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Collection;
import org.opengis.util.InternationalString;
-import org.opengis.feature.IdentifiedType;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
@@ -31,6 +30,9 @@ import static org.apache.sis.test.Assert
import static java.util.Collections.singletonMap;
import static org.apache.sis.test.TestUtilities.getSingleton;
+// Branch-dependent imports
+import org.opengis.feature.PropertyType;
+
/**
* Tests {@link DefaultFeatureType}.
@@ -193,7 +195,7 @@ public final strictfp class DefaultFeatu
final String... expected)
{
int index = 0;
- for (final IdentifiedType property : feature.getProperties(includeSuperTypes)) {
+ for (final PropertyType property : feature.getProperties(includeSuperTypes)) {
assertTrue("Found more properties than expected.", index < expected.length);
final String name = expected[index++];
assertNotNull(name, property);
@@ -259,8 +261,8 @@ public final strictfp class DefaultFeatu
false, null, city, population, festival);
assertUnmodifiable(complex);
- final Collection<IdentifiedType> properties = complex.getProperties(false);
- final Iterator<IdentifiedType> it = properties.iterator();
+ final Collection<PropertyType> properties = complex.getProperties(false);
+ final Iterator<PropertyType> it = properties.iterator();
assertEquals("name", "Festival", complex.getName().toString());
assertTrue ("superTypes", complex.getSuperTypes().isEmpty());
Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonAssociationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonAssociationTest.java?rev=1597732&r1=1597731&r2=1597732&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonAssociationTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/SingletonAssociationTest.java [UTF-8] Tue May 27 10:09:58 2014
@@ -23,6 +23,9 @@ import org.junit.Test;
import static java.util.Collections.singletonMap;
import static org.apache.sis.test.Assert.*;
+// Branch-dependent imports
+import org.opengis.feature.PropertyType;
+
/**
* Tests {@link SingletonAssociation}.