sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1633816 [3/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
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractStatement.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractStatement.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractStatement.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractStatement.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -18,317 +18,328 @@ package org.apache.sis.internal.shapefil
 
 import java.sql.*;
 
+
 /**
- * This base class holds all the unimplemented feature of a Statement.
- * (In order to avoid having a Statement implementation of thousand lines and unreadable).
+ * This base class holds most of the unimplemented feature of a {@code Statement}.
+ * This is used in order to avoid having a Statement 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 #getResultSetType()}</td>        <td>{@link ResultSet#TYPE_SCROLL_SENSITIVE}</td></tr>
+ *   <tr><td>{@link #getResultSetConcurrency()}</td> <td>{@link ResultSet#CONCUR_READ_ONLY}</td></tr>
+ *   <tr><td>{@link #getResultSetHoldability()}</td> <td>{@link ResultSet#CLOSE_CURSORS_AT_COMMIT}</td></tr>
+ *   <tr><td>{@link #getFetchDirection()}</td>       <td>{@link ResultSet#FETCH_FORWARD}</td></tr>
+ *   <tr><td>{@link #getQueryTimeout()}</td>         <td>0</td></tr>
+ *   <tr><td>{@link #isPoolable()}</td>              <td>{@code false}</td></tr>
+ *   <tr><td>{@link #setPoolable(boolean)}</td>      <td>Ignored</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 AbstractStatement extends AbstractJDBC implements Statement {
+@SuppressWarnings("unused")
+abstract class AbstractStatement extends AbstractJDBC implements Statement {
     /**
-     * @see java.sql.Wrapper#unwrap(java.lang.Class)
+     * Constructs a new {@code Statement} instance.
      */
-    @Override
-    public <T> T unwrap(@SuppressWarnings("unused") Class<T> iface) throws SQLException {
-        throw unsupportedOperation(Statement.class, "unwrap");
+    AbstractStatement() {
     }
 
     /**
-     * @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) throws SQLException {
-        throw unsupportedOperation(Statement.class, "isWrapperFor");
+    final Class<?> getInterface() {
+        return Statement.class;
     }
 
     /**
-     * @see java.sql.Statement#executeUpdate(java.lang.String)
+     * Default to {@link ResultSet#TYPE_SCROLL_SENSITIVE}, meaning that a change in the underlying
+     * database may affect the result set.
      */
     @Override
-    public int executeUpdate(@SuppressWarnings("unused") String sql) throws SQLException {
-        throw unsupportedOperation(Statement.class, "executeUpdate");
-    }
-
-    /**
-     * @see java.sql.Statement#getMaxFieldSize()
-     */
-    @Override
-    public int getMaxFieldSize() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getMaxFieldSize");
+    public int getResultSetType() throws SQLException {
+        return ResultSet.TYPE_SCROLL_SENSITIVE;
     }
 
     /**
-     * @see java.sql.Statement#setMaxFieldSize(int)
+     * Default to {@link ResultSet#CONCUR_READ_ONLY}, which is a conservative vale meaning
+     * that the underlying database should not be updated while we iterate in a result set.
      */
     @Override
-    public void setMaxFieldSize(@SuppressWarnings("unused") int max) throws SQLException {
-        throw unsupportedOperation(Statement.class, "setMaxFieldSize");
+    public int getResultSetConcurrency() throws SQLException {
+        return ResultSet.CONCUR_READ_ONLY;
     }
 
     /**
-     * @see java.sql.Statement#getMaxRows()
+     * Defaults to {@link ResultSet#CLOSE_CURSORS_AT_COMMIT}, which seems the most conservative option.
      */
     @Override
-    public int getMaxRows() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getMaxRows");
+    public int getResultSetHoldability() throws SQLException {
+        return ResultSet.CLOSE_CURSORS_AT_COMMIT;
     }
 
     /**
-     * @see java.sql.Statement#setMaxRows(int)
+     * Unsupported by default.
      */
     @Override
-    public void setMaxRows(@SuppressWarnings("unused") int max) throws SQLException {
-        throw unsupportedOperation(Statement.class, "setMaxRows");
+    public int getMaxFieldSize() throws SQLException {
+        throw unsupportedOperation("getMaxFieldSize");
     }
 
     /**
-     * @see java.sql.Statement#setEscapeProcessing(boolean)
+     * Unsupported by default.
      */
     @Override
-    public void setEscapeProcessing(@SuppressWarnings("unused") boolean enable) throws SQLException {
-        throw unsupportedOperation(Statement.class, "setEscapeProcessing");
+    public void setMaxFieldSize(int max) throws SQLException {
+        throw unsupportedOperation("setMaxFieldSize");
     }
 
     /**
-     * @see java.sql.Statement#getQueryTimeout()
+     * Unsupported by default.
      */
     @Override
-    public int getQueryTimeout() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getQueryTimeout");
+    public int getFetchSize() throws SQLException {
+        throw unsupportedOperation("getFetchSize");
     }
 
     /**
-     * @see java.sql.Statement#setQueryTimeout(int)
+     * Unsupported by default.
      */
     @Override
-    public void setQueryTimeout(@SuppressWarnings("unused") int seconds) throws SQLException {
-        throw unsupportedOperation(Statement.class, "setQueryTimeout");
+    public void setFetchSize(int rows) throws SQLException {
+        throw unsupportedOperation("setFetchSize");
     }
 
     /**
-     * @see java.sql.Statement#cancel()
+     * Defaults to {@link ResultSet#FETCH_FORWARD}.
      */
     @Override
-    public void cancel() throws SQLException {
-        throw unsupportedOperation(Statement.class, "cancel");
+    public int getFetchDirection() throws SQLException {
+        return ResultSet.FETCH_FORWARD;
     }
 
     /**
-     * @see java.sql.Statement#getWarnings()
+     * Unsupported by default.
      */
     @Override
-    public SQLWarning getWarnings() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getWarnings");
+    public void setFetchDirection(int direction) throws SQLException {
+        if (direction != ResultSet.FETCH_FORWARD) {
+            throw unsupportedOperation("setFetchDirection");
+        }
     }
 
     /**
-     * @see java.sql.Statement#clearWarnings()
+     * Unsupported by default.
      */
     @Override
-    public void clearWarnings() throws SQLException {
-        throw unsupportedOperation(Statement.class, "clearWarnings");
+    public int getMaxRows() throws SQLException {
+        throw unsupportedOperation("getMaxRows");
     }
 
     /**
-     * @see java.sql.Statement#setCursorName(java.lang.String)
+     * Unsupported by default.
      */
     @Override
-    public void setCursorName(@SuppressWarnings("unused") String name) throws SQLException {
-        throw unsupportedOperation(Statement.class, "setCursorName");
+    public void setMaxRows(int max) throws SQLException {
+        throw unsupportedOperation("setMaxRows");
     }
 
     /**
-     * @see java.sql.Statement#getUpdateCount()
+     * Defaults to 0, meaning to limit.
      */
     @Override
-    public int getUpdateCount() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getUpdateCount");
+    public int getQueryTimeout() throws SQLException {
+        return 0;
     }
 
     /**
-     * @see java.sql.Statement#setFetchDirection(int)
+     * Unsupported by default.
      */
     @Override
-    public void setFetchDirection(@SuppressWarnings("unused") int direction) throws SQLException {
-        throw unsupportedOperation(Statement.class, "setFetchDirection");
+    public void setQueryTimeout(int seconds) throws SQLException {
+        throw unsupportedOperation("setQueryTimeout");
     }
 
     /**
-     * @see java.sql.Statement#getFetchDirection()
+     * Unsupported by default.
      */
     @Override
-    public int getFetchDirection() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getFetchDirection");
+    public void setEscapeProcessing(boolean enable) throws SQLException {
+        throw unsupportedOperation("setEscapeProcessing");
     }
 
     /**
-     * @see java.sql.Statement#setFetchSize(int)
+     * Unsupported by default.
      */
     @Override
-    public void setFetchSize(@SuppressWarnings("unused") int rows) throws SQLException {
-        throw unsupportedOperation(Statement.class, "setFetchSize");
+    public void setCursorName(String name) throws SQLException {
+        throw unsupportedOperation("setCursorName");
     }
 
     /**
-     * @see java.sql.Statement#getFetchSize()
+     * Unsupported by default.
      */
     @Override
-    public int getFetchSize() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getFetchSize");
+    public boolean execute(String sql) throws SQLException {
+        throw unsupportedOperation("execute");
     }
 
     /**
-     * @see java.sql.Statement#getResultSetConcurrency()
+     * Unsupported by default.
      */
     @Override
-    public int getResultSetConcurrency() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getResultSetConcurrency");
+    public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
+        throw unsupportedOperation("execute");
     }
 
     /**
-     * @see java.sql.Statement#addBatch(java.lang.String)
+     * Unsupported by default.
      */
     @Override
-    public void addBatch(@SuppressWarnings("unused") String sql) throws SQLException {
-        throw unsupportedOperation(Statement.class, "addBatch");
+    public boolean execute(String sql, int[] columnIndexes) throws SQLException {
+        throw unsupportedOperation("execute");
     }
 
     /**
-     * @see java.sql.Statement#clearBatch()
+     * Unsupported by default.
      */
     @Override
-    public void clearBatch() throws SQLException {
-        throw unsupportedOperation(Statement.class, "clearBatch");
+    public boolean execute(String sql, String[] columnNames) throws SQLException {
+        throw unsupportedOperation("execute");
     }
 
     /**
-     * @see java.sql.Statement#executeBatch()
+     * Unsupported by default.
      */
     @Override
-    public int[] executeBatch() throws SQLException {
-        throw unsupportedOperation(Statement.class, "executeBatch");
+    public int executeUpdate(String sql) throws SQLException {
+        throw unsupportedOperation("executeUpdate");
     }
 
     /**
-     * @see java.sql.Statement#getMoreResults(int)
+     * Unsupported by default.
      */
     @Override
-    public boolean getMoreResults(@SuppressWarnings("unused") int current) throws SQLException {
-        throw unsupportedOperation(Statement.class, "getMoreResults");
+    public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
+        throw unsupportedOperation("executeUpdate");
     }
 
     /**
-     * @see java.sql.Statement#getGeneratedKeys()
+     * Unsupported by default.
      */
     @Override
-    public ResultSet getGeneratedKeys() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getGeneratedKeys");
+    public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
+        throw unsupportedOperation("executeUpdate");
     }
 
     /**
-     * @see java.sql.Statement#executeUpdate(java.lang.String, int)
+     * Unsupported by default.
      */
     @Override
-    public int executeUpdate(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") int autoGeneratedKeys) throws SQLException {
-        throw unsupportedOperation(Statement.class, "executeUpdate");
+    public int executeUpdate(String sql, String[] columnNames) throws SQLException {
+        throw unsupportedOperation("executeUpdate");
     }
 
     /**
-     * @see java.sql.Statement#executeUpdate(java.lang.String, int[])
+     * Unsupported by default.
      */
     @Override
-    public int executeUpdate(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") int[] columnIndexes) throws SQLException {
-        throw unsupportedOperation(Statement.class, "executeUpdate");
+    public int getUpdateCount() throws SQLException {
+        throw unsupportedOperation("getUpdateCount");
     }
 
     /**
-     * @see java.sql.Statement#executeUpdate(java.lang.String, java.lang.String[])
+     * Unsupported by default.
      */
     @Override
-    public int executeUpdate(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") String[] columnNames) throws SQLException {
-        throw unsupportedOperation(Statement.class, "executeUpdate");
+    public void addBatch(String sql) throws SQLException {
+        throw unsupportedOperation("addBatch");
     }
 
     /**
-     * @see java.sql.Statement#getResultSetHoldability()
+     * Unsupported by default.
      */
     @Override
-    public int getResultSetHoldability() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getResultSetHoldability");
+    public void clearBatch() throws SQLException {
+        throw unsupportedOperation("clearBatch");
     }
 
     /**
-     * @see java.sql.Statement#setPoolable(boolean)
+     * Unsupported by default.
      */
     @Override
-    public void setPoolable(@SuppressWarnings("unused") boolean poolable) throws SQLException {
-        throw unsupportedOperation(Statement.class, "setPoolable");
+    public int[] executeBatch() throws SQLException {
+        throw unsupportedOperation("executeBatch");
     }
 
     /**
-     * @see java.sql.Statement#isPoolable()
+     * Unsupported by default.
      */
     @Override
-    public boolean isPoolable() throws SQLException {
-        throw unsupportedOperation(Statement.class, "isPoolable");
+    public boolean getMoreResults() throws SQLException {
+        throw unsupportedOperation("getMoreResults");
     }
 
     /**
-     * @see java.sql.Statement#closeOnCompletion()
+     * Unsupported by default.
      */
     @Override
-    public void closeOnCompletion() throws SQLException {
-        throw unsupportedOperation(Statement.class, "closeOnCompletion");
+    public boolean getMoreResults(int current) throws SQLException {
+        throw unsupportedOperation("getMoreResults");
     }
 
     /**
-     * @see java.sql.Statement#isCloseOnCompletion()
+     * Unsupported by default.
      */
     @Override
-    public boolean isCloseOnCompletion() throws SQLException {
-        throw unsupportedOperation(Statement.class, "isCloseOnCompletion");
+    public ResultSet getGeneratedKeys() throws SQLException {
+        throw unsupportedOperation("getGeneratedKeys");
     }
 
     /**
-     * @see java.sql.Statement#getMoreResults()
+     * Defaults to {@code false} since simple statement imlementations are not poolable.
      */
     @Override
-    public boolean getMoreResults() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getMoreResults");
+    public boolean isPoolable() throws SQLException {
+        return false;
     }
 
     /**
-     * @see java.sql.Statement#getResultSetType()
+     * Ignored by default since this method is only a hint.
      */
     @Override
-    public int getResultSetType() throws SQLException {
-        throw unsupportedOperation(Statement.class, "getResultSetType");
+    public void setPoolable(boolean poolable) throws SQLException {
     }
 
     /**
-     * @see java.sql.Statement#execute(java.lang.String, int)
+     * Unsupported by default.
      */
     @Override
-    public boolean execute(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") int autoGeneratedKeys) throws SQLException {
-        throw unsupportedOperation(Statement.class, "execute");
+    public void cancel() throws SQLException {
+        throw unsupportedOperation("cancel");
     }
 
     /**
-     * @see java.sql.Statement#execute(java.lang.String, int[])
+     * Unsupported by default.
      */
     @Override
-    public boolean execute(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") int[] columnIndexes) throws SQLException {
-        throw unsupportedOperation(Statement.class, "execute");
+    public void closeOnCompletion() throws SQLException {
+        throw unsupportedOperation("closeOnCompletion");
     }
 
     /**
-     * @see java.sql.Statement#execute(java.lang.String, java.lang.String[])
+     * Unsupported by default.
      */
     @Override
-    public boolean execute(@SuppressWarnings("unused") String sql, @SuppressWarnings("unused") String[] columnNames) throws SQLException {
-        throw unsupportedOperation(Statement.class, "execute");
+    public boolean isCloseOnCompletion() throws SQLException {
+        throw unsupportedOperation("isCloseOnCompletion");
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFConnection.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFConnection.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFConnection.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -16,109 +16,92 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
-import org.apache.sis.storage.shapefile.Database;
-import static java.util.logging.Level.*;
-
-import java.io.*;
 import java.sql.*;
-import java.util.*;
-import java.util.logging.*;
+import java.io.File;
+import java.io.IOException;
+import org.apache.sis.util.resources.Errors;
+import org.apache.sis.storage.shapefile.Database;
 
 
 /**
- * DBF Connection.
+ * Connection to a DBF database.
  *
  * @author  Marc Le Bihan
  * @version 0.5
  * @since   0.5
  * @module
  */
-public class DBFConnection extends AbstractConnection {
-    /** Database file. */
-    private File m_dataFile;
-
-    /** Database file. */
-    private Database m_database;
-
+final class DBFConnection extends AbstractConnection {
     /**
-     * Return the binary representation of the database.
-     * @return Database.
+     * The object to use for reading the database content.
      */
-    public Database getDatabase() {
-        return m_database;
-    }
+    final Database database;
 
     /**
-     * Return the data part file of this Dbase.
-     * @return *.dbf part of the database.
+     * Constructs a connection to the given database.
+     *
+     * @param  datafile Data file ({@code .dbf} extension).
+     * @throws IOException if the given file is invalid.
      */
-    public File getDataFile() {
-        return m_dataFile;
-    }
-
-    /**
-     * Construct a connection.
-     * @param datafile Data file (.dbf extension).
-     * @throws SQLException if the given file is invalid.
-     */
-    DBFConnection(File datafile) throws SQLException {
-        Objects.requireNonNull(datafile, "the database file to connect to cannot be null.");
-
+    DBFConnection(final File datafile) throws SQLException, IOException {
         // Check that file exists.
-        if (datafile.exists() == false)
-            throw(new SQLException(format(SEVERE, "excp.file_not_found", datafile.getAbsolutePath())));
-
+        if (!datafile.exists()) {
+            throw new SQLException(Errors.format(Errors.Keys.FileNotFound_1, datafile.getAbsolutePath()));
+        }
         // Check that its not a directory.
-        if (datafile.isDirectory())
-            throw(new SQLException(format(SEVERE, "excp.directory_not_expected", datafile.getAbsolutePath())));
-
-        m_dataFile = datafile;
-
-        try {
-            m_database = new Database(m_dataFile.getAbsolutePath());
-            m_database.loadDescriptor();
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException("Bug : File existence has been checked before.");
-        } catch(IOException e) {
-            String message = format(Level.SEVERE, "excp.invalid_dbf_format_descriptor", datafile.getAbsolutePath(), e.getMessage());
-            throw new InvalidDbaseFileFormatException(message);
+        if (datafile.isDirectory()) {
+            throw new SQLException(Errors.format(Errors.Keys.DirectoryNotExpected_1, datafile.getAbsolutePath()));
         }
+        database = new Database(datafile.getAbsolutePath());
+        database.loadDescriptor();
     }
 
     /**
-     * @see java.sql.Connection#createStatement()
+     * Creates an object for sending SQL statements to the database.
      */
     @Override
-    public Statement createStatement() {
+    public Statement createStatement() throws SQLException {
+        assertNotClosed();
         return new DBFStatement(this);
     }
 
     /**
-     * @see java.sql.Connection#close()
+     * Closes the connection to the database.
      */
     @Override
     public void close() throws SQLException {
         try {
-            m_database.close();
-        } catch(IOException e) {
-            throw new SQLException(e.getMessage(), e);
+            database.close();
+        } catch (IOException e) {
+            throw new SQLException(e.getLocalizedMessage(), e);
         }
     }
 
     /**
-     * @see java.sql.Connection#isClosed()
+     * Returns {@code true} if this connection has been closed.
      */
     @Override
     public boolean isClosed() {
-        return m_database.isClosed();
+        return database.isClosed();
+    }
+
+    /**
+     * Asserts that the connection is opened.
+     *
+     * @throws SQLException if the connection is closed.
+     */
+    final void assertNotClosed() throws SQLException {
+        if (isClosed()) {
+            throw new SQLNonTransientException(Resources.format(Resources.Keys.ClosedConnection));
+        }
     }
 
     /**
-     * @see java.sql.Connection#isValid(int)
+     * 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) {
-        this.getLogger().log(WARNING, "Connection.isValid(..) timeout parameter is ignored and the function bases itself only on isClosed state.");
-        return isClosed() == false;
+        return !isClosed();
     }
 }

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=1633816&r1=1633815&r2=1633816&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] Thu Oct 23 14:05:57 2014
@@ -16,10 +16,14 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
-import java.io.*;
 import java.sql.*;
-import java.util.*;
-import java.util.logging.*;
+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;
+
 
 /**
  * Database driver for DBF 3.
@@ -31,48 +35,82 @@ import java.util.logging.*;
  */
 public class DBFDriver extends AbstractJDBC implements Driver {
     /**
-     * @see java.sql.Driver#connect(java.lang.String, java.util.Properties)
+     * Creates a new driver.
+     */
+    public DBFDriver() {
+    }
+
+    /**
+     * Returns the JDBC interface implemented by this class.
+     * This is used for formatting error messages.
+     */
+    @Override
+    final Class<?> getInterface() {
+        return Driver.class;
+    }
+
+    /**
+     * Attempts to make a database connection to the given filename.
+     *
+     * @param  url  The path to a {@code .dbf} file.
+     * @param  info Ignored in current implementation.
+     * @return A connection to the given DBF file.
+     * @throws SQLException if this method can not create a connection to the given file.
      */
     @Override
-    public Connection connect(String url, @SuppressWarnings("unused") Properties info) throws SQLException {
-        return new DBFConnection(new File(url));
+    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()));
+        }
     }
 
     /**
-     * @see java.sql.Driver#acceptsURL(java.lang.String)
+     * Returns {@code true} if this driver thinks that it can open the given URL.
      */
     @Override
-    public boolean acceptsURL(@SuppressWarnings("unused") String url) {
-        return true;
+    public boolean acceptsURL(final String url) {
+        if (!url.endsWith(".dbf")) {
+            return false;
+        }
+        final File datafile = new File(url);
+        return datafile.isFile(); // Future version should check for magic number.
     }
 
     /**
-     * @see java.sql.Driver#getPropertyInfo(java.lang.String, java.util.Properties)
+     * Gets information about the possible properties for this driver.
+     * The current version has none.
      */
     @Override
-    public DriverPropertyInfo[] getPropertyInfo(@SuppressWarnings("unused") String url, @SuppressWarnings("unused") Properties info) {
-        return new DriverPropertyInfo[]{};
+    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
+        return new DriverPropertyInfo[0];
     }
 
     /**
-     * @see java.sql.Driver#getMajorVersion()
+     * The major version number of this driver.
+     * This is set to the Apache SIS version.
      */
     @Override
     public int getMajorVersion() {
-        return 0;
+        return Modules.MAJOR_VERSION;
     }
 
     /**
-     * @see java.sql.Driver#getMinorVersion()
+     * The minor version number of this driver.
+     * This is set to the Apache SIS version.
      */
     @Override
     public int getMinorVersion() {
-        return 1;
+        return Modules.MINOR_VERSION;
     }
 
     /**
-     * This driver is currently not compliant. It has to succeed these tests first : <a href="http://www.oracle.com/technetwork/java/jdbctestsuite-1-3-1-140675.html">Compliance tests</a>
-     * @see java.sql.Driver#jdbcCompliant()
+     * This driver is currently not compliant.
+     * It has to succeed these tests first:
+     * <a href="http://www.oracle.com/technetwork/java/jdbctestsuite-1-3-1-140675.html">Compliance tests</a>.
      */
     @Override
     public boolean jdbcCompliant() {
@@ -80,10 +118,10 @@ public class DBFDriver extends AbstractJ
     }
 
     /**
-     * @see java.sql.Driver#getParentLogger()
+     * The logger used by this driver.
      */
     @Override
     public Logger getParentLogger() {
-        return getLogger();
+        return LOGGER;
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSet.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSet.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSet.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -16,14 +16,9 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
-import org.apache.sis.storage.shapefile.Database;
-import static java.util.logging.Level.*;
-
-import java.math.*;
 import java.sql.*;
-import java.sql.Date;
-import java.util.*;
-import java.util.logging.*;
+import java.util.Map;
+import org.apache.sis.storage.shapefile.Database;
 
 
 /**
@@ -34,371 +29,104 @@ import java.util.logging.*;
  * @since   0.5
  * @module
  */
-public class DBFResultSet extends AbstractResultSet {
-    /** Parent statement. */
-    private DBFStatement m_parentStatement;
-
-    /** Indicate if the ResultSet is closed. */
-    private boolean m_closed;
-
-    /** Current record. */
-    private HashMap<String, Object> m_currentRecord;
-
-    /**
-     * Constructs a ResultSet.
-     * @param parentStatement Parent statement.
-     */
-    DBFResultSet(DBFStatement parentStatement) {
-        Objects.requireNonNull(parentStatement, "The parent Statement of the ResulSet cannot be null.");
-
-        m_parentStatement = parentStatement;
-        m_closed = false;
-    }
-
-    /**
-     * @see java.sql.ResultSet#next()
-     */
-    @Override
-    public boolean next() throws SQLException {
-        assertNotClosed();
-
-        // Check that we aren't at the end of the Database file.
-        if (getDatabase().getRowNum() >= getDatabase().getRecordCount()) {
-            String message = format(Level.SEVERE, "excp.no_more_results");
-            throw new SQLException(message);
-        }
-
-        // TODO : Currently this function is only able to return String objects.
-        m_currentRecord = getDatabase().readNextRowAsObjects();
-
-        // Return the availability of a next record.
-        boolean nextRecord = getDatabase().getRowNum() < getDatabase().getRecordCount();
-        return nextRecord;
-    }
-
-    /**
-     * @see java.sql.ResultSet#close()
-     */
-    @Override
-    public void close() {
-        m_closed = true;
-    }
-
-    /**
-     * @see java.sql.ResultSet#isClosed()
-     */
-    @Override
-    public boolean isClosed() {
-        return m_closed || this.m_parentStatement.isClosed();
-    }
-
-    /**
-     * @see java.sql.ResultSet#getString(int)
-     */
-    @Override
-    public String getString(int columnIndex) throws SQLException {
-        assertNotClosed();
-
-        return null;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getBoolean(int)
-     */
-    @Override
-    public boolean getBoolean(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return false;
-    }
-
+final class DBFResultSet extends AbstractResultSet {
     /**
-     * @see java.sql.ResultSet#getByte(int)
+     * Parent statement.
      */
-    @Override
-    public byte getByte(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return 0;
-    }
+    private final DBFStatement statement;
 
     /**
-     * @see java.sql.ResultSet#getShort(int)
+     * A copy of the {@link DBFConnection#database} reference, copied here for efficiency.
      */
-    @Override
-    public short getShort(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return 0;
-    }
+    private final Database database;
 
     /**
-     * @see java.sql.ResultSet#getInt(int)
+     * Indicates if the ResultSet is closed.
      */
-    @Override
-    public int getInt(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return 0;
-    }
+    private boolean isClosed;
 
     /**
-     * @see java.sql.ResultSet#getLong(int)
+     * The current records.
      */
-    @Override
-    public long getLong(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return 0;
-    }
+    private Map<String, Object> records;
 
     /**
-     * @see java.sql.ResultSet#getFloat(int)
+     * Constructs a result set.
+     *
+     * @param statement Parent statement.
      */
-    @Override
-    public float getFloat(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return 0;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getDouble(int)
-     */
-    @Override
-    public double getDouble(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return 0;
+    DBFResultSet(final DBFStatement statement) {
+        this.statement = statement;
+        database = statement.connection.database;
     }
 
     /**
-     * @see java.sql.ResultSet#getBigDecimal(int, int)
+     * Returns the parent statement.
      */
     @Override
-    public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+    public Statement getStatement() throws SQLException {
         assertNotClosed();
-        return null;
+        return statement;
     }
 
     /**
-     * @see java.sql.ResultSet#getBytes(int)
+     * Moves the cursor forward one row from its current position.
      */
     @Override
-    public byte[] getBytes(int columnIndex) throws SQLException {
+    public boolean next() throws SQLException {
         assertNotClosed();
-        return null;
-    }
 
-    /**
-     * @see java.sql.ResultSet#getDate(int)
-     */
-    @Override
-    public Date getDate(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return null;
-    }
+        // Check that we aren't at the end of the Database file.
+        final int remaining = database.getRecordCount() - database.getRowNum();
+        if (remaining <= 0) {
+            throw new SQLNonTransientException(Resources.format(Resources.Keys.NoMoreResults));
+        }
 
-    /**
-     * @see java.sql.ResultSet#getTime(int)
-     */
-    @Override
-    public Time getTime(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return null;
-    }
+        // TODO : Currently this function is only able to return String objects.
+        records = database.readNextRowAsObjects();
 
-    /**
-     * @see java.sql.ResultSet#getTimestamp(int)
-     */
-    @Override
-    public Timestamp getTimestamp(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return null;
+        // Return the availability of a next record.
+        return remaining > 1;
     }
 
     /**
-     * @see java.sql.ResultSet#getString(java.lang.String)
+     * Returns the value in the current row for the given column.
      */
     @Override
     public String getString(String columnLabel) throws SQLException {
         assertNotClosed();
-        return (String)m_currentRecord.get(columnLabel);
-    }
-
-    /**
-     * @see java.sql.ResultSet#getBoolean(java.lang.String)
-     */
-    @Override
-    public boolean getBoolean(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return false;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getByte(java.lang.String)
-     */
-    @Override
-    public byte getByte(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return 0;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getShort(java.lang.String)
-     */
-    @Override
-    public short getShort(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return 0;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getInt(java.lang.String)
-     */
-    @Override
-    public int getInt(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return 0;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getLong(java.lang.String)
-     */
-    @Override
-    public long getLong(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return 0;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getFloat(java.lang.String)
-     */
-    @Override
-    public float getFloat(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return 0;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getDouble(java.lang.String)
-     */
-    @Override
-    public double getDouble(String columnLabel) throws SQLException {
-        assertNotClosed();
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getBigDecimal(java.lang.String, int)
-     */
-    @Override
-    public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
-        assertNotClosed();
-        return null;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getBytes(java.lang.String)
-     */
-    @Override
-    public byte[] getBytes(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return null;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getDate(java.lang.String)
-     */
-    @Override
-    public Date getDate(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return null;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getTime(java.lang.String)
-     */
-    @Override
-    public Time getTime(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return null;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getTimestamp(java.lang.String)
-     */
-    @Override
-    public Timestamp getTimestamp(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return null;
-    }
-
-
-    /**
-     * @see java.sql.ResultSet#getMetaData()
-     */
-    @Override
-    public ResultSetMetaData getMetaData() throws SQLException {
-        assertNotClosed();
-        return null;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getObject(int)
-     */
-    @Override
-    public Object getObject(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return null;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getObject(java.lang.String)
-     */
-    @Override
-    public Object getObject(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return null;
-    }
-
-    /**
-     * @see java.sql.ResultSet#getBigDecimal(int)
-     */
-    @Override
-    public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
-        assertNotClosed();
-        return null;
+        final Object value = records.get(columnLabel);
+        if (value != null) {
+            return (String) value;
+        }
+        throw new SQLNonTransientException(Resources.format(Resources.Keys.NoSuchColumn_1, columnLabel));
     }
 
     /**
-     * @see java.sql.ResultSet#getBigDecimal(java.lang.String)
+     * Closes this result set.
      */
     @Override
-    public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
-        assertNotClosed();
-        return null;
+    public void close() {
+        isClosed = true;
     }
 
     /**
-     * @see java.sql.ResultSet#getStatement()
+     * Returns {@code true} if this result set has been closed.
      */
     @Override
-    public Statement getStatement() throws SQLException {
-        assertNotClosed();
-        return m_parentStatement;
+    public boolean isClosed() {
+        return isClosed || statement.isClosed();
     }
 
     /**
-     * Asserts that the connection and the statement are together opened.
+     * Asserts that the connection, statement and result set are together opened.
+     *
      * @throws SQLException if one of them is closed.
      */
     private void assertNotClosed() throws SQLException {
-        if (isClosed())
-            throw new SQLException(this.format(SEVERE, "excp.closed_connection"));
-    }
-
-    /**
-     * Return the underlying database binary representation.
-     * @return Database.
-     * @throws SQLException if the database is closed.
-     */
-    private Database getDatabase() throws SQLException {
-        assertNotClosed();
-        return ((DBFConnection)m_parentStatement.getConnection()).getDatabase();
+        statement.assertNotClosed();
+        if (isClosed) {
+            throw new SQLNonTransientException(Resources.format(Resources.Keys.ClosedResultSet));
+        }
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFStatement.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFStatement.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFStatement.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFStatement.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -16,10 +16,9 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
-import static java.util.logging.Level.*;
-
 import java.sql.*;
-import java.util.*;
+import org.apache.sis.util.ArgumentChecks;
+
 
 /**
  * DBF Statement.
@@ -29,88 +28,91 @@ import java.util.*;
  * @since   0.5
  * @module
  */
-public class DBFStatement extends AbstractStatement {
-    /** Connection this statement is relying on. */
-    private DBFConnection m_parentConnection;
-
-    /** Indicate if the statement is currently closed. */
-    boolean m_closed;
-
+final class DBFStatement extends AbstractStatement {
     /**
-     * Create a statement.
-     * @param connection Connection associated to this statement.
+     * Connection this statement is relying on.
      */
-    DBFStatement(DBFConnection connection) {
-        Objects.requireNonNull(connection, "The parent Connection of the ResulSet cannot be null.");
+    final DBFConnection connection;
 
-        m_parentConnection = connection;
-        m_closed = false;
-    }
+    /**
+     * The current result set, or {@code null} if none.
+     */
+    private DBFResultSet resultSet;
 
     /**
-     * @see java.sql.Statement#executeQuery(java.lang.String)
+     * Indicates if the statement is currently closed.
      */
-    @Override
-    public ResultSet executeQuery(String sql) throws SQLException {
-        Objects.requireNonNull(sql, "The SQL query for executeQuery cannot be null.");
+    private boolean isClosed;
 
-        assertNotClosed();
-        return new DBFResultSet(this);
+    /**
+     * Constructs a statement.
+     *
+     * @param connection Connection associated to this statement.
+     */
+    DBFStatement(final DBFConnection connection) {
+        this.connection = connection;
     }
 
     /**
-     * @see java.sql.Statement#close()
+     * Returns the connection.
      */
     @Override
-    public void close() {
-        m_closed = true;
+    public Connection getConnection() throws SQLException {
+        assertNotClosed();
+        return connection;
     }
 
     /**
-     * @see java.sql.Statement#execute(java.lang.String)
+     * Executes the given SQL statement.
      */
     @Override
-    public boolean execute(String sql) throws SQLException {
-        Objects.requireNonNull(sql, "The SQL query for execute cannot be null.");
-        return false;
+    public ResultSet executeQuery(final String sql) throws SQLException {
+        ArgumentChecks.ensureNonNull("sql", sql);
+        assertNotClosed();
+        if (resultSet != null) {
+            resultSet.close();
+        }
+        return resultSet = new DBFResultSet(this);
     }
 
     /**
-     * @see java.sql.Statement#getResultSet()
+     * Returns the result set created by the last call to {@link #executeQuery(String)}.
      */
     @Override
     public ResultSet getResultSet() throws SQLException {
         assertNotClosed();
-        return new DBFResultSet(this);
+        return resultSet;
     }
 
-
     /**
-     * @see java.sql.Statement#getConnection()
+     * Closes this statement.
      */
     @Override
-    public Connection getConnection() throws SQLException {
-        if (m_parentConnection.isClosed())
-            throw new SQLException(this.format(SEVERE, "excp.closed_connection"));
-        else
-            return m_parentConnection;
+    public void close() {
+        if (resultSet != null) {
+            resultSet.close();
+        }
+        isClosed = true;
     }
 
     /**
-     * @see java.sql.Statement#isClosed()
+     * Returns {@code true} if this statement has been closed
+     * or if the underlying connection is closed.
      */
     @Override
     public boolean isClosed() {
-        assert(m_parentConnection != null);
-        return m_parentConnection.isClosed() || m_closed;
+        return isClosed || connection.isClosed();
     }
 
     /**
      * Asserts that the connection and the statement are together opened.
+     *
      * @throws SQLException if one of them is closed.
      */
-    private void assertNotClosed() throws SQLException {
-        if (isClosed())
-            throw new SQLException(this.format(SEVERE, "excp.closed_connection"));
+    final void assertNotClosed() throws SQLException {
+        connection.assertNotClosed();
+        if (isClosed) {
+            throw new SQLNonTransientException(Resources.format(Resources.Keys.ClosedStatement));
+        }
     }
 }

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.java?rev=1633816&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -0,0 +1,164 @@
+/*
+ * 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.net.URL;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import org.apache.sis.util.resources.IndexedResourceBundle;
+
+
+/**
+ * Locale-dependent resources for messages.
+ *
+ * @author  Marc Le Bihan
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.5
+ * @version 0.5
+ * @module
+ */
+public final class Resources extends IndexedResourceBundle {
+    /**
+     * Resource keys. This class is used when compiling sources, but no dependencies to
+     * {@code Keys} should appear in any resulting class files. Since the Java compiler
+     * inlines final integer values, using long identifiers will not bloat the constant
+     * pools of compiled classes.
+     *
+     * @author  Marc Le Bihan
+     * @author  Martin Desruisseaux (Geomatys)
+     * @since   0.5
+     * @version 0.5
+     * @module
+     */
+    public static final class Keys {
+        /**
+         * For {@link #INSTANCE} creation only.
+         */
+        private Keys() {
+        }
+
+        /**
+         * The auto-commit ‘{0}’ value is currently ignored (not implemented): auto-commit is always
+         * true.
+         */
+        public static final short AutoCommitIgnored_1 = 0;
+
+        /**
+         * The connection is closed.
+         */
+        public static final short ClosedConnection = 1;
+
+        /**
+         * The result set is closed.
+         */
+        public static final short ClosedResultSet = 3;
+
+        /**
+         * The statement is closed.
+         */
+        public static final short ClosedStatement = 2;
+
+        /**
+         * Commit and rollback has no effect (currently not implemented): auto-commit is always true.
+         */
+        public static final short CommitRollbackIgnored = 4;
+
+        /**
+         * The “{0}” DBF file seems to have an invalid format, as its descriptor could not be read: {1}
+         */
+        public static final short InvalidDBFFormatDescriptor_2 = 5;
+
+        /**
+         * The result set has no more results.
+         */
+        public static final short NoMoreResults = 6;
+
+        /**
+         * There is no “{0}” column in this query.
+         */
+        public static final short NoSuchColumn_1 = 8;
+
+        /**
+         * Internal JDBC driver currently does not support the {0}.{1} ability/calls.
+         */
+        public static final short UnsupportedDriverFeature_2 = 7;
+    }
+
+    /**
+     * Constructs a new resource bundle loading data from the given UTF file.
+     *
+     * @param resources The path of the binary file containing resources, or {@code null} if
+     *        there is no resources. The resources may be a file or an entry in a JAR file.
+     */
+    public Resources(final URL resources) {
+        super(resources);
+    }
+
+    /**
+     * Returns resources in the given locale.
+     *
+     * @param  locale The locale, or {@code null} for the default locale.
+     * @return Resources in the given locale.
+     * @throws MissingResourceException if resources can't be found.
+     */
+    public static Resources getResources(final Locale locale) throws MissingResourceException {
+        return getBundle(Resources.class, locale);
+    }
+
+    /**
+     * Gets a string for the given key from this resource bundle or one of its parents.
+     *
+     * @param  key The key for the desired string.
+     * @return The string for the given key.
+     * @throws MissingResourceException If no object for the given key can be found.
+     */
+    public static String format(final short key) throws MissingResourceException {
+        return getResources(null).getString(key);
+    }
+
+    /**
+     * Gets a string for the given key are replace all occurrence of "{0}"
+     * with values of {@code arg0}.
+     *
+     * @param  key The key for the desired string.
+     * @param  arg0 Value to substitute to "{0}".
+     * @return The formatted string for the given key.
+     * @throws MissingResourceException If no object for the given key can be found.
+     */
+    public static String format(final short  key,
+                                final Object arg0) throws MissingResourceException
+    {
+        return getResources(null).getString(key, arg0);
+    }
+
+    /**
+     * Gets a string for the given key are replace all occurrence of "{0}",
+     * "{1}", with values of {@code arg0}, {@code arg1}.
+     *
+     * @param  key The key for the desired string.
+     * @param  arg0 Value to substitute to "{0}".
+     * @param  arg1 Value to substitute to "{1}".
+     * @return The formatted string for the given key.
+     * @throws MissingResourceException If no object for the given key can be found.
+     */
+    public static String format(final short  key,
+                                final Object arg0,
+                                final Object arg1) throws MissingResourceException
+    {
+        return getResources(null).getString(key, arg0, arg1);
+    }
+}

Propchange: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.properties?rev=1633816&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.properties (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.properties [ISO-8859-1] Thu Oct 23 14:05:57 2014
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+#0: true / false.
+AutoCommitIgnored_1   = The auto-commit \u2018{0}\u2019 value is currently ignored (not implemented): auto-commit is always true.
+ClosedConnection      = The connection is closed.
+ClosedStatement       = The statement is closed.
+ClosedResultSet       = The result set is closed.
+CommitRollbackIgnored = Commit and rollback has no effect (currently not implemented): auto-commit is always true.
+
+#0: File that causes trouble.
+#1: Message coming with the root cause.
+InvalidDBFFormatDescriptor_2 = The \u201c{0}\u201d DBF file seems to have an invalid format, as its descriptor could not be read: {1}
+NoMoreResults = The result set has no more results.
+NoSuchColumn_1 = There is no \u201c{0}\u201d column in this query.
+
+#0: Simple class name.
+#1: Method name (or goal / feature asked for).
+UnsupportedDriverFeature_2 = Internal JDBC driver currently does not support the {0}.{1} ability/calls.

Propchange: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=ISO-8859-1

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources_fr.properties?rev=1633816&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources_fr.properties (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources_fr.properties [ISO-8859-1] Thu Oct 23 14:05:57 2014
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+#0: true / false.
+AutoCommitIgnored_1   = L\u2019auto-commit \u2018{0}\u2019 est actuellement ignor\u00e9 (non impl\u00e9ment\u00e9)\u202f: L\u2019auto-commit vaut toujours \u2018vrai\u2019.
+ClosedConnection      = La connexion est ferm\u00e9e.
+ClosedStatement       = La connexion ou le statement sont ferm\u00e9s.
+ClosedResultSet       = La connexion, le statement ou le ResultSet sont ferm\u00e9s.
+CommitRollbackIgnored = Les commit et rollback n'ont pas d\u2019effet (ils ne sont pas actuellement impl\u00e9ment\u00e9s)\u202f: l\u2019auto-commit vaut toujours \u2018vrai\u2019.
+
+#0: File that causes trouble.
+#1: Message coming with the root cause.
+InvalidDBFFormatDescriptor_2 = Le fichier DBF \u00ab\u202f{0}\u202f\u00bb semble avoir un format invalide, son descripteur n\u2019a pas pu \u00eatre lu\u202f: {1}
+NoMoreResults = Le ResultSet n\u2019a plus de r\u00e9sultats.
+NoSuchColumn_1 = Il n\u2019y a pas de colonne \u00ab\u202f{0}\u202f\u00bb dans cette requ\u00eate.
+
+#0: Simple class name.
+#1: Method name (or goal / feature asked for).
+UnsupportedDriverFeature_2 = Le pilote JDBC interne n'a pas actuellement la capacit\u00e9 de, ou ne soutient pas les appels \u00e0 {0}.{1}.

Propchange: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources_fr.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Resources_fr.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=ISO-8859-1

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/package-info.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/package-info.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-
 /**
  * Shapefile.
  *

Copied: sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java (from r1633642, sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/ResultSetTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java?p2=sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java&p1=sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/ResultSetTest.java&r1=1633642&r2=1633816&rev=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/ResultSetTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -16,75 +16,106 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
-import static org.junit.Assert.*;
-
-import java.io.*;
 import java.sql.*;
-import java.text.*;
-
+import java.io.File;
+import java.net.URL;
+import java.net.URISyntaxException;
+import org.apache.sis.storage.shapefile.Database;
+import org.apache.sis.test.DependsOnMethod;
+import org.apache.sis.test.TestCase;
 import org.junit.*;
-import org.opengis.test.*;
+
+import static org.junit.Assert.*;
+
 
 /**
- * ResultSet test.
+ * Tests {@link DBFResultSet}.
  *
  * @author  Marc Le Bihan
  * @version 0.5
  * @since   0.5
  * @module
  */
-public class ResultSetTest extends TestCase {
-	/** Database file. */
-	private File dbfFile;
-
-	/**
-	 * Read the first record.
-	 * @throws SQLException if an SQL error occurs.
-	 */
-	@Test public void readFirstRecord() throws SQLException {
-		Driver driver = new DBFDriver();
-
-		Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
-		Statement stmt = connection.createStatement();
-		ResultSet rs = stmt.executeQuery("Dummy"); // We don't care currently of the request : we are returning everything each time.
-
-		rs.next();
-		assertEquals("The record has not the expected field value.", "336TH ST", rs.getString("ST_NAME"));
-
-		rs.close();
-		stmt.close();
-		connection.close();
-	}
-
-	/**
-	 * Read all the DBF records.
-	 * @throws SQLException if an SQL error occurs.
-	 */
-	@Test public void readAllRecords() throws SQLException {
-		Driver driver = new DBFDriver();
-
-		Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
-		Statement stmt = connection.createStatement();
-		ResultSet rs = stmt.executeQuery("Dummy"); // We don't care currently of the request : we are returning everything each time.
-
-		int count = 0;
-
-		while(rs.next())
-			count ++;
-
-		assertTrue("Less than one record was readed.", count > 1);
-
-		rs.close();
-		stmt.close();
-		connection.close();
-	}
-
-	/**
-	 * Test setup.
-	 */
-	@Before public void setup() {
-		dbfFile = new File("src/test/resources/org/apache/sis/storage/shapefile/SignedBikeRoute_4326_clipped.dbf");
-		assertTrue(MessageFormat.format("The database file ''{0}'' used for testing doesn''t exist." , dbfFile.getAbsolutePath()), dbfFile.exists());
-	}
-
+public class DBFResultSetTest extends TestCase {
+    /**
+     * The database file to use for testing purpose.
+     */
+    private File dbfFile;
+
+    /**
+     * Test setup.
+     *
+     * @throws URISyntaxException If an error occurred while getting the file to the test database.
+     */
+    @Before
+    public void setup() throws URISyntaxException {
+        final URL url = Database.class.getResource("SignedBikeRoute_4326_clipped.dbf");
+        assertNotNull("The database file used for testing doesn't exist.", url);
+        dbfFile = new File(url.toURI());
+        assertTrue(dbfFile.isFile());
+    }
+
+    /**
+     * Open and close a connection.
+     *
+     * @throws SQLException if an error occurred while querying the database.
+     */
+    @Test
+    public void openCloseConnection() throws SQLException {
+        final Driver     driver     = new DBFDriver();
+        final Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
+        assertFalse("Connection should be opened", connection.isClosed());
+        assertTrue ("Connection should be valid",  connection.isValid(0));
+
+        connection.close();
+        assertTrue ("Connection should be closed", connection.isClosed());
+        assertFalse("Connection should no more be valid", connection.isValid(0));
+    }
+
+    /**
+     * Reads the first record.
+     *
+     * @throws SQLException if an error occurred while querying the database.
+     */
+    @Test
+    @DependsOnMethod("openCloseConnection")
+    public void readFirstRecord() throws SQLException {
+        final Driver     driver     = new DBFDriver();
+        final Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
+        final Statement  stmt       = connection.createStatement();
+        final ResultSet  rs         = stmt.executeQuery("SELECT * FROM SignedBikeRoute");
+        // We don't care currently of the request: we are returning everything each time.
+
+        rs.next();
+        assertEquals("getString(\"ST_NAME\")", "336TH ST", rs.getString("ST_NAME"));
+
+        rs.close();
+        stmt.close();
+        connection.close();
+    }
+
+    /**
+     * Read all the DBF records.
+     *
+     * @throws SQLException if an error occurred while querying the database.
+     */
+    @Test
+    @DependsOnMethod("readFirstRecord")
+    public void readAllRecords() throws SQLException {
+        final Driver     driver     = new DBFDriver();
+        final Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
+        final Statement  stmt       = connection.createStatement();
+        final ResultSet  rs         = stmt.executeQuery("SELECT * FROM SignedBikeRoute");
+        // We don't care currently of the request: we are returning everything each time.
+
+        int count = 0;
+        while (rs.next()) {
+            count++;
+        }
+        assertTrue("Less than one record was readed.", count > 1);
+
+        rs.close();
+        stmt.close();
+        connection.close();
+    }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java?rev=1633816&r1=1633815&r2=1633816&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java [UTF-8] Thu Oct 23 14:05:57 2014
@@ -26,8 +26,7 @@ import org.junit.BeforeClass;
  */
 @Suite.SuiteClasses({
     org.apache.sis.storage.shapefile.ShapeFileTest.class,
-    org.apache.sis.internal.shapefile.jdbc.ConnectionTest.class,
-    org.apache.sis.internal.shapefile.jdbc.ResultSetTest.class
+    org.apache.sis.internal.shapefile.jdbc.DBFResultSetTest.class
 })
 public final strictfp class ShapefileTestSuite extends TestSuite {
     /**



Mime
View raw message