sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1686191 - /sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/
Date Thu, 18 Jun 2015 11:34:00 GMT
Author: desruisseaux
Date: Thu Jun 18 11:33:59 2015
New Revision: 1686191

URL: http://svn.apache.org/r1686191
Log:
Feature: throw more accurate exceptions.

Modified:
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAssociation.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAttribute.java
    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/CharacteristicMap.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/DenseFeature.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Field.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAssociation.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAttribute.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/NamedFeatureType.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAssociation.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAssociation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAssociation.java?rev=1686191&r1=1686190&r2=1686191&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAssociation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAssociation.java
[UTF-8] Thu Jun 18 11:33:59 2015
@@ -30,6 +30,8 @@ import org.opengis.feature.Feature;
 import org.opengis.feature.FeatureType;
 import org.opengis.feature.FeatureAssociation;
 import org.opengis.feature.FeatureAssociationRole;
+import org.opengis.feature.InvalidPropertyValueException;
+import org.opengis.feature.MultiValuedPropertyException;
 
 
 /**
@@ -47,7 +49,7 @@ import org.opengis.feature.FeatureAssoci
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see DefaultAssociationRole#newInstance()
@@ -130,12 +132,12 @@ public abstract class AbstractAssociatio
      * features is restricted to 1 or 0.
      *
      * @return The associated feature (may be {@code null}).
-     * @throws IllegalStateException if this association contains more than one value.
+     * @throws MultiValuedPropertyException if this association contains more than one value.
      *
      * @see AbstractFeature#getPropertyValue(String)
      */
     @Override
-    public abstract Feature getValue();
+    public abstract Feature getValue() throws MultiValuedPropertyException;
 
     /**
      * Returns all features, or an empty collection if none.
@@ -162,12 +164,12 @@ public abstract class AbstractAssociatio
      * 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.
+     * @throws InvalidPropertyValueException If the given feature is not valid for this association.
      *
      * @see AbstractFeature#setPropertyValue(String, Object)
      */
     @Override
-    public abstract void setValue(final Feature value) throws IllegalArgumentException;
+    public abstract void setValue(final Feature value) throws InvalidPropertyValueException;
 
     /**
      * Sets the features. All previous values are replaced by the given collection.
@@ -176,10 +178,10 @@ public abstract class AbstractAssociatio
      * then delegates to {@link #setValue(Feature)}.</p>
      *
      * @param  values The new values.
-     * @throws IllegalArgumentException if the given collection contains too many elements.
+     * @throws InvalidPropertyValueException if the given collection contains too many elements.
      */
     @Override
