sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlebi...@apache.org
Subject svn commit: r1643155 [1/6] - in /sis/branches/JDK8: core/sis-utility/src/main/java/org/apache/sis/util/logging/ storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/ storage/sis-shapefile/src/main/java/org/apache/sis/internal/shap...
Date Fri, 05 Dec 2014 05:53:24 GMT
Author: mlebihan
Date: Fri Dec  5 05:53:23 2014
New Revision: 1643155

URL: http://svn.apache.org/viewvc?rev=1643155&view=rev
Log:
SIS-184 : Ability to run SQL request on DBF 3 Database.
SELECT * FROM <DBase> [WHERE] simple condition

Added:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/AbstractAutoChecker.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/AbstractAutoCheckerList.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/package-info.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractUnimplementedFeaturesOfDatabaseMetaData.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/package-info.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractBuiltInMemoryResultSet.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractUnimplementedFeaturesOfResultSet.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForCatalogNamesListing.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForSchemaListing.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLIllegalColumnIndexException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoResultException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoSuchFieldException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotDateException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotNumericException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/package-info.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/AbstractClauseResolver.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ConditionalClauseResolver.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLIllegalParameterException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLInvalidStatementException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLUnsupportedParsingFeatureException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/package-info.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/package-info.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/FieldsDescriptors.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InvalidDbaseFileFormatException.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractUnimplementedFeaturesOfResultSet.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractUnimplementedFeaturesOfResultSet_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/AbstractClauseResolver.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/AbstractClauseResolver_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/Database.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/Database_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/FieldDescriptor.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/FieldDescriptor_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/FieldsDescriptors.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/FieldsDescriptors_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/readme.txt
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java
Removed:
    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/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/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/internal/shapefile/jdbc/Resources.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources_fr.properties
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/CodePage.java
Modified:
    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/DBFDriver.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/Database.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/FieldDescriptor.java
    sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java
    sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java

Added: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/AbstractAutoChecker.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/AbstractAutoChecker.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/AbstractAutoChecker.java (added)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/AbstractAutoChecker.java Fri Dec  5 05:53:23 2014
@@ -0,0 +1,136 @@
+/*
+ * 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.logging;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.Objects;
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ * Base class for objets having auto-checking abilities
+ * and easy access to Bundle and logging function. 
+ * @author Marc LE BIHAN
+ */
+abstract public class AbstractAutoChecker {
+    /** Logger. */
+    private Logger logger = Logger.getLogger(getClass().getSimpleName());
+
+    /**
+     * Format a resource bundle message.
+     *
+     * @param classForResourceBundleName class from which ResourceBundle name will be extracted.
+     * @param key Message key.
+     * @param args Message arguments.
+     * @return Message.
+     */
+    final protected 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.");
+
+        Class<?> candidateClass = classForResourceBundleName;
+        MessageFormat format = null;
+        
+        // Find the key in the bundle having for name this class, or in one of its superclasses.
+        do {
+            try {
+                ResourceBundle rsc = ResourceBundle.getBundle(candidateClass.getName());
+                format = new MessageFormat(rsc.getString(key));
+            }
+            catch(MissingResourceException e) {
+                candidateClass = candidateClass.getSuperclass();
+            }
+        }
+        while(candidateClass != null && format == null);
+        
+        if (format == null) {
+            String fmt = "Cannot find property key {0} in {1} properties file or any of its superclasses.";
+            String message = MessageFormat.format(fmt, key, classForResourceBundleName.getName());
+            throw new MissingResourceException(message, classForResourceBundleName.getName(), key);
+        }
+        else
+            return format.format(args);
+    }
+
+    /**
+     * Format a resource bundle message.
+     *
+     * @param key Message key.
+     * @param args Message arguments.
+     * @return Message.
+     */
+    final protected String format(String key, Object... args) {
+        return format(getClass(), key, args);
+    }
+
+    /**
+     * 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.
+     */
+    final protected String format(Level logLevel, String key, Object... args) {
+        Objects.requireNonNull(logLevel, "The log level cannot be null.");
+        
+        String message = format(key, args);
+        logger.log(logLevel, message);
+        return(message);
+    }
+
+    /**
+     * 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.
+     */
+    final protected String format(Level logLevel, Class<?> classForResourceBundleName, String key, Object... args) {
+        Objects.requireNonNull(logLevel, "The log level cannot be null.");
+        
+        String message = format(classForResourceBundleName, key, args);
+        logger.log(logLevel, message);
+        return(message);
+    }
+
+    /**
+     * Logs (and take the time to format an entry log) only if the logger accepts the message.
+     * @param logLevel Log level.
+     * @param key Message key.
+     * @param args Message arguments.
+     */
+    final protected void log(Level logLevel, String key, Object... args) {
+        Objects.requireNonNull(logLevel, "The log level cannot be null.");
+
+        if (logger.isLoggable(logLevel))
+            format(logLevel, key, args);
+    }
+    
+    /**
+     * Return the class logger.
+     * @return logger.
+     */
+    public Logger getLogger() {
+        return logger;
+    }
+}

