sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1723257 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/provider/ main/java/org/apache/sis/parameter/ main/java/org/apache/sis/referencing/factory/sql/ test/java/org/apache/sis/referencing/fa...
Date Wed, 06 Jan 2016 09:33:50 GMT
Author: desruisseaux
Date: Wed Jan  6 09:33:50 2016
New Revision: 1723257

URL: http://svn.apache.org/viewvc?rev=1723257&view=rev
Log:
Consolidation in the way FileParameter are handled.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java?rev=1723257&r1=1723256&r2=1723257&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftGridLoader.java
[UTF-8] Wed Jan  6 09:33:50 2016
@@ -22,13 +22,17 @@ import java.io.EOFException;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.channels.ReadableByteChannel;
+import org.opengis.util.FactoryException;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.resources.Messages;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.referencing.factory.FactoryDataException;
+import org.apache.sis.referencing.factory.MissingFactoryResourceException;
 
 // Branch-dependent imports
 import java.nio.file.Path;
+import java.nio.file.NoSuchFileException;
 
 
 /**
@@ -146,4 +150,20 @@ class DatumShiftGridLoader {
         record.setLoggerName(Loggers.COORDINATE_OPERATION);
         Logging.log(caller, "createMathTransform", record);
     }
+
+    /**
+     * Creates the exception to thrown when the provider failed to load the grid file.
+     *
+     * @param format   The format name (e.g. "NTv2" or "NADCON").
+     * @param file     The grid file that the subclass tried to load.
+     * @param cause    The cause of the failure to load the grid file.
+     */
+    static FactoryException canNotLoad(final String format, final Path file, final Exception
cause) {
+        final String message = Errors.format(Errors.Keys.CanNotParseFile_2, format, file);
+        if (cause instanceof NoSuchFileException) {
+            return new MissingFactoryResourceException(message, cause);
+        } else {
+            return new FactoryDataException(message, cause);
+        }
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java?rev=1723257&r1=1723256&r2=1723257&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
[UTF-8] Wed Jan  6 09:33:50 2016
@@ -41,8 +41,6 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.Transformation;
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
-import org.apache.sis.referencing.factory.MissingFactoryResourceException;
-import org.apache.sis.referencing.factory.FactoryDataException;
 import org.opengis.util.FactoryException;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.system.DataDirectory;
@@ -64,7 +62,6 @@ import static java.lang.Float.parseFloat
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.Files;
-import java.nio.file.NoSuchFileException;
 
 
 /**
@@ -372,12 +369,7 @@ public class FranceGeocentricInterpolati
                         grid = DatumShiftGridCompressed.compress(g, averages, scale);
                     } catch (IOException | NoninvertibleTransformException | RuntimeException
e) {
                         // NumberFormatException, ArithmeticException, NoSuchElementException,
possibly other.
-                        final String message = Errors.format(Errors.Keys.CanNotParseFile_2,
HEADER, file);
-                        if (e instanceof NoSuchFileException) {
-                            throw new MissingFactoryResourceException(message, e);
-                        } else {
-                            throw new FactoryDataException(message, e);
-                        }
+                        throw DatumShiftGridLoader.canNotLoad(HEADER, file, e);
                     }
                     grid = grid.useSharedData();
                 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java?rev=1723257&r1=1723256&r2=1723257&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NADCON.java
[UTF-8] Wed Jan  6 09:33:50 2016
@@ -34,8 +34,6 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.Transformation;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
-import org.apache.sis.referencing.factory.MissingFactoryResourceException;
-import org.apache.sis.referencing.factory.FactoryDataException;
 import org.apache.sis.referencing.operation.transform.InterpolatedTransform;
 import org.apache.sis.parameter.ParameterBuilder;
 import org.apache.sis.parameter.Parameters;
@@ -48,7 +46,6 @@ import org.apache.sis.internal.system.Da
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.Files;
-import java.nio.file.NoSuchFileException;
 
 
 /**
@@ -179,12 +176,7 @@ public final class NADCON extends Abstra
                             new Loader(in, buffer, file).readGrid(fb, loader, null);
                         }
                     } catch (IOException | NoninvertibleTransformException | RuntimeException
e) {
-                        final String message = Errors.format(Errors.Keys.CanNotParseFile_2,
"NADCON", file);
-                        if (e instanceof NoSuchFileException) {
-                            throw new MissingFactoryResourceException(message, e);
-                        } else {
-                            throw new FactoryDataException(message, e);
-                        }
+                        throw DatumShiftGridLoader.canNotLoad("NADCON", file, e);
                     }
                     grid = DatumShiftGridCompressed.compress(loader.grid, null, loader.grid.accuracy);
                     grid = grid.useSharedData();

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java?rev=1723257&r1=1723256&r2=1723257&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/NTv2.java
[UTF-8] Wed Jan  6 09:33:50 2016
@@ -40,8 +40,6 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.Transformation;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
-import org.apache.sis.referencing.factory.MissingFactoryResourceException;
-import org.apache.sis.referencing.factory.FactoryDataException;
 import org.apache.sis.referencing.operation.transform.InterpolatedTransform;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.system.DataDirectory;
@@ -55,7 +53,6 @@ import org.apache.sis.util.resources.Mes
 // Branch-dependent imports
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.NoSuchFileException;
 import java.nio.charset.StandardCharsets;
 
 
@@ -153,12 +150,7 @@ public final class NTv2 extends Abstract
                         grid = loader.readGrid();
                         loader.reportWarnings();
                     } catch (IOException | NoninvertibleTransformException | RuntimeException
e) {
-                        final String message = Errors.format(Errors.Keys.CanNotParseFile_2,
"NTv2", file);
-                        if (e instanceof NoSuchFileException) {
-                            throw new MissingFactoryResourceException(message, e);
-                        } else {
-                            throw new FactoryDataException(message, e);
-                        }
+                        throw DatumShiftGridLoader.canNotLoad("NTv2", file, e);
                     }
                     grid = grid.useSharedData();
                 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java?rev=1723257&r1=1723256&r2=1723257&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] Wed Jan  6 09:33:50 2016
@@ -514,7 +514,7 @@ public class DefaultParameterValue<T> ex
      * Same as {@link #isFile(Object)}, but accepts also a {@link String} if the type specified
      * in the parameter descriptor is one of the types documented in {@link #valueFile()}.
      */
-    private boolean isFileOrString(final Object value) {
+    private boolean isOrNeedFile(final Object value) {
         if (value instanceof String) {
             final Class<?> type = descriptor.getValueClass();
             return (type == URI.class) || (type == URL.class)
@@ -567,7 +567,7 @@ public class DefaultParameterValue<T> ex
          * to allow too many conversions for reducing the risk of unexpected behavior.  If
we fail to convert, try
          * to set the value anyway since the user may have redefined the setValue(Object,
Unit) method.
          */
-        if (isFileOrString(value)) try {
+        if (isOrNeedFile(value)) try {
             value = ObjectConverters.convert(value, descriptor.getValueClass());
         } catch (UnconvertibleObjectException e) {
             // Level.FINE (not WARNING) because this log duplicates the exception

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1723257&r1=1723256&r2=1723257&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
[UTF-8] Wed Jan  6 09:33:50 2016
@@ -106,6 +106,8 @@ import org.apache.sis.util.Version;
 import org.apache.sis.measure.Units;
 import org.apache.sis.measure.MeasurementRange;
 
+// Branch-dependent imports
+
 
 /**
  * <cite>Data Access Object</cite> (DAO) creating geodetic objects from a JDBC
connection to an EPSG database.
@@ -2311,7 +2313,7 @@ addURIs:    for (int i=0; ; i++) {
                 final String name  = getString(operation, result, 1);
                 final double value = getOptionalDouble(result, 2);
                 final Unit<?> unit;
-                Object reference;
+                String reference;
                 if (Double.isNaN(value)) {
                     /*
                      * If no numeric values were provided in the database, then the values
should be

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java?rev=1723257&r1=1723256&r2=1723257&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
[UTF-8] Wed Jan  6 09:33:50 2016
@@ -663,6 +663,7 @@ public final strictfp class EPSGFactoryT
     @Test
     @DependsOnMethod("testProjected_32210")
     public void testCreateFromCoordinateReferenceSystemCodes() throws FactoryException {
+        assumeNotNull(factory);
         final ProjectedCRS crs = factory.createProjectedCRS("32210");
         assertEquals("baseCRS", "4322", getIdentifier(crs.getBaseCRS()));
         final Set<CoordinateOperation> all = factory.createFromCoordinateReferenceSystemCodes("4322",
"32210");



Mime
View raw message