sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1762629 [14/15] - in /sis/trunk: ./ application/sis-console/src/main/java/org/apache/sis/console/ application/sis-console/src/test/java/org/apache/sis/console/ application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ application...
Date Wed, 28 Sep 2016 09:59:48 GMT
Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -20,6 +20,7 @@ import java.io.File;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
+import java.util.Objects;
 import java.util.logging.Level;
 
 import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC;
@@ -28,10 +29,6 @@ import org.apache.sis.internal.shapefile
 import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
 import org.apache.sis.internal.shapefile.jdbc.resultset.*;
 
-// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
-
-
 /**
  * ResultSet Metadata.
  * @author Marc LE BIHAN
@@ -95,16 +92,13 @@ public class DBFResultSetMataData extend
     @Override public boolean isAutoIncrement(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("isAutoIncrement", column);
 
-        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
             return rsDatabase.getString("TYPE_NAME").equals("AUTO_INCREMENT");
         }
         catch(SQLNoSuchFieldException e) {
             // We encounter an internal API error in this case.
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
             throw new RuntimeException(message, e);
-        } finally {
-            rsDatabase.close();
         }
     }
 
@@ -132,15 +126,12 @@ public class DBFResultSetMataData extend
     @Override public boolean isCurrency(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("isCurrency", column);
 
-        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
             return rsDatabase.getString("TYPE_NAME").equals("CURRENCY");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
             throw new RuntimeException(message, e);
-        } finally {
-            rsDatabase.close();
         }
     }
 
@@ -168,47 +159,43 @@ public class DBFResultSetMataData extend
     @Override public int getColumnDisplaySize(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getColumnDisplaySize", column);
 
-        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
-        try {
-            final String v = rsDatabase.getString("TYPE_NAME");
-            if (v.equals("AUTO_INCREMENT") ||
-                v.equals("CHAR") ||
-                v.equals("INTEGER"))
-            {
-                return rsDatabase.getInt("COLUMN_SIZE");
-            }
-            if (v.equals("DATE")) {
-                return 8;
-            }
-            if (v.equals("DOUBLE") ||
-                v.equals("FLOAT") ||
-                v.equals("DECIMAL"))
-            {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+            switch(rsDatabase.getString("TYPE_NAME")) {
+                case "AUTO_INCREMENT":
+                case "CHAR":
+                case "INTEGER":
+                   return rsDatabase.getInt("COLUMN_SIZE");
+
+                case "DATE":
+                    return 8;
+
                 // Add decimal separator for decimal numbers.
-                return rsDatabase.getInt("COLUMN_SIZE") + 1;
-            }
-            if (v.equals("BOOLEAN")) {
-                return 5; // Translation for true, false, null.
-            }
-            if (v.equals("CURRENCY") ||
-                v.equals("DATETIME") ||
-                v.equals("TIMESTAMP") ||
-                v.equals("MEMO") ||
-                v.equals("PICTURE") ||
-                v.equals("VARIFIELD") ||
-                v.equals("VARIANT") ||
-                v.equals("UNKNOWN"))
-            {
+                case "DOUBLE":
+                case "FLOAT":
+                case "DECIMAL":
+                    return rsDatabase.getInt("COLUMN_SIZE") + 1;
+
+                case "BOOLEAN":
+                    return 5; // Translation for true, false, null.
+
                 // Unhandled types default to field length.
-                return rsDatabase.getInt("COLUMN_SIZE");
+                case "CURRENCY":
+                case "DATETIME":
+                case "TIMESTAMP":
+                case "MEMO":
+                case "PICTURE":
+                case "VARIFIELD":
+                case "VARIANT":
+                case "UNKNOWN":
+                    return rsDatabase.getInt("COLUMN_SIZE");
+
+                default:
+                    return rsDatabase.getInt("COLUMN_SIZE");
             }
-            return rsDatabase.getInt("COLUMN_SIZE");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
             throw new RuntimeException(message, e);
-        } finally {
-            rsDatabase.close();
         }
     }
 
@@ -220,15 +207,12 @@ public class DBFResultSetMataData extend
     @Override public String getColumnLabel(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getColumnLabel", column);
 
-        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
             return rsDatabase.getString("COLUMN_NAME");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "COLUMN_NAME", e.getMessage());
             throw new RuntimeException(message, e);
-        } finally {
-            rsDatabase.close();
         }
     }
 
@@ -240,15 +224,12 @@ public class DBFResultSetMataData extend
     @Override public String getColumnName(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getColumnName", column);
 
-        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
             return rsDatabase.getString("COLUMN_NAME");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "COLUMN_NAME", e.getMessage());
             throw new RuntimeException(message, e);
-        } finally {
-            rsDatabase.close();
         }
     }
 
@@ -268,15 +249,12 @@ public class DBFResultSetMataData extend
     @Override public int getPrecision(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getPrecision", column);
 
-        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
             return rsDatabase.getInt("COLUMN_SIZE");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "COLUMN_SIZE", e.getMessage());
             throw new RuntimeException(message, e);
-        } finally {
-            rsDatabase.close();
         }
     }
 
@@ -288,15 +266,12 @@ public class DBFResultSetMataData extend
     @Override public int getScale(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getScale", column);
 
-        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
             return rsDatabase.getInt("DECIMAL_DIGITS");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "DECIMAL_DIGITS", e.getMessage());
             throw new RuntimeException(message, e);
-        } finally {
-            rsDatabase.close();
         }
     }
 
@@ -329,15 +304,12 @@ public class DBFResultSetMataData extend
     @Override public int getColumnType(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getColumnType", column);
 
-        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
             return rsDatabase.getInt("DATA_TYPE");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "DATA_TYPE", e.getMessage());
             throw new RuntimeException(message, e);
-        } finally {
-            rsDatabase.close();
         }
     }
 
@@ -349,15 +321,12 @@ public class DBFResultSetMataData extend
     @Override public String getColumnTypeName(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getColumnTypeName", column);
 
-        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
             return rsDatabase.getString("TYPE_NAME");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
             throw new RuntimeException(message, e);
-        } finally {
-            rsDatabase.close();
         }
     }
 
@@ -394,65 +363,64 @@ public class DBFResultSetMataData extend
     @Override public String getColumnClassName(int column) throws SQLFeatureNotSupportedException, SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getColumnClassName", column);
 
-        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
-        try {
-            final String v = rsDatabase.getString("TYPE_NAME");
-            if (v.equals("AUTO_INCREMENT"))
-                return Integer.class.getName();
+        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+            switch(rsDatabase.getString("TYPE_NAME")) {
+                case "AUTO_INCREMENT":
+                    return Integer.class.getName();
 
-            if (v.equals("CHAR"))
-                return String.class.getName();
+                case "CHAR":
+                    return String.class.getName();
 
-            if (v.equals("INTEGER"))
-               return Integer.class.getName();
+                case "INTEGER":
+                   return Integer.class.getName();
 
-            if (v.equals("DATE"))
-                return java.sql.Date.class.getName();
+                case "DATE":
+                    return java.sql.Date.class.getName();
 
-            if (v.equals("DOUBLE"))
-                return Double.class.getName();
+                case "DOUBLE":
+                    return Double.class.getName();
 
-            if (v.equals("FLOAT"))
-                return Float.class.getName();
+                case "FLOAT":
+                    return Float.class.getName();
 
-            if (v.equals("DECIMAL"))
-                return Double.class.getName();
+                case "DECIMAL":
+                    return Double.class.getName();
 
-            if (v.equals("BOOLEAN"))
-                return Boolean.class.getName();
+                case "BOOLEAN":
+                    return Boolean.class.getName();
 
-            if (v.equals("CURRENCY"))
-                return Double.class.getName();
+                case "CURRENCY":
+                    return Double.class.getName();
 
-            if (v.equals("DATETIME"))
-                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime");
+                case "DATETIME":
+                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime");
 
-            if (v.equals("TIMESTAMP"))
-                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp");
+                case "TIMESTAMP":
+                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp");
 
-            if (v.equals("MEMO"))
-                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo");
+                case "MEMO":
+                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo");
 
-            if (v.equals("PICTURE"))
-                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture");
+                case "PICTURE":
+                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture");
 
-            if (v.equals("VARIFIELD"))
-                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField");
+                case "VARIFIELD":
+                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField");
 
-            if (v.equals("VARIANT"))
-                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant");
+                case "VARIANT":
+                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant");
 
-            if (v.equals("UNKNOWN"))
-                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
+                case "UNKNOWN":
+                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
 
-            throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
+                default:
+                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
+            }
         }
         catch(SQLNoSuchFieldException e) {
             // We encounter an internal API error in this case.
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
             throw new RuntimeException(message, e);
-        } finally {
-            rsDatabase.close();
         }
     }
 
@@ -492,7 +460,7 @@ public class DBFResultSetMataData extend
             try {
                 rsDatabase.next();
             }
-            catch(java.sql.SQLException e) {
+            catch(SQLNoResultException e) {
                 // We encounter an internal API error in this case.
                 rsDatabase.close();
                 String message = format(Level.SEVERE, "assert.less_column_in_metadata_than_expected", column, getColumnCount());

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -289,6 +289,7 @@ public abstract class AbstractResultSet
     /**
      * Unsupported by default.
      */