Added: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/AbstractAutoCheckerList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/AbstractAutoCheckerList.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/AbstractAutoCheckerList.java (added)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/logging/AbstractAutoCheckerList.java Fri Dec  5 05:53:23 2014
@@ -0,0 +1,29 @@
+/*
+ * 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.logging;
+
+import java.util.ArrayList;
+
+/**
+ * Array of objects having the ability of auto-checking.
+ * @author Marc LE BIHAN
+ * @param <T> Objects type.
+ */
+public class AbstractAutoCheckerList<T extends AbstractAutoChecker> extends ArrayList<T> {
+    /** Serial ID. */
+    private static final long serialVersionUID = 4337592104848939780L;
+}

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=1643155&r1=1643154&r2=1643155&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] Fri Dec  5 05:53:23 2014
@@ -16,71 +16,46 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
+import java.sql.*;
 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;
+
+import org.apache.sis.util.logging.AbstractAutoChecker;
 
 
 /**
  * Base class for each JDBC class.
- *
  * @author  Marc Le Bihan
  * @version 0.5
  * @since   0.5
  * @module
  */
-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");
-
+public abstract class AbstractJDBC extends AbstractAutoChecker implements Wrapper {
     /**
      * Constructs a new instance of a JDBC interface.
      */
-    AbstractJDBC() {
+    public AbstractJDBC() {
     }
 
     /**
      * Returns the JDBC interface implemented by this class.
      * This is used for formatting error messages.
-     *
      * @return The JDBC interface implemented by this class.
      */
-    abstract Class<?> getInterface();
+    abstract protected Class<?> getInterface();
 
     /**
      * Unsupported by default.
-     *
-     * @param  iface the type of the wrapped object.
+     * @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");
-    }
-
-    /**
-     * Default to {@code false}, assuming that no non-standard features are handled.
-     *
-     * @param  iface the type of the wrapped object.
-     * @return {@code true} if this instance is a wrapper for the given type of object.
-     */
-    @Override
-    public boolean isWrapperFor(Class<?> iface) {
-        return false;
+        throw unsupportedOperation("unwrap", iface);
     }
 
     /**
      * Defaults to {@code null}.
+     * @return SQL Warning.
      */
     public SQLWarning getWarnings() {
         return null;
@@ -94,36 +69,85 @@ abstract class AbstractJDBC implements W
 
     /**
      * Returns an unsupported operation exception to be thrown.
-     *
-     * @param  methodOrWishedFeatureName The feature / call the caller attempted.
-     * @return The exception to throw.
-     */
-    final SQLException unsupportedOperation(final String methodOrWishedFeatureName) {
-        return new SQLFeatureNotSupportedException(Resources.format(Resources.Keys.UnsupportedDriverFeature_2,
-                getInterface(), methodOrWishedFeatureName));
+     * @param methodOrWishedFeatureName The feature / call the caller attempted.
+     * @return the not supported feature exception.
+     * @throws SQLFeatureNotSupportedException the not supported feature.
+     */
+    public final SQLFeatureNotSupportedException unsupportedOperation(final String methodOrWishedFeatureName) throws SQLFeatureNotSupportedException {
+        String message = format(Level.SEVERE, "excp.unsupportedDriverFeature", getInterface(), methodOrWishedFeatureName, getClass().getSimpleName());
+        throw new SQLFeatureNotSupportedException(message);
+    }
+
+    /**
+     * Returns an unsupported operation exception to be thrown : this exception add parameters sent to the method that isn't implemented.
+     * @param methodOrWishedFeatureName The feature / call the caller attempted.
+     * @param args Arguments that where sent to the unimplemented function.
+     * @return the not supported feature exception.
+     * @throws SQLFeatureNotSupportedException the not supported feature.
+     */
+    public final SQLFeatureNotSupportedException unsupportedOperation(final String methodOrWishedFeatureName, Object... args) throws SQLFeatureNotSupportedException {
+        StringBuffer arguments = new StringBuffer();
+        
+        for(Object arg : args) {
+            arguments.append(arguments.length() == 0 ? "" : ", ");   // Separator if needed.
+            arguments.append(arg instanceof String ? "\"" : "");     // Enclosing " for String, if needed.
+            arguments.append(arg == null ? "null" : arg.toString()); // String value of the argument.
+            arguments.append(arg instanceof String ? "\"" : "");     // Enclosing " for String, if needed. 
+        }
+        
+        String message = format(Level.SEVERE, "excp.unsupportedDriverFeature_with_arguments", getInterface(), methodOrWishedFeatureName, getClass().getSimpleName(), arguments.toString());
+        throw new SQLFeatureNotSupportedException(message);
+    }
+
+    /**
+     * log a function call in the driver : very verbose.
+     * @param methodName The call the caller attempted.
+     */
+    public void logStep(final String methodName) {
+        format(Level.FINER, "log.step", methodName, getClass().getSimpleName());
+    }
+
+    /**
+     * log a function call in the driver : very verbose.
+     * @param methodName The call the caller attempted.
+     * @param args Arguments that where sent to the unimplemented function.
+     */
+    public void logStep(final String methodName, Object... args) {
+        format(Level.FINER, "log.step_with_arguments", methodName, getClass().getSimpleName(), arguments(args));
     }
 
     /**
      * log an unsupported feature as a warning.
-     *
      * @param methodName The call the caller attempted.
      */
-    final void logUnsupportedOperation(final String methodName) {
-        logWarning(methodName, Resources.Keys.UnsupportedDriverFeature_2, getInterface(), methodName);
+    public void logUnsupportedOperation(final String methodName) {
+        format(Level.WARNING, "excp.unsupportedDriverFeature", getInterface(), methodName, getClass().getSimpleName());
     }
 
     /**
-     * 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.
-     */
-    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);
+     * log an unsupported feature as a warning.
+     * @param methodName The call the caller attempted.
+     * @param args Arguments that where sent to the unimplemented function.
+     */
+    public void logUnsupportedOperation(final String methodName, Object... args) {
+        format(Level.WARNING, "excp.unsupportedDriverFeature_with_arguments", getInterface(), methodName, getClass().getSimpleName(), arguments(args));
+    }
+    
+    /**
+     * Concat arguments in a StringBuffer.
+     * @param args arguments.
+     * @return Arguments.
+     */
+    private StringBuffer arguments(Object... args) {
+        StringBuffer arguments = new StringBuffer();
+        
+        for(Object arg : args) {
+            arguments.append(arguments.length() == 0 ? "" : ", ");   // Separator if needed.
+            arguments.append(arg instanceof String ? "\"" : "");     // Enclosing " for String, if needed.
+            arguments.append(arg == null ? "null" : arg.toString()); // String value of the argument.
+            arguments.append(arg instanceof String ? "\"" : "");     // Enclosing " for String, if needed. 
+        }
+        
+        return arguments;
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java?rev=1643155&r1=1643154&r2=1643155&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] Fri Dec  5 05:53:23 2014
@@ -16,13 +16,13 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
+import java.io.*;
 import java.sql.*;
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.logging.Logger;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.internal.system.Modules;
+import java.util.*;
+import java.util.logging.*;
+
+import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
+import org.apache.sis.internal.system.*;
 
 
 /**
@@ -39,13 +39,21 @@ public class DBFDriver extends AbstractJ
      */
     public DBFDriver() {
     }
+    
+    /**
+     * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
+     */
+    @Override
+    public boolean isWrapperFor(Class<?> iface) {
+        return iface.isAssignableFrom(getInterface());
+    }
 
     /**
      * Returns the JDBC interface implemented by this class.
      * This is used for formatting error messages.
      */
     @Override
-    final Class<?> getInterface() {
+    final protected Class<?> getInterface() {
         return Driver.class;
     }
 
@@ -59,13 +67,8 @@ public class DBFDriver extends AbstractJ
      */
     @Override
     public Connection connect(final String url, @SuppressWarnings("unused") Properties info) throws SQLException {
-        ArgumentChecks.ensureNonNull("url", url);
-        try {
-            return new DBFConnection(new File(url));
-        } catch (IOException e) {
-            throw new SQLNonTransientConnectionException(Resources.format(
-                    Resources.Keys.InvalidDBFFormatDescriptor_2, url, e.getLocalizedMessage()));
-        }
+        Objects.requireNonNull(url, "the DBase3 url cannot be null");
+        return new DBFConnection(new File(url));
     }
 
     /**
@@ -76,6 +79,7 @@ public class DBFDriver extends AbstractJ
         if (!url.endsWith(".dbf")) {
             return false;
         }
+        
         final File datafile = new File(url);
         return datafile.isFile(); // Future version should check for magic number.
     }
@@ -122,6 +126,6 @@ public class DBFDriver extends AbstractJ
      */
     @Override
     public Logger getParentLogger() {
-        return LOGGER;
+        return super.getLogger();
     }
 }

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java Fri Dec  5 05:53:23 2014
@@ -0,0 +1,63 @@
+/*
+ * 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.internal.shapefile.jdbc;
+
+import java.io.File;
+import java.sql.SQLException;
+
+/**
+ * Exception thrown when a connection is closed.
+ * @author Marc LE BIHAN
+ */
+public class SQLConnectionClosedException extends SQLException {
+    /** Serial ID. */
+    private static final long serialVersionUID = -7806101485624353416L;
+
+    /** The SQL Statement that whas attempted (if known). */
+    private String m_sql;
+    
+    /** The database file. */
+    private File m_database;
+    
+    /**
+     * Build the exception.
+     * @param message Exception message.
+     * @param sql SQL Statement who encountered the trouble, if known.
+     * @param database The database that was queried.
+     */
+    public SQLConnectionClosedException(String message, String sql, File database) {
+        super(message);
+        m_sql = sql;
+        m_database = database;
+    }
+    
+    /**
+     * Returns the SQL statement who encountered the "connection closed" alert, if known.
+     * @return SQL statement or null.
+     */
+    public String getSQL() {
+        return m_sql;
+    }
+    
+    /**
+     * Returns the database file that is not opened for connection.
+     * @return Database file.
+     */
+    public File getDatabase() {
+        return m_database;
+    }
+}

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java Fri Dec  5 05:53:23 2014
@@ -0,0 +1,418 @@
+/*
+ * 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.internal.shapefile.jdbc.connection;
+
+import java.sql.*;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+import java.util.logging.Level;
+
+import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC;
+
+
+/**
+ * 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
+ */
+@SuppressWarnings("unused")
+abstract class AbstractConnection extends AbstractJDBC implements Connection {
+    /**
+     * Constructs a new {@code Connection} instance.
+     */
+    AbstractConnection() {
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void setCatalog(String catalog) {
+        logUnsupportedOperation("setCatalog");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public String getSchema() throws SQLException {
+        throw unsupportedOperation("getSchema");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void setSchema(String schema) throws SQLException {
+        throw unsupportedOperation("setSchema");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public Map<String, Class<?>> getTypeMap() {
+        return Collections.emptyMap();
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void setTypeMap(Map<String, Class<?>> map) {
+        if (!map.isEmpty()) {
+            throw new UnsupportedOperationException("setTypeMap");
+        }
+    }
+
+    /**
+     * Returns {@code true} by default, assuming a driver without write capabilities.
+     */
+    @Override
+    public boolean isReadOnly() {
+        return true;
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void setReadOnly(boolean readOnly) {
+        if (!readOnly) {
+            throw new UnsupportedOperationException("setReadOnly");
+        }
+    }
+
+    /**
+     * Defaults to {@link #TRANSACTION_NONE}.
+     */
+    @Override
+    public int getTransactionIsolation() {
+        return TRANSACTION_NONE; // No guarantees of anything.
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void setTransactionIsolation(int level) {
+        if (level != TRANSACTION_NONE) {
+            throw new UnsupportedOperationException("setTransactionIsolation");
+        }
+    }
+
+    /**
+     * Defaults to {@code true}, assuming that auto-commit state is not handled.
+     */
+    @Override
+    public boolean getAutoCommit() {
+        return true;
+    }
+
+    /**
+     * Defaults to ignoring the commit / rollback.
+     * The auto-commit mode is assumed fixed to {@code true}.
+     */
+    @Override
+    public void setAutoCommit(boolean autoCommit) {
+        format(Level.WARNING, "log.auto_commit_ignored", autoCommit);
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void commit() {
+        format(Level.WARNING, "log.commit_rollback_ignored");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void rollback() {
+        format(Level.WARNING, "log.commit_rollback_ignored");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void rollback(Savepoint savepoint) throws SQLException {
+        throw unsupportedOperation("rollback");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public Savepoint setSavepoint() throws SQLException {
+        throw unsupportedOperation("setSavepoint");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public Savepoint setSavepoint(String name) throws SQLException {
+        throw unsupportedOperation("setSavepoint");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+        throw unsupportedOperation("releaseSavepoint");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public int getHoldability() throws SQLException {
+        throw unsupportedOperation("getHoldability");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void setHoldability(int holdability) {
+        logUnsupportedOperation("setHoldability");
+    }
+
+    /**
+     * Returns the given string unchanged by default.
+     */
+    @Override
+    public String nativeSQL(String sql) {
+        return sql; // We do nothing at the moment.
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw unsupportedOperation("createStatement");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw unsupportedOperation("createStatement");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public PreparedStatement prepareStatement(String sql) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw unsupportedOperation("prepareCall");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
+        throw unsupportedOperation("prepareStatement");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public CallableStatement prepareCall(String sql) throws SQLException {
+        throw unsupportedOperation("prepareCall");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw unsupportedOperation("prepareCall");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public Clob createClob() throws SQLException {
+        throw unsupportedOperation("createClob");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public Blob createBlob() throws SQLException {
+        throw unsupportedOperation("createBlob");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public NClob createNClob() throws SQLException {
+        throw unsupportedOperation("createNClob");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public SQLXML createSQLXML() throws SQLException {
+        throw unsupportedOperation("createSQLXML");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
+        throw unsupportedOperation("createArrayOf");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
+        throw unsupportedOperation("createStruct");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public String getClientInfo(String name) throws SQLException {
+        throw unsupportedOperation("getClientInfo");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public Properties getClientInfo() throws SQLException {
+        throw unsupportedOperation("getClientInfo");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void setClientInfo(String name, String value) {
+        logUnsupportedOperation("setClientInfo");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void setClientInfo(Properties properties) {
+        logUnsupportedOperation("setClientInfo");
+    }
+
+    /**
+     * Defaults to 0, which means there is no limit.
+     */
+    @Override
+    public int getNetworkTimeout() {
+        return 0; // Means there is no limt.
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void setNetworkTimeout(Executor executor, int milliseconds) {
+        logUnsupportedOperation("setNetworkTimeout");
+    }
+
+    /**
+     * Unsupported by default.
+     */
+    @Override
+    public void abort(Executor executor) throws SQLException {
+        throw unsupportedOperation("abort");
+    }
+}

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java Fri Dec  5 05:53:23 2014
@@ -0,0 +1,194 @@
+/*
+ * 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.internal.shapefile.jdbc.connection;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.sql.*;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.logging.Level;
+import java.util.stream.Collectors;
+
+import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
+import org.apache.sis.internal.shapefile.jdbc.metadata.DBFDatabaseMetaData;
+import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
+import org.apache.sis.storage.shapefile.Database;
+
+
+/**
+ * Connection to a DBF database.
+ * @author  Marc Le Bihan
+ * @version 0.5
+ * @since   0.5
+ * @module
+ */
+public class DBFConnection extends AbstractConnection {
+    /** The object to use for reading the database content. */
+    final Database database;
+    
+    /** Opened statement. */
+    private HashSet<DBFStatement> m_openedStatements = new HashSet<>(); 
+
+    /**
+     * Constructs a connection to the given database.
+     * @param datafile Data file ({@code .dbf} extension).
+     * @throws SQLException if the Database file cannot be found or is not a file. 
+     */
+    public DBFConnection(final File datafile) throws SQLException {
+        // Check that file exists.
+        if (!datafile.exists()) {
+            throw new SQLException(format(Level.SEVERE, "excp.file_not_found", datafile.getAbsolutePath()));
+        }
+        
+        // Check that its not a directory.
+        if (datafile.isDirectory()) {
+            throw new SQLException(format(Level.SEVERE, "excp.directory_not_expected", datafile.getAbsolutePath()));
+        }
+        
+        try {
+           database = new Database(datafile.getAbsolutePath());
+           format(Level.FINE, "log.database_connection_opened", database.getFile().getAbsolutePath(), database.getFieldsDescriptor());
+        }
+        catch(FileNotFoundException e) {
+           throw(new SQLException(e.getMessage(), e));
+        }
+    }
+
+    /**
+     * Closes the connection to the database.
+     */
+    @Override
+    public void close() throws SQLClosingIOFailureException {
+        if (isClosed())
+            return;
+        
+        try {
+            // Check if all the underlying connections that has been opened with this connection has been closed.
+            // If not, we log a warning to help the developper.
+            if (m_openedStatements.size() > 0) {
+                format(Level.WARNING, "log.statements_left_opened", m_openedStatements.size(), m_openedStatements.stream().map(DBFStatement::toString).collect(Collectors.joining(", ")));  
+            }
+            
+            database.close();
+        } catch (IOException e) {
+            throw new SQLClosingIOFailureException(format(e.getLocalizedMessage(), e), null, database.getFile());
+        }
+    }
+
+    /**
+     * Creates an object for sending SQL statements to the database.
+     */
+    @Override
+    public Statement createStatement() throws SQLException {
+        assertNotClosed();
+        
+        DBFStatement stmt = new DBFStatement(this);
+        m_openedStatements.add(stmt);
+        return stmt;
+    }
+
+    /**
+     * @see java.sql.Connection#getCatalog()
+     */
+    @Override
+    public String getCatalog() {
+        return null; // DBase 3 offers no catalog.
+    }
+
+    /**
+     * Returns the binary representation of the database.
+     * @return Database.
+     */
+    public Database getDatabase() {
+        return database;
+    }
+
+    /**
+     * Returns the JDBC interface implemented by this class.
+     * This is used for formatting error messages.
+     */
+    @Override
+    final protected Class<?> getInterface() {
+        return Connection.class;
+    }
+
+    /**
+     * @see java.sql.Connection#getMetaData()
+     */
+    @Override
+    public DatabaseMetaData getMetaData() {
+        return new DBFDatabaseMetaData(this);
+    }
+
+    /**
+     * Returns {@code true} if this connection has been closed.
+     */
+    @Override
+    public boolean isClosed() {
+        return database.isClosed();
+    }
+
+    /**
+     * Returns {@code true} if the connection has not been closed and is still valid.
+     * The timeout parameter is ignored and this method bases itself only on {@link #isClosed()} state.
+     */
+    @Override
+    public boolean isValid(@SuppressWarnings("unused") int timeout) {
+        return !isClosed();
+    }
+
+    /**
+     * @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
+     */
+    @Override
+    public boolean isWrapperFor(Class<?> iface) {
+        return iface.isAssignableFrom(getInterface());
+    }
+
+    /**
+     * Asserts that the connection is opened.
+     * @throws SQLConnectionClosedException if the connection is closed.
+     */
+    public void assertNotClosed() throws SQLConnectionClosedException {
+        // If closed throw an exception specifying the name if the DBF that is closed. 
+        if (isClosed()) {
+            throw new SQLConnectionClosedException(format(Level.SEVERE, "excp.closed_connection", database.getFile().getName()), null, database.getFile());
+        }
+    }
+    
+    /**
+     * Method called by Statement class to notity this connection that a statement has been closed.
+     * @param stmt Statement that has been closed.
+     */
+    public void notifyCloseStatement(DBFStatement stmt) {
+        Objects.requireNonNull(stmt, "The statement notified being closed cannot be null.");
+        
+        if (m_openedStatements.remove(stmt) == false) {
+            throw new RuntimeException(format(Level.SEVERE, "assert.statement_not_opened_by_me", stmt, toString()));
+        }
+    }
+    
+    /**
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString() {
+        return format("toString", database.getFile().getAbsolutePath(), isClosed() == false);
+    }
+}

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java Fri Dec  5 05:53:23 2014
@@ -0,0 +1,63 @@
+/*
+ * 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.internal.shapefile.jdbc.connection;
+
+import java.io.File;
+import java.sql.SQLException;
+
+/**
+ * Exception thrown when a connection cannot be closed due to an environement trouble.
+ * @author Marc LE BIHAN
+ */
+public class SQLClosingIOFailureException extends SQLException {
+    /** Serial ID. */
+    private static final long serialVersionUID = -3327372119927661463L;
+
+    /** The SQL Statement that whas attempted (if known). */
+    private String m_sql;
+    
+    /** The database file. */
+    private File m_database;
+    
+    /**
+     * Build the exception.
+     * @param message Exception message.
+     * @param sql SQL Statement who encountered the trouble, if known.
+     * @param database The database that was queried.
+     */
+    public SQLClosingIOFailureException(String message, String sql, File database) {
+        super(message);
+        m_sql = sql;
+        m_database = database;
+    }
+    
+    /**
+     * Returns the SQL statement who encountered the "connection closed" alert, if known.
+     * @return SQL statement or null.
+     */
+    public String getSQL() {
+        return m_sql;
+    }
+    
+    /**
+     * Returns the database file that is not opened for connection.
+     * @return Database file.
+     */
+    public File getDatabase() {
+        return m_database;
+    }
+}

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/package-info.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/package-info.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/package-info.java Fri Dec  5 05:53:23 2014
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+/** Connections */
+package org.apache.sis.internal.shapefile.jdbc.connection;
\ No newline at end of file

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractUnimplementedFeaturesOfDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractUnimplementedFeaturesOfDatabaseMetaData.java?rev=1643155&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractUnimplementedFeaturesOfDatabaseMetaData.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractUnimplementedFeaturesOfDatabaseMetaData.java Fri Dec  5 05:53:23 2014
@@ -0,0 +1,194 @@
+package org.apache.sis.internal.shapefile.jdbc.metadata;
+
+import java.sql.*;
+
+import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC;
+
+/**
+ * Unimplemented methods of DatabaseMetaData.
+ * @author Marc LE BIHAN
+ */
+public abstract class AbstractUnimplementedFeaturesOfDatabaseMetaData extends AbstractJDBC implements DatabaseMetaData {
+    /**
+     * @see java.sql.DatabaseMetaData#getAttributes(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) throws SQLException {
+        throw unsupportedOperation("getAttributes", catalog, schemaPattern, typeNamePattern, attributeNamePattern);
+    }
+    
+    /**
+     * @see java.sql.DatabaseMetaData#getBestRowIdentifier(java.lang.String, java.lang.String, java.lang.String, int, boolean)
+     */
+    @Override public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException {
+        throw unsupportedOperation("getBestRowIdentifier", catalog, schema, table, scope, nullable);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getClientInfoProperties()
+     */
+    @Override public ResultSet getClientInfoProperties() throws SQLException {
+        throw unsupportedOperation("getClientInfoProperties");
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
+        throw unsupportedOperation("getColumns", catalog, schemaPattern, tableNamePattern, columnNamePattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getColumnPrivileges(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException {
+        throw unsupportedOperation("getColumnPrivileges", catalog, schema, table, columnNamePattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getCrossReference(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException {
+        throw unsupportedOperation("getCrossReference", parentCatalog, parentSchema, parentTable, foreignCatalog, foreignSchema, foreignTable);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getExportedKeys(java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException {
+        throw unsupportedOperation("getExportedKeys", catalog, schema, table);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getFunctions(java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) throws SQLException {
+        throw unsupportedOperation("getFunctions", catalog, schemaPattern, functionNamePattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getFunctionColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException {
+        throw unsupportedOperation("getFunctionColumns", catalog, schemaPattern, functionNamePattern, columnNamePattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getIndexInfo(java.lang.String, java.lang.String, java.lang.String, boolean, boolean)
+     */
+    @Override public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException {
+        throw unsupportedOperation("getIndexInfo", catalog, schema, table, unique, approximate);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getImportedKeys(java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException {
+        throw unsupportedOperation("getImportedKeys", catalog, schema, table);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getPrimaryKeys(java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
+        throw unsupportedOperation("getPrimaryKeys", catalog, schema, table);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getProcedures(java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException {
+        throw unsupportedOperation("getProcedures", catalog, schemaPattern, procedureNamePattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getProcedureColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException{
+        throw unsupportedOperation("getProcedureColumns", catalog, schemaPattern, procedureNamePattern, columnNamePattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getPseudoColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
+        throw unsupportedOperation("getPseudoColumns", catalog, schemaPattern, tableNamePattern, columnNamePattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getRowIdLifetime()
+     */
+    @Override public RowIdLifetime getRowIdLifetime() throws SQLException {
+        throw unsupportedOperation("getRowIdLifetime");
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getSchemas(java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
+        throw unsupportedOperation("getSchemas", catalog, schemaPattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getSearchStringEscape()
+     */
+    @Override public String getSearchStringEscape() throws SQLException {
+        throw unsupportedOperation("getSearchStringEscape");
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getSQLStateType()
+     */
+    @Override public int getSQLStateType() throws SQLException {
+        throw unsupportedOperation("getSQLStateType");
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getSuperTypes(java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException {
+        throw unsupportedOperation("getSuperTypes", catalog, schemaPattern, typeNamePattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getSuperTables(java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
+        throw unsupportedOperation("getSuperTables", catalog, schemaPattern, tableNamePattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getTablePrivileges(java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
+        throw unsupportedOperation("getTablePrivileges", catalog, schemaPattern, tableNamePattern);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getTypeInfo()
+     */
+    @Override public ResultSet getTypeInfo() throws SQLException {
+        throw unsupportedOperation("getTypeInfo");
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getUDTs(java.lang.String, java.lang.String, java.lang.String, int[])
+     */
+    @Override public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException {
+        throw unsupportedOperation("getUDTs", catalog, schemaPattern, typeNamePattern, types);
+    }
+
+    /**
+     * @see java.sql.DatabaseMetaData#getVersionColumns(java.lang.String, java.lang.String, java.lang.String)
+     */
+    @Override public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException {
+        throw unsupportedOperation("getVersionColumns", catalog, schema, table);
+    }
+
+    /**
+     * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#unwrap(java.lang.Class)
+     */
+    @Override public <T> T unwrap(Class<T> iface) throws SQLFeatureNotSupportedException {
+        throw unsupportedOperation("unwrap", iface);
+    }
+
+}



Mime
View raw message