Author: desruisseaux
Date: Fri Feb 28 22:10:14 2014
New Revision: 1573095

URL: http://svn.apache.org/r1573095
Log:
Initial draft of support classes for DefaultFeature.

Added:
    
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
   (with props)
    
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
   (with props)
    
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
   (with props)
Modified:
    sis/branches/JDK7/src/main/javadoc/stylesheet.css

Added: 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java?rev=1573095&view=auto
==============================================================================
--- 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
 (added)
+++ 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
 [UTF-8] Fri Feb 28 22:10:14 2014
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.feature;
+
+import java.io.Serializable;
+import org.opengis.util.GenericName;
+import org.apache.sis.util.ArgumentChecks;
+
+// Related to JDK7
+import java.util.Objects;
+
+
+/**
+ * Identification and description information inherited by property types and 
feature types.
+ *
+ * <div class="warning"><b>Warning:</b>
+ * This class is expected to implement a GeoAPI {@code IdentifiedType} 
interface in a future version.
+ * When such interface will be available, most references to {@code 
AbstractIdentifiedType} in the API
+ * will be replaced by references to the {@code IdentifiedType} 
interface.</div>
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public class AbstractIdentifiedType implements Serializable {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = 277130188958446740L;
+
+    /**
+     * The name of this type.
+     */
+    private final GenericName name;
+
+    /**
+     * Creates a type of the given name.
+     *
+     * @param name The name of this type.
+     */
+    protected AbstractIdentifiedType(final GenericName name) {
+        ArgumentChecks.ensureNonNull("name", name);
+        this.name = name;
+    }
+
+    /**
+     * Returns the name of this type.
+     * The namespace can be either explicit
+     * ({@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name}) or 
implicit
+     * ({@linkplain org.apache.sis.util.iso.DefaultLocalName local name}).
+     *
+     * <p>For {@linkplain DefaultFeatureType feature types}, the name is 
mandatory and shall be unique
+     * in the unit processing the data (e.g. a {@link 
org.apache.sis.storage.DataStore} reading a file).</p>
+     *
+     * @return The type name.
+     */
+    public GenericName getName() {
+        return name;
+    }
+
+    /**
+     * Returns a hash code value for this type.
+     *
+     * @return The hash code for this type.
+     */
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(name);
+    }
+
+    /**
+     * Compares this type with the given object for equality.
+     *
+     * @param  obj The object to compare with this class.
+     * @return {@code true} if the given object is equals to this map.
+     */
+    @Override
+    public boolean equals(final Object obj) {
+        if (obj != null && getClass() != obj.getClass()) {
+            final AbstractIdentifiedType that = (AbstractIdentifiedType) obj;
+            return Objects.equals(this.name, that.name);
+        }
+        return false;
+    }
+}

Propchange: 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractIdentifiedType.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java?rev=1573095&view=auto
==============================================================================
--- 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
 (added)
+++ 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
 [UTF-8] Fri Feb 28 22:10:14 2014
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.feature;
+
+import org.opengis.util.GenericName;
+import org.apache.sis.internal.util.Numerics;
+
+import static org.apache.sis.util.ArgumentChecks.*;
+
+
+/**
+ * Definition of an attribute in a feature type.
+ *
+ * <div class="note"><b>Note:</b>
+ * Compared to the Java language, {@code FeatureType} is equivalent to {@link 
Class} and
+ * {@code AttributeType} is equivalent to {@link 
java.lang.reflect.Field}.</div>
+ *
+ * <div class="warning"><b>Warning:</b>
+ * This class is expected to implement a GeoAPI {@code AttributeType} 
interface in a future version.
+ * When such interface will be available, most references to {@code 
DefaultAttributeType} in the API
+ * will be replaced by references to the {@code AttributeType} interface.</div>
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public class DefaultAttributeType<T> extends AbstractIdentifiedType {
+    /**
+     * The class that describe the type of attribute values.
+     *
+     * @see #getValueClass()
+     */
+    private final Class<T> valueClass;
+
+    /**
+     * The default value for the attribute, or {@code null}.
+     *
+     * @see #getDefaultValue()
+     */
+    private final T defaultValue;
+
+    /**
+     * Creates an attribute type of the given name.
+     *
+     * @param name          The name of this attribute type.
+     * @param valueClass    The type of attribute values.
+     * @param defaultValue  The default value, or {@code null} if none.
+     */
+    public DefaultAttributeType(final GenericName name, final Class<T> 
valueClass, final T defaultValue) {
+        super(name);
+        ensureNonNull("valueClass",   valueClass);
+        ensureCanCast("defaultValue", valueClass, defaultValue);
+        this.valueClass   = valueClass;
+        this.defaultValue = Numerics.cached(defaultValue);
+    }
+
+    /**
+     * The type of attribute values.
+     */
+    public Class<T> getValueClass() {
+        return valueClass;
+    }
+
+    /**
+     * The minimum number of occurrences of the property within its containing 
entity.
+     * This value is always an integer greater than or equal to zero.
+     */
+    public int getMinimumOccurs() {
+        return 0;
+    }
+
+    /**
+     * The maximum number of occurrences of the property within its containing 
entity.
+     * This value is a positive integer. A value of {@link Integer#MAX_VALUE} 
means that
+     * the maximum number of occurrences is unbounded.
+     */
+    public int getMaximumOccurs() {
+        return 1;
+    }
+
+    /**
+     * The default value for the attribute.
+     * This value is used when an attribute is created and no value for it is 
specified.
+     */
+    public T getDefaultValue() {
+        return defaultValue;
+    }
+}

Propchange: 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttributeType.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: 
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=1573095&view=auto
==============================================================================
--- 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
 (added)
+++ 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
 [UTF-8] Fri Feb 28 22:10:14 2014
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.feature;
+
+import org.opengis.util.GenericName;
+
+
+/**
+ * Abstraction of a real-world phenomena. A {@code FeatureType} instance 
describes the class of all
+ * {@link DefaultFeature} instances of that type.
+ *
+ * <div class="note"><b>Note:</b>
+ * Compared to the Java language, {@code FeatureType} is equivalent to {@link 
Class} and
+ * {@code Feature} instances are equivalent to {@link Object} instances of 
that class.</div>
+ *
+ * <div class="warning"><b>Warning:</b>
+ * This class is expected to implement a GeoAPI {@code FeatureType} interface 
in a future version.
+ * When such interface will be available, most references to {@code 
DefaultFeatureType} in the API
+ * will be replaced by references to the {@code FeatureType} interface.</div>
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+public class DefaultFeatureType extends AbstractIdentifiedType {
+    /**
+     * Creates a feature type of the given name.
+     *
+     * @param name The name of this feature type.
+     */
+    public DefaultFeatureType(final GenericName name) {
+        super(name);
+    }
+}

Propchange: 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
sis/branches/JDK7/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultFeatureType.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/src/main/javadoc/stylesheet.css
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK7/src/main/javadoc/stylesheet.css?rev=1573095&r1=1573094&r2=1573095&view=diff
==============================================================================
--- sis/branches/JDK7/src/main/javadoc/stylesheet.css (original)
+++ sis/branches/JDK7/src/main/javadoc/stylesheet.css Fri Feb 28 22:10:14 2014
@@ -146,6 +146,17 @@ div.note {
   margin-bottom: 9pt;
 }
 
+/*
+ * Note, examples or warnings.
+ */
+div.warning {
+  color:   firebrick;
+  margin-left:  30pt;
+  margin-right: 30pt;
+  margin-top:    9pt;
+  margin-bottom: 9pt;
+}
+
 
 
 


Reply via email to