sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlebi...@apache.org
Subject svn commit: r1718297 [2/2] - in /sis/branches/JDK8/storage/sis-shapefile/src: main/java/org/apache/sis/internal/shapefile/ main/java/org/apache/sis/internal/shapefile/jdbc/ main/java/org/apache/sis/internal/shapefile/jdbc/connection/ main/java/org/apac...
Date Mon, 07 Dec 2015 10:35:09 GMT
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -49,6 +49,9 @@ public class DBFRecordBasedResultSet ext
     /** Indicates that the last result set record matching conditions has already been returned, and a further call of next() shall throw a "no more record" exception. */
     private boolean lastResultSetRecordAlreadyReturned;
     
+    /** The record number of this record. */
+    private int recordNumber;
+    
     /**
      * Constructs a result set.
      * @param stmt Parent statement.
@@ -57,7 +60,7 @@ public class DBFRecordBasedResultSet ext
      */
     public DBFRecordBasedResultSet(final DBFStatement stmt, String sqlQuery) throws SQLInvalidStatementException {
         super(stmt, sqlQuery);
-        singleConditionOfWhereClause = new CrudeSQLParser(this).parse();
+        this.singleConditionOfWhereClause = new CrudeSQLParser(this).parse();
     }
 
     /**
@@ -79,11 +82,11 @@ public class DBFRecordBasedResultSet ext
 
             if (doubleValue != null) {
                 BigDecimal number = new BigDecimal(doubleValue, mc);
-                wasNull = false;
+                this.wasNull = false;
                 return number;
             }
             else {
-                wasNull = true;
+                this.wasNull = true;
                 return null;
             }
         }
@@ -99,7 +102,7 @@ public class DBFRecordBasedResultSet ext
     @Override
     public BigDecimal getBigDecimal(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException {
         logStep("getBigDecimal", columnIndex);
-        return getBigDecimal(getFieldName(columnIndex, sql));
+        return getBigDecimal(getFieldName(columnIndex, this.sql));
     }
 
     /**
@@ -120,11 +123,11 @@ public class DBFRecordBasedResultSet ext
 
         if (doubleValue != null) {
             BigDecimal number = new BigDecimal(getDouble(columnLabel), mc);
-            wasNull = false;
+            this.wasNull = false;
             return number;
         }
         else {
-            wasNull = true;
+            this.wasNull = true;
             return null;
         }
     }
@@ -143,18 +146,18 @@ public class DBFRecordBasedResultSet ext
         String value = getString(columnLabel);
 
         if (value == null || value.equals("00000000")) { // "00000000" is stored in Database to represent a null value too.
-            wasNull = true;
+            this.wasNull = true;
             return null; // The ResultSet:getDate() contract is to return null when a null date is encountered.
         }
         else {
-            wasNull = false;
+            this.wasNull = false;
         }
 
         // The DBase 3 date format is "YYYYMMDD".
         // if the length of the string isn't eight characters, the field format is incorrect.
         if (value.length() != 8) {
-            String message = format(Level.WARNING, "excp.field_is_not_a_date", columnLabel, sql, value);
-            throw new SQLNotDateException(message, sql, getFile(), columnLabel, value);
+            String message = format(Level.WARNING, "excp.field_is_not_a_date", columnLabel, this.sql, value);
+            throw new SQLNotDateException(message, this.sql, getFile(), columnLabel, value);
         }
 
         // Extract the date parts.
@@ -166,8 +169,8 @@ public class DBFRecordBasedResultSet ext
             dayOfMonth = Integer.parseInt(value.substring(7));
         }
         catch(NumberFormatException e) {
-            String message = format(Level.WARNING, "excp.field_is_not_a_date", columnLabel, sql, value);
-            throw new SQLNotDateException(message, sql, getFile(), columnLabel, value);
+            String message = format(Level.WARNING, "excp.field_is_not_a_date", columnLabel, this.sql, value);
+            throw new SQLNotDateException(message, this.sql, getFile(), columnLabel, value);
         }
 
         // Create a date.
@@ -186,7 +189,7 @@ public class DBFRecordBasedResultSet ext
     @Override
     public Date getDate(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotDateException, SQLIllegalColumnIndexException {
         logStep("getDate", columnIndex);
-        return getDate(getFieldName(columnIndex, sql));
+        return getDate(getFieldName(columnIndex, this.sql));
     }
 
     /**
@@ -200,7 +203,7 @@ public class DBFRecordBasedResultSet ext
         logStep("getDouble", columnLabel);
 
         Double value = getNumeric(columnLabel, Double::parseDouble);
-        wasNull = (value == null);
+        this.wasNull = (value == null);
         return value != null ? value : 0.0; // The ResultSet contract for numbers is to return 0 when a null value is encountered.
     }
 
@@ -214,7 +217,7 @@ public class DBFRecordBasedResultSet ext
     @Override
     public double getDouble(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException {
         logStep("getDouble", columnIndex);
-        return getDouble(getFieldName(columnIndex, sql));
+        return getDouble(getFieldName(columnIndex, this.sql));
     }
 
     /**
@@ -228,7 +231,7 @@ public class DBFRecordBasedResultSet ext
         logStep("getFloat", columnLabel);
 
         Float value = getNumeric(columnLabel, Float::parseFloat);
-        wasNull = (value == null);
+        this.wasNull = (value == null);
         return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered.
     }
 
@@ -242,7 +245,7 @@ public class DBFRecordBasedResultSet ext
     @Override
     public float getFloat(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException {
         logStep("getFloat", columnIndex);
-        return getFloat(getFieldName(columnIndex, sql));
+        return getFloat(getFieldName(columnIndex, this.sql));
     }
 
     /**
@@ -256,7 +259,7 @@ public class DBFRecordBasedResultSet ext
         logStep("getInt", columnLabel);
 
         Integer value = getNumeric(columnLabel, Integer::parseInt);
-        wasNull = (value == null);
+        this.wasNull = (value == null);
         return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered.
     }
 
@@ -270,7 +273,7 @@ public class DBFRecordBasedResultSet ext
     @Override
     public int getInt(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException {
         logStep("getInt", columnIndex);
-        return getInt(getFieldName(columnIndex, sql));
+        return getInt(getFieldName(columnIndex, this.sql));
     }
 
     /**
@@ -284,7 +287,7 @@ public class DBFRecordBasedResultSet ext
         logStep("getLong", columnLabel);
 
         Long value = getNumeric(columnLabel, Long::parseLong);
-        wasNull = (value == null);
+        this.wasNull = (value == null);
         return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered.
     }
 
@@ -297,7 +300,7 @@ public class DBFRecordBasedResultSet ext
      */
     @Override public long getLong(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException {
         logStep("getLong", columnIndex);
-        return getLong(getFieldName(columnIndex, sql));
+        return getLong(getFieldName(columnIndex, this.sql));
     }
 
     /**
@@ -316,7 +319,7 @@ public class DBFRecordBasedResultSet ext
      */
     @Override
     public Object getObject(int column) throws SQLConnectionClosedException, SQLIllegalColumnIndexException, SQLFeatureNotSupportedException, SQLNoSuchFieldException, SQLNotNumericException, SQLNotDateException {
-        try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(column, sql)) {
+        try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(column, this.sql)) {
             String fieldType;
 
             try {
@@ -405,6 +408,14 @@ public class DBFRecordBasedResultSet ext
     }
 
     /**
+     * Return the record number of this record.
+     * @return Record number of this record.
+     */
+    public int getRowNum()  {
+        return this.recordNumber;
+    }
+    
+    /**
      * @see java.sql.ResultSet#getShort(java.lang.String)
      * @throws SQLConnectionClosedException if the connection is closed.
      * @throws SQLNoSuchFieldException if the field looked for doesn't exist.
@@ -415,7 +426,7 @@ public class DBFRecordBasedResultSet ext
         logStep("getShort", columnLabel);
 
         Short value = getNumeric(columnLabel, Short::parseShort);
-        wasNull = (value == null);
+        this.wasNull = (value == null);
         return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered.
     }
 
@@ -429,7 +440,7 @@ public class DBFRecordBasedResultSet ext
     @Override
     public short getShort(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException {
         logStep("getShort", columnIndex);
-        return getShort(getFieldName(columnIndex, sql));
+        return getShort(getFieldName(columnIndex, this.sql));
     }
 
     /**
@@ -444,15 +455,15 @@ public class DBFRecordBasedResultSet ext
         logStep("getString", columnLabel);
         assertNotClosed();
 
-        getFieldDesc(columnLabel, sql); // Ensure that the field queried exists, else a null value here can be interpreted as "not existing" or "has a null value".
-        byte[] bytes = record.get(columnLabel);
+        getFieldDesc(columnLabel, this.sql); // Ensure that the field queried exists, else a null value here can be interpreted as "not existing" or "has a null value".
+        byte[] bytes = this.record.get(columnLabel);
 
         if (bytes == null) {
-            wasNull = true;
+            this.wasNull = true;
             return null;
         }
         else {
-            wasNull = false;
+            this.wasNull = false;
         }
 
         // If a non null value has been readed, convert it to the wished Charset (provided one has been given).
@@ -478,7 +489,7 @@ public class DBFRecordBasedResultSet ext
     @Override
     public String getString(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLIllegalColumnIndexException {
         logStep("getString", columnIndex);
-        return(getString(getFieldName(columnIndex, sql)));
+        return(getString(getFieldName(columnIndex, this.sql)));
     }
 
     /**
@@ -502,7 +513,7 @@ public class DBFRecordBasedResultSet ext
         // Check that we aren't at the end of the Database file.
         if (cnt.nextRowAvailable() == false) {
             if (this.lastResultSetRecordAlreadyReturned) {
-                throw new SQLNoResultException(format(Level.WARNING, "excp.no_more_results", sql, getFile().getName()), sql, getFile());
+                throw new SQLNoResultException(format(Level.WARNING, "excp.no_more_results", this.sql, getFile().getName()), this.sql, getFile());
             }
             else {
                 this.lastResultSetRecordAlreadyReturned = true;
@@ -530,8 +541,9 @@ public class DBFRecordBasedResultSet ext
         DBFConnection cnt = (DBFConnection)((DBFStatement)getStatement()).getConnection();
 
         while(cnt.nextRowAvailable() && recordMatchesConditions == false) {
-            record = cnt.readNextRowAsObjects();
-            recordMatchesConditions = singleConditionOfWhereClause == null || singleConditionOfWhereClause.isVerified(this);
+            this.record = cnt.readNextRowAsObjects();
+            this.recordNumber = cnt.getRowNum();
+            recordMatchesConditions = this.singleConditionOfWhereClause == null || this.singleConditionOfWhereClause.isVerified(this);
         }
 
         return recordMatchesConditions;
@@ -552,7 +564,7 @@ public class DBFRecordBasedResultSet ext
     @Override
     public boolean wasNull() {
         logStep("wasNull");
-        return wasNull;
+        return this.wasNull;
     }
 
     /**
@@ -568,7 +580,7 @@ public class DBFRecordBasedResultSet ext
     private <T extends Number> T getNumeric(String columnLabel, Function<String, T> parse) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException {
         assertNotClosed();
 
-        try(DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql)) {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, this.sql)) {
             String textValue = getString(columnLabel);
             
             if (textValue == null) {
@@ -581,8 +593,8 @@ public class DBFRecordBasedResultSet ext
                 return(value);
             }
             catch(NumberFormatException e) {
-                String message = format(Level.WARNING, "excp.field_is_not_numeric", columnLabel, rs.getString("TYPE_NAME"), sql, textValue);
-                throw new SQLNotNumericException(message, sql, getFile(), columnLabel, textValue);
+                String message = format(Level.WARNING, "excp.field_is_not_numeric", columnLabel, rs.getString("TYPE_NAME"), this.sql, textValue);
+                throw new SQLNotNumericException(message, this.sql, getFile(), columnLabel, textValue);
             }
         }
     }
@@ -592,6 +604,6 @@ public class DBFRecordBasedResultSet ext
      */
     @Override
     public String toString() {
-        return format("toString", statement != null ? statement.toString() : null, sql, isClosed() == false);
+        return format("toString", this.statement != null ? this.statement.toString() : null, this.sql, isClosed() == false);
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -56,8 +56,8 @@ public abstract class DBFResultSet exten
     public DBFResultSet(final DBFStatement stmt, String sqlQuery) {
         Objects.requireNonNull(stmt, "the statement referred by the ResultSet cannot be null.");
 
-        statement = stmt;
-        sql = sqlQuery;
+        this.statement = stmt;
+        this.sql = sqlQuery;
     }
 
     /**
@@ -73,10 +73,10 @@ public abstract class DBFResultSet exten
      * @throws SQLConnectionClosedException if one of them is closed.
      */
     protected void assertNotClosed() throws SQLConnectionClosedException {
-        statement.assertNotClosed();
+        this.statement.assertNotClosed();
 
-        if (isClosed) {
-            throw new SQLConnectionClosedException(format(Level.WARNING, "excp.closed_resultset", sql, getFile().getName()), sql, getFile());
+        if (this.isClosed) {
+            throw new SQLConnectionClosedException(format(Level.WARNING, "excp.closed_resultset", this.sql, getFile().getName()), this.sql, getFile());
         }
     }
 
@@ -96,8 +96,8 @@ public abstract class DBFResultSet exten
         if (isClosed())
             return;
 
-        statement.notifyCloseResultSet(this);
-        isClosed = true;
+        this.statement.notifyCloseResultSet(this);
+        this.isClosed = true;
     }
 
     /**
@@ -111,7 +111,7 @@ public abstract class DBFResultSet exten
     @Override
     @SuppressWarnings("resource") // The connection is only used to get the column index.
     public int findColumn(String columnLabel) throws SQLNoSuchFieldException, SQLConnectionClosedException {
-        DBFConnection cnt = (DBFConnection)statement.getConnection();
+        DBFConnection cnt = (DBFConnection)this.statement.getConnection();
         return cnt.findColumn(columnLabel, getSQL());
     }
 
@@ -231,7 +231,7 @@ public abstract class DBFResultSet exten
      */
     @SuppressWarnings("resource") // Only use the current connection to get the field name.
     public String getFieldName(int columnIndex, String sqlStatement) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
-        DBFConnection cnt = (DBFConnection)statement.getConnection();
+        DBFConnection cnt = (DBFConnection)this.statement.getConnection();
         return cnt.getFieldName(columnIndex, sqlStatement);
     }
 
@@ -241,7 +241,7 @@ public abstract class DBFResultSet exten
      */
     @Override
     public File getFile() {
-        return statement.getFile();
+        return this.statement.getFile();
     }
 
     /**
@@ -391,7 +391,7 @@ public abstract class DBFResultSet exten
      * @return SQL query.
      */
     public String getSQL() {
-        return sql;
+        return this.sql;
     }
 
     /**
@@ -410,7 +410,7 @@ public abstract class DBFResultSet exten
     @Override
     public Statement getStatement() throws SQLConnectionClosedException {
         assertNotClosed();
-        return statement;
+        return this.statement;
     }
 
     /**
@@ -445,7 +445,7 @@ public abstract class DBFResultSet exten
      */
     @Override
     public boolean isClosed() {
-        return isClosed || statement.isClosed();
+        return this.isClosed || this.statement.isClosed();
     }
 
     /**
@@ -928,7 +928,7 @@ public abstract class DBFResultSet exten
      */
     @Override
     public boolean wasNull() {
-        return wasNull;
+        return this.wasNull;
     }
 
     /**
@@ -960,6 +960,6 @@ public abstract class DBFResultSet exten
      */
     @Override
     public String toString() {
-        return format("toString", statement != null ? statement.toString() : null, sql, isClosed() == false);
+        return format("toString", this.statement != null ? this.statement.toString() : null, this.sql, isClosed() == false);
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLIllegalColumnIndexException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLIllegalColumnIndexException.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLIllegalColumnIndexException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLIllegalColumnIndexException.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -45,9 +45,9 @@ public class SQLIllegalColumnIndexExcept
      */
     public SQLIllegalColumnIndexException(String message, String sqlStatement, File dbf, int colIndex) {
         super(message);
-        sql = sqlStatement;
-        database = dbf;
-        columnIndex = colIndex;
+        this.sql = sqlStatement;
+        this.database = dbf;
+        this.columnIndex = colIndex;
     }
 
     /**
@@ -55,7 +55,7 @@ public class SQLIllegalColumnIndexExcept
      * @return SQL statement or null.
      */
     public String getSQL() {
-        return sql;
+        return this.sql;
     }
 
     /**
@@ -63,7 +63,7 @@ public class SQLIllegalColumnIndexExcept
      * @return Column index.
      */
     public int getColumnIndex() {
-        return columnIndex;
+        return this.columnIndex;
     }
 
     /**
@@ -71,6 +71,6 @@ public class SQLIllegalColumnIndexExcept
      * @return Database file.
      */
     public File getDatabase() {
-        return database;
+        return this.database;
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoResultException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoResultException.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoResultException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoResultException.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -41,8 +41,8 @@ public class SQLNoResultException extend
      */
     public SQLNoResultException(String message, String sqlStatement, File dbf) {
         super(message);
-        sql = sqlStatement;
-        database = dbf;
+        this.sql = sqlStatement;
+        this.database = dbf;
     }
 
     /**
@@ -50,7 +50,7 @@ public class SQLNoResultException extend
      * @return SQL statement.
      */
     public String getSQL() {
-        return sql;
+        return this.sql;
     }
 
     /**
@@ -58,6 +58,6 @@ public class SQLNoResultException extend
      * @return The database that was queried.
      */
     public File getDatabase() {
-        return database;
+        return this.database;
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoSuchFieldException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoSuchFieldException.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoSuchFieldException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoSuchFieldException.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -45,9 +45,9 @@ public class SQLNoSuchFieldException ext
      */
     public SQLNoSuchFieldException(String message, String sqlStatement, File dbf, String colName) {
         super(message);
-        sql = sqlStatement;
-        database = dbf;
-        columnName = colName;
+        this.sql = sqlStatement;
+        this.database = dbf;
+        this.columnName = colName;
     }
 
     /**
@@ -55,7 +55,7 @@ public class SQLNoSuchFieldException ext
      * @return SQL statement or null.
      */
     public String getSQL() {
-        return sql;
+        return this.sql;
     }
 
     /**
@@ -63,7 +63,7 @@ public class SQLNoSuchFieldException ext
      * @return Column name.
      */
     public String getColumnName() {
-        return columnName;
+        return this.columnName;
     }
 
     /**
@@ -71,6 +71,6 @@ public class SQLNoSuchFieldException ext
      * @return Database file.
      */
     public File getDatabase() {
-        return database;
+        return this.database;
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotDateException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotDateException.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotDateException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotDateException.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -49,10 +49,10 @@ public class SQLNotDateException extends
      */
     public SQLNotDateException(String message, String sqlStatement, File dbf, String colName, String wrongValue) {
         super(message);
-        sql = sqlStatement;
-        database = dbf;
-        columnName = colName;
-        value = wrongValue;
+        this.sql = sqlStatement;
+        this.database = dbf;
+        this.columnName = colName;
+        this.value = wrongValue;
     }
 
     /**
@@ -60,7 +60,7 @@ public class SQLNotDateException extends
      * @return SQL statement or null.
      */
     public String getSQL() {
-        return sql;
+        return this.sql;
     }
 
     /**
@@ -68,7 +68,7 @@ public class SQLNotDateException extends
      * @return Column name.
      */
     public String getColumnName() {
-        return columnName;
+        return this.columnName;
     }
 
     /**
@@ -76,7 +76,7 @@ public class SQLNotDateException extends
      * @return Value.
      */
     public String getValue() {
-        return value;
+        return this.value;
     }
 
     /**
@@ -84,6 +84,6 @@ public class SQLNotDateException extends
      * @return Database file.
      */
     public File getDatabase() {
-        return database;
+        return this.database;
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotNumericException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotNumericException.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotNumericException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotNumericException.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -49,10 +49,10 @@ public class SQLNotNumericException exte
      */
     public SQLNotNumericException(String message, String sqlStatement, File dbf, String colName, String wrongValue) {
         super(message);
-        sql = sqlStatement;
-        database = dbf;
-        columnName = colName;
-        value = wrongValue;
+        this.sql = sqlStatement;
+        this.database = dbf;
+        this.columnName = colName;
+        this.value = wrongValue;
     }
 
     /**
@@ -60,7 +60,7 @@ public class SQLNotNumericException exte
      * @return SQL statement or null.
      */
     public String getSQL() {
-        return sql;
+        return this.sql;
     }
 
     /**
@@ -68,7 +68,7 @@ public class SQLNotNumericException exte
      * @return Column name.
      */
     public String getColumnName() {
-        return columnName;
+        return this.columnName;
     }
 
     /**
@@ -76,7 +76,7 @@ public class SQLNotNumericException exte
      * @return Value.
      */
     public String getValue() {
-        return value;
+        return this.value;
     }
 
     /**
@@ -84,6 +84,6 @@ public class SQLNotNumericException exte
      * @return Database file.
      */
     public File getDatabase() {
-        return database;
+        return this.database;
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -45,9 +45,9 @@ public abstract class ClauseResolver ext
      * @param op The operator to apply.
      */
     public ClauseResolver(Object cmp1, Object cmp2, String op) {
-        comparand1 = cmp1;
-        comparand2 = cmp2;
-        operator = op;
+        this.comparand1 = cmp1;
+        this.comparand2 = cmp2;
+        this.operator = op;
     }
 
     /**
@@ -55,7 +55,7 @@ public abstract class ClauseResolver ext
      * @return First comparand.
      */
     public Object getComparand1() {
-        return comparand1;
+        return this.comparand1;
     }
 
     /**
@@ -63,7 +63,7 @@ public abstract class ClauseResolver ext
      * @return Second comparand.
      */
     public Object getComparand2() {
-        return comparand2;
+        return this.comparand2;
     }
 
     /**
@@ -71,7 +71,7 @@ public abstract class ClauseResolver ext
      * @return Operator.
      */
     public String getOperator() {
-        return operator;
+        return this.operator;
     }
 
     /**
@@ -79,7 +79,7 @@ public abstract class ClauseResolver ext
      * @param comparand First comparand.
      */
     public void setComparand1(Object comparand) {
-        comparand1 = comparand;
+        this.comparand1 = comparand;
     }
 
     /**
@@ -87,7 +87,7 @@ public abstract class ClauseResolver ext
      * @param comparand Second comparand.
      */
     public void setComparand2(Object comparand) {
-        comparand2 = comparand;
+        this.comparand2 = comparand;
     }
 
     /**
@@ -95,7 +95,7 @@ public abstract class ClauseResolver ext
      * @param op Operator.
      */
     public void setOperator(String op) {
-        operator = op;
+        this.operator = op;
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -37,7 +37,7 @@ public class CrudeSQLParser extends Abst
      */
     public CrudeSQLParser(DBFRecordBasedResultSet resultset) {
         Objects.requireNonNull(resultset, "The ResultSet given to the SQL parser cannot be null.");
-        rs = resultset;
+        this.rs = resultset;
     }
 
     /**
@@ -48,11 +48,11 @@ public class CrudeSQLParser extends Abst
     public ConditionalClauseResolver parse() throws SQLInvalidStatementException {
         logStep("parse");
 
-        String sql = rs.getSQL().trim();
+        String sql = this.rs.getSQL().trim();
 
         if (sql.toLowerCase().startsWith("select * from ") == false) {
             String message = format(Level.WARNING, "excp.limited_feature_syntax", sql);
-            throw new SQLInvalidStatementException(message, rs.getSQL(), rs.getFile());
+            throw new SQLInvalidStatementException(message, this.rs.getSQL(), this.rs.getFile());
         }
 
         final String whereWord = " where ";
@@ -69,7 +69,7 @@ public class CrudeSQLParser extends Abst
         // If the condition is empty, it's a syntax error because a WHERE clause went before.
         if (whereCondition.isEmpty()) {
             String message = format(Level.WARNING, "excp.where_without_conditions", sql);
-            throw new SQLInvalidStatementException(message, rs.getSQL(), rs.getFile());
+            throw new SQLInvalidStatementException(message, this.rs.getSQL(), this.rs.getFile());
         }
 
         // Currently, all the condition are made of three parts :
@@ -80,7 +80,7 @@ public class CrudeSQLParser extends Abst
 
         if (parts.length != 3) {
             String message = format(Level.WARNING, "excp.limited_feature_conditional_parsing", whereCondition, sql);
-            throw new SQLInvalidStatementException(message, rs.getSQL(), rs.getFile());
+            throw new SQLInvalidStatementException(message, this.rs.getSQL(), this.rs.getFile());
         }
 
         // Detect and promote litterals in parameters to their best types.
@@ -124,7 +124,7 @@ public class CrudeSQLParser extends Abst
      * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#getFile()
      */
     @Override protected File getFile() {
-        return rs.getFile();
+        return this.rs.getFile();
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLIllegalParameterException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLIllegalParameterException.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLIllegalParameterException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLIllegalParameterException.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -49,10 +49,10 @@ public class SQLIllegalParameterExceptio
      */
     public SQLIllegalParameterException(String message, String sqlStatement, File dbf, String name, String value) {
         super(message);
-        sql = sqlStatement;
-        database = dbf;
-        parameterName = name;
-        parameterValue = value;
+        this.sql = sqlStatement;
+        this.database = dbf;
+        this.parameterName = name;
+        this.parameterValue = value;
     }
 
     /**
@@ -60,7 +60,7 @@ public class SQLIllegalParameterExceptio
      * @return SQL statement or null.
      */
     public String getSQL() {
-        return sql;
+        return this.sql;
     }
 
     /**
@@ -68,7 +68,7 @@ public class SQLIllegalParameterExceptio
      * @return Parameter name.
      */
     public String geParameterName() {
-        return parameterName;
+        return this.parameterName;
     }
 
     /**
@@ -76,7 +76,7 @@ public class SQLIllegalParameterExceptio
      * @return Parameter name.
      */
     public String geParameterValue() {
-        return parameterValue;
+        return this.parameterValue;
     }
 
     /**
@@ -84,6 +84,6 @@ public class SQLIllegalParameterExceptio
      * @return Database file.
      */
     public File getDatabase() {
-        return database;
+        return this.database;
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLInvalidStatementException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLInvalidStatementException.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLInvalidStatementException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLInvalidStatementException.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -41,8 +41,8 @@ public class SQLInvalidStatementExceptio
      */
     public SQLInvalidStatementException(String message, String sqlStatement, File dbf) {
         super(message);
-        sql = sqlStatement;
-        database = dbf;
+        this.sql = sqlStatement;
+        this.database = dbf;
     }
 
     /**
@@ -50,7 +50,7 @@ public class SQLInvalidStatementExceptio
      * @return SQL statement or null.
      */
     public String getSQL() {
-        return sql;
+        return this.sql;
     }
 
     /**
@@ -58,6 +58,6 @@ public class SQLInvalidStatementExceptio
      * @return Database file.
      */
     public File getDatabase() {
-        return database;
+        return this.database;
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLUnsupportedParsingFeatureException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLUnsupportedParsingFeatureException.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLUnsupportedParsingFeatureException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLUnsupportedParsingFeatureException.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -41,8 +41,8 @@ public class SQLUnsupportedParsingFeatur
      */
     public SQLUnsupportedParsingFeatureException(String message, String sqlStatement, File dbf) {
         super(message);
-        sql = sqlStatement;
-        database = dbf;
+        this.sql = sqlStatement;
+        this.database = dbf;
     }
 
     /**
@@ -50,7 +50,7 @@ public class SQLUnsupportedParsingFeatur
      * @return SQL statement.
      */
     public String getSQL() {
-        return sql;
+        return this.sql;
     }
 
     /**
@@ -58,6 +58,6 @@ public class SQLUnsupportedParsingFeatur
      * @return The database that was queried.
      */
     public File getDatabase() {
-        return database;
+        return this.database;
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -67,7 +67,7 @@ public class DBFStatement extends Abstra
     @Override
     public Connection getConnection() throws SQLConnectionClosedException {
         assertNotClosed();
-        return connection;
+        return this.connection;
     }
 
     /**
@@ -76,7 +76,7 @@ public class DBFStatement extends Abstra
      */
     @Override
     public File getFile() {
-        return connection.getFile();
+        return this.connection.getFile();
     }
 
     /**
@@ -133,7 +133,7 @@ public class DBFStatement extends Abstra
     @Override
     public ResultSet getResultSet() throws SQLConnectionClosedException {
         assertNotClosed();
-        return currentResultSet;
+        return this.currentResultSet;
     }
 
     /**
@@ -152,23 +152,23 @@ public class DBFStatement extends Abstra
         if (isClosed())
             return;
 
-        if (currentResultSet != null) {
+        if (this.currentResultSet != null) {
             // Inform that this ResultSet could have been closed but that we are handling this :
             // Some developpers may expect their ResultSet should have been closed before in their program.
-            format(Level.FINE, "log.closing_underlying_resultset", currentResultSet);
-            currentResultSet.close();
+            log(Level.FINE, "log.closing_underlying_resultset", this.currentResultSet);
+            this.currentResultSet.close();
 
-            currentResultSet = null;
+            this.currentResultSet = null;
         }
 
         // Check if all the underlying ResultSets that has been opened with this statement has been closed.
         // If not, we log a warning to help the developper.
-        if (openedResultSets.size() > 0) {
-            format(Level.WARNING, "log.resultsets_left_opened", openedResultSets.size(), openedResultSets.stream().map(DBFResultSet::toString).collect(Collectors.joining(", ")));
+        if (this.openedResultSets.size() > 0) {
+            log(Level.WARNING, "log.resultsets_left_opened", this.openedResultSets.size(), this.openedResultSets.stream().map(DBFResultSet::toString).collect(Collectors.joining(", ")));
         }
 
-        isClosed = true;
-        connection.notifyCloseStatement(this);
+        this.isClosed = true;
+        this.connection.notifyCloseStatement(this);
     }
 
     /**
@@ -177,7 +177,7 @@ public class DBFStatement extends Abstra
      */
     @Override
     public boolean isClosed() {
-        return isClosed || connection.isClosed();
+        return this.isClosed || this.connection.isClosed();
     }
 
     /**
@@ -185,11 +185,11 @@ public class DBFStatement extends Abstra
      * @throws SQLConnectionClosedException if one of them is closed.
      */
     public void assertNotClosed() throws SQLConnectionClosedException {
-        connection.assertNotClosed(); // First, the underlying shall not be closed.
+        this.connection.assertNotClosed(); // First, the underlying shall not be closed.
 
         // Then, this statement shouldn't be closed too.
-        if (isClosed) {
-            throw new SQLConnectionClosedException(format(Level.WARNING, "excp.closed_statement", connection.getFile().getName()), null, connection.getFile());
+        if (this.isClosed) {
+            throw new SQLConnectionClosedException(format(Level.WARNING, "excp.closed_statement", this.connection.getFile().getName()), null, this.connection.getFile());
         }
     }
 
@@ -209,10 +209,10 @@ public class DBFStatement extends Abstra
         Objects.requireNonNull(rs, "The ResultSet notified being closed cannot be null.");
 
         // If this ResultSet was the current ResultSet, now there is no more current ResultSet.
-        if (currentResultSet == rs)
-            currentResultSet = null;
+        if (this.currentResultSet == rs)
+            this.currentResultSet = null;
 
-        if (openedResultSets.remove(rs) == false) {
+        if (this.openedResultSets.remove(rs) == false) {
             throw new RuntimeException(format(Level.SEVERE, "assert.resultset_not_opened_by_me", rs, toString()));
         }
     }
@@ -222,8 +222,8 @@ public class DBFStatement extends Abstra
      * @param rs Result Set.
      */
     public void registerResultSet(DBFResultSet rs) {
-        currentResultSet = rs;
-        openedResultSets.add(rs);
+        this.currentResultSet = rs;
+        this.openedResultSets.add(rs);
     }
 
     /**
@@ -239,6 +239,6 @@ public class DBFStatement extends Abstra
      */
     @Override
     public String toString() {
-        return format("toString", connection != null ? connection.toString() : null, isClosed() == false);
+        return format("toString", this.connection != null ? this.connection.toString() : null, isClosed() == false);
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -22,11 +22,12 @@ import java.sql.SQLFeatureNotSupportedEx
 import java.text.DecimalFormat;
 import java.text.MessageFormat;
 import java.util.List;
+import java.util.ResourceBundle;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.apache.sis.feature.DefaultFeatureType;
-import org.apache.sis.internal.shapefile.SQLShapefileNotFoundException;
-import org.apache.sis.internal.shapefile.ShapefileByteReader;
-import org.apache.sis.internal.shapefile.ShapefileDescriptor;
+import org.apache.sis.internal.shapefile.*;
 import org.apache.sis.internal.shapefile.jdbc.*;
 import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
 import org.apache.sis.internal.shapefile.jdbc.metadata.DBFDatabaseMetaData;
@@ -36,6 +37,7 @@ import org.apache.sis.internal.shapefile
 import org.apache.sis.internal.shapefile.jdbc.sql.SQLUnsupportedParsingFeatureException;
 import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
 import org.apache.sis.storage.DataStoreClosedException;
+import org.apache.sis.util.logging.Logging;
 import org.opengis.feature.Feature;
 
 /**
@@ -47,6 +49,12 @@ import org.opengis.feature.Feature;
  * @module
  */
 public class InputFeatureStream extends InputStream {
+    /** Logger. */
+    private static Logger LOGGER = Logging.getLogger(InputFeatureStream.class.getSimpleName());
+    
+    /** Resource bundle. */
+    private ResourceBundle rsc = ResourceBundle.getBundle(InputFeatureStream.class.getName());
+    
     /** Dedicated connection to DBF. */
     private DBFConnection connection;
 
@@ -67,6 +75,12 @@ public class InputFeatureStream extends
 
     /** Database file. */
     private File databaseFile;
+    
+    /** Shapefile index. */
+    private File shapefileIndex;
+    
+    /** Indicates that the shape file has a valid index provided with it. */
+    private boolean hasShapefileIndex; 
 
     /** Type of the features contained in this shapefile. */
     private DefaultFeatureType featuresType;
@@ -78,20 +92,37 @@ public class InputFeatureStream extends
      * Create an input stream of features over a connection.
      * @param shpfile Shapefile.
      * @param dbaseFile Database file.
+     * @param shpfileIndex Shapefile index, null if none provided, will be checked for existence.
+     * @param sqlStatement SQL Statement to run, if null, a SELECT * FROM DBF will occurs.
      * @throws InvalidShapefileFormatException if the shapefile format is invalid.
      * @throws InvalidDbaseFileFormatException if the Dbase file format is invalid.
      * @throws ShapefileNotFoundException if the shapefile has not been found.
      * @throws DbaseFileNotFoundException if the database file has not been found.
      */
-    public InputFeatureStream(File shpfile, File dbaseFile) throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
+    public InputFeatureStream(File shpfile, File dbaseFile, File shpfileIndex, String sqlStatement) throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
         try {
-            connection = (DBFConnection)new DBFDriver().connect(dbaseFile.getAbsolutePath(), null);
-            sql = MessageFormat.format("SELECT * FROM {0}", dbaseFile.getName());
-            shapefile = shpfile;
-            databaseFile = dbaseFile;
+            this.connection = (DBFConnection)new DBFDriver().connect(dbaseFile.getAbsolutePath(), null);
+            
+            if (sqlStatement == null) {
+                this.sql = MessageFormat.format("SELECT * FROM {0}", dbaseFile.getName());
+            }
+            else {
+                this.sql = sqlStatement;
+            }
+            
+            this.shapefile = shpfile;
+            this.databaseFile = dbaseFile;
+            
+            if (shpfileIndex != null && (shpfileIndex.exists() && shpfileIndex.isFile())) {
+                this.shapefileIndex = shpfileIndex;
+                this.hasShapefileIndex = true;
+            }
+            else {
+                this.hasShapefileIndex = false;
+            }
     
-            shapefileReader = new ShapefileByteReader(shapefile, databaseFile);
-            featuresType = shapefileReader.getFeaturesType();
+            this.shapefileReader = new ShapefileByteReader(this.shapefile, this.databaseFile, this.shapefileIndex);
+            this.featuresType = this.shapefileReader.getFeaturesType();
     
             try {
                 executeQuery();
@@ -118,8 +149,35 @@ public class InputFeatureStream extends
             throw new ShapefileNotFoundException(ex.getMessage(), ex);
         }
     }
+    
+    /**
+     * Create an input stream of features over a connection, responding to a SELECT * FROM DBF statement.
+     * @param shpfile Shapefile.
+     * @param dbaseFile Database file.
+     * @param shpfileIndex Shapefile index, null if none provided, will be checked for existence.
+     * @throws InvalidShapefileFormatException if the shapefile format is invalid.
+     * @throws InvalidDbaseFileFormatException if the Dbase file format is invalid.
+     * @throws ShapefileNotFoundException if the shapefile has not been found.
+     * @throws DbaseFileNotFoundException if the database file has not been found.
+     */
+    public InputFeatureStream(File shpfile, File dbaseFile, File shpfileIndex) throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
+        this(shpfile, dbaseFile, shpfileIndex, null);
+    }
 
     /**
+     * Create an input stream of features over a connection, responding to a SELECT * FROM DBF statement.
+     * @param shpfile Shapefile.
+     * @param dbaseFile Database file.
+     * @throws InvalidShapefileFormatException if the shapefile format is invalid.
+     * @throws InvalidDbaseFileFormatException if the Dbase file format is invalid.
+     * @throws ShapefileNotFoundException if the shapefile has not been found.
+     * @throws DbaseFileNotFoundException if the database file has not been found.
+     */
+    public InputFeatureStream(File shpfile, File dbaseFile) throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
+        this(shpfile, dbaseFile, null);
+    }
+    
+    /**
      * @see java.io.InputStream#read()
      */
     @Override
@@ -140,16 +198,16 @@ public class InputFeatureStream extends
      */
     @Override
     public void close() {
-        rs.close();
-        stmt.close();
-        connection.close();
+        this.rs.close();
+        this.stmt.close();
+        this.connection.close();
     }
 
     /**
      * Read next feature responding to the SQL query.
      * @return Feature, null if no more feature is available.
      * @throws DataStoreClosedException if the current connection used to query the shapefile has been closed.
-     * @throws DataStoreQueryException if the statement used to query the shapefile content is incorrect.
+     * @throws DataStoreQueryException if the statement used to query the shapefile content is incorrect, or requires a shapefile index to be executed and none is available.
      * @throws DataStoreQueryResultException if the shapefile results cause a trouble (wrong format, for example).
      * @throws InvalidShapefileFormatException if the shapefile structure shows a problem.
      */
@@ -166,14 +224,16 @@ public class InputFeatureStream extends
         catch(SQLNotNumericException | SQLNotDateException e) {
             throw new DataStoreQueryResultException(e.getMessage(), e);
         }
+        catch(SQLNoDirectAccessAvailableException e) {
+            throw new DataStoreQueryException(e.getMessage(), e);
+        }
     }
     
     /**
      * Return the features type.
      * @return Features type.
      */
-    public DefaultFeatureType getFeaturesType()
-    {
+    public DefaultFeatureType getFeaturesType() {
         return this.featuresType;
     }
     
@@ -181,8 +241,7 @@ public class InputFeatureStream extends
      * Returns the shapefile descriptor.
      * @return Shapefile descriptor.
      */
-    public ShapefileDescriptor getShapefileDescriptor()
-    {
+    public ShapefileDescriptor getShapefileDescriptor() {
         return this.shapefileReader.getShapefileDescriptor();
     }
     
@@ -190,12 +249,19 @@ public class InputFeatureStream extends
      * Returns the database fields descriptors.
      * @return List of fields descriptors. 
      */
-    public List<DBase3FieldDescriptor> getDatabaseFieldsDescriptors()
-    {
+    public List<DBase3FieldDescriptor> getDatabaseFieldsDescriptors() {
         return this.shapefileReader.getFieldsDescriptors();
     }
     
     /**
+     * Checks if the shapefile has an index provided with it.
+     * @return true if an index file (.shx) has been given with the shapefile.
+     */
+    public boolean hasShapefileIndex() {
+        return this.hasShapefileIndex;
+    }
+    
+    /**
      * Read next feature responding to the SQL query.
      * @return Feature, null if no more feature is available.
      * @throws SQLNotNumericException if a field expected numeric isn't.
@@ -207,26 +273,55 @@ public class InputFeatureStream extends
      * @throws SQLUnsupportedParsingFeatureException if a SQL ability is not currently available through this driver.
      * @throws SQLFeatureNotSupportedException if a SQL ability is not currently available through this driver.
      * @throws InvalidShapefileFormatException if the shapefile format is invalid.
+     * @throws SQLNoDirectAccessAvailableException if the underlying SQL statement requires a direct access in the shapefile, but the shapefile cannot allow it.
      */
-    private Feature internalReadFeature() throws SQLConnectionClosedException, SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLNotNumericException, SQLNotDateException, SQLFeatureNotSupportedException, InvalidShapefileFormatException {
+    private Feature internalReadFeature() throws SQLConnectionClosedException, SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLNotNumericException, SQLNotDateException, SQLFeatureNotSupportedException, InvalidShapefileFormatException, SQLNoDirectAccessAvailableException {
         try {
-            if (endOfFile) {
+            if (this.endOfFile) {
                 return null;
             }
 
-            if (rs.next() == false) {
-                endOfFile = true;
+            int previousRecordNumber = this.rs.getRowNum();
+            
+            if (this.rs.next() == false) {
+                this.endOfFile = true;
                 return null;
             }
-
-            Feature feature = featuresType.newInstance();
-            shapefileReader.completeFeature(feature);
-            DBFDatabaseMetaData metadata = (DBFDatabaseMetaData)connection.getMetaData();
+            
+            int currentRecordNumber = this.rs.getRowNum();
+            
+            // On the shapefile, only jump in another place if a direct access is needed.
+            boolean directAccesRequired = currentRecordNumber != (previousRecordNumber + 1);
+            
+            if (directAccesRequired) {
+                try {
+                    if (LOGGER.isLoggable(Level.FINER)) {
+                        MessageFormat format = new MessageFormat(this.rsc.getString("log.shapefile_reading_with_direct_access"));
+                        LOGGER.finer(format.format(new Object[] {previousRecordNumber, currentRecordNumber}));
+                    }
+                    
+                    this.shapefileReader.setRowNum(currentRecordNumber);
+                }
+                catch(SQLInvalidRecordNumberForDirectAccessException e) {
+                    // This would be an internal API problem, because as soon as we handle a shapefile index, we shall go through its relative shape feature file correctly.
+                    throw new RuntimeException(e.getMessage(), e);
+                }
+            }
+            else {
+                if (LOGGER.isLoggable(Level.FINER)) {
+                    MessageFormat format = new MessageFormat(this.rsc.getString("log.shapefile_reading_with_sequential_access"));
+                    LOGGER.finer(format.format(new Object[] {previousRecordNumber, currentRecordNumber}));
+                }
+            }
+            
+            Feature feature = this.featuresType.newInstance();
+            this.shapefileReader.completeFeature(feature);
+            DBFDatabaseMetaData metadata = (DBFDatabaseMetaData)this.connection.getMetaData();
 
             try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = (DBFBuiltInMemoryResultSetForColumnsListing)metadata.getColumns(null, null, null, null)) {
                 while(rsDatabase.next()) {
                     String fieldName = rsDatabase.getString("COLUMN_NAME");
-                    Object fieldValue = rs.getObject(fieldName);
+                    Object fieldValue = this.rs.getObject(fieldName);
 
                     // FIXME To allow features to be filled again, the values are converted to String again : feature should allow any kind of data.
                     String stringValue;
@@ -272,7 +367,7 @@ public class InputFeatureStream extends
      * @throws SQLInvalidStatementException if the given SQL Statement is invalid.
      */
     private void executeQuery() throws SQLConnectionClosedException, SQLInvalidStatementException {
-        stmt = (DBFStatement)connection.createStatement();
-        rs = (DBFRecordBasedResultSet)stmt.executeQuery(sql);
+        this.stmt = (DBFStatement)this.connection.createStatement();
+        this.rs = (DBFRecordBasedResultSet)this.stmt.executeQuery(this.sql);
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -41,6 +41,9 @@ public class ShapeFile {
 
     /** Database file. */
     private File databaseFile;
+    
+    /** Shapefile index, if any. */
+    private File shapeFileIndex;
 
     /** Type of the features contained in this shapefile. */
     private DefaultFeatureType featuresType;
@@ -58,7 +61,7 @@ public class ShapeFile {
     public ShapeFile(String shpfile) {
         Objects.requireNonNull(shpfile, "The shapefile to load cannot be null.");
 
-        shapeFile = new File(shpfile);
+        this.shapeFile = new File(shpfile);
 
         // Deduct database file name by suffixing it by dbf (trying to respect the same case).
         StringBuilder dbfFileName = new StringBuilder(shpfile);
@@ -70,7 +73,19 @@ public class ShapeFile {
         dbfSuffix = (dbfSuffix == null) ? "dbf" : dbfSuffix;
         
         dbfFileName.replace(shpfile.length() - 3, shpfile.length(), dbfSuffix);
-        databaseFile = new File(dbfFileName.toString());
+        this.databaseFile = new File(dbfFileName.toString());
+        
+        // Deduct shapefile index file name by suffixing it by shx (trying to respect the same case).
+        StringBuilder shapeFileIndexName = new StringBuilder(shpfile);
+        
+        String shapeFileIndexSuffix = null;
+        shapeFileIndexSuffix = shpfile.endsWith("shp") ? "shx" : shapeFileIndexSuffix;
+        shapeFileIndexSuffix = shpfile.endsWith("SHP") ? "SHX" : shapeFileIndexSuffix;
+        shapeFileIndexSuffix = shpfile.endsWith("Shp") ? "Shx" : shapeFileIndexSuffix;
+        shapeFileIndexSuffix = (shapeFileIndexSuffix == null) ? "shx" : shapeFileIndexSuffix;
+        
+        shapeFileIndexName.replace(shpfile.length() - 3, shpfile.length(), shapeFileIndexSuffix);
+        this.shapeFileIndex = new File(shapeFileIndexName.toString()); 
     }
     
     /**
@@ -85,6 +100,17 @@ public class ShapeFile {
         this.shapeFile = new File(shpfile);
         this.databaseFile = new File(dbasefile);
     }
+    
+    /**
+     * Construct a Shapefile from a file.
+     * @param shpfile file to read.
+     * @param dbasefile Associated DBase file.
+     * @param shpfileIndex Associated Shapefile index, may be null.
+     */
+    public ShapeFile(String shpfile, String dbasefile, String shpfileIndex) {
+        this(shpfile, dbasefile);
+        this.shapeFileIndex = new File(shpfileIndex);
+    }
 
     /**
      * Return the default feature type.
@@ -111,6 +137,30 @@ public class ShapeFile {
     }
 
     /**
+     * Returns the underlying DBase file used by this Shapefile.
+     * @return Dbase file.
+     */
+    public File getFileDatabase() {
+        return this.databaseFile;
+    }
+    
+    /**
+     * Returns the shape file designed by this shapefile object. 
+     * @return Shape file.
+     */
+    public File getFileShapefile() {
+        return this.shapeFile;
+    }
+    
+    /**
+     * Return the shapefile Index provided with the shapefile, if any.
+     * @return Shapefile Index file or null if none given.
+     */
+    public File getFileShapefileIndex() {
+        return this.shapeFileIndex;
+    }
+    
+    /**
      * Find features corresponding to an SQL request SELECT * FROM database.
      * @return Features
      * @throws DbaseFileNotFoundException if the database file has not been found.
@@ -119,7 +169,20 @@ public class ShapeFile {
      * @throws InvalidShapefileFormatException if the shapefile format is invalid.
      */
     public InputFeatureStream findAll() throws InvalidDbaseFileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException, InvalidShapefileFormatException {
-        InputFeatureStream is = new InputFeatureStream(shapeFile, databaseFile);
+        return find(null);
+    }
+    
+    /**
+     * Find features corresponding to an SQL request SELECT * FROM database.
+     * @param sqlStatement SQL Statement to run, if null, will default to SELECT * FROM database.
+     * @return Features
+     * @throws DbaseFileNotFoundException if the database file has not been found.
+     * @throws ShapefileNotFoundException if the shapefile has not been found.
+     * @throws InvalidDbaseFileFormatException if the database file format is invalid.
+     * @throws InvalidShapefileFormatException if the shapefile format is invalid.
+     */
+    public InputFeatureStream find(String sqlStatement) throws InvalidDbaseFileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException, InvalidShapefileFormatException {
+        InputFeatureStream is = new InputFeatureStream(this.shapeFile, this.databaseFile, this.shapeFileIndex, sqlStatement);
         this.featuresType = is.getFeaturesType();
         this.shapefileDescriptor = is.getShapefileDescriptor();
         this.databaseFieldsDescriptors = is.getDatabaseFieldsDescriptors();

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader.properties?rev=1718297&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader.properties (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader.properties Mon Dec  7 10:35:08 2015
@@ -0,0 +1,36 @@
+# Assertion : Internal API problem : the calculated index from a record number has led to a under or overflow of the shapefile byte buffer.
+#0,number : Record number asked for.
+#1,number : Index position in the byte buffer that has been calculated from the record number.
+#2 : Shapefile name.
+#3 : Message returned by the MappedByteBuffer.position(index) method.
+assert.wrong_position=[Internal API trouble] : While reading the shapefile {2}, ShapefileByteReader:setRowNum({0,number,#0}) method has made a wrong calculation with this record number that led it to buffer position {1,number,#0} invalid : "{3}".  
+
+# Exception : the shapefile has no index, and cannot easily go to a given entry.
+#0 : Shapefile name.
+excp.no_direct_access=The shapefile {0} has no index and doesn't allow direct access.
+
+# Exception : the given record number is below 1. 
+#0 : Wrong record number.
+#1 : Shapefile name.
+excp.wrong_direct_access_before_start=The given record number {0} for direct access in the shapefile {1} is below its beginning (starting at 1).
+
+# Exception : the given record number is after last (EOF). 
+#0 : Wrong record number.
+#1 : Shapefile name.
+excp.wrong_direct_access_after_last=The given record number {0} for direct access in the shapefile {1} is after its end.
+
+# Log : reading of the shapefile index is successful.
+#0 : Shapefile index file name.
+#1 : Number of entries indexed.
+#2 : Main shapefile file name.
+log.index_has_been_read=The shapefile index {0} has given {1,number} entries for the main shapefile {2}.
+
+# Log : the Shapefile index given has not been found.
+#0 : Wrong file location.
+#1 : Related shapefile.
+log.invalid_file_content_for_shapefile_index=The shapefile index given, {0}, has not been found. No Index will be used for reading the shapefile {1}.
+
+# Log : the shapefile index has an invalid content.
+#0 : Shapefile index file name that has an invalid content.
+#1 : Cause of the problem.
+log.no_shapefile_index_found_at_location=The shapefile index {0} has an invalid content and will be discarded : {1}.

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader_fr.properties?rev=1718297&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader_fr.properties (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader_fr.properties Mon Dec  7 10:35:08 2015
@@ -0,0 +1,36 @@
+# Assertion : Internal API problem : the calculated index from a record number has led to a under or overflow of the shapefile byte buffer.
+#0,number : Record number asked for.
+#1,number : Index position in the byte buffer that has been calculated from the record number.
+#2 : Shapefile name.
+#3 : Message returned by the MappedByteBuffer.position(index) method.
+assert.wrong_position=[Problème interne de l''API] : Pendant la lecture du shapefile {2}, ShapefileByteReader:setRowNum({0,number,#0}) la methode a fait un mauvais calcul avec ce numéro d''enregistrement qui l''a conduite vers la position de buffer {1,number,#0} invalide : "{3}".  
+
+# Exception : the shapefile has no index, and cannot easily go to a given entry.
+#0 : Shapefile name.
+excp.no_direct_access=Le shapefile {0} n''a pas d''index et ne permet pas d''accès direct.
+
+# Exception : the given record number is below 1. 
+#0 : Wrong record number.
+#1 : Shapefile name.
+excp.wrong_direct_access_before_start=Le numéro d''enregistrement donné {0} pour l''accès direct dans le shapefile {1} est en-deçà de son début (débutant à 1).
+
+# Exception : the given record number is after last (EOF). 
+#0 : Wrong record number.
+#1 : Shapefile name.
+excp.wrong_direct_access_after_last=Le numéro d''enregistrement donné {0} pour l''accès direct dans le shapefile {1} est au-delà de sa fin.
+
+# Log : reading of the shapefile index is successful.
+#0 : Shapefile index file name.
+#1 : Number of entries indexed.
+#2 : Main shapefile file name.
+log.index_has_been_read=L''index du shapefile {0} a donné {1,number} entrées pour le shapefile principal {2}.
+
+# Log : the Shapefile index given has not been found.
+#0 : Wrong file location.
+#1 : Related shapefile.
+log.invalid_file_content_for_shapefile_index=L''index du shapefile donné, {0}, n''a pas été trouvé. Aucun index ne va être utilisé pour lire le shapefile {1}.
+
+# Log : the shapefile index has an invalid content.
+#0 : Shapefile index file name that has an invalid content.
+#1 : Cause of the problem.
+log.no_shapefile_index_found_at_location=L''index du shapefile {0} a un contenu invalide et va être écarté : {1}.

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream.properties?rev=1718297&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream.properties (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream.properties Mon Dec  7 10:35:08 2015
@@ -0,0 +1,9 @@
+# Log : direct access
+#0 : Previous record number.
+#1 : Current record number.
+log.shapefile_reading_with_direct_access=Direct access in the shapefile from record number {0} to {1}.
+
+# Log : sequential access
+#0 : Previous record number.
+#1 : Current record number.
+log.shapefile_reading_with_sequential_access=Sequential access in the shapefile from record number {0} to {1}.

Added: sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream_fr.properties?rev=1718297&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream_fr.properties (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream_fr.properties Mon Dec  7 10:35:08 2015
@@ -0,0 +1,9 @@
+# Log : direct access
+#0 : Previous record number.
+#1 : Current record number.
+log.shapefile_reading_with_direct_access=Accès direct dans le shapefile depuis l''enregistrement numéro {0} vers le {1}.
+
+# Log : sequential access
+#0 : Previous record number.
+#1 : Current record number.
+log.shapefile_reading_with_sequential_access=Accès séquentiel dans le shapefile depuis l''enregistrement numéro {0} vers le {1}.

Modified: sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -51,7 +51,7 @@ public abstract class AbstractTestBaseFo
      */
     public Connection connect() throws SQLException {
         final Driver driver = new DBFDriver();
-        return driver.connect(dbfFile.getAbsolutePath(), null);
+        return driver.connect(this.dbfFile.getAbsolutePath(), null);
     }
 
     /**
@@ -62,7 +62,7 @@ public abstract class AbstractTestBaseFo
     public void setup() throws URISyntaxException {
         final URL url = ShapeFileTest.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());
+        this.dbfFile = new File(url.toURI());
+        assertTrue(this.dbfFile.isFile());
     }
 }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -41,7 +41,7 @@ public class DBFConnectionTest extends A
     @Test
     public void openCloseConnection() throws SQLException {
         final Driver driver = new DBFDriver();
-        final Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
+        final Connection connection = driver.connect(this.dbfFile.getAbsolutePath(), null);
         assertFalse("Connection should be opened", connection.isClosed());
         assertTrue ("Connection should be valid",  connection.isValid(0));
 
@@ -60,7 +60,7 @@ public class DBFConnectionTest extends A
         info.put("record_charset", "UTF-8");
         
         final Driver driver = new DBFDriver();
-        final Connection connection = driver.connect(dbfFile.getAbsolutePath(), info);
+        final Connection connection = driver.connect(this.dbfFile.getAbsolutePath(), info);
         assertFalse("Connection should be opened", connection.isClosed());
         assertTrue ("Connection should be valid",  connection.isValid(0));
 
@@ -78,14 +78,14 @@ public class DBFConnectionTest extends A
     public void connectionClosed() throws SQLException {
         // Open and close an connection.
         final Driver driver = new DBFDriver();
-        final Connection connection = driver.connect(dbfFile.getAbsolutePath(), null);
+        final Connection connection = driver.connect(this.dbfFile.getAbsolutePath(), null);
         connection.close();
 
         // Then, attempt to use it.
         try {
             connection.createStatement();
         } catch(SQLConnectionClosedException e) {
-            assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), dbfFile.getName());
+            assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), this.dbfFile.getName());
             throw e;
         }
     }

Modified: sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -125,7 +125,8 @@ public class DBFResultSetTest extends Ab
                 record.add(rs.getBigDecimal("SHAPE_LEN"));  // Type : Number, Field length : 19, Decimal positions : 11
 
                 count ++;
-                log.info(MessageFormat.format("Record {0,number} : {1}\n", count, record));
+                assertEquals("The record number returned by the ResultSet is not the same of the manual counting we are doing." , count, ((DBFRecordBasedResultSet)rs).getRowNum());
+                this.log.info(MessageFormat.format("Record {0,number} : {1}\n", count, record));
             }
 
             assertTrue("Less than one record was readed.", count > 1);
@@ -148,7 +149,7 @@ public class DBFResultSetTest extends Ab
                 rs.close();
             }
             catch(SQLConnectionClosedException e) {
-                assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), dbfFile.getName());
+                assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), this.dbfFile.getName());
                 assertEquals("The SQL Query is exception is not well set.", e.getSQL(), sql);
             }
             catch(SQLException e) {
@@ -168,7 +169,7 @@ public class DBFResultSetTest extends Ab
             rs.next();
         }
         catch(SQLConnectionClosedException e) {
-            assertEquals("The database name is exception message is not well set.", e.getDatabase().getName(), dbfFile.getName());
+            assertEquals("The database name is exception message is not well set.", e.getDatabase().getName(), this.dbfFile.getName());
         }
         catch(SQLException e) {
             fail("Not the expected exception for using a closed ResultSet.");
@@ -190,7 +191,7 @@ public class DBFResultSetTest extends Ab
                 rs.next();
             }
             catch(SQLConnectionClosedException e) {
-                assertEquals("The database name is exception message is not well set.", e.getDatabase().getName(), dbfFile.getName());
+                assertEquals("The database name is exception message is not well set.", e.getDatabase().getName(), this.dbfFile.getName());
             }
             catch(SQLException e) {
                 fail("Not the expected exception for using a closed ResultSet.");

Modified: sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -41,7 +41,7 @@ public class DBFStatementTest extends Ab
     public void openCloseStatement() throws SQLException {
         final Driver driver = new DBFDriver();
 
-        try(Connection connection = driver.connect(dbfFile.getAbsolutePath(), null)) {
+        try(Connection connection = driver.connect(this.dbfFile.getAbsolutePath(), null)) {
             final Statement stmt = connection.createStatement();
             assertFalse("Statement should be opened", stmt.isClosed());
 
@@ -67,7 +67,7 @@ public class DBFStatementTest extends Ab
                 stmt.executeQuery("Must detect that the statement is closed, and not try to parse this query.");
             }
             catch(SQLConnectionClosedException e) {
-                assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), dbfFile.getName());
+                assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), this.dbfFile.getName());
             }
             catch(SQLException e) {
                 fail("Not the expected exception for using a closed statement.");
@@ -85,7 +85,7 @@ public class DBFStatementTest extends Ab
             stmt.executeQuery("Must detect that the statement is closed, and not try to parse this query.");
         }
         catch(SQLConnectionClosedException e) {
-            assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), dbfFile.getName());
+            assertEquals("The database name in this exception is not well set.", e.getDatabase().getName(), this.dbfFile.getName());
         }
         catch(SQLException e) {
             fail("Not the expected exception for using a closed statement.");

Modified: sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] Mon Dec  7 10:35:08 2015
@@ -144,6 +144,49 @@ public final strictfp class ShapeFileTes
          assertEquals("The last record red must be DEUX-SEVRES department.", "DEUX-SEVRES", last.getProperty("NOM_DEPT").getValue());
      }
      
+     /**
+      * Testing direct access in the shapefile.
+      * @throws URISyntaxException if the resource name is incorrect.
+      * @throws DataStoreException if a general file reading trouble occurs.
+      */
+     @Test 
+     public void testDirectAcces() throws DataStoreException, URISyntaxException {
+         ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
+         
+         // 1) Find the third record, sequentially.
+         Feature thirdFeature;
+         
+         try(InputFeatureStream isSequential = shp.findAll()) {
+             isSequential.readFeature();
+             isSequential.readFeature();
+             thirdFeature = isSequential.readFeature();
+         }
+         
+         // Take one of its key fields and another field for reference, and its geometry.
+         Double sequentialAddressId = Double.valueOf((String)(thirdFeature.getProperty("ADDRID")).getValue());
+         String sequentialAddress = (String)(thirdFeature.getProperty("ADDRESS")).getValue();
+         Object sequentialGeometry = thirdFeature.getPropertyValue("geometry");
+         
+         // 2) Now attempt a direct access to this feature.         
+         Feature directFeature;
+         String sql = MessageFormat.format("SELECT * FROM ABRALicenseePt_4326_clipped WHERE ADDRID = {0,number,#0}", sequentialAddressId);
+         
+         try(InputFeatureStream isDirect = shp.find(sql)) {
+             directFeature = isDirect.readFeature();
+             assertNotNull("The direct access feature returned should not be null", directFeature);
+         }
+
+         assertNotNull("The field ADDRID in the direct access feature has not been found again.", directFeature.getProperty("ADDRID"));
+         
+         Double directAddressId = Double.valueOf((String)(directFeature.getProperty("ADDRID")).getValue());
+         String directAddress = (String)(directFeature.getProperty("ADDRESS")).getValue();
+         Object directGeometry = directFeature.getPropertyValue("geometry");
+         
+         assertEquals("DBase part : direct access didn't returned the same address id than sequential access.", sequentialAddressId, directAddressId);
+         assertEquals("DBase part : direct access didn't returned the same address than sequential access.", sequentialAddress, directAddress);
+         assertEquals("Shapefile part : direct access didn't returned the same geometry than sequential access.", sequentialGeometry, directGeometry);
+     }
+     
     /**
      * Read all the shapefile content.
      * @param shp Shapefile to read.



Mime
View raw message