sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1701294 - in /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis: internal/jaxb/referencing/ referencing/crs/ referencing/operation/
Date Fri, 04 Sep 2015 17:05:51 GMT
Author: desruisseaux
Date: Fri Sep  4 17:05:51 2015
New Revision: 1701294

URL: http://svn.apache.org/r1701294
Log:
Safety checks against some NullPointerException.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/SC_GeographicCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java?rev=1701294&r1=1701293&r2=1701294&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
[UTF-8] Fri Sep  4 17:05:51 2015
@@ -156,6 +156,14 @@ public final class CC_GeneralOperationPa
     }
 
     /**
+     * Verifies that the given descriptor is non-null and contains at least a name.
+     * This method is used after unmarshalling.
+     */
+    static boolean isValid(final GeneralParameterDescriptor descriptor) {
+        return descriptor != null && descriptor.getName() != null;
+    }
+
+    /**
      * Returns a descriptor with the same properties than the {@code provided} one, but completed
with information
      * not found in GML. Those missing information are given by the {@code complete} descriptor,
which may come from
      * two sources:

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java?rev=1701294&r1=1701293&r2=1701294&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralParameterValue.java
[UTF-8] Fri Sep  4 17:05:51 2015
@@ -24,6 +24,7 @@ import org.opengis.parameter.GeneralPara
 import org.apache.sis.parameter.DefaultParameterValue;
 import org.apache.sis.parameter.DefaultParameterValueGroup;
 import org.apache.sis.internal.jaxb.gco.PropertyType;
+import org.apache.sis.util.resources.Errors;
 
 
 /**
@@ -109,6 +110,13 @@ public final class CC_GeneralParameterVa
      * @param parameter The unmarshalled element.
      */
     public void setElement(final GeneralParameterValue parameter) {
+        if (!CC_GeneralOperationParameter.isValid(parameter.getDescriptor())) {
+            /*
+             * Descriptors are mandatory and SIS classes need them. Provide an error message
+             * here instead than waiting for a NullPointerException in some arbitrary place.
+             */
+            throw new IllegalArgumentException(Errors.format(Errors.Keys.MissingValueForProperty_1,
"operationParameter"));
+        }
         metadata = parameter;
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java?rev=1701294&r1=1701293&r2=1701294&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationMethod.java
[UTF-8] Fri Sep  4 17:05:51 2015
@@ -40,6 +40,7 @@ import org.apache.sis.parameter.DefaultP
 import org.apache.sis.parameter.DefaultParameterDescriptorGroup;
 import org.apache.sis.referencing.operation.DefaultOperationMethod;
 import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArraysExt;
 
 
@@ -108,6 +109,13 @@ public final class CC_OperationMethod ex
      * @param method The unmarshalled element.
      */
     public void setElement(final DefaultOperationMethod method) {
+        if (!CC_GeneralOperationParameter.isValid(method.getParameters())) {
+            /*
+             * Parameters are mandatory and SIS classes need them. Provide an error message
+             * here instead than waiting for a NullPointerException in some arbitrary place.
+             */
+            throw new IllegalArgumentException(Errors.format(Errors.Keys.MissingValueForProperty_1,
"parameters"));
+        }
         metadata = method;
     }
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/SC_GeographicCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/SC_GeographicCRS.java?rev=1701294&r1=1701293&r2=1701294&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/SC_GeographicCRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/SC_GeographicCRS.java
[UTF-8] Fri Sep  4 17:05:51 2015
@@ -16,8 +16,8 @@
  */
 package org.apache.sis.referencing.crs;
 
-import org.opengis.referencing.crs.GeographicCRS;
 import javax.xml.bind.annotation.XmlElement;
+import org.opengis.referencing.crs.GeographicCRS;
 import org.apache.sis.internal.jaxb.gco.PropertyType;
 
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java?rev=1701294&r1=1701293&r2=1701294&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
[UTF-8] Fri Sep  4 17:05:51 2015
@@ -798,6 +798,13 @@ public class DefaultOperationMethod exte
      * But we would need to make sure that {@link AbstractSingleOperation#getParameters()}
is consistent
      * with the decision taken by this method.</div>
      *
+     * <p><b>Historical note:</b> older, deprecated, names for the parameters
were:
+     * <ul>
+     *   <li>{@code includesParameter}</li>
+     *   <li>{@code generalOperationParameter} - note that this name was used by the
EPSG registry</li>
+     *   <li>{@code usesParameter}</li>
+     * </ul>
+     *
      * @see #getParameters()
      * @see AbstractSingleOperation#getParameters()
      */



Mime
View raw message