+    @Override
     public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
         throw unsupportedOperation("getObject", columnIndex, type);
     }

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -60,23 +60,23 @@ public class DBFBuiltInMemoryResultSetFo
     @Override public String getString(String columnLabel) throws SQLNoSuchFieldException {
         logStep("getString", columnLabel);
 
-        {   // On the JDK7 branch, this is a switch on strings.
+        switch(columnLabel) {
             // String => table name
-            if (columnLabel.equals("TABLE_NAME")) {
+            case "TABLE_NAME": {
                 String tableName = getTableName();
                 this.wasNull = (tableName == null);
                 return tableName;
             }
 
             // String => column name
-            else if (columnLabel.equals("COLUMN_NAME")) {
+            case "COLUMN_NAME": {
                 String columnName = this.current.getName();
                 this.wasNull = (columnName == null);
                 return columnName;
             }
 
             // String => Data source dependent type name, for a UDT the type name is fully qualified
-            else if (columnLabel.equals("TYPE_NAME")) {
+            case "TYPE_NAME": {
                 String typeName = this.current.getType() != null ? toColumnTypeName() : null;
                 this.wasNull = (typeName == null);
                 return typeName;
@@ -88,43 +88,42 @@ public class DBFBuiltInMemoryResultSetFo
              */
 
             // String => table catalog (may be null)
-            else if (columnLabel.equals("TABLE_CAT")) {
+            case "TABLE_CAT": {
                 this.wasNull = true;
                 return null;
             }
 
             // String => table schema (may be null)
-            else if (columnLabel.equals("TABLE_SCHEM")) {
+            case "TABLE_SCHEM": {
                 this.wasNull = true;
                 return null;
             }
 
             // String => comment describing column (may be null)
-            else if (columnLabel.equals("REMARKS")) {
+            case "REMARKS":
                 this.wasNull = true;
                 return null;
-            }
 
             // String => default value for the column, which should be interpreted as a string when the value is enclosed in single quotes (may be null)
-            else if (columnLabel.equals("COLUMN_DEF")) {
+            case "COLUMN_DEF": {
                 this.wasNull = true;
                 return null;
             }
 
             // String => catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF)
-            else if (columnLabel.equals("SCOPE_CATALOG")) {
+            case "SCOPE_CATALOG": {
                 this.wasNull = true;
                 return null;
             }
 
             // String => schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF)
-            else if (columnLabel.equals("SCOPE_SCHEMA")) {
+            case "SCOPE_SCHEMA": {
                 this.wasNull = true;
                 return null;
             }
 
             // String => table name that this the scope of a reference attribute (null if the DATA_TYPE isn't REF)
-            else if (columnLabel.equals("SCOPE_TABLE")) {
+            case "SCOPE_TABLE": {
                 this.wasNull = true;
                 return null;
             }
@@ -135,7 +134,7 @@ public class DBFBuiltInMemoryResultSetFo
              * NO --- if the column is not auto incremented
              * empty string --- if it cannot be determined whether the column is auto incremented
              */
-            else if (columnLabel.equals("IS_AUTOINCREMENT")) {
+            case "IS_AUTOINCREMENT": {
                 this.wasNull = false;
                 return "NO";
             }
@@ -146,12 +145,12 @@ public class DBFBuiltInMemoryResultSetFo
              * NO --- if this not a generated column
              * empty string --- if it cannot be determined whether this is a generated column
              */
-            else if (columnLabel.equals("IS_GENERATEDCOLUMN")) {
+            case "IS_GENERATEDCOLUMN": {
                 this.wasNull = false;
                 return "NO";
             }
 
-            else {
+            default: {
                 // Attempt to load it from an Integer column and convert it.
                 int value = getInt(columnLabel);
                 return MessageFormat.format("{0,number,#0}", value); // Remove decimal separators.
@@ -166,28 +165,28 @@ public class DBFBuiltInMemoryResultSetFo
     @Override public int getInt(String columnLabel) throws SQLNoSuchFieldException {
         logStep("getInt", columnLabel);
 
-        {   // On the JDK7 branch, this is a switch on strings.
+        switch(columnLabel) {
             // int => SQL type from java.sql.Types
-            if (columnLabel.equals("DATA_TYPE")) {
+            case "DATA_TYPE": {
                 this.wasNull = false;
                 return toSQLDataType();
             }
 
             // int => column size.
-            else if (columnLabel.equals("COLUMN_SIZE")) {
+            case "COLUMN_SIZE": {
                 this.wasNull = false;
                 return toPrecision();
             }
 
             // int => the number of fractional digits. Null is returned for data types where DECIMAL_DIGITS is not applicable.
-            else if (columnLabel.equals("DECIMAL_DIGITS")) {
+            case "DECIMAL_DIGITS": {
                 int scale = toScale();
                 this.wasNull = toScale() == -1;
                 return scale == -1 ? 0 : scale;
             }
 
             // int => Radix (typically either 10 or 2)
-            else if (columnLabel.equals("NUM_PREC_RADIX")) {
+            case "NUM_PREC_RADIX": {
                 return 10;
             }
 
@@ -197,19 +196,19 @@ public class DBFBuiltInMemoryResultSetFo
              * columnNullable - definitely allows NULL values
              * columnNullableUnknown - nullability unknown
              */
-            else if (columnLabel.equals("NULLABLE")) {
+            case "NULLABLE": {
                 this.wasNull = false;
                 return DatabaseMetaData.columnNullableUnknown;
             }
 
             // int => unused
-            else if (columnLabel.equals("SQL_DATA_TYPE")) {
+            case "SQL_DATA_TYPE": {
                 this.wasNull = false;
                 return toSQLDataType();
             }
 
             // int => for char types the maximum number of bytes in the column
-            else if (columnLabel.equals("CHAR_OCTET_LENGTH")) {
+            case "CHAR_OCTET_LENGTH": {
                 if (toSQLDataType() == Types.CHAR) {
                     return toPrecision();
                 }
@@ -218,7 +217,7 @@ public class DBFBuiltInMemoryResultSetFo
             }
 
             // int => index of column in table (starting at 1)
-            else if (columnLabel.equals("ORDINAL_POSITION")) {
+            case "ORDINAL_POSITION": {
                 return this.columnIndex;
             }
 
@@ -228,30 +227,29 @@ public class DBFBuiltInMemoryResultSetFo
              */
 
             // short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF)
-            else if (columnLabel.equals("SOURCE_DATA_TYPE")) {
+            case "SOURCE_DATA_TYPE": {
                 this.wasNull = true;
                 return 0;
             }
 
             // is not used.
-            else if (columnLabel.equals("BUFFER_LENGTH")) {
+            case "BUFFER_LENGTH": {
                 this.wasNull = false;
                 return 0;
             }
 
             // int => unused
-            else if (columnLabel.equals("SQL_DATETIME_SUB")) {
+            case "SQL_DATETIME_SUB": {
                 this.wasNull = false;
                 return 0;
             }
 
-            else {
+            default:
                 // FIXME : this function is not perfect. It a column label is given that refers to a field described in getString(..) this function
                 // will tell that the field doesn't exist. It's not true : the field is not numeric. But as getString(..) defaults to getInt(...),
                 // getInt(..) cannot default to getString(..), else the function will run in a cycle.
                 String message = format(Level.WARNING, "excp.no_desc_field", columnLabel, getTableName());
                 throw new SQLNoSuchFieldException(message, "asking columns desc", getFile(), columnLabel);
-            }
         }
     }
 

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -42,35 +42,32 @@ public class DBFBuiltInMemoryResultSetFo
     @Override public String getString(String columnLabel) {
         logStep("getString", columnLabel);
 
-        {   // On the JDK7 branch, this is a switch on strings.
-            if (columnLabel.equals("TABLE_NAME"))                // String => table name.
+        switch(columnLabel) {
+            case "TABLE_NAME":                // String => table name.
             {
                 String tableName = getTableName();
                 this.wasNull = (tableName == null);
                 return tableName;
             }
 
-            else if (columnLabel.equals("TABLE_TYPE")) {             // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
+            case "TABLE_TYPE":                // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
                 this.wasNull = false;
                 return "TABLE";
-            }
 
-            else if (columnLabel.equals("TYPE_NAME")                 // String => type name (may be null)
-                  || columnLabel.equals("TABLE_CAT")                 // String => table catalog (may be null)
-                  || columnLabel.equals("TABLE_SCHEM")               // String => table schema (may be null)
-                  || columnLabel.equals("REMARKS")                   // String => explanatory comment on the table
-                  || columnLabel.equals("TYPE_CAT")                  // String => the types catalog (may be null)
-                  || columnLabel.equals("TYPE_SCHEM")                // String => the types schema (may be null)
-                  || columnLabel.equals("SELF_REFERENCING_COL_NAME") // String => name of the designated "identifier" column of a typed table (may be null)
-                  || columnLabel.equals("REF_GENERATION")) {         // String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null)
+            case "TYPE_NAME":                 // String => type name (may be null)
+            case "TABLE_CAT":                 // String => table catalog (may be null)
+            case "TABLE_SCHEM":               // String => table schema (may be null)
+            case "REMARKS":                   // String => explanatory comment on the table
+            case "TYPE_CAT":                  // String => the types catalog (may be null)
+            case "TYPE_SCHEM":                // String => the types schema (may be null)
+            case "SELF_REFERENCING_COL_NAME": // String => name of the designated "identifier" column of a typed table (may be null)
+            case "REF_GENERATION":            // String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null)
                 this.wasNull = true;
                 return null;
-            }
 
-            else {
+            default:
                 this.wasNull = true;
                 return null;
-            }
         }
     }
 

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -42,21 +42,18 @@ public class DBFBuiltInMemoryResultSetFo
     @Override public String getString(String columnLabel) {
         logStep("getString", columnLabel);
 
-        {   // On the JDK7 branch, this is a switch on strings.
-            if (columnLabel.equals("OBJECTID")) {    // FIXME Documentation of ObjectId for geTabletTypes() has not been found. What are the rules about this field ?
+        switch(columnLabel) {
+            case "OBJECTID":                  // FIXME Documentation of ObjectId for geTabletTypes() has not been found. What are the rules about this field ?
                 this.wasNull = false;
                 return "1";
-            }
 
-            else if (columnLabel.equals("TABLE_TYPE")) {         // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
+            case "TABLE_TYPE":                // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
                 this.wasNull = false;
                 return "TABLE";               // and DBase 3 only knows tables.
-            }
 
-            else {
+            default:
                 this.wasNull = true;
                 return null;
-            }
         }
     }
 

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -51,10 +51,10 @@ 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.
@@ -79,8 +79,7 @@ public class DBFRecordBasedResultSet ext
         assertNotClosed();
 
         // Act as if we were a double, but store the result in a pre-created BigDecimal at the end.
-        final DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql)) {
             MathContext mc = new MathContext(field.getInt("DECIMAL_DIGITS"), RoundingMode.HALF_EVEN);
             Double doubleValue = getDouble(columnLabel);
 
@@ -93,8 +92,6 @@ public class DBFRecordBasedResultSet ext
                 this.wasNull = true;
                 return null;
             }
-        } finally {
-            field.close();
         }
     }
 
@@ -341,8 +338,7 @@ public class DBFRecordBasedResultSet ext
      */
     @Override
     public Object getObject(int column) throws SQLConnectionClosedException, SQLIllegalColumnIndexException, SQLFeatureNotSupportedException, SQLNoSuchFieldException, SQLNotNumericException, SQLNotDateException {
-        DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(column, this.sql);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(column, this.sql)) {
             String fieldType;
 
             try {
@@ -353,18 +349,18 @@ public class DBFRecordBasedResultSet ext
                 throw new RuntimeException(e.getMessage(), e);
             }
 
-            {   // On the JDK7 branch, this is a switch on strings.
-                if (fieldType.equals("AUTO_INCREMENT") ||
-                    fieldType.equals("INTEGER"))
+            switch(fieldType) {
+                case "AUTO_INCREMENT":
+                case "INTEGER":
                     return getInt(column);
 
-                else if (fieldType.equals("CHAR"))
+                case "CHAR":
                     return getString(column);
 
-                else if (fieldType.equals("DATE"))
+                case "DATE":
                     return getDate(column);
 
-                else if (fieldType.equals("DECIMAL")) {
+                case "DECIMAL": {
                     // Choose Integer or Long type, if no decimal and that the field is not to big.
                     if (field.getInt("DECIMAL_DIGITS") == 0 && field.getInt("COLUMN_SIZE") <= 18) {
                         if (field.getInt("COLUMN_SIZE") <= 9)
@@ -376,42 +372,40 @@ public class DBFRecordBasedResultSet ext
                     return getDouble(column);
                 }
 
-                else if (fieldType.equals("DOUBLE")
-                      || fieldType.equals("CURRENCY"))
+                case "DOUBLE":
+                case "CURRENCY":
                     return getDouble(column);
 
-                else if (fieldType.equals("FLOAT"))
+                case "FLOAT":
                     return getFloat(column);
 
-                else if (fieldType.equals("BOOLEAN"))
+                case "BOOLEAN":
                     throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Boolean");
 
-                else if (fieldType.equals("DATETIME"))
+                case "DATETIME":
                     throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime");
 
-                else if (fieldType.equals("TIMESTAMP"))
+                case "TIMESTAMP":
                     throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp");
 
-                else if (fieldType.equals("MEMO"))
+                case "MEMO":
                     throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo");
 
-                else if (fieldType.equals("PICTURE"))
+                case "PICTURE":
                     throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture");
 
-                else if (fieldType.equals("VARIFIELD"))
+                case "VARIFIELD":
                     throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField");
 
-                else if (fieldType.equals("VARIANT"))
+                case "VARIANT":
                     throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant");
 
-                else if (fieldType.equals("UNKNOWN"))
+                case "UNKNOWN":
                     throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + fieldType);
 
-                else
+                default:
                     throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + fieldType);
             }
-        } finally {
-            field.close();
         }
     }
 
@@ -421,7 +415,7 @@ public class DBFRecordBasedResultSet ext
     @Override
     public Object getObject(String columnLabel) throws SQLConnectionClosedException, SQLFeatureNotSupportedException, SQLNoSuchFieldException, SQLNotNumericException, SQLNotDateException {
         int index = -1;
-
+        
         try {
             index = findColumn(columnLabel);
             return getObject(index);
@@ -439,7 +433,7 @@ public class DBFRecordBasedResultSet ext
     public int getRowNum()  {
         return this.recordNumber;
     }
-
+    
     /**
      * @see java.sql.ResultSet#getShort(java.lang.String)
      * @throws SQLConnectionClosedException if the connection is closed.
@@ -498,7 +492,7 @@ public class DBFRecordBasedResultSet ext
         // If a non null value has been readed, convert it to the wished Charset (provided one has been given).
         DBFConnection cnt = (DBFConnection)((DBFStatement)getStatement()).getConnection();
         Charset charset = cnt.getCharset();
-
+        
         if (charset == null) {
             return new String(bytes);
         }
@@ -609,10 +603,9 @@ public class DBFRecordBasedResultSet ext
     private <T extends Number> T getNumeric(String columnLabel, Function<String, T> parse) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException {
         assertNotClosed();
 
-        DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, this.sql);
-        try {
+        try(DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, this.sql)) {
             String textValue = getString(columnLabel);
-
+            
             if (textValue == null) {
                 return null;
             }
@@ -626,8 +619,6 @@ public class DBFRecordBasedResultSet ext
                 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);
             }
-        } finally {
-            rs.close();
         }
     }
 

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -24,16 +24,13 @@ import java.net.URL;
 import java.sql.*;
 import java.util.Calendar;
 import java.util.Map;
+import java.util.Objects;
 import java.util.logging.Level;
 
 import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
 import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
 import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
 
-// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
-
-
 /**
  * Common implemented features of all ResultSets : those based on a record, but also those returning results forged in memory.
  * @author Marc LE BIHAN
@@ -375,6 +372,7 @@ public abstract class DBFResultSet exten
      * Defaults to the index-based version of this method.
      * The given column name is mapped to a column index by {@link #findColumn(String)}.
      */
+    @Override
     public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
         return getObject(findColumn(columnLabel), type);
     }

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.internal.shapefile.jdbc.sql;
 
+import java.util.Objects;
 import java.util.logging.Level;
 
 import org.apache.sis.internal.shapefile.AutoChecker;
@@ -24,7 +25,6 @@ import org.apache.sis.internal.shapefile
 
 // Branch-dependent imports
 import org.apache.sis.internal.jdk8.Function;
-import org.apache.sis.internal.jdk7.Objects;
 import org.apache.sis.util.Numbers;
 
 
@@ -116,24 +116,26 @@ public abstract class ClauseResolver ext
      * @throws SQLConnectionClosedException if the connection is closed.
      */
     public boolean isVerified(DBFRecordBasedResultSet rs) throws SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLConnectionClosedException, SQLNotNumericException, SQLNotDateException {
-        final String v = getOperator();
-        if (v.equals("="))
-            return compare(rs) == 0;
+        switch(getOperator()) {
+            case "=" :
+                return compare(rs) == 0;
 
-        if (v.equals(">"))
-            return compare(rs) > 0;
+            case ">" :
+                return compare(rs) > 0;
 
-        if (v.equals(">="))
-            return compare(rs) >= 0;
+            case ">=" :
+                return compare(rs) >= 0;
 
-        if (v.equals("<"))
-            return compare(rs) < 0;
+            case "<" :
+                return compare(rs) < 0;
 
-        if (v.equals("<="))
-            return compare(rs) <= 0;
+            case "<=" :
+                return compare(rs) <= 0;
 
-        String message = format(Level.WARNING, "excp.invalid_statement_operator", getOperator(), rs.getSQL());
-        throw new SQLInvalidStatementException(message, rs.getSQL(), rs.getFile());
+            default :
+                 String message = format(Level.WARNING, "excp.invalid_statement_operator", getOperator(), rs.getSQL());
+                 throw new SQLInvalidStatementException(message, rs.getSQL(), rs.getFile());
+        }
     }
 
     /**
@@ -309,11 +311,8 @@ public abstract class ClauseResolver ext
         }
         else {
             // The string designs a field name, return its value.
-            DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)rs.getFieldDesc(text, rs.getSQL());
-            try {
+            try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)rs.getFieldDesc(text, rs.getSQL())) {
                 return valueOf(rs, field);
-            } finally {
-                field.close();
             }
         }
     }
@@ -332,51 +331,52 @@ public abstract class ClauseResolver ext
     private Object valueOf(DBFRecordBasedResultSet rs, DBFBuiltInMemoryResultSetForColumnsListing field) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLUnsupportedParsingFeatureException, SQLNotDateException {
         String columnName = field.getString("COLUMN_NAME");
 
-        final String v = field.getString("TYPE_NAME");
-        if (v.equals("AUTO_INCREMENT"))
-            return rs.getInt(columnName);
+        switch(field.getString("TYPE_NAME")) {
+            case "AUTO_INCREMENT":
+                return rs.getInt(columnName);
+
+            case "CHAR":
+                return rs.getString(columnName);
 
-        if (v.equals("CHAR"))
-            return rs.getString(columnName);
+            case "INTEGER":
+                return rs.getInt(columnName);
 
-        if (v.equals("INTEGER"))
-            return rs.getInt(columnName);
+            case "DATE":
+                return rs.getDate(columnName);
 
-        if (v.equals("DATE"))
-            return rs.getDate(columnName);
+            case "DOUBLE":
+                return rs.getDouble(columnName);
 
-        if (v.equals("DOUBLE"))
-            return rs.getDouble(columnName);
+            case "FLOAT":
+                return rs.getFloat(columnName);
 
-        if (v.equals("FLOAT"))
-            return rs.getFloat(columnName);
 
+            case "DECIMAL": {
+                // Choose Integer or Long type, if no decimal and that the field is not to big.
+                if (field.getInt("DECIMAL_DIGITS") == 0 && field.getInt("COLUMN_SIZE") <= 18) {
+                    if (field.getInt("COLUMN_SIZE") <= 9)
+                        return rs.getInt(columnName);
+                    else
+                        return rs.getLong(columnName);
+                }
 
-        if (v.equals("DECIMAL")) {
-            // Choose Integer or Long type, if no decimal and that the field is not to big.
-            if (field.getInt("DECIMAL_DIGITS") == 0 && field.getInt("COLUMN_SIZE") <= 18) {
-                if (field.getInt("COLUMN_SIZE") <= 9)
-                    return rs.getInt(columnName);
-                else
-                    return rs.getLong(columnName);
+                return rs.getDouble(columnName);
             }
 
-            return rs.getDouble(columnName);
-        }
+            case "BOOLEAN":
+            case "CURRENCY":
+            case "DATETIME":
+            case "TIMESTAMP":
+            case "MEMO":
+            case "PICTURE":
+            case "VARIFIELD":
+            case "VARIANT":
+            case "UNKNOWN":
+                String message = format(Level.WARNING, "excp.unparsable_field_type", columnName, field.getString("TYPE_NAME"), rs.getSQL());
+                throw new SQLUnsupportedParsingFeatureException(message, rs.getSQL(), rs.getFile());
 
-        if (v.equals("BOOLEAN") ||
-            v.equals("CURRENCY") ||
-            v.equals("DATETIME") ||
-            v.equals("TIMESTAMP") ||
-            v.equals("MEMO") ||
-            v.equals("PICTURE") ||
-            v.equals("VARIFIELD") ||
-            v.equals("VARIANT") ||
-            v.equals("UNKNOWN"))
-        {
-            String message = format(Level.WARNING, "excp.unparsable_field_type", columnName, field.getString("TYPE_NAME"), rs.getSQL());
-            throw new SQLUnsupportedParsingFeatureException(message, rs.getSQL(), rs.getFile());
+            default:
+                throw new RuntimeException(format(Level.WARNING, "assert.unknown_field_type", field.getString("TYPE_NAME")));
         }
-        throw new RuntimeException(format(Level.WARNING, "assert.unknown_field_type", field.getString("TYPE_NAME")));
     }
 }

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -17,15 +17,12 @@
 package org.apache.sis.internal.shapefile.jdbc.sql;
 
 import java.io.File;
+import java.util.Objects;
 import java.util.logging.Level;
 
 import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC;
 import org.apache.sis.internal.shapefile.jdbc.resultset.DBFRecordBasedResultSet;
 
-// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
-
-
 /**
  * Simple and temporary SQL parser.
  * @author Marc LE BIHAN

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -293,6 +293,7 @@ abstract class AbstractStatement extends
     /**
      * Unsupported by default.
      */
+    @Override
     public void closeOnCompletion() throws SQLException {
         throw unsupportedOperation("closeOnCompletion");
     }
@@ -300,6 +301,7 @@ abstract class AbstractStatement extends
     /**
      * Unsupported by default.
      */
+    @Override
     public boolean isCloseOnCompletion() throws SQLException {
         throw unsupportedOperation("isCloseOnCompletion");
     }

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -20,6 +20,7 @@ import java.io.File;
 import java.sql.*;
 import java.text.MessageFormat;
 import java.util.HashSet;
+import java.util.Objects;
 import java.util.logging.Level;
 
 import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException;
@@ -28,9 +29,6 @@ import org.apache.sis.internal.shapefile
 import org.apache.sis.internal.shapefile.jdbc.resultset.DBFRecordBasedResultSet;
 import org.apache.sis.internal.shapefile.jdbc.sql.SQLInvalidStatementException;
 
-// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
-
 
 /**
  * DBF Statement.
@@ -44,7 +42,7 @@ public class DBFStatement extends Abstra
     private DBFConnection connection;
 
     /** ResultSets that are currently opened. */
-    private HashSet<DBFResultSet> openedResultSets = new HashSet<DBFResultSet>();
+    private HashSet<DBFResultSet> openedResultSets = new HashSet<>();
 
     /** The current result set, or {@code null} if none. */
     private DBFResultSet currentResultSet;

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -51,10 +51,10 @@ import org.apache.sis.feature.AbstractFe
 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;
 
@@ -75,12 +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;
+    private boolean hasShapefileIndex; 
 
     /** Type of the features contained in this shapefile. */
     private DefaultFeatureType featuresType;
@@ -102,17 +102,17 @@ public class InputFeatureStream extends
     public InputFeatureStream(File shpfile, File dbaseFile, File shpfileIndex, String sqlStatement) throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
         try {
             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;
@@ -120,10 +120,10 @@ public class InputFeatureStream extends
             else {
                 this.hasShapefileIndex = false;
             }
-
+    
             this.shapefileReader = new ShapefileByteReader(this.shapefile, this.databaseFile, this.shapefileIndex);
             this.featuresType = this.shapefileReader.getFeaturesType();
-
+    
             try {
                 executeQuery();
             }
@@ -149,7 +149,7 @@ 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.
@@ -176,7 +176,7 @@ public class InputFeatureStream extends
     public InputFeatureStream(File shpfile, File dbaseFile) throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
         this(shpfile, dbaseFile, null);
     }
-
+    
     /**
      * @see java.io.InputStream#read()
      */
@@ -218,17 +218,17 @@ public class InputFeatureStream extends
         catch(SQLConnectionClosedException e) {
             throw new DataStoreClosedException(e.getMessage(), e);
         }
-        catch(SQLNotNumericException e) {
-            throw new DataStoreQueryResultException(e.getMessage(), e);
+        catch(SQLInvalidStatementException | SQLIllegalParameterException | SQLNoSuchFieldException | SQLUnsupportedParsingFeatureException | SQLFeatureNotSupportedException e) {
+            throw new DataStoreQueryException(e.getMessage(), e);
         }
-        catch(SQLNotDateException e) {
+        catch(SQLNotNumericException | SQLNotDateException e) {
             throw new DataStoreQueryResultException(e.getMessage(), e);
         }
-        catch(java.sql.SQLException e) {
+        catch(SQLNoDirectAccessAvailableException e) {
             throw new DataStoreQueryException(e.getMessage(), e);
         }
     }
-
+    
     /**
      * Return the features type.
      * @return Features type.
@@ -236,7 +236,7 @@ public class InputFeatureStream extends
     public DefaultFeatureType getFeaturesType() {
         return this.featuresType;
     }
-
+    
     /**
      * Returns the shapefile descriptor.
      * @return Shapefile descriptor.
@@ -244,15 +244,15 @@ public class InputFeatureStream extends
     public ShapefileDescriptor getShapefileDescriptor() {
         return this.shapefileReader.getShapefileDescriptor();
     }
-
-    /**
+    
+    /** 
      * Returns the database fields descriptors.
-     * @return List of fields descriptors.
+     * @return List of fields descriptors. 
      */
     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.
@@ -260,7 +260,7 @@ public class InputFeatureStream extends
     public boolean hasShapefileIndex() {
         return this.hasShapefileIndex;
     }
-
+    
     /**
      * Read next feature responding to the SQL query.
      * @return Feature, null if no more feature is available.
@@ -282,24 +282,24 @@ public class InputFeatureStream extends
             }
 
             int previousRecordNumber = this.rs.getRowNum();
-
+            
             if (this.rs.next() == false) {
                 this.endOfFile = true;
                 return null;
             }
-
+            
             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) {
@@ -313,13 +313,12 @@ public class InputFeatureStream extends
                     LOGGER.finer(format.format(new Object[] {previousRecordNumber, currentRecordNumber}));
                 }
             }
-
+            
             AbstractFeature feature = this.featuresType.newInstance();
             this.shapefileReader.completeFeature(feature);
             DBFDatabaseMetaData metadata = (DBFDatabaseMetaData)this.connection.getMetaData();
 
-            DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = (DBFBuiltInMemoryResultSetForColumnsListing)metadata.getColumns(null, null, null, null);
-            try {
+            try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = (DBFBuiltInMemoryResultSetForColumnsListing)metadata.getColumns(null, null, null, null)) {
                 while(rsDatabase.next()) {
                     String fieldName = rsDatabase.getString("COLUMN_NAME");
                     Object fieldValue = this.rs.getObject(fieldName);
@@ -351,11 +350,9 @@ public class InputFeatureStream extends
 
                 return feature;
             }
-            catch(java.sql.SQLException e) {
+            catch(SQLNoResultException e) {
                 // This an internal trouble, if it occurs.
                 throw new RuntimeException(e.getMessage(), e);
-            } finally {
-                rsDatabase.close();
             }
         }
         catch(SQLNoResultException e) {

Modified: sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -18,7 +18,7 @@ package org.apache.sis.storage.shapefile
 
 import java.io.File;
 import java.util.List;
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
 
 import org.apache.sis.feature.DefaultFeatureType;
 import org.apache.sis.internal.shapefile.ShapefileDescriptor;
@@ -50,10 +50,10 @@ public class ShapeFile {
 
     /** Shapefile descriptor. */
     private ShapefileDescriptor shapefileDescriptor;
-
+    
     /** Database field descriptors. */
     private List<DBase3FieldDescriptor> databaseFieldsDescriptors;
-
+    
     /**
      * Construct a Shapefile from a file.
      * @param shpfile file to read.
@@ -119,7 +119,7 @@ public class ShapeFile {
     public DefaultFeatureType getFeaturesType() {
         return this.featuresType;
     }
-
+    
     /**
      * Returns the shapefile descriptor.
      * @return Shapefile descriptor.
@@ -127,10 +127,10 @@ public class ShapeFile {
     public ShapefileDescriptor getShapefileDescriptor() {
         return this.shapefileDescriptor;
     }
-
-    /**
+    
+    /** 
      * Returns the database fields descriptors.
-     * @return List of fields descriptors.
+     * @return List of fields descriptors. 
      */
     public List<DBase3FieldDescriptor> getDatabaseFieldsDescriptors() {
         return this.databaseFieldsDescriptors;
@@ -200,7 +200,7 @@ public class ShapeFile {
     public void loadDescriptors() throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
         // Doing an simple query will init the internal descriptors.
         // It prepares a SELECT * FROM <DBase> but don't read a record by itself.
-        InputFeatureStream is = findAll();
-        is.close();
+        try(InputFeatureStream is = findAll()) {
+        }
     }
 }

Modified: sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -44,20 +44,13 @@ public class DBFResultSetTest extends Ab
      */
     @Test
     public void readFirstRecord() throws SQLException {
-        Connection connection = connect();
-        Statement stmt = connection.createStatement();
-        ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute");
-        try {
+        try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute")) {
             rs.next();
             assertEquals("getString(\"ST_NAME\")", "36TH ST", rs.getString("ST_NAME"));                                    // ST_NAME Character(29)
             assertEquals("getInt(\"FNODE_\")", 1199, rs.getInt("FNODE_"));                                                 // FNODE_ Number(10, 0)
             assertEquals("getDouble(\"SHAPE_LEN\")", 43.0881492571, rs.getDouble("SHAPE_LEN"), 0.1);                       // SHAPE_LEN Number(19, 11)
             assertEquals("getBigDecimal(\"SHAPE_LEN\")", 43.0881492571, rs.getBigDecimal("SHAPE_LEN").doubleValue(), 0.1); // SHAPE_LEN Number(19, 11)
             assertEquals("getDate(\"TR_DATE\")", null, rs.getDate("TR_DATE"));                       // TR_DATE Date(8)
-        } finally {
-            rs.close();
-            stmt.close();
-            connection.close();
         }
     }
 
@@ -68,14 +61,11 @@ public class DBFResultSetTest extends Ab
     @Test
     @DependsOnMethod("readFirstRecord")
     public void readAllRecords() throws SQLException {
-        Connection connection = connect();
-        Statement stmt = connection.createStatement();
-        ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute");
-        try {
+        try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute")) {
             int count = 0;
 
             while(rs.next()) {
-                ArrayList<Object> record = new ArrayList<Object>();
+                ArrayList<Object> record = new ArrayList<>();
 
                 record.add(rs.getLong("OBJECTID"));         // Type : Number, Field length : 10, Decimal positions : 0
                 record.add(rs.getLong("FNODE_"));           // Type : Number, Field length : 10, Decimal positions : 0
@@ -140,10 +130,6 @@ public class DBFResultSetTest extends Ab
             }
 
             assertTrue("Less than one record was readed.", count > 1);
-        } finally {
-            rs.close();
-            stmt.close();
-            connection.close();
         }
     }
 
@@ -155,9 +141,8 @@ public class DBFResultSetTest extends Ab
     public void resultSetClosed() throws SQLException {
         // 1) Open a connection, open a statement, open and close a ResultSet.
         String sql = "SELECT * FROM SignedBikeRoute";
-        Connection connection = connect();
-        Statement stmt = connection.createStatement();
-        try {
+
+        try(Connection connection = connect(); Statement stmt = connection.createStatement()) {
             // Then, attempt to use it.
             try {
                 ResultSet rs = stmt.executeQuery(sql);
@@ -170,14 +155,11 @@ public class DBFResultSetTest extends Ab
             catch(SQLException e) {
                 fail("Not the expected exception for using a closed ResultSet.");
             }
-        } finally {
-            stmt.close();
-            connection.close();
         }
 
         // 2) Same, but we close the connection instead.
-        connection = connect();
-        stmt = connection.createStatement();
+        Connection connection = connect();
+        Statement stmt = connection.createStatement();
         ResultSet rs = stmt.executeQuery(sql);
 
         connection.close(); // At this time, you expect also a warning on the console, telling that you have one statement and one ResultSet still opened.
@@ -198,8 +180,7 @@ public class DBFResultSetTest extends Ab
         }
 
         // 3) Same, but we close the statement instead .
-        Connection cnt = connect();
-        try {
+        try(Connection cnt = connect()) {
             stmt = cnt.createStatement();
             rs = stmt.executeQuery(sql);
 
@@ -219,8 +200,6 @@ public class DBFResultSetTest extends Ab
                 rs.close();
                 stmt.close();
             }
-        } finally {
-            cnt.close();
         }
     }
 }

Modified: sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -41,15 +41,12 @@ public class DBFStatementTest extends Ab
     public void openCloseStatement() throws SQLException {
         final Driver driver = new DBFDriver();
 
-        Connection connection = driver.connect(this.dbfFile.getAbsolutePath(), null);
-        try {
+        try(Connection connection = driver.connect(this.dbfFile.getAbsolutePath(), null)) {
             final Statement stmt = connection.createStatement();
             assertFalse("Statement should be opened", stmt.isClosed());
 
             stmt.close();
             assertTrue ("Statement should be closed", stmt.isClosed());
-        } finally {
-            connection.close();
         }
     }
 
@@ -61,8 +58,7 @@ public class DBFStatementTest extends Ab
     @DependsOnMethod("openCloseStatement")
     public void statementClosed() throws SQLException {
         // Open a connection, open and close a statement.
-        Connection connection = connect();
-        try {
+        try(Connection connection = connect()) {
             final Statement stmt = connection.createStatement();
             stmt.close();
 
@@ -76,12 +72,10 @@ public class DBFStatementTest extends Ab
             catch(SQLException e) {
                 fail("Not the expected exception for using a closed statement.");
             }
-        } finally {
-            connection.close();
         }
 
         // Same, but we close the connection instead.
-        connection = connect();
+        Connection connection = connect();
         final Statement stmt = connection.createStatement();
 
         connection.close(); // At this time, you expect also a warning on the console, telling that you have one statement still opened.

Modified: sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -36,10 +36,7 @@ public class WhereClauseTest extends Abs
      */
     @Test
     public void operators() throws SQLException {
-        Connection connection = connect();
-        Statement stmt = connection.createStatement();
-        DBFRecordBasedResultSet rs = (DBFRecordBasedResultSet)stmt.executeQuery("SELECT * FROM SignedBikeRoute");
-        try {
+        try(Connection connection = connect(); Statement stmt = connection.createStatement(); DBFRecordBasedResultSet rs = (DBFRecordBasedResultSet)stmt.executeQuery("SELECT * FROM SignedBikeRoute")) {
             rs.next();
 
             assertTrue("FNODE_ = 1199", new ConditionalClauseResolver("FNODE_", 1199L, "=").isVerified(rs));
@@ -63,10 +60,6 @@ public class WhereClauseTest extends Abs
             assertTrue("SHAPE_LEN = 43.0881492571", new ConditionalClauseResolver("SHAPE_LEN", 43.0881492571, "=").isVerified(rs));
             assertTrue("SHAPE_LEN > 43.088", new ConditionalClauseResolver("SHAPE_LEN", 43.088, ">").isVerified(rs));
             assertFalse("SHAPE_LEN < 43.0881492571", new ConditionalClauseResolver("SHAPE_LEN", 43.0881492571, "<").isVerified(rs));
-        } finally {
-            rs.close();
-            stmt.close();
-            connection.close();
         }
     }
 
@@ -147,10 +140,7 @@ public class WhereClauseTest extends Abs
     private void checkAndCount(String whereCondition, ResultSetPredicate<ResultSet> condition, int countExpected) throws SQLException {
         String sql = "SELECT * FROM SignedBikeRoute WHERE " + whereCondition;
 
-        Connection connection = connect();
-        Statement stmt = connection.createStatement();
-        ResultSet rs = stmt.executeQuery(sql);
-        try {
+        try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery(sql)) {
             int count = 0;
 
             while(rs.next()) {
@@ -160,10 +150,6 @@ public class WhereClauseTest extends Abs
 
             if (countExpected != -1)
                 assertEquals("Wrong number of records red by : " + sql, countExpected, count);
-        } finally {
-            rs.close();
-            stmt.close();
-            connection.close();
         }
     }
 }

Modified: sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] (original)
+++ sis/trunk/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -85,30 +85,30 @@ public final strictfp class ShapeFileTes
      }
 
      /**
-      * Test loading of shapefile descriptors.
+      * Test loading of shapefile descriptors. 
       * @throws URISyntaxException if the resource name is incorrect.
       * @throws DataStoreException if a general file reading trouble occurs.
       */
      @Test
      public void testDescriptors() throws URISyntaxException, DataStoreException {
          Logger log = org.apache.sis.util.logging.Logging.getLogger(ShapeFileTest.class.getName());
-
+         
          ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
          shp.loadDescriptors();
-
+         
          assertNotNull("The features type of the shapefile should have been set.", shp.getFeaturesType());
          log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp features type : {0}", shp.getFeaturesType()));
-
+         
          assertNotNull("The shapefile descriptor of the shapefile should have been set.", shp.getShapefileDescriptor());
          log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp shapefile descriptor : {0}", shp.getShapefileDescriptor()));
 
          assertNotNull("The DBase III fields descriptors of the shapefile should have been set.", shp.getDatabaseFieldsDescriptors());
          log.info(MessageFormat.format("ABRALicenseePt_4326_clipped.shp DBase fields descriptors : {0}", shp.getDatabaseFieldsDescriptors()));
-
+         
          // Loading of the descriptor shall not prevent the shapefile from being red again.
          readAll(shp);
      }
-
+     
      /**
       * Checks that the reader is able to detect EoF signs in the DBase file.
       * @throws URISyntaxException if the resource name is incorrect.
@@ -121,8 +121,7 @@ public final strictfp class ShapeFileTes
 
          Logger log = org.apache.sis.util.logging.Logging.getLogger(ShapeFileTest.class.getName());
 
-         InputFeatureStream is = shp.findAll();
-         try {
+         try(InputFeatureStream is = shp.findAll()) {
              AbstractFeature feature = is.readFeature();
 
              // Read and retain the first and the last feature.
@@ -130,7 +129,7 @@ public final strictfp class ShapeFileTes
                  if (first == null) {
                      first = feature;
                  }
-
+                 
                  // Advice : To debug just before the last record, put a conditional breakpoint on department name "MEURTHE-ET-MOSELLE".
                  String deptName = (String)((AbstractAttribute) feature.getProperty("NOM_DEPT")).getValue();
                  log.info(deptName);
@@ -138,80 +137,69 @@ public final strictfp class ShapeFileTes
                  last = feature;
                  feature = is.readFeature();
              }
-         } finally {
-             is.close();
          }
-
+         
          assertNotNull("No record has been found in the DBase file or Shapefile.", first);
          assertNotNull("This test is not working well : last feature should always be set if any feature has been found.", last);
          assertEquals("The first record red must be JURA department.", "JURA", ((AbstractAttribute) first.getProperty("NOM_DEPT")).getValue());
          assertEquals("The last record red must be DEUX-SEVRES department.", "DEUX-SEVRES", ((AbstractAttribute) 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
+     @Test 
      public void testDirectAcces() throws DataStoreException, URISyntaxException {
          ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
-
+         
          // 1) Find the third record, sequentially.
          AbstractFeature thirdFeature;
-
-         InputFeatureStream isSequential = shp.findAll();
-         try {
+         
+         try(InputFeatureStream isSequential = shp.findAll()) {
              isSequential.readFeature();
              isSequential.readFeature();
              thirdFeature = isSequential.readFeature();
-         } finally {
-             isSequential.close();
          }
-
+         
          // Take one of its key fields and another field for reference, and its geometry.
          Double sequentialAddressId = Double.valueOf((String)(((AbstractAttribute) thirdFeature.getProperty("ADDRID"))).getValue());
          String sequentialAddress = (String)(((AbstractAttribute) thirdFeature.getProperty("ADDRESS"))).getValue();
          Object sequentialGeometry = thirdFeature.getPropertyValue("geometry");
-
-         // 2) Now attempt a direct access to this feature.
+         
+         // 2) Now attempt a direct access to this feature.         
          AbstractFeature directFeature;
          String sql = MessageFormat.format("SELECT * FROM ABRALicenseePt_4326_clipped WHERE ADDRID = {0,number,#0}", sequentialAddressId);
-
-         InputFeatureStream isDirect = shp.find(sql);
-         try {
+         
+         try(InputFeatureStream isDirect = shp.find(sql)) {
              directFeature = isDirect.readFeature();
              assertNotNull("The direct access feature returned should not be null", directFeature);
-         } finally {
-             isDirect.close();
          }
 
          assertNotNull("The field ADDRID in the direct access feature has not been found again.", directFeature.getProperty("ADDRID"));
-
+         
          Double directAddressId = Double.valueOf((String)(((AbstractAttribute) directFeature.getProperty("ADDRID"))).getValue());
          String directAddress = (String)(((AbstractAttribute) 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.
      * @throws DataStoreException if a general file reading trouble occurs.
      */
     private void readAll(ShapeFile shp) throws DataStoreException {
-        InputFeatureStream is = shp.findAll();
-        try {
+        try(InputFeatureStream is = shp.findAll()) {
             AbstractFeature feature = is.readFeature();
 
             while(feature != null) {
                 feature = is.readFeature();
             }
-        } finally {
-            is.close();
         }
     }
 }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelData.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -26,7 +26,7 @@ import org.apache.sis.util.resources.Err
 import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
 // Branch-dependent imports
-import java.nio.channels.FileChannel;
+import java.nio.channels.SeekableByteChannel;
 
 
 /**
@@ -121,7 +121,7 @@ public abstract class ChannelData {
     ChannelData(final String filename, final Channel channel, final ByteBuffer buffer) throws IOException {
         this.filename      = filename;
         this.buffer        = buffer;
-        this.channelOffset = (channel instanceof FileChannel) ? ((FileChannel) channel).position() : 0;
+        this.channelOffset = (channel instanceof SeekableByteChannel) ? ((SeekableByteChannel) channel).position() : 0;
     }
 
     /**

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -33,7 +33,7 @@ import org.apache.sis.util.Debug;
 import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
 // Branch-dependent imports
-import java.nio.channels.FileChannel;
+import java.nio.channels.SeekableByteChannel;
 
 
 /**
@@ -847,14 +847,14 @@ public class ChannelDataInput extends Ch
              * Requested position is inside the current limits of the buffer.
              */
             buffer.position((int) p);
-        } else if (channel instanceof FileChannel) {
+        } else if (channel instanceof SeekableByteChannel) {
             /*
              * Requested position is outside the current limits of the buffer,
              * but we can set the new position directly in the channel. Note
              * that StorageConnector.rewind() needs the buffer content to be
              * valid as a result of this seek, so we reload it immediately.
              */
-            ((FileChannel) channel).position(channelOffset + position);
+            ((SeekableByteChannel) channel).position(channelOffset + position);
             bufferOffset = position;
             buffer.clear().limit(0);
         } else if (p >= 0) {

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataOutput.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -33,7 +33,7 @@ import org.apache.sis.util.resources.Err
 import static org.apache.sis.util.ArgumentChecks.ensureBetween;
 
 // Branch-dependent imports
-import java.nio.channels.FileChannel;
+import java.nio.channels.SeekableByteChannel;
 
 
 /**
@@ -616,13 +616,13 @@ public class ChannelDataOutput extends C
              */
             buffer.position((int) p);
             clearBitOffset();
-        } else if (channel instanceof FileChannel) {
+        } else if (channel instanceof SeekableByteChannel) {
             /*
              * Requested position is outside the current limits of the buffer,
              * but we can set the new position directly in the channel.
              */
             flush();
-            ((FileChannel) channel).position(channelOffset + position);
+            ((SeekableByteChannel) channel).position(channelOffset + position);
             bufferOffset = position;
         } else if (p >= 0) {
             /*

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelImageInputStream.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -25,7 +25,7 @@ import javax.imageio.stream.IIOByteBuffe
 import javax.imageio.stream.ImageInputStream;
 
 // Branch-dependent imports
-import java.nio.channels.FileChannel;
+import java.nio.channels.SeekableByteChannel;
 
 
 /**
@@ -112,8 +112,8 @@ public class ChannelImageInputStream ext
      */
     @Override
     public final long length() throws IOException {
-        if (channel instanceof FileChannel) {
-            return ((FileChannel) channel).size();
+        if (channel instanceof SeekableByteChannel) {
+            return ((SeekableByteChannel) channel).size();
         }
         return -1;
     }

Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/CodeType.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/CodeType.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/CodeType.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/CodeType.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -93,7 +93,7 @@ public enum CodeType {
      */
     private static final Map<String,CodeType> FOR_PROTOCOL;
     static {
-        FOR_PROTOCOL = new HashMap<String,CodeType>();
+        FOR_PROTOCOL = new HashMap<>();
         FOR_PROTOCOL.put("urn",   CodeType.URN);
         FOR_PROTOCOL.put("http",  CodeType.HTTP_OGC);   // Will actually need verification.
         FOR_PROTOCOL.put("https", CodeType.HTTP_OGC);   // Will actually need verification.




Mime
View raw message