-    public void setValues(final Collection<? extends Feature> values) throws IllegalArgumentException
{
+    public void setValues(final Collection<? extends Feature> values) throws InvalidPropertyValueException
{
         super.setValues(values);
     }
 
@@ -189,7 +191,7 @@ public abstract class AbstractAssociatio
      */
     final void ensureValid(final FeatureType base, final FeatureType type) {
         if (base != type && !DefaultFeatureType.maybeAssignableFrom(base, type))
{
-            throw new IllegalArgumentException(
+            throw new InvalidPropertyValueException(
                     Errors.format(Errors.Keys.IllegalArgumentClass_3, getName(), base.getName(),
type.getName()));
         }
     }

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAttribute.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAttribute.java?rev=1686191&r1=1686190&r2=1686191&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAttribute.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractAttribute.java
[UTF-8] Thu Jun 18 11:33:59 2015
@@ -35,6 +35,8 @@ import org.apache.sis.util.ArgumentCheck
 // Branch-dependent imports
 import org.opengis.feature.Attribute;
 import org.opengis.feature.AttributeType;
+import org.opengis.feature.InvalidPropertyValueException;
+import org.opengis.feature.MultiValuedPropertyException;
 
 
 /**
@@ -67,7 +69,7 @@ import org.opengis.feature.AttributeType
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see DefaultAttributeType#newInstance()
@@ -206,12 +208,12 @@ public abstract class AbstractAttribute<
      * of attribute values is restricted to 1 or 0.
      *
      * @return The attribute value (may be {@code null}).
-     * @throws IllegalStateException if this attribute contains more than one value.
+     * @throws MultiValuedPropertyException if this attribute contains more than one value.
      *
      * @see AbstractFeature#getPropertyValue(String)
      */
     @Override
-    public abstract V getValue() throws IllegalStateException;
+    public abstract V getValue() throws MultiValuedPropertyException;
 
     /**
      * Returns all attribute values, or an empty collection if none.
@@ -251,10 +253,10 @@ public abstract class AbstractAttribute<
      * then delegates to {@link #setValue(Object)}.</p>
      *
      * @param  values The new values.
-     * @throws IllegalArgumentException if the given collection contains too many elements.
+     * @throws InvalidPropertyValueException if the given collection contains too many elements.
      */
     @Override
-    public void setValues(final Collection<? extends V> values) throws IllegalArgumentException
{
+    public void setValues(final Collection<? extends V> values) throws InvalidPropertyValueException
{
         super.setValues(values);
     }
 

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=1686191&r1=1686190&r2=1686191&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] Thu Jun 18 11:33:59 2015
@@ -31,6 +31,8 @@ import org.apache.sis.internal.util.Chec
 // Branch-dependent imports
 import org.opengis.feature.Property;
 import org.opengis.feature.PropertyType;
+import org.opengis.feature.PropertyNotFoundException;
+import org.opengis.feature.InvalidPropertyValueException;
 import org.opengis.feature.Attribute;
 import org.opengis.feature.AttributeType;
 import org.opengis.feature.Feature;
@@ -130,13 +132,13 @@ public abstract class AbstractFeature im
      *
      * @param  name The property name.
      * @return The property of the given name (never {@code null}).
-     * @throws IllegalArgumentException If the given argument is not a property name of this
feature.
+     * @throws PropertyNotFoundException if the given argument is not a property name of
this feature.
      *
      * @see #getPropertyValue(String)
      * @see DefaultFeatureType#getProperty(String)
      */
     @Override
-    public abstract Property getProperty(final String name) throws IllegalArgumentException;
+    public abstract Property getProperty(final String name) throws PropertyNotFoundException;
 
     /**
      * Sets the property (attribute or feature association).
@@ -159,8 +161,9 @@ public abstract class AbstractFeature im
      * the {@link #setPropertyValue(String, Object)} method is preferred.</div>
      *
      * @param  property The property to set.
-     * @throws IllegalArgumentException if the type of the given property is not one of the
types
-     *         known to this feature, or if the property can not be set of an other reason.
+     * @throws PropertyNotFoundException if the name of the given property is not a property
name of this feature.
+     * @throws InvalidPropertyValueException if the value of the given property is not valid.
+     * @throws IllegalArgumentException if the property can not be set for another reason.
      *
      * @see #setPropertyValue(String, Object)
      */
@@ -192,10 +195,10 @@ public abstract class AbstractFeature im
      *
      * @param  name The name of the property to create.
      * @return A {@code Property} of the given name.
-     * @throws IllegalArgumentException If the given argument is not the name of an attribute
or
+     * @throws PropertyNotFoundException if the given argument is not the name of an attribute
or
      *         feature association of this feature.
      */
-    final Property createProperty(final String name) throws IllegalArgumentException {
+    final Property createProperty(final String name) throws PropertyNotFoundException {
         final PropertyType pt = type.getProperty(name);
         if (pt instanceof AttributeType<?>) {
             return ((AttributeType<?>) pt).newInstance();
@@ -260,9 +263,9 @@ public abstract class AbstractFeature im
      *
      * @param  name The name of the property for which to get the default value.
      * @return The default value for the {@code Property} of the given name.
-     * @throws IllegalArgumentException If the given argument is not an attribute or association
name of this feature.
+     * @throws PropertyNotFoundException if the given argument is not an attribute or association
name of this feature.
      */
-    final Object getDefaultValue(final String name) throws IllegalArgumentException {
+    final Object getDefaultValue(final String name) throws PropertyNotFoundException {
         final PropertyType pt = type.getProperty(name);
         if (pt instanceof AttributeType<?>) {
             return getDefaultValue((AttributeType<?>) pt);
@@ -306,12 +309,12 @@ public abstract class AbstractFeature im
      *
      * @param  name The property name.
      * @return The value for the given property, or {@code null} if none.
-     * @throws IllegalArgumentException If the given argument is not an attribute or association
name of this feature.
+     * @throws PropertyNotFoundException if the given argument is not an attribute or association
name of this feature.
      *
      * @see AbstractAttribute#getValue()
      */
     @Override
-    public abstract Object getPropertyValue(final String name) throws IllegalArgumentException;
+    public abstract Object getPropertyValue(final String name) throws PropertyNotFoundException;
 
     /**
      * Sets the value for the property of the given name.
@@ -324,8 +327,9 @@ public abstract class AbstractFeature im
      *
      * @param  name  The attribute name.
      * @param  value The new value for the given attribute (may be {@code null}).
-     * @throws ClassCastException If the value is not assignable to the expected value class.
-     * @throws IllegalArgumentException If the given value can not be assigned for an other
reason.
+     * @throws PropertyNotFoundException if the given name is not an attribute or association
name of this feature.
+     * @throws ClassCastException if the value is not assignable to the expected value class.
+     * @throws InvalidPropertyValueException if the given value is not valid for a reason
other than its type.
      *
      * @see AbstractAttribute#setValue(Object)
      */
@@ -454,9 +458,11 @@ public abstract class AbstractFeature im
             throw illegalPropertyType(base.getName(), property.getClass());
         }
         if (pt != base) {
-            throw new IllegalArgumentException(base == null
-                    ? Errors.format(Errors.Keys.PropertyNotFound_2, getName(), name)
-                    : Errors.format(Errors.Keys.MismatchedPropertyType_1, name));
+            if (base == null) {
+                throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,
getName(), name));
+            } else {
+                throw new InvalidPropertyValueException(Errors.format(Errors.Keys.MismatchedPropertyType_1,
name));
+            }
         }
     }
 
@@ -565,7 +571,7 @@ public abstract class AbstractFeature im
     }
 
     /**
-     * Returns the exception for a property type which neither an attribute or an association.
+     * Returns the exception for a property type which is neither an attribute or an association.
      * This method is invoked after a {@link PropertyType} has been found for the user-supplied
name,
      * but that property can not be stored in a {@link Property} instance.
      */
@@ -585,8 +591,8 @@ public abstract class AbstractFeature im
     /**
      * Returns the exception for a property value (usually a feature) of wrong type.
      */
-    private static IllegalArgumentException illegalPropertyType(final GenericName name, final
Object value) {
-        return new IllegalArgumentException(Errors.format(Errors.Keys.IllegalPropertyClass_2,
name, value));
+    private static InvalidPropertyValueException illegalPropertyType(final GenericName name,
final Object value) {
+        return new InvalidPropertyValueException(Errors.format(Errors.Keys.IllegalPropertyClass_2,
name, value));
     }
 
     /**

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=1686191&r1=1686190&r2=1686191&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] Thu Jun 18 11:33:59 2015
@@ -38,7 +38,7 @@ import org.opengis.feature.IdentifiedTyp
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  */
 public class AbstractIdentifiedType implements IdentifiedType, Serializable {
@@ -165,9 +165,7 @@ public class AbstractIdentifiedType impl
      * @param  identification The name and other information to be given to this identified
type.
      * @throws IllegalArgumentException if a property has an invalid value.
      */
-    protected AbstractIdentifiedType(final Map<String,?> identification)
-            throws IllegalArgumentException
-    {
+    protected AbstractIdentifiedType(final Map<String,?> identification) throws IllegalArgumentException
{
         ensureNonNull("identification", identification);
         Object value = identification.get(NAME_KEY);
         if (value == null) {

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/CharacteristicMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/CharacteristicMap.java?rev=1686191&r1=1686190&r2=1686191&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/CharacteristicMap.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/CharacteristicMap.java
[UTF-8] Thu Jun 18 11:33:59 2015
@@ -27,6 +27,8 @@ import org.apache.sis.internal.util.Abst
 // Branch-dependent imports
 import org.opengis.feature.Attribute;
 import org.opengis.feature.AttributeType;
+import org.opengis.feature.InvalidPropertyValueException;
+import org.opengis.feature.PropertyNotFoundException;
 
 
 /**
@@ -35,7 +37,7 @@ import org.opengis.feature.AttributeType
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  */
 final class CharacteristicMap extends AbstractMap<String,Attribute<?>> implements
Cloneable {
@@ -166,13 +168,13 @@ final class CharacteristicMap extends Ab
      *
      * @param  key The name for which to get the characteristic index.
      * @return The index for the characteristic of the given name.
-     * @throws IllegalArgumentException if the given key is not the name of a characteristic
in this map.
+     * @throws PropertyNotFoundException if the given key is not the name of a characteristic
in this map.
      */
     private int indexOf(final String key) {
         ArgumentChecks.ensureNonNull("key", key);
         final Integer index = types.indices.get(key);
         if (index == null) {
-            throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,
source.getName(), key));
+            throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,
source.getName(), key));
         }
         return index;
     }
@@ -190,7 +192,7 @@ final class CharacteristicMap extends Ab
         if (!expected.equals(type)) {
             final GenericName en = expected.getName();
             final GenericName an = type.getName();
-            throw new IllegalArgumentException(String.valueOf(en).equals(String.valueOf(an))
+            throw new InvalidPropertyValueException(String.valueOf(en).equals(String.valueOf(an))
                     ? Errors.format(Errors.Keys.MismatchedPropertyType_1, en)
                     : Errors.format(Errors.Keys.CanNotAssign_2, en.push(source.getName()),
an));
         }

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=1686191&r1=1686190&r2=1686191&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] Thu Jun 18 11:33:59 2015
@@ -46,6 +46,8 @@ import org.opengis.feature.Feature;
 import org.opengis.feature.FeatureType;
 import org.opengis.feature.FeatureAssociationRole;
 import org.opengis.feature.Operation;
+import org.opengis.feature.FeatureInstantiationException;
+import org.opengis.feature.PropertyNotFoundException;
 
 
 /**
@@ -606,7 +608,7 @@ public class DefaultFeatureType extends
             final PropertyType other;
             try {
                 other = type.getProperty(entry.getKey());
-            } catch (IllegalArgumentException e) {
+            } catch (PropertyNotFoundException e) {
                 /*
                  * A property in this FeatureType does not exist in the given FeatureType.
                  * Catching exceptions is not an efficient way to perform this check, but
@@ -712,17 +714,17 @@ public class DefaultFeatureType extends
      *
      * @param  name The name of the property to search.
      * @return The property for the given name, or {@code null} if none.
-     * @throws IllegalArgumentException If the given argument is not a property name of this
feature.
+     * @throws PropertyNotFoundException If the given argument is not a property name of
this feature.
      *
      * @see AbstractFeature#getProperty(String)
      */
     @Override
-    public PropertyType getProperty(final String name) throws IllegalArgumentException {
+    public PropertyType getProperty(final String name) throws PropertyNotFoundException {
         final PropertyType pt = byName.get(name);
         if (pt != null) {
             return pt;
         }
-        throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,
getName(), name));
+        throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,
getName(), name));
     }
 
     /**
@@ -741,12 +743,12 @@ public class DefaultFeatureType extends
      * then this method is equivalent to {@link Class#newInstance()}.</div>
      *
      * @return A new feature instance.
-     * @throws IllegalStateException if this feature type {@linkplain #isAbstract() is abstract}.
+     * @throws FeatureInstantiationException if this feature type {@linkplain #isAbstract()
is abstract}.
      */
     @Override
-    public Feature newInstance() throws IllegalStateException {
+    public Feature newInstance() throws FeatureInstantiationException {
         if (isAbstract) {
-            throw new IllegalStateException(Errors.format(Errors.Keys.AbstractType_1, getName()));
+            throw new FeatureInstantiationException(Errors.format(Errors.Keys.AbstractType_1,
getName()));
         }
         return isSparse ? new SparseFeature(this) : new DenseFeature(this);
     }

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java?rev=1686191&r1=1686190&r2=1686191&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
[UTF-8] Thu Jun 18 11:33:59 2015
@@ -28,6 +28,7 @@ import org.apache.sis.util.resources.Err
 import org.opengis.feature.Property;
 import org.opengis.feature.Attribute;
 import org.opengis.feature.FeatureAssociation;
+import org.opengis.feature.PropertyNotFoundException;
 
 
 /**
@@ -84,14 +85,14 @@ final class DenseFeature extends Abstrac
      * @param  name The property name.
      * @return The index for the property of the given name,
      *         or a negative value if the property is a parameterless operation.
-     * @throws IllegalArgumentException If the given argument is not a property name of this
feature.
+     * @throws PropertyNotFoundException if the given argument is not a property name of
this feature.
      */
-    private int getIndex(final String name) throws IllegalArgumentException {
+    private int getIndex(final String name) throws PropertyNotFoundException {
         final Integer index = indices.get(name);
         if (index != null) {
             return index;
         }
-        throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,
getName(), name));
+        throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,
getName(), name));
     }
 
     /**
@@ -99,10 +100,10 @@ final class DenseFeature extends Abstrac
      *
      * @param  name The property name.
      * @return The property of the given name.
-     * @throws IllegalArgumentException If the given argument is not a property name of this
feature.
+     * @throws PropertyNotFoundException If the given argument is not a property name of
this feature.
      */
     @Override
-    public Property getProperty(final String name) throws IllegalArgumentException {
+    public Property getProperty(final String name) throws PropertyNotFoundException {
         ArgumentChecks.ensureNonNull("name", name);
         final int index = getIndex(name);
         if (index < 0) {
@@ -132,7 +133,7 @@ final class DenseFeature extends Abstrac
      *
      * @param  property The property to set.
      * @throws IllegalArgumentException if the type of the given property is not one of the
types
-     *         known to this feature.
+     *         known to this feature, or if the property can not be set or another reason.
      */
     @Override
     public void setProperty(final Property property) throws IllegalArgumentException {
@@ -175,10 +176,10 @@ final class DenseFeature extends Abstrac
      *
      * @param  name The property name.
      * @return The value for the given property, or {@code null} if none.
-     * @throws IllegalArgumentException If the given argument is not an attribute or association
name of this feature.
+     * @throws PropertyNotFoundException If the given argument is not an attribute or association
name of this feature.
      */
     @Override
-    public Object getPropertyValue(final String name) throws IllegalArgumentException {
+    public Object getPropertyValue(final String name) throws PropertyNotFoundException {
         ArgumentChecks.ensureNonNull("name", name);
         final int index = getIndex(name);
         if (index < 0) {
@@ -207,7 +208,7 @@ final class DenseFeature extends Abstrac
      * @param  name  The attribute name.
      * @param  value The new value for the given attribute (may be {@code null}).
      * @throws ClassCastException If the value is not assignable to the expected value class.
-     * @throws IllegalArgumentException If the given value can not be assigned for an other
reason.
+     * @throws IllegalArgumentException If the given value can not be assigned for another
reason.
      */
     @Override
     public void setPropertyValue(final String name, Object value) throws IllegalArgumentException
{

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Field.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Field.java?rev=1686191&r1=1686190&r2=1686191&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Field.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Field.java [UTF-8]
Thu Jun 18 11:33:59 2015
@@ -23,6 +23,9 @@ import org.apache.sis.util.resources.Err
 
 // Branch-dependent imports
 import org.opengis.feature.Property;
+import org.opengis.feature.MultiValuedPropertyException;
+import org.opengis.feature.InvalidPropertyValueException;
+
 
 /**
  * Base class of property that can be stored in a {@link AbstractFeature} instance.
@@ -30,7 +33,7 @@ import org.opengis.feature.Property;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  */
 abstract class Field<V> implements Property {
@@ -55,12 +58,12 @@ abstract class Field<V> implements Prope
      * Returns the field feature or attribute value, or {@code null} if none.
      *
      * @return The feature or attribute value (may be {@code null}).
-     * @throws IllegalStateException if this field contains more than one value.
+     * @throws MultiValuedPropertyException if this field contains more than one value.
      *
      * @see AbstractFeature#getPropertyValue(String)
      */
     @Override
-    public abstract V getValue() throws IllegalStateException;
+    public abstract V getValue() throws MultiValuedPropertyException;
 
     /**
      * Returns all features or attribute values, or an empty collection if none.
@@ -89,16 +92,16 @@ abstract class Field<V> implements Prope
      * then delegates to {@link #setValue(Object)}.</p>
      *
      * @param values The new values.
-     * @throws IllegalArgumentException if the given collection contains too many elements.
+     * @throws InvalidPropertyValueException if the given collection contains too many elements.
      */
-    public void setValues(final Collection<? extends V> values) throws IllegalArgumentException
{
+    public void setValues(final Collection<? extends V> values) throws InvalidPropertyValueException
{
         V value = null;
         ArgumentChecks.ensureNonNull("values", values);
         final Iterator<? extends V> it = values.iterator();
         if (it.hasNext()) {
             value = it.next();
             if (it.hasNext()) {
-                throw new IllegalArgumentException(Errors.format(Errors.Keys.TooManyOccurrences_2,
1, getName()));
+                throw new InvalidPropertyValueException(Errors.format(Errors.Keys.TooManyOccurrences_2,
1, getName()));
             }
         }
         setValue(value);

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAssociation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAssociation.java?rev=1686191&r1=1686190&r2=1686191&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAssociation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAssociation.java
[UTF-8] Thu Jun 18 11:33:59 2015
@@ -25,6 +25,7 @@ import org.apache.sis.util.resources.Err
 import org.opengis.feature.Feature;
 import org.opengis.feature.FeatureType;
 import org.opengis.feature.FeatureAssociationRole;
+import org.opengis.feature.MultiValuedPropertyException;
 
 
 /**
@@ -44,7 +45,7 @@ import org.opengis.feature.FeatureAssoci
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see DefaultAssociationRole
@@ -89,14 +90,14 @@ final class MultiValuedAssociation exten
      * Returns the feature, or {@code null} if none.
      *
      * @return The feature (may be {@code null}).
-     * @throws IllegalStateException if this association contains more than one value.
+     * @throws MultiValuedPropertyException if this association contains more than one value.
      */
     @Override
     public Feature getValue() {
         switch (values.size()) {
             case 0:  return null;
             case 1:  return values.get(0);
-            default: throw new IllegalStateException(Errors.format(Errors.Keys.NotASingleton_1,
getName()));
+            default: throw new MultiValuedPropertyException(Errors.format(Errors.Keys.NotASingleton_1,
getName()));
         }
     }
 

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAttribute.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAttribute.java?rev=1686191&r1=1686190&r2=1686191&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAttribute.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/MultiValuedAttribute.java
[UTF-8] Thu Jun 18 11:33:59 2015
@@ -23,6 +23,7 @@ import org.apache.sis.util.resources.Err
 
 // Branch-dependent imports
 import org.opengis.feature.AttributeType;
+import org.opengis.feature.MultiValuedPropertyException;
 
 
 /**
@@ -45,7 +46,7 @@ import org.opengis.feature.AttributeType
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see DefaultAttributeType
@@ -100,14 +101,14 @@ final class MultiValuedAttribute<V> exte
      * Returns the attribute value, or {@code null} if none.
      *
      * @return The attribute value (may be {@code null}).
-     * @throws IllegalStateException if this attribute contains more than one value.
+     * @throws MultiValuedPropertyException if this attribute contains more than one value.
      */
     @Override
     public V getValue() {
         switch (values.size()) {
             case 0:  return null;
             case 1:  return values.get(0);
-            default: throw new IllegalStateException(Errors.format(Errors.Keys.NotASingleton_1,
getName()));
+            default: throw new MultiValuedPropertyException(Errors.format(Errors.Keys.NotASingleton_1,
getName()));
         }
     }
 

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/NamedFeatureType.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/NamedFeatureType.java?rev=1686191&r1=1686190&r2=1686191&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/NamedFeatureType.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/NamedFeatureType.java
[UTF-8] Thu Jun 18 11:33:59 2015
@@ -23,6 +23,8 @@ import java.io.Serializable;
 import org.opengis.feature.Feature;
 import org.opengis.feature.FeatureType;
 import org.opengis.feature.PropertyType;
+import org.opengis.feature.PropertyNotFoundException;
+import org.opengis.feature.FeatureInstantiationException;
 import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import org.apache.sis.util.resources.Errors;
@@ -35,7 +37,7 @@ import org.apache.sis.util.resources.Err
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  */
 final class NamedFeatureType implements FeatureType, Serializable {
@@ -86,11 +88,11 @@ final class NamedFeatureType implements
     }
 
     /**
-     * Always throws {@link IllegalArgumentException} since this feature type has no declared
property yet.
+     * Always throws {@link PropertyNotFoundException} since this feature type has no declared
property yet.
      */
     @Override
-    public PropertyType getProperty(final String name) throws IllegalArgumentException {
-        throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,
getName(), name));
+    public PropertyType getProperty(final String name) throws PropertyNotFoundException {
+        throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,
getName(), name));
     }
 
     /**
@@ -121,8 +123,8 @@ final class NamedFeatureType implements
      * Unsupported operation, since the feature has not yet been resolved.
      */
     @Override
-    public Feature newInstance() throws IllegalStateException {
-        throw new IllegalStateException(Errors.format(Errors.Keys.UnresolvedFeatureName_1,
getName()));
+    public Feature newInstance() throws FeatureInstantiationException {
+        throw new FeatureInstantiationException(Errors.format(Errors.Keys.UnresolvedFeatureName_1,
getName()));
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAssociation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAssociation.java?rev=1686191&r1=1686190&r2=1686191&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAssociation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SingletonAssociation.java
[UTF-8] Thu Jun 18 11:33:59 2015
@@ -20,6 +20,7 @@ package org.apache.sis.feature;
 import java.util.Objects;
 import org.opengis.feature.Feature;
 import org.opengis.feature.FeatureAssociationRole;
+import org.opengis.feature.InvalidPropertyValueException;
 
 
 /**
@@ -36,7 +37,7 @@ import org.opengis.feature.FeatureAssoci
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see DefaultAssociationRole
@@ -91,10 +92,10 @@ final class SingletonAssociation extends
      * Sets the associated feature.
      *
      * @param  value The new value, or {@code null}.
-     * @throws IllegalArgumentException If the given feature is not valid for this association.
+     * @throws InvalidPropertyValueException If the given feature is not valid for this association.
      */
     @Override
-    public void setValue(final Feature value) {
+    public void setValue(final Feature value) throws InvalidPropertyValueException {
         if (value != null) {
             ensureValid(role.getValueType(), value.getType());
         }

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java?rev=1686191&r1=1686190&r2=1686191&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
[UTF-8] Thu Jun 18 11:33:59 2015
@@ -30,6 +30,7 @@ import org.apache.sis.util.resources.Err
 import org.opengis.feature.Property;
 import org.opengis.feature.Attribute;
 import org.opengis.feature.FeatureAssociation;
+import org.opengis.feature.PropertyNotFoundException;
 
 
 /**
@@ -118,14 +119,14 @@ final class SparseFeature extends Abstra
      * @param  name The property name.
      * @return The index for the property of the given name,
      *         or a negative value if the property is a parameterless operation.
-     * @throws IllegalArgumentException If the given argument is not a property name of this
feature.
+     * @throws PropertyNotFoundException If the given argument is not a property name of
this feature.
      */
-    private int getIndex(final String name) throws IllegalArgumentException {
+    private int getIndex(final String name) throws PropertyNotFoundException {
         final Integer index = indices.get(name);
         if (index != null) {
             return index;
         }
-        throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,
getName(), name));
+        throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,
getName(), name));
     }
 
     /**
@@ -170,10 +171,10 @@ final class SparseFeature extends Abstra
      *
      * @param  name The property name.
      * @return The property of the given name.
-     * @throws IllegalArgumentException If the given argument is not a property name of this
feature.
+     * @throws PropertyNotFoundException If the given argument is not a property name of
this feature.
      */
     @Override
-    public Property getProperty(final String name) throws IllegalArgumentException {
+    public Property getProperty(final String name) throws PropertyNotFoundException {
         ArgumentChecks.ensureNonNull("name", name);
         requireMapOfProperties();
         return getPropertyInstance(name);
@@ -183,7 +184,7 @@ final class SparseFeature extends Abstra
      * Implementation of {@link #getProperty(String)} invoked when we know that the {@link
#properties}
      * map contains {@code Property} instances (as opposed to their value).
      */
-    private Property getPropertyInstance(final String name) throws IllegalArgumentException
{
+    private Property getPropertyInstance(final String name) throws PropertyNotFoundException
{
         assert valuesKind == PROPERTIES : valuesKind;
         final Integer index = getIndex(name);
         if (index < 0) {
@@ -202,7 +203,7 @@ final class SparseFeature extends Abstra
      *
      * @param  property The property to set.
      * @throws IllegalArgumentException if the type of the given property is not one of the
types
-     *         known to this feature.
+     *         known to this feature, or if the property can not be set for another reason.
      */
     @Override
     public void setProperty(final Property property) throws IllegalArgumentException {
@@ -222,10 +223,10 @@ final class SparseFeature extends Abstra
      *
      * @param  name The property name.
      * @return The value for the given property, or {@code null} if none.
-     * @throws IllegalArgumentException If the given argument is not an attribute or association
name of this feature.
+     * @throws PropertyNotFoundException If the given argument is not an attribute or association
name of this feature.
      */
     @Override
-    public Object getPropertyValue(final String name) throws IllegalArgumentException {
+    public Object getPropertyValue(final String name) throws PropertyNotFoundException {
         ArgumentChecks.ensureNonNull("name", name);
         final Integer index = getIndex(name);
         if (index < 0) {
@@ -257,7 +258,7 @@ final class SparseFeature extends Abstra
      * @param  name  The attribute name.
      * @param  value The new value for the given attribute (may be {@code null}).
      * @throws ClassCastException If the value is not assignable to the expected value class.
-     * @throws IllegalArgumentException If the given value can not be assigned for an other
reason.
+     * @throws IllegalArgumentException If the given value can not be assigned for another
reason.
      */
     @Override
     public void setPropertyValue(final String name, final Object value) throws IllegalArgumentException
{



Mime
View raw message