sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1633816 [1/3] - in /sis/branches/JDK8: core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ core/sis-build-helper/src/test/ core/sis-build-helper/src/test/java/ core/sis-build-helper/src/test/java/org/ core/sis-build-helper/s...
Date Thu, 23 Oct 2014 14:05:59 GMT
Author: desruisseaux
Date: Thu Oct 23 14:05:57 2014
New Revision: 1633816

URL: http://svn.apache.org/r1633816
Log:
Review of JDBC base driver class:
- Retrofit resources in to the SIS system.
- Do not log exceptions.
- Provide default implementations for some methods.
- Rearrange method order for keeping together related methods.

Added:
    sis/branches/JDK8/core/sis-build-helper/src/test/
    sis/branches/JDK8/core/sis-build-helper/src/test/java/
    sis/branches/JDK8/core/sis-build-helper/src/test/java/org/
    sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/
    sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/sis/
    sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/sis/util/
    sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/sis/util/resources/
    sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/sis/util/resources/ResourceCompilerMojoTest.java   (with props)
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.java   (with props)
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.properties   (with props)
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources_fr.properties   (with props)
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java
      - copied, changed from r1633642, sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/ResultSetTest.java
Removed:
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/InvalidDbaseFileFormatException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/ConnectionTest.java
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/ResultSetTest.java
Modified:
    sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Version.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
    sis/branches/JDK8/ide-project/NetBeans/build.xml
    sis/branches/JDK8/storage/sis-shapefile/pom.xml
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractConnection.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractResultSet.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractStatement.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFConnection.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSet.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFStatement.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/package-info.java
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java

Modified: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ResourceCompilerMojo.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -18,6 +18,7 @@ package org.apache.sis.util.resources;
 
 import java.io.File;
 import java.io.FilenameFilter;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.maven.model.Resource;
@@ -27,6 +28,9 @@ import org.apache.maven.project.MavenPro
 import org.codehaus.plexus.util.Scanner;
 import org.sonatype.plexus.build.incremental.BuildContext;
 
+import static org.apache.sis.util.resources.IndexedResourceCompiler.JAVA_EXT;
+import static org.apache.sis.util.resources.IndexedResourceCompiler.PROPERTIES_EXT;
+
 
 /**
  * Compiles the international resources that are found in the module from which this mojo is invoked.
@@ -35,7 +39,7 @@ import org.sonatype.plexus.build.increme
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Olivier Nouguier (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
- * @version 0.4
+ * @version 0.5
  * @module
  *
  * @goal compile-resources
@@ -96,6 +100,12 @@ public class ResourceCompilerMojo extend
     private File javaDirectoryFile;
 
     /**
+     * Constructs a new resource compiler MOJO.
+     */
+    public ResourceCompilerMojo() {
+    }
+
+    /**
      * Executes the mojo.
      *
      * @throws MojoExecutionException if the plugin execution failed.
@@ -146,8 +156,8 @@ public class ResourceCompilerMojo extend
     }
 
     /**
-     * Recursively scans the directories for a sub-package named "resources",
-     * then invokes the resource compiler for that directory.
+     * Recursively scans the directories and find all Java classes having a property files of the same name.
+     * Then invokes the resource compiler for those files.
      */
     private int processAllResourceDirectories(final File directory) throws ResourceCompilerException {
         int errors = 0;
@@ -155,14 +165,16 @@ public class ResourceCompilerMojo extend
         if (subdirs != null) { // Appears to be sometime null with auto-generated sub-directories.
             for (final File subdir : subdirs) {
                 if (subdir.isDirectory()) {
-                    if (subdir.getName().equals("resources")) {
-                        final File[] resourcesToProcess = subdir.listFiles(this);
-                        if (resourcesToProcess != null && resourcesToProcess.length != 0) {
+                    File[] resourcesToProcess = subdir.listFiles(this);
+                    int count = filterLanguages(resourcesToProcess);
+                    if (count != 0) {
+                        count = toJavaSourceFiles(resourcesToProcess, count);
+                        if (count != 0) {
+                            resourcesToProcess = Arrays.copyOf(resourcesToProcess, count);
                             errors += new Compiler(resourcesToProcess).run();
                         }
-                    } else {
-                        errors += processAllResourceDirectories(subdir);
                     }
+                    errors += processAllResourceDirectories(subdir);
                 }
             }
         }
@@ -170,22 +182,84 @@ public class ResourceCompilerMojo extend
     }
 
     /**
-     * Returns {@code true} if the given file is the source code for a resources bundle.
-     * This method returns {@code true} if the given file is a Java source file and if a
-     * properties file of the same name exists.
+     * Accepts all {@code "*.properties"} files.
      *
      * @param directory The directory.
      * @param name The file name.
      * @return {@code true} if the given file is a property file.
      */
     @Override
-    public final boolean accept(final File directory, String name) {
-        if (!name.endsWith(IndexedResourceCompiler.JAVA_EXT)) {
-            return false;
-        }
-        name = name.substring(0, name.length() - IndexedResourceCompiler.JAVA_EXT.length());
-        name += IndexedResourceCompiler.PROPERTIES_EXT;
-        return new File(directory, name).isFile();
+    public final boolean accept(final File directory, final String name) {
+        return name.endsWith(PROPERTIES_EXT);
+    }
+
+    /**
+     * Retains only the properties files which seems to be about internationalized resources.
+     * For example if the given array contains the following files:
+     * <ul>
+     *   <li>{@code "Errors.properties"}</li>
+     *   <li>{@code "Errors_en.properties"}</li>
+     *   <li>{@code "Errors_fr.properties"}</li>
+     *   <li>{@code "Messages.properties"}</li>
+     *   <li>{@code "Messages_en.properties"}</li>
+     *   <li>{@code "Messages_fr.properties"}</li>
+     *   <li>{@code "NotAnInternationalResource.properties"}</li>
+     * </ul>
+     *
+     * Then this method will retain the following files:
+     * <ul>
+     *   <li>{@code "Errors.properties"}</li>
+     *   <li>{@code "Messages.properties"}</li>
+     * </ul>
+     *
+     * @param  resourcesToProcess The files to filter. This array will be overwritten in-place.
+     * @return Number of valid elements in the {@code resourcesToProcess} after this method completion.
+     */
+    static int filterLanguages(final File[] resourcesToProcess) {
+        int count = 0;
+        if (resourcesToProcess != null) {
+            Arrays.sort(resourcesToProcess);
+            for (int i=0; i<resourcesToProcess.length;) {
+                final File file = resourcesToProcess[i];
+                String name = file.getName();
+                name = name.substring(0, name.length() - PROPERTIES_EXT.length()) + '_';
+                final int fileIndex = i;
+                while (++i < resourcesToProcess.length) {
+                    if (!resourcesToProcess[i].getName().startsWith(name)) {
+                        break;
+                    }
+                }
+                // Accepts the property file only if we found at least one language.
+                // Example: "Messages.properties" and "Messages_en.properties".
+                if (i - fileIndex >= 2) {
+                    resourcesToProcess[count++] = file;
+                }
+            }
+        }
+        return count;
+    }
+
+    /**
+     * Converts the given property files into Java source file, provided that the later exists.
+     * The given array is overwritten in place.
+     *
+     * @param  resourcesToProcess The filtered resource files, as returned by {@link #filterLanguages(File[])}.
+     * @param  count Number of valid elements in {@code resourcesToProcess}.
+     * @return Number of valid elements after this method completion.
+     */
+    private static int toJavaSourceFiles(final File[] resourcesToProcess, final int count) {
+        int n = 0;
+        for (int i=0; i<count; i++) {
+            File file = resourcesToProcess[i];
+            String name = file.getName();
+            name = name.substring(0, name.length() - PROPERTIES_EXT.length());
+            name += JAVA_EXT;
+            file = new File(file.getParentFile(), name);
+            if (file.isFile()) {
+                resourcesToProcess[n++] = file;
+            }
+        }
+        return n;
     }
 
     /**

Added: sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/sis/util/resources/ResourceCompilerMojoTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/sis/util/resources/ResourceCompilerMojoTest.java?rev=1633816&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/sis/util/resources/ResourceCompilerMojoTest.java (added)
+++ sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/sis/util/resources/ResourceCompilerMojoTest.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -0,0 +1,52 @@
+/*
+ * 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.util.resources;
+
+import java.io.File;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests {@link ResourceCompilerMojo}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.5
+ * @version 0.5
+ * @module
+ */
+public strictfp class ResourceCompilerMojoTest {
+    /**
+     * Tests {@link ResourceCompilerMojo#filterLanguages(File[])}.
+     */
+    @Test
+    public void testFilterLanguages() {
+        final File[] files = {
+            new File("Errors_en.properties"),
+            new File("Messages_fr.properties"),
+            new File("Errors.properties"),
+            new File("Errors_fr.properties"),
+            new File("ShallIgnore.properties"),
+            new File("Messages_en.properties"),
+            new File("Messages.properties")
+        };
+        assertEquals(2, ResourceCompilerMojo.filterLanguages(files));
+        assertEquals("Errors.properties",   files[0].getName());
+        assertEquals("Messages.properties", files[1].getName());
+    }
+}

Propchange: sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/sis/util/resources/ResourceCompilerMojoTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-build-helper/src/test/java/org/apache/sis/util/resources/ResourceCompilerMojoTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -24,7 +24,7 @@ package org.apache.sis.internal.system;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final class Modules {
@@ -54,6 +54,20 @@ public final class Modules {
     public static final String NETCDF = "org.apache.sis.storage.netcdf";
 
     /**
+     * The major version number of all Apache SIS modules.
+     *
+     * @see org.apache.sis.util.Version
+     */
+    public static final int MAJOR_VERSION = 0;
+
+    /**
+     * The minor version number of all Apache SIS modules.
+     *
+     * @see org.apache.sis.util.Version
+     */
+    public static final int MINOR_VERSION = 5;
+
+    /**
      * Do not allows instantiation of this class.
      */
     private Modules() {

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Version.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Version.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Version.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Version.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -20,6 +20,9 @@ import java.io.Serializable;
 import java.util.StringTokenizer;
 import org.apache.sis.util.resources.Errors;
 
+import static org.apache.sis.internal.system.Modules.MAJOR_VERSION;
+import static org.apache.sis.internal.system.Modules.MINOR_VERSION;
+
 
 /**
  * Holds a version number as a sequence of strings separated by either a dot or a dash.
@@ -57,7 +60,7 @@ public class Version implements CharSequ
     /**
      * The version of this Apache SIS distribution.
      */
-    public static final Version SIS = new Version("0.5-SNAPSHOT");
+    public static final Version SIS = new Version(MAJOR_VERSION + "." + MINOR_VERSION + "-SNAPSHOT");
 
     /**
      * A few commonly used version numbers. This list is based on SIS needs, e.g. in {@code DataStore}

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -165,6 +165,11 @@ public final class Errors extends Indexe
         public static final short DeadThread_1 = 15;
 
         /**
+         * The “{0}” file points to a directory instead of a regular file.
+         */
+        public static final short DirectoryNotExpected_1 = 165;
+
+        /**
          * Element “{0}” is duplicated.
          */
         public static final short DuplicatedElement_1 = 16;
@@ -230,6 +235,11 @@ public final class Errors extends Indexe
         public static final short ExcessiveStringSize = 153;
 
         /**
+         * File “{0}” has not been found.
+         */
+        public static final short FileNotFound_1 = 166;
+
+        /**
          * Attribute “{0}” is not allowed for an object of type ‘{1}’.
          */
         public static final short ForbiddenAttribute_2 = 26;

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Thu Oct 23 14:05:57 2014
@@ -44,6 +44,7 @@ ClassNotFinal_1                   = Clas
 CloneNotSupported_1               = Can not clone an object of type \u2018{0}\u2019.
 ColinearAxisDirections_2          = Axis directions {0} and {1} are colinear.
 DeadThread_1                      = Thread \u201c{0}\u201d is dead.
+DirectoryNotExpected_1            = The \u201c{0}\u201d file points to a directory instead of a regular file.
 DuplicatedElement_1               = Element \u201c{0}\u201d is duplicated.
 DuplicatedIdentifier_1            = Identifier \u201c{0}\u201d is duplicated.
 DuplicatedOption_1                = Option \u201c{0}\u201d is duplicated.
@@ -57,6 +58,7 @@ EmptyProperty_1                   = Prop
 ExcessiveArgumentSize_3           = Argument \u2018{0}\u2019 shall not contain more than {1} elements. A number of {2} is excessive.
 ExcessiveListSize_2               = A size of {1} elements is excessive for the \u201c{0}\u201d list.
 ExcessiveStringSize               = The character string is too long.
+FileNotFound_1                    = File \u201c{0}\u201d has not been found.
 ForbiddenAttribute_2              = Attribute \u201c{0}\u201d is not allowed for an object of type \u2018{1}\u2019.
 ForbiddenProperty_1               = Property \u201c{0}\u201d is not allowed.
 IllegalArgumentClass_2            = Argument \u2018{0}\u2019 can not be an instance of \u2018{1}\u2019.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Thu Oct 23 14:05:57 2014
@@ -34,6 +34,7 @@ ClassNotFinal_1                   = La c
 CloneNotSupported_1               = Un objet de type \u2018{0}\u2019 ne peut pas \u00eatre clon\u00e9.
 ColinearAxisDirections_2          = Les directions d\u2019axes {0} et {1} sont colin\u00e9aires.
 DeadThread_1                      = La t\u00e2che \u00ab\u202f{0}\u202f\u00bb est morte.
+DirectoryNotExpected_1            = Le fichier \u00ab\u202f{0}\u202f\u00bb d\u00e9signe un r\u00e9pertoire plut\u00f4t qu\u2019un fichier r\u00e9gulier.
 DuplicatedElement_1               = L\u2019\u00e9lement \u00ab\u202f{0}\u202f\u00bb est dupliqu\u00e9.
 DuplicatedIdentifier_1            = L\u2019identifiant \u00ab\u202f{0}\u202f\u00bb est dupliqu\u00e9.
 DuplicatedOption_1                = L\u2019option \u00ab\u202f{0}\u202f\u00bb est dupliqu\u00e9e.
@@ -47,6 +48,7 @@ EmptyProperty_1                   = La p
 ExcessiveArgumentSize_3           = L\u2019argument \u2018{0}\u2019 ne peut pas contenir plus de {1} \u00e9l\u00e9ments. Un nombre de {2} est excessif.
 ExcessiveListSize_2               = Une taille de {1} \u00e9l\u00e9ments est excessive pour la liste \u00ab\u202f{0}\u202f\u00bb.
 ExcessiveStringSize               = La cha\u00eene de caract\u00e8res est trop longue.
+FileNotFound_1                    = Le fichier \u00ab\u202f{0}\u202f\u00bb n\u2019a pas \u00e9t\u00e9 trouv\u00e9.
 ForbiddenAttribute_2              = L\u2019attribut \u00ab\u202f{0}\u202f\u00bb n\u2019est pas autoris\u00e9 pour un objet de type \u2018{1}\u2019.
 ForbiddenProperty_1               = La propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb n\u2019est pas autoris\u00e9e.
 IllegalArgumentClass_2            = L\u2019argument \u2018{0}\u2019 ne peut pas \u00eatre de type \u2018{1}\u2019.

Modified: sis/branches/JDK8/ide-project/NetBeans/build.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/build.xml?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/ide-project/NetBeans/build.xml (original)
+++ sis/branches/JDK8/ide-project/NetBeans/build.xml Thu Oct 23 14:05:57 2014
@@ -36,6 +36,9 @@
       <fileset dir="${project.root}/core/sis-utility/target/generated-resources/org/apache/sis/util/resources">
         <include name="*.utf"/>
       </fileset>
+      <fileset dir="${project.root}/storage/sis-shapefile/target/generated-resources/org/apache/sis/internal/shapefile/jdbc">
+        <include name="*.utf"/>
+      </fileset>
     </copy>
 
     <!-- Following are classical properties resources files. -->

Modified: sis/branches/JDK8/storage/sis-shapefile/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/pom.xml?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/pom.xml (original)
+++ sis/branches/JDK8/storage/sis-shapefile/pom.xml Thu Oct 23 14:05:57 2014
@@ -66,6 +66,22 @@ Read and write files in the Shapefile fo
        =========================================================== -->
   <build>
     <plugins>
+
+      <!-- Compile properties files into resources UTF files. -->
+      <plugin>
+        <groupId>org.apache.sis.core</groupId>
+        <artifactId>sis-build-helper</artifactId>
+        <version>${sis.plugin.version}</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compile-resources</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+      <!-- Package as OSGi bundle -->
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractConnection.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractConnection.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractConnection.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -16,425 +16,425 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
-import static java.util.logging.Level.*;
-
 import java.sql.*;
-import java.util.*;
-import java.util.concurrent.*;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Collections;
+import java.util.concurrent.Executor;
+
 
 /**
- * This base class holds all the unimplemented feature of a Connection.
- * (In order to avoid having a Connection implementation of thousand lines and unreadable).
+ * This base class holds most of the unimplemented feature of a {@code Connection}.
+ * This is used in order to avoid having a Connection implementation of thousand lines and unreadable.
+ *
+ * <table class="sis">
+ *   <caption>Connection default values</caption>
+ *   <tr><th>Property</th>                           <th>Value</th></tr>
+ *   <tr><td>{@link #isReadOnly()}</td>              <td>{@code false}</td></tr>
+ *   <tr><td>{@link #getAutoCommit()}</td>           <td>{@code true}</td></tr>
+ *   <tr><td>{@link #getNetworkTimeout()}</td>       <td>0</td></tr>
+ *   <tr><td>{@link #getTransactionIsolation()}</td> <td>{@link #TRANSACTION_NONE}</td></tr>
+ *   <tr><td>{@link #getTypeMap()}</td>              <td>Empty map</td></tr>
+ *   <tr><td>{@link #nativeSQL(String)}</td>         <td>No change</td></tr>
+ *   <tr><td>{@link #getWarnings()}</td>             <td>{@code null}</td></tr>
+ *   <tr><td>{@link #clearWarnings()}</td>           <td>Ignored</td></tr>
+ * </table>
  *
  * @author  Marc Le Bihan
+ * @author  Martin Desruisseaux (Geomatys)
  * @version 0.5
  * @since   0.5
  * @module
  */
-abstract public class AbstractConnection extends AbstractJDBC implements Connection {
+@SuppressWarnings("unused")
+abstract class AbstractConnection extends AbstractJDBC implements Connection {
     /**
-     * @see java.sql.Wrapper#unwrap(java.lang.Class)
+     * Constructs a new {@code Connection} instance.
      */
-    @Override
-    public <T> T unwrap(@SuppressWarnings("unused") Class<T> iface) throws SQLException {
-        throw unsupportedOperation(Connection.class, "unwrap(..)");
+    AbstractConnection() {
     }
 
     /**
-     * No non-standard features are currently handled.
-     * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
+     * Returns the JDBC interface implemented by this class.
+     * This is used for formatting error messages.
      */
     @Override
-    public boolean isWrapperFor(@SuppressWarnings("unused") Class<?> iface) {
-        return false;
+    final Class<?> getInterface() {
+        return Connection.class;
     }
 
     /**
-     * @see java.sql.Connection#prepareCall(java.lang.String)
+     * Unsupported by default.
      */
     @Override
-    public CallableStatement prepareCall(@SuppressWarnings("unused") String sql) throws SQLException {
-        throw unsupportedOperation(Connection.class, "prepareCall");
-    }
-
-    /**
-     * @see java.sql.Connection#nativeSQL(java.lang.String)
-     */
-    @Override
-    public String nativeSQL(String sql) {
-        return sql; // We do nothing at the moment.
+    public DatabaseMetaData getMetaData() throws SQLException {
+        throw unsupportedOperation("getMetaData");
     }
 
     /**
-     * Commit / rollback are currently ignored (autocommit = true).
-     * @see java.sql.Connection#setAutoCommit(boolean)
+     * Unsupported by default.
      */
     @Override
-    public void setAutoCommit(boolean autoCommit){
-        format(WARNING, "log.autocommit_ignored", autoCommit);
+    public String getCatalog() throws SQLException {
+        throw unsupportedOperation("getCatalog");
     }
 
     /**
-     * Currently the autocommit state is not handled : always true.
-     * @see java.sql.Connection#getAutoCommit()
+     * Unsupported by default.
      */
     @Override
-    public boolean getAutoCommit() {
-        return true;
+    public void setCatalog(String catalog) {
+        logUnsupportedOperation("setCatalog");
     }
 
     /**
-     * @see java.sql.Connection#commit()
+     * Unsupported by default.
      */
     @Override
-    public void commit() {
-        format(WARNING, "log.commit_rollback_ignored");
+    public String getSchema() throws SQLException {
+        throw unsupportedOperation("getSchema");
     }
 
     /**
-     * @see java.sql.Connection#rollback()
+     * Unsupported by default.
      */
     @Override
-    public void rollback() {
-        format(WARNING, "log.commit_rollback_ignored");
+    public void setSchema(String schema) throws SQLException {
+        throw unsupportedOperation("setSchema");
     }
 
     /**
-     * @see java.sql.Connection#getMetaData()
+     * Unsupported by default.
      */
     @Override
-    public DatabaseMetaData getMetaData() throws SQLException {
-        throw unsupportedOperation(Connection.class, "getMetaData()");
+    public Map<String, Class<?>> getTypeMap() {
+        return Collections.emptyMap();
     }
 
     /**
-     * @see java.sql.Connection#setReadOnly(boolean)
+     * Unsupported by default.
      */
     @Override
-    public void setReadOnly(@SuppressWarnings("unused") boolean readOnly) {
-        logUnsupportedOperation(WARNING, Connection.class, "setReadOnly(..)");
+    public void setTypeMap(Map<String, Class<?>> map) {
+        if (!map.isEmpty()) {
+            throw new UnsupportedOperationException("setTypeMap");
+        }
     }
 
     /**
-     * @see java.sql.Connection#isReadOnly()
+     * Returns {@code true} by default, assuming a driver without write capabilities.
      */
     @Override
     public boolean isReadOnly() {
-        return false;
+        return true;
     }
 
     /**
-     * @see java.sql.Connection#setCatalog(java.lang.String)
+     * Unsupported by default.
      */
     @Override
-    public void setCatalog(@SuppressWarnings("unused") String catalog) {
-        logUnsupportedOperation(WARNING, Connection.class, "setCatalog(..)");
+    public void setReadOnly(boolean readOnly) {
+        if (!readOnly) {
+            throw new UnsupportedOperationException("setReadOnly");
+        }
     }
 
     /**
-     * @see java.sql.Connection#getCatalog()
+     * Defaults to {@link #TRANSACTION_NONE}.
      */
     @Override
-    public String getCatalog() throws SQLException {
-        throw unsupportedOperation(Connection.class, "getCatalog()");
+    public int getTransactionIsolation() {
+        return TRANSACTION_NONE; // No guarantees of anything.
     }
 
     /**
-     * @see java.sql.Connection#setTransactionIsolation(int)
+     * Unsupported by default.
      */
     @Override
-    public void setTransactionIsolation(@SuppressWarnings("unused") int level) {
-        logUnsupportedOperation(WARNING, Connection.class, "transaction isolation");
+    public void setTransactionIsolation(int level) {
+        if (level != TRANSACTION_NONE) {
+            throw new UnsupportedOperationException("setTransactionIsolation");
+        }
     }
 
     /**
-     * @see java.sql.Connection#getTransactionIsolation()
+     * Defaults to {@code true}, assuming that auto-commit state is not handled.
      */
     @Override
-    public int getTransactionIsolation() {
-        return 0; // No guarantees of anything.
+    public boolean getAutoCommit() {
+        return true;
     }
 
     /**
-     * @see java.sql.Connection#getWarnings()
+     * Defaults to ignoring the commit / rollback.
+     * The auto-commit mode is assumed fixed to {@code true}.
      */
     @Override
-    public SQLWarning getWarnings() {
-        logUnsupportedOperation(WARNING, Connection.class, "returning SQL warnings");
-        return null;
+    public void setAutoCommit(boolean autoCommit) {
+        logWarning("setAutoCommit", Resources.Keys.AutoCommitIgnored_1, autoCommit);
     }
 
     /**
-     * @see java.sql.Connection#clearWarnings()
+     * Unsupported by default.
      */
     @Override
-    public void clearWarnings() {
-        logUnsupportedOperation(WARNING, Connection.class, "clearing SQL warnings");
+    public void commit() {
+        logWarning("commit", Resources.Keys.CommitRollbackIgnored, (Object[]) null);
     }
 
     /**
-     * @see java.sql.Connection#prepareCall(java.lang.String, int, int)
+     * Unsupported by default.
      */
     @Override
-    public CallableStatement prepareCall(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") int resultSetType, @SuppressWarnings("unused") int resultSetConcurrency) throws SQLException {
-        throw unsupportedOperation(Connection.class, "stored procedures (prepareCall(..))");
+    public void rollback() {
+        logWarning("commit", Resources.Keys.CommitRollbackIgnored, (Object[]) null);
     }
 
     /**
-     * @see java.sql.Connection#getTypeMap()
+     * Unsupported by default.
      */
     @Override
-    public Map<String, Class<?>> getTypeMap() {
-        logUnsupportedOperation(WARNING, Connection.class, "getTypeMap()");
-        return new HashMap<>();
+    public void rollback(Savepoint savepoint) throws SQLException {
+        throw unsupportedOperation("rollback");
     }
 
     /**
-     * @see java.sql.Connection#setTypeMap(java.util.Map)
+     * Unsupported by default.
      */
     @Override
-    public void setTypeMap(@SuppressWarnings("unused") Map<String, Class<?>> map) {
-        logUnsupportedOperation(WARNING, Connection.class, "setTypeMap(..)");
+    public Savepoint setSavepoint() throws SQLException {
+        throw unsupportedOperation("setSavepoint");
     }
 
     /**
-     * @see java.sql.Connection#prepareStatement(java.lang.String, int, int)
+     * Unsupported by default.
      */
     @Override
-    public PreparedStatement prepareStatement(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") int resultSetType, @SuppressWarnings("unused") int resultSetConcurrency) throws SQLException {
-        throw unsupportedOperation(Connection.class, "prepareStatement(String sql, int resultSetType, int resultSetConcurrency)");
+    public Savepoint setSavepoint(String name) throws SQLException {
+        throw unsupportedOperation("setSavepoint");
     }
 
     /**
-     * @see java.sql.Connection#setHoldability(int)
+     * Unsupported by default.
      */
     @Override
-    public void setHoldability(@SuppressWarnings("unused") int holdability) {
-        logUnsupportedOperation(WARNING, Connection.class, "setHoldability(..)");
+    public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+        throw unsupportedOperation("releaseSavepoint");
     }
 
     /**
-     * @see java.sql.Connection#getHoldability()
+     * Unsupported by default.
      */
     @Override
     public int getHoldability() throws SQLException {
-        throw unsupportedOperation(Connection.class, "getHoldability()");
+        throw unsupportedOperation("getHoldability");
     }
 
     /**
-     * @see java.sql.Connection#setSavepoint()
+     * Unsupported by default.
      */
     @Override
-    public Savepoint setSavepoint() throws SQLException {
-        throw unsupportedOperation(Connection.class, "setSavepoint()");
+    public void setHoldability(int holdability) {
+        logUnsupportedOperation("setHoldability");
     }
 
     /**
-     * @see java.sql.Connection#setSavepoint(java.lang.String)
+     * Returns the given string unchanged by default.
      */
     @Override
-    public Savepoint setSavepoint(@SuppressWarnings("unused") String name) throws SQLException {
-        throw unsupportedOperation(Connection.class, "setSavepoint(..)");
+    public String nativeSQL(String sql) {
+        return sql; // We do nothing at the moment.
     }
 
     /**
-     * @see java.sql.Connection#rollback(java.sql.Savepoint)
+     * Unsupported by default.
      */
     @Override
-    public void rollback(@SuppressWarnings("unused") Savepoint savepoint) throws SQLException {
-        throw unsupportedOperation(Connection.class, "rollback(Savepoint)");
+    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw unsupportedOperation("createStatement");
     }
 
     /**
-     * @see java.sql.Connection#releaseSavepoint(java.sql.Savepoint)
+     * Unsupported by default.
      */
     @Override
-    public void releaseSavepoint(@SuppressWarnings("unused") Savepoint savepoint) throws SQLException {
-        throw unsupportedOperation(Connection.class, "releaseSavepoint(Savepoint)");
+    public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw unsupportedOperation("createStatement");
     }
 
     /**
-     * @see java.sql.Connection#createStatement(int, int, int)
+     * Unsupported by default.
      */
     @Override
-    public Statement createStatement(@SuppressWarnings("unused") int resultSetType, @SuppressWarnings("unused") int resultSetConcurrency, @SuppressWarnings("unused") int resultSetHoldability) throws SQLException {
-        throw unsupportedOperation(Connection.class, "createStatement(int, int, int)");
+    public PreparedStatement prepareStatement(String sql) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
     }
 
     /**
-     * @see java.sql.Connection#prepareStatement(java.lang.String, int, int, int)
+     * Unsupported by default.
      */
     @Override
-    public PreparedStatement prepareStatement(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") int resultSetType, @SuppressWarnings("unused") int resultSetConcurrency, @SuppressWarnings("unused") int resultSetHoldability) throws SQLException {
-        throw unsupportedOperation(Connection.class, "prepareStatement(String, int, int, int)");
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
     }
 
     /**
-     * @see java.sql.Connection#prepareCall(java.lang.String, int, int, int)
+     * Unsupported by default.
      */
     @Override
-    public CallableStatement prepareCall(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") int resultSetType, @SuppressWarnings("unused") int resultSetConcurrency, @SuppressWarnings("unused") int resultSetHoldability) throws SQLException {
-        throw unsupportedOperation(Connection.class, "stored procedures (prepareCall(String, int, int, int))");
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
     }
 
     /**
-     * @see java.sql.Connection#prepareStatement(java.lang.String)
+     * Unsupported by default.
      */
     @Override
-    public PreparedStatement prepareStatement(@SuppressWarnings("unused") String sql) throws SQLException {
-        throw unsupportedOperation(Connection.class, "prepareStatement(String sql)");
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw unsupportedOperation("prepareCall");
     }
 
     /**
-     * @see java.sql.Connection#prepareStatement(java.lang.String, int)
+     * Unsupported by default.
      */
     @Override
-    public PreparedStatement prepareStatement(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") int autoGeneratedKeys) throws SQLException {
-        throw unsupportedOperation(Connection.class, "prepareStatement with autogenerated keys (prepareStatement(String, int))");
+    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
     }
 
     /**
-     * @see java.sql.Connection#prepareStatement(java.lang.String, int[])
+     * Unsupported by default.
      */
     @Override
-    public PreparedStatement prepareStatement(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") int[] columnIndexes) throws SQLException {
-        throw unsupportedOperation(Connection.class, "prepareStatement with autogenerated keys (prepareStatement(String, int[]))");
+    public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
     }
 
     /**
-     * @see java.sql.Connection#prepareStatement(java.lang.String, java.lang.String[])
+     * Unsupported by default.
      */
     @Override
-    public PreparedStatement prepareStatement(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") String[] columnNames) throws SQLException {
-        throw unsupportedOperation(Connection.class, "prepareStatement with autogenerated keys (prepareStatement(String, String[]))");
+    public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
     }
 
     /**
-     * @see java.sql.Connection#createClob()
+     * Unsupported by default.
      */
     @Override
-    public Clob createClob() throws SQLException {
-        throw unsupportedOperation(Connection.class, "createClob()");
+    public CallableStatement prepareCall(String sql) throws SQLException {
+        throw unsupportedOperation("prepareCall");
     }
 
     /**
-     * @see java.sql.Connection#createBlob()
+     * Unsupported by default.
      */
     @Override
-    public Blob createBlob() throws SQLException {
-        throw unsupportedOperation(Connection.class, "createBlob()");
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw unsupportedOperation("prepareCall");
     }
 
     /**
-     * @see java.sql.Connection#createNClob()
+     * Unsupported by default.
      */
     @Override
-    public NClob createNClob() throws SQLException {
-        throw unsupportedOperation(Connection.class, "createNClob()");
-    }
-
-    /**
-     * @see java.sql.Connection#createSQLXML()
-     */
-    @Override
-    public SQLXML createSQLXML() throws SQLException {
-        throw unsupportedOperation(Connection.class, "createSQLXML()");
+    public Clob createClob() throws SQLException {
+        throw unsupportedOperation("createClob");
     }
 
     /**
-     * @see java.sql.Connection#setClientInfo(java.lang.String, java.lang.String)
+     * Unsupported by default.
      */
     @Override
-    public void setClientInfo(@SuppressWarnings("unused") String name, @SuppressWarnings("unused") String value) {
-        logUnsupportedOperation(WARNING, Connection.class, "setClientInfo(..)");
+    public Blob createBlob() throws SQLException {
+        throw unsupportedOperation("createBlob");
     }
 
     /**
-     * @see java.sql.Connection#setClientInfo(java.util.Properties)
+     * Unsupported by default.
      */
     @Override
-    public void setClientInfo(@SuppressWarnings("unused") Properties properties) {
-        logUnsupportedOperation(WARNING, Connection.class, "setClientInfo(Properties)");
+    public NClob createNClob() throws SQLException {
+        throw unsupportedOperation("createNClob");
     }
 
     /**
-     * @see java.sql.Connection#getClientInfo(java.lang.String)
+     * Unsupported by default.
      */
     @Override
-    public String getClientInfo(@SuppressWarnings("unused") String name) throws SQLException {
-        throw unsupportedOperation(Connection.class, "getClientInfo(String name)");
+    public SQLXML createSQLXML() throws SQLException {
+        throw unsupportedOperation("createSQLXML");
     }
 
     /**
-     * @see java.sql.Connection#getClientInfo()
+     * Unsupported by default.
      */
     @Override
-    public Properties getClientInfo() throws SQLException {
-        throw unsupportedOperation(Connection.class, "getClientInfo()");
+    public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
+        throw unsupportedOperation("createArrayOf");
     }
 
     /**
-     * @see java.sql.Connection#createArrayOf(java.lang.String, java.lang.Object[])
+     * Unsupported by default.
      */
     @Override
-    public Array createArrayOf(@SuppressWarnings("unused") String typeName, @SuppressWarnings("unused") Object[] elements) throws SQLException {
-        throw unsupportedOperation(Connection.class, "createArrayOf(String typeName, Object[] elements)");
+    public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
+        throw unsupportedOperation("createStruct");
     }
 
     /**
-     * @see java.sql.Connection#createStruct(java.lang.String, java.lang.Object[])
+     * Unsupported by default.
      */
     @Override
-    public Struct createStruct(@SuppressWarnings("unused") String typeName, @SuppressWarnings("unused") Object[] attributes) throws SQLException {
-        throw unsupportedOperation(Connection.class, "createStruct(String typeName, Object[] attributes)");
+    public String getClientInfo(String name) throws SQLException {
+        throw unsupportedOperation("getClientInfo");
     }
 
     /**
-     * @see java.sql.Connection#setSchema(java.lang.String)
+     * Unsupported by default.
      */
     @Override
-    public void setSchema(@SuppressWarnings("unused") String schema) throws SQLException {
-        throw unsupportedOperation(Connection.class, "setSchema(String schema)");
+    public Properties getClientInfo() throws SQLException {
+        throw unsupportedOperation("getClientInfo");
     }
 
     /**
-     * @see java.sql.Connection#getSchema()
+     * Unsupported by default.
      */
     @Override
-    public String getSchema() throws SQLException {
-        throw unsupportedOperation(Connection.class, "getSchema()");
+    public void setClientInfo(String name, String value) {
+        logUnsupportedOperation("setClientInfo");
     }
 
     /**
-     * @see java.sql.Connection#abort(java.util.concurrent.Executor)
+     * Unsupported by default.
      */
     @Override
-    public void abort(@SuppressWarnings("unused") Executor executor) throws SQLException {
-        throw unsupportedOperation(Connection.class, "abort(Executor executor)");
+    public void setClientInfo(Properties properties) {
+        logUnsupportedOperation("setClientInfo");
     }
 
     /**
-     * @see java.sql.Connection#setNetworkTimeout(java.util.concurrent.Executor, int)
+     * Defaults to 0, which means there is no limit.
      */
     @Override
-    public void setNetworkTimeout(@SuppressWarnings("unused") Executor executor, @SuppressWarnings("unused") int milliseconds) {
-        logUnsupportedOperation(WARNING, Connection.class, "setNetworkTimeout(Executor executor, int milliseconds)");
+    public int getNetworkTimeout() {
+        return 0; // Means there is no limt.
     }
 
     /**
-     * @see java.sql.Connection#getNetworkTimeout()
+     * Unsupported by default.
      */
     @Override
-    public int getNetworkTimeout() {
-        logUnsupportedOperation(WARNING, Connection.class, "getNetworkTimeout()");
-        return 0;
+    public void setNetworkTimeout(Executor executor, int milliseconds) {
+        logUnsupportedOperation("setNetworkTimeout");
     }
 
     /**
-     * @see java.sql.Connection#createStatement(int, int)
+     * Unsupported by default.
      */
     @Override
-    public Statement createStatement(@SuppressWarnings("unused") int resultSetType, @SuppressWarnings("unused") int resultSetConcurrency) throws SQLException {
-        throw unsupportedOperation(Connection.class, "createStatement(int resultSetType, int resultSetConcurrency)");
+    public void abort(Executor executor) throws SQLException {
+        throw unsupportedOperation("abort");
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -16,11 +16,14 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
-import java.text.*;
-import java.util.*;
-import java.util.logging.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.logging.LogRecord;
+import java.sql.Wrapper;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
+import java.sql.SQLWarning;
+import org.apache.sis.util.logging.Logging;
 
 
 /**
@@ -31,98 +34,96 @@ import java.sql.SQLFeatureNotSupportedEx
  * @since   0.5
  * @module
  */
-public abstract class AbstractJDBC {
-    /** Logger. */
-    private Logger logger = Logger.getLogger(getClass().getSimpleName());
+abstract class AbstractJDBC implements Wrapper {
+    /**
+     * The logger for JDBC operations. We use the {@code "org.apache.sis.storage.jdbc"} logger name instead than
+     * the package name because this package is internal and may move in any future SIS version. The logger name
+     * does not need to be the name of an existing package. The important thing is to not change it, because it
+     * can been seen as a kind of public API since user may want to control verbosity level by logger names.
+     */
+    static final Logger LOGGER = Logging.getLogger("org.apache.sis.storage.jdbc");
 
     /**
-     * Format a resource bundle message.
+     * Constructs a new instance of a JDBC interface.
+     */
+    AbstractJDBC() {
+    }
+
+    /**
+     * Returns the JDBC interface implemented by this class.
+     * This is used for formatting error messages.
      *
-     * @param classForResourceBundleName class from which ResourceBundle name will be extracted.
-     * @param key Message key.
-     * @param args Message arguments.
-     * @return Message.
+     * @return The JDBC interface implemented by this class.
      */
-    final String format(Class<?> classForResourceBundleName, String key, Object... args) {
-        Objects.requireNonNull(classForResourceBundleName, "Class from with the ResourceBundle name is extracted cannot be null.");
-        Objects.requireNonNull(key, "Message key cannot be bull.");
+    abstract Class<?> getInterface();
 
-        ResourceBundle rsc = ResourceBundle.getBundle(classForResourceBundleName.getName());
-        MessageFormat format = new MessageFormat(rsc.getString(key));
-        return format.format(args);
+    /**
+     * Unsupported by default.
+     *
+     * @param  iface the type of the wrapped object.
+     * @return The wrapped object.
+     */
+    @Override
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        throw unsupportedOperation("unwrap");
     }
 
     /**
-     * Format a resource bundle message.
+     * Default to {@code false}, assuming that no non-standard features are handled.
      *
-     * @param key Message key.
-     * @param args Message arguments.
-     * @return Message.
+     * @param  iface the type of the wrapped object.
+     * @return {@code true} if this instance is a wrapper for the given type of object.
      */
-    final String format(String key, Object... args) {
-        return format(getClass(), key, args);
+    @Override
+    public boolean isWrapperFor(Class<?> iface) {
+        return false;
     }
 
     /**
-     * Format a resource bundle message and before returning it, log it.
-     *
-     * @param logLevel Log Level.
-     * @param key Message key.
-     * @param args Message arguments.
-     * @return Message.
+     * Defaults to {@code null}.
      */
-    final String format(Level logLevel, String key, Object... args) {
-        String message = format(key, args);
-        logger.log(logLevel, message);
-        return(message);
+    public SQLWarning getWarnings() {
+        return null;
     }
 
     /**
-     * Format a resource bundle message and before returning it, log it.
-     *
-     * @param classForResourceBundleName class from which ResourceBundle name will be extracted.
-     * @param logLevel Log Level.
-     * @param key Message key.
-     * @param args Message arguments.
-     * @return Message.
+     * Defaults to nothing, since there is no SQL warning.
      */
-    final String format(Level logLevel, Class<?> classForResourceBundleName, String key, Object... args) {
-        String message = format(classForResourceBundleName, key, args);
-        logger.log(logLevel, message);
-        return(message);
+    public void clearWarnings() {
     }
 
     /**
-     * Returns an unsupported operation exception.
+     * Returns an unsupported operation exception to be thrown.
      *
-     * @param unhandledInterface Interface we cannot handle.
-     * @param methodOrWishedFeatureName The feature / call the caller attempted.
+     * @param  methodOrWishedFeatureName The feature / call the caller attempted.
+     * @return The exception to throw.
      */
-    final SQLException unsupportedOperation(Class<?> unhandledInterface, String methodOrWishedFeatureName) {
-        Objects.requireNonNull(unhandledInterface, "The unhandled interface cannot be null.");
-
-        String message = logUnsupportedOperation(Level.SEVERE, unhandledInterface, methodOrWishedFeatureName);
-        return new SQLFeatureNotSupportedException(message);
+    final SQLException unsupportedOperation(final String methodOrWishedFeatureName) {
+        return new SQLFeatureNotSupportedException(Resources.format(Resources.Keys.UnsupportedDriverFeature_2,
+                getInterface(), methodOrWishedFeatureName));
     }
 
     /**
      * log an unsupported feature as a warning.
      *
-     * @param logLevel Log Level.
-     * @param unhandledInterface Interface we cannot handle.
-     * @param methodOrWishedFeatureName The feature / call the caller attempted.
-     * @return The message that has been logged.
+     * @param methodName The call the caller attempted.
      */
-    final String logUnsupportedOperation(Level logLevel, Class<?> unhandledInterface, String methodOrWishedFeatureName) {
-        Objects.requireNonNull(unhandledInterface, "The unhandled interface cannot be null.");
-        return format(logLevel, AbstractJDBC.class, "excp.unsupported_driver_feature", unhandledInterface.getClass(), methodOrWishedFeatureName);
+    final void logUnsupportedOperation(final String methodName) {
+        logWarning(methodName, Resources.Keys.UnsupportedDriverFeature_2, getInterface(), methodName);
     }
 
     /**
-     * Return the class logger.
-     * @return logger.
+     * Logs a warning with the given resource keys and arguments.
+     *
+     * @param methodName  The name of the method which is emitting the warning.
+     * @param resourceKey One of the {@link org.apache.sis.internal.shapefile.jdbc.Resources.Keys} values.
+     * @param arguments   Arguments to be given to {@link java.text.MessageFormat}, or {@code null} if none.
      */
-    public Logger getLogger() {
-        return logger;
+    final void logWarning(final String methodName, final short resourceKey, final Object... arguments) {
+        final LogRecord record = Resources.getResources(null).getLogRecord(Level.WARNING, resourceKey, arguments);
+        record.setSourceClassName(getClass().getCanonicalName());
+        record.setSourceMethodName(methodName);
+        record.setLoggerName(LOGGER.getName());
+        LOGGER.log(record);
     }
 }



Mime
View raw message