sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1574958 - /sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
Date Thu, 06 Mar 2014 16:47:22 GMT
Author: desruisseaux
Date: Thu Mar  6 16:47:22 2014
New Revision: 1574958

URL: http://svn.apache.org/r1574958
Log:
First draft of a DefaultFeatureType implementation containing the attributes.

Modified:
    sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java

Modified: sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java?rev=1574958&r1=1574957&r2=1574958&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
[UTF-8] Thu Mar  6 16:47:22 2014
@@ -17,6 +17,14 @@
 package org.apache.sis.feature;
 
 import java.util.Map;
+import java.util.Set;
+import java.util.List;
+import java.util.Collections;
+import org.opengis.util.GenericName;
+import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.util.CollectionsExt;
+import org.apache.sis.internal.util.UnmodifiableArrayList;
 
 
 /**
@@ -39,6 +47,24 @@ import java.util.Map;
  */
 public class DefaultFeatureType extends AbstractIdentifiedType {
     /**
+     * If {@code true}, the feature type acts as an abstract super-type.
+     *
+     * @see #isAbstract()
+     */
+    private final boolean isAbstract;
+
+    /**
+     * The parents of this feature type, or an empty set if none.
+     */
+    private final Set<DefaultFeatureType> superTypes;
+
+    /**
+     * Any feature operation, any feature attribute type and any feature association role
+     * that carries characteristics of a feature type.
+     */
+    private final List<DefaultAttributeType<?>> characteristics;
+
+    /**
      * Constructs a feature 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:
@@ -72,8 +98,70 @@ public class DefaultFeatureType extends 
      * </table>
      *
      * @param properties The name and other properties 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.
+     * @param characteristics Any feature operation, any feature attribute type and any feature
+     *        association role that carries characteristics of a feature type.
      */
-    public DefaultFeatureType(final Map<String,?> properties) {
+    public DefaultFeatureType(final Map<String,?> properties, final boolean isAbstract,
+            final DefaultFeatureType[] superTypes, final DefaultAttributeType... characteristics)
+    {
         super(properties);
+        ArgumentChecks.ensureNonNull("characteristics", characteristics);
+        this.isAbstract = isAbstract;
+        this.superTypes = (superTypes == null) ? Collections.<DefaultFeatureType>emptySet()
:
+                          CollectionsExt.<DefaultFeatureType>immutableSet(true, superTypes);
+        final DefaultAttributeType<?>[] copy = new DefaultAttributeType<?>[characteristics.length];
+        for (int i=0; i<characteristics.length; i++) {
+            copy[i] = characteristics[i];
+            ArgumentChecks.ensureNonNullElement("characteristics", i, copy);
+            /*
+             * Ensure there is no conflict in property names.
+             */
+            final GenericName name = copy[i].getName();
+            if (name == null) {
+                throw new IllegalArgumentException(Errors.format(
+                        Errors.Keys.MissingValueForProperty_1, "characteristics[" + i + "].name"));
+            }
+            for (int j=i; --j >= 0;) {
+                if (name.equals(copy[j].getName())) {
+                    throw new IllegalArgumentException(Errors.format(
+                            Errors.Keys.DuplicatedIdentifier_1, name));
+                }
+            }
+        }
+        this.characteristics = UnmodifiableArrayList.wrap(copy);
+    }
+
+    /**
+     * Returns {@code true} if the feature type acts as an abstract super-type.
+     *
+     * @return {@code true} if the feature type acts as an abstract super-type.
+     */
+    public boolean isAbstract() {
+        return isAbstract;
+    }
+
+    /**
+     * Returns the parents of this feature type.
+     *
+     * @return The parents of this feature type, or an empty set if none.
+     */
+    public Set<DefaultFeatureType> superTypes() {
+        return superTypes;
+    }
+
+    /**
+     * Returns any feature operation, any feature attribute type and any feature association
role
+     * that carries characteristics of a feature type.
+     *
+     * <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>
+     *
+     * @return Feature operation, attribute type and association role that carries characteristics
of a feature type.
+     */
+    public List<DefaultAttributeType<?>> getCharacteristics() {
+        return characteristics;
     }
 }



Mime
View raw message