From e09ecedb1f447bac92aa842fa4a920243cffe56b Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Mon, 9 May 2022 17:14:38 +0200 Subject: [PATCH 1/8] Remove the modules to be excluded from 1.2 release. --- ide-project/NetBeans/build.xml | 11 - ide-project/NetBeans/nbproject/build-impl.xml | 47 +- .../NetBeans/nbproject/genfiles.properties | 6 +- .../NetBeans/nbproject/project.properties | 2 - ide-project/NetBeans/nbproject/project.xml | 2 - storage/pom.xml | 1 - storage/sis-shapefile/pom.xml | 132 -- .../sis/internal/shapefile/AutoChecker.java | 186 --- ...dRecordNumberForDirectAccessException.java | 65 - .../SQLNoDirectAccessAvailableException.java | 50 - .../SQLShapefileNotFoundException.java | 50 - .../shapefile/ShapefileByteReader.java | 465 ------ .../shapefile/ShapefileDescriptor.java | 201 --- .../jdbc/AbstractDbase3ByteReader.java | 283 ---- .../internal/shapefile/jdbc/AbstractJDBC.java | 162 -- .../shapefile/jdbc/CommonByteReader.java | 132 -- .../internal/shapefile/jdbc/DBFDriver.java | 145 -- .../shapefile/jdbc/DBase3FieldDescriptor.java | 150 -- .../shapefile/jdbc/DBaseDataType.java | 103 -- .../shapefile/jdbc/Dbase3ByteReader.java | 130 -- .../shapefile/jdbc/MappedByteReader.java | 309 ---- .../jdbc/SQLConnectionClosedException.java | 63 - .../jdbc/SQLDbaseFileNotFoundException.java | 50 - .../SQLInvalidDbaseFileFormatException.java | 50 - .../jdbc/connection/AbstractConnection.java | 418 ------ .../jdbc/connection/DBFConnection.java | 336 ----- .../SQLClosingIOFailureException.java | 63 - .../jdbc/connection/package-info.java | 19 - .../metadata/AbstractDatabaseMetaData.java | 202 --- .../jdbc/metadata/DBFDatabaseMetaData.java | 1300 ----------------- .../jdbc/metadata/DBFResultSetMataData.java | 473 ------ .../shapefile/jdbc/metadata/package-info.java | 21 - .../internal/shapefile/jdbc/package-info.java | 26 - .../jdbc/resultset/AbstractResultSet.java | 707 --------- .../resultset/BuiltInMemoryResultSet.java | 196 --- ...MemoryResultSetForCatalogNamesListing.java | 51 - ...iltInMemoryResultSetForColumnsListing.java | 460 ------ ...uiltInMemoryResultSetForSchemaListing.java | 51 - ...uiltInMemoryResultSetForTablesListing.java | 88 -- ...nMemoryResultSetForTablesTypesListing.java | 74 - .../resultset/DBFRecordBasedResultSet.java | 609 -------- .../jdbc/resultset/DBFResultSet.java | 965 ------------ .../SQLIllegalColumnIndexException.java | 76 - .../jdbc/resultset/SQLNoResultException.java | 63 - .../resultset/SQLNoSuchFieldException.java | 76 - .../jdbc/resultset/SQLNotDateException.java | 89 -- .../resultset/SQLNotNumericException.java | 89 -- .../jdbc/resultset/package-info.java | 21 - .../shapefile/jdbc/sql/ClauseResolver.java | 391 ----- .../jdbc/sql/ConditionalClauseResolver.java | 38 - .../shapefile/jdbc/sql/CrudeSQLParser.java | 137 -- .../sql/SQLIllegalParameterException.java | 89 -- .../sql/SQLInvalidStatementException.java | 63 - ...SQLUnsupportedParsingFeatureException.java | 63 - .../shapefile/jdbc/sql/package-info.java | 20 - .../jdbc/statement/AbstractStatement.java | 308 ---- .../jdbc/statement/DBFStatement.java | 244 ---- .../jdbc/statement/package-info.java | 19 - .../sis/internal/shapefile/package-info.java | 25 - .../shapefile/DataStoreQueryException.java | 53 - .../DataStoreQueryResultException.java | 53 - .../shapefile/DbaseFileNotFoundException.java | 53 - .../storage/shapefile/InputFeatureStream.java | 377 ----- .../InvalidDbaseFileFormatException.java | 36 - .../InvalidShapefileFormatException.java | 52 - .../sis/storage/shapefile/ShapeFile.java | 210 --- .../sis/storage/shapefile/ShapeTypeEnum.java | 77 - .../shapefile/ShapefileNotFoundException.java | 53 - .../sis/storage/shapefile/cpg/CpgFiles.java | 79 - .../sis/storage/shapefile/package-info.java | 30 - .../shapefile/ShapefileByteReader.properties | 36 - .../ShapefileByteReader_fr.properties | 36 - .../jdbc/AbstractDbase3ByteReader.properties | 14 - .../AbstractDbase3ByteReader_fr.properties | 14 - .../shapefile/jdbc/AbstractJDBC.properties | 23 - .../shapefile/jdbc/AbstractJDBC_fr.properties | 1 - .../jdbc/CommonByteReader.properties | 3 - .../jdbc/DBase3FieldDescriptor.properties | 7 - .../jdbc/DBase3FieldDescriptor_fr.properties | 1 - .../jdbc/MappedByteReader.properties | 30 - .../jdbc/MappedByteReader_fr.properties | 30 - .../connection/AbstractConnection.properties | 6 - .../AbstractConnection_fr.properties | 6 - .../jdbc/connection/DBFConnection.properties | 49 - .../connection/DBFConnection_fr.properties | 39 - .../metadata/DBFResultSetMataData.properties | 14 - .../DBFResultSetMataData_fr.properties | 4 - .../resultset/AbstractResultSet.properties | 1 - .../resultset/AbstractResultSet_fr.properties | 1 - ...emoryResultSetForColumnsListing.properties | 8 - ...ryResultSetForColumnsListing_fr.properties | 8 - ...MemoryResultSetForTablesListing.properties | 2 - ...yResultSetForTablesTypesListing.properties | 2 - .../DBFRecordBasedResultSet.properties | 28 - .../DBFRecordBasedResultSet_fr.properties | 28 - .../jdbc/resultset/DBFResultSet.properties | 10 - .../jdbc/resultset/DBFResultSet_fr.properties | 4 - .../jdbc/sql/ClauseResolver.properties | 25 - .../jdbc/sql/ClauseResolver_fr.properties | 16 - .../jdbc/sql/CrudeSQLParser.properties | 12 - .../jdbc/statement/DBFStatement.properties | 22 - .../jdbc/statement/DBFStatement_fr.properties | 12 - .../shapefile/InputFeatureStream.properties | 9 - .../InputFeatureStream_fr.properties | 9 - .../jdbc/AbstractTestBaseForInternalJDBC.java | 68 - .../shapefile/jdbc/DBFConnectionTest.java | 92 -- .../shapefile/jdbc/DBFResultSetTest.java | 205 --- .../shapefile/jdbc/DBFStatementTest.java | 97 -- .../sis/internal/shapefile/jdbc/readme.txt | 58 - .../shapefile/jdbc/sql/WhereClauseTest.java | 140 -- .../sis/storage/shapefile/ShapeFileTest.java | 206 --- .../sis/test/suite/ShapefileTestSuite.java | 44 - .../apache/sis/test/suite/package-info.txt | 3 - .../shapefile/ABRALicenseePt_4326_clipped.dbf | Bin 5861 -> 0 bytes .../shapefile/ABRALicenseePt_4326_clipped.prj | 1 - .../shapefile/ABRALicenseePt_4326_clipped.shp | Bin 184 -> 0 bytes .../shapefile/ABRALicenseePt_4326_clipped.shx | Bin 124 -> 0 bytes .../org/apache/sis/storage/shapefile/NOTES.md | 12 - .../SignedBikeRoute_4326_clipped.dbf | Bin 7363 -> 0 bytes .../SignedBikeRoute_4326_clipped.prj | 1 - .../SignedBikeRoute_4326_clipped.shp | Bin 1148 -> 0 bytes .../SignedBikeRoute_4326_clipped.shx | Bin 148 -> 0 bytes 122 files changed, 17 insertions(+), 13158 deletions(-) delete mode 100644 storage/sis-shapefile/pom.xml delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLInvalidRecordNumberForDirectAccessException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLNoDirectAccessAvailableException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLShapefileNotFoundException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBaseDataType.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLDbaseFileNotFoundException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLInvalidDbaseFileFormatException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/package-info.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/package-info.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/BuiltInMemoryResultSet.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForCatalogNamesListing.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForSchemaListing.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLIllegalColumnIndexException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoResultException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoSuchFieldException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotDateException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotNumericException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/package-info.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ConditionalClauseResolver.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLIllegalParameterException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLInvalidStatementException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLUnsupportedParsingFeatureException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/package-info.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/package-info.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/package-info.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DataStoreQueryException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DataStoreQueryResultException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DbaseFileNotFoundException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InvalidDbaseFileFormatException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InvalidShapefileFormatException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeTypeEnum.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapefileNotFoundException.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/cpg/CpgFiles.java delete mode 100644 storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/package-info.java delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement_fr.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream.properties delete mode 100644 storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream_fr.properties delete mode 100644 storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java delete mode 100644 storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java delete mode 100644 storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java delete mode 100644 storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java delete mode 100644 storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/readme.txt delete mode 100644 storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java delete mode 100644 storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java delete mode 100644 storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java delete mode 100644 storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/package-info.txt delete mode 100644 storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.dbf delete mode 100644 storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.prj delete mode 100644 storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.shp delete mode 100644 storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.shx delete mode 100644 storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/NOTES.md delete mode 100644 storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/SignedBikeRoute_4326_clipped.dbf delete mode 100644 storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/SignedBikeRoute_4326_clipped.prj delete mode 100644 storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/SignedBikeRoute_4326_clipped.shp delete mode 100644 storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/SignedBikeRoute_4326_clipped.shx diff --git a/ide-project/NetBeans/build.xml b/ide-project/NetBeans/build.xml index 853102e986d..ebcc09aff70 100644 --- a/ide-project/NetBeans/build.xml +++ b/ide-project/NetBeans/build.xml @@ -87,11 +87,6 @@ - @@ -329,12 +324,6 @@ - - - - - - diff --git a/ide-project/NetBeans/nbproject/build-impl.xml b/ide-project/NetBeans/nbproject/build-impl.xml index 451e1a75325..fa02cdab9de 100644 --- a/ide-project/NetBeans/nbproject/build-impl.xml +++ b/ide-project/NetBeans/nbproject/build-impl.xml @@ -90,7 +90,7 @@ is divided into following sections: - + @@ -185,7 +185,6 @@ is divided into following sections: - @@ -208,7 +207,6 @@ is divided into following sections: - @@ -329,7 +327,6 @@ is divided into following sections: Must set src.earth-obs.dir Must set src.geotiff.dir Must set src.netcdf.dir - Must set src.shapefile.dir Must set src.sql.dir Must set src.xmlstore.dir Must set src.storage.dir @@ -345,7 +342,6 @@ is divided into following sections: Must set test.earth-obs.dir Must set test.geotiff.dir Must set test.netcdf.dir - Must set test.shapefile.dir Must set test.sql.dir Must set test.xmlstore.dir Must set test.storage.dir @@ -376,7 +372,7 @@ is divided into following sections: - + @@ -388,7 +384,7 @@ is divided into following sections: - + @@ -443,7 +439,7 @@ is divided into following sections: - + @@ -486,7 +482,7 @@ is divided into following sections: - + @@ -521,7 +517,7 @@ is divided into following sections: - + @@ -669,9 +665,6 @@ is divided into following sections: - - - @@ -740,9 +733,6 @@ is divided into following sections: - - - @@ -1246,7 +1236,7 @@ is divided into following sections: - + @@ -1259,7 +1249,6 @@ is divided into following sections: - @@ -1290,7 +1279,7 @@ is divided into following sections: Must select some files in the IDE or set javac.includes - + @@ -1706,9 +1695,6 @@ is divided into following sections: - - - @@ -1771,9 +1757,6 @@ is divided into following sections: - - - @@ -1826,14 +1809,14 @@ is divided into following sections: - - + + - + @@ -1874,10 +1857,10 @@ is divided into following sections: - + - + @@ -1888,7 +1871,6 @@ is divided into following sections: - @@ -1913,7 +1895,7 @@ is divided into following sections: Must select some files in the IDE or set javac.includes - + @@ -1924,7 +1906,6 @@ is divided into following sections: - diff --git a/ide-project/NetBeans/nbproject/genfiles.properties b/ide-project/NetBeans/nbproject/genfiles.properties index 9598b10f144..7dd48539a1e 100644 --- a/ide-project/NetBeans/nbproject/genfiles.properties +++ b/ide-project/NetBeans/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.data.CRC32=58e6b21c build.xml.script.CRC32=462eaba0 build.xml.stylesheet.CRC32=28e38971@1.53.1.46 -nbproject/build-impl.xml.data.CRC32=f188e30a -nbproject/build-impl.xml.script.CRC32=933f5834 -nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.101.0.48 +nbproject/build-impl.xml.data.CRC32=51b00f24 +nbproject/build-impl.xml.script.CRC32=ef1e5433 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.102.0.48 diff --git a/ide-project/NetBeans/nbproject/project.properties b/ide-project/NetBeans/nbproject/project.properties index 29feef3a457..69e4277c3ac 100644 --- a/ide-project/NetBeans/nbproject/project.properties +++ b/ide-project/NetBeans/nbproject/project.properties @@ -62,8 +62,6 @@ src.geotiff.dir = ${project.root}/storage/sis-geotiff/src/main/java test.geotiff.dir = ${project.root}/storage/sis-geotiff/src/test/java src.netcdf.dir = ${project.root}/storage/sis-netcdf/src/main/java test.netcdf.dir = ${project.root}/storage/sis-netcdf/src/test/java -src.shapefile.dir = ${project.root}/storage/sis-shapefile/src/main/java -test.shapefile.dir = ${project.root}/storage/sis-shapefile/src/test/java src.sql.dir = ${project.root}/storage/sis-sqlstore/src/main/java test.sql.dir = ${project.root}/storage/sis-sqlstore/src/test/java src.xmlstore.dir = ${project.root}/storage/sis-xmlstore/src/main/java diff --git a/ide-project/NetBeans/nbproject/project.xml b/ide-project/NetBeans/nbproject/project.xml index 80deeba67d2..11f31f33b31 100644 --- a/ide-project/NetBeans/nbproject/project.xml +++ b/ide-project/NetBeans/nbproject/project.xml @@ -31,7 +31,6 @@ - @@ -49,7 +48,6 @@ - diff --git a/storage/pom.xml b/storage/pom.xml index ffe626f2580..a69678d0330 100644 --- a/storage/pom.xml +++ b/storage/pom.xml @@ -164,7 +164,6 @@ =========================================================== --> sis-storage - sis-shapefile sis-xmlstore sis-sqlstore sis-netcdf diff --git a/storage/sis-shapefile/pom.xml b/storage/sis-shapefile/pom.xml deleted file mode 100644 index 0c9dd8fe916..00000000000 --- a/storage/sis-shapefile/pom.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.sis - storage - 1.2-SNAPSHOT - - - - - org.apache.sis.storage - sis-shapefile - Apache SIS Shapefile storage - - Read and write files in the Shapefile format. - - - - - - - Travis L. Pinney - tlpinney - travis.pinney@gmail.com - - developer - - - - - - - - - - - - org.apache.sis.core - sis-build-helper - ${sis.plugin.version} - - - - compile-resources - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - org.apache.sis.storage.shapefile - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - - true - - - - - - - - - - - - org.apache.sis.core - sis-feature - ${project.version} - - - org.apache.sis.storage - sis-storage - ${project.version} - - - com.esri.geometry - esri-geometry-api - false - - - - diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java deleted file mode 100644 index b6565114a60..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile; - -import java.lang.reflect.Constructor; -import java.text.MessageFormat; -import java.util.MissingResourceException; -import java.util.Objects; -import java.util.ResourceBundle; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.apache.sis.internal.system.Modules; - -import org.apache.sis.util.logging.Logging; - - -/** - * Base class for objets having auto-checking abilities - * and easy access to Bundle and logging function. - * @author Marc LE BIHAN - */ -public abstract class AutoChecker { - /** Logger. */ - static Logger LOGGER = Logging.getLogger(Modules.SHAPEFILE); - - /** - * Format a resource bundle message. - * - * @param classForResourceBundleName class from which ResourceBundle name will be extracted. - * @param key Message key. - * @param args Message arguments. - * @return Message. - */ - final protected String format(Class classForResourceBundleName, String key, Object... args) { - Objects.requireNonNull(classForResourceBundleName, "Class from with the ResourceBundle name is extracted cannot be null."); - Objects.requireNonNull(key, "Message key cannot be bull."); - - Class candidateClass = classForResourceBundleName; - MessageFormat format = null; - - // Find the key in the bundle having for name this class, or in one of its superclasses. - do { - try { - ResourceBundle rsc = ResourceBundle.getBundle(candidateClass.getName()); - format = new MessageFormat(rsc.getString(key)); - } - catch(MissingResourceException e) { - candidateClass = candidateClass.getSuperclass(); - } - } - while(candidateClass != null && format == null); - - if (format == null) { - String fmt = "Cannot find property key {0} in {1} properties file or any of its superclasses."; - String message = MessageFormat.format(fmt, key, classForResourceBundleName.getName()); - throw new MissingResourceException(message, classForResourceBundleName.getName(), key); - } - else - return format.format(args); - } - - /** - * Format a resource bundle message. - * - * @param key Message key. - * @param args Message arguments. - * @return Message. - */ - final protected String format(String key, Object... args) { - return format(getClass(), key, args); - } - - /** - * Format a resource bundle message and before returning it, log it. - * - * @param logLevel Log Level. - * @param key Message key. - * @param args Message arguments. - * @return Message. - */ - final protected String format(Level logLevel, String key, Object... args) { - Objects.requireNonNull(logLevel, "The log level cannot be null."); - - String message = format(key, args); - LOGGER.log(logLevel, message); - return(message); - } - - /** - * Format a resource bundle message and before returning it, log it. - * - * @param classForResourceBundleName class from which ResourceBundle name will be extracted. - * @param logLevel Log Level. - * @param key Message key. - * @param args Message arguments. - * @return Message. - */ - final protected String format(Level logLevel, Class classForResourceBundleName, String key, Object... args) { - Objects.requireNonNull(logLevel, "The log level cannot be null."); - - String message = format(classForResourceBundleName, key, args); - LOGGER.log(logLevel, message); - return(message); - } - - /** - * Tells if the logger of the base class will log this level of log. - * @param level Wished level of logging. - * @return true if it will log it. - */ - protected boolean isLoggable(Level level) { - return LOGGER.isLoggable(level); - } - - /** - * Logs (and take the time to format an entry log) only if the logger accepts the message. - * @param logLevel Log level. - * @param key Message key. - * @param args Message arguments. - */ - final protected void log(Level logLevel, String key, Object... args) { - Objects.requireNonNull(logLevel, "The log level cannot be null."); - - if (LOGGER.isLoggable(logLevel)) - format(logLevel, key, args); - } - - /** - * Throw an exception by reflection. - * @param Class of the exception to build. - * @param classException Class of the exception to build. - * @param message Exception message. - * @param cause Exception root cause. - * @throws E wished exception. - */ - public static void throwException(Class classException, String message, Throwable cause) throws E { - throw(exception(classException, message, cause)); - } - - /** - * Build an exception by reflection. - * @param Class of the exception to build. - * @param classException Class of the exception to build. - * @param message Exception message. - * @param cause Exception root cause. - * @return E wished exception. - */ - private static E exception(Class classException, String message, Throwable cause) { - Objects.requireNonNull(classException, "The class of the exception to throw cannot be null."); //$NON-NLS-1$ - - try - { - Constructor cstr = classException.getConstructor(String.class, Throwable.class); - E exception = cstr.newInstance(message, cause); - return(exception); - } - catch(Exception e) { - // Create the error message manually to avoid re-entrance in function of this class, that if it has a trouble here could have also a problem everywhere. - String format = "The exception of class {0} (message ''{1}'') can''t be created by reflection. An exception of class {2} happened with the message {3}."; - String msg = MessageFormat.format(format, classException.getName(), message, e.getClass().getName(), e.getMessage()); - throw new RuntimeException(msg, e); - } - } - - /** - * Return the class logger. - * @return logger. - */ - public Logger getLogger() { - return LOGGER; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLInvalidRecordNumberForDirectAccessException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLInvalidRecordNumberForDirectAccessException.java deleted file mode 100644 index ec5642c4164..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLInvalidRecordNumberForDirectAccessException.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile; - -import java.sql.SQLNonTransientException; - - -/** - * Thrown when a record number is invalid to do a direct access in a Shapefile or a DBase III file. - * - * @author Marc Le Bihan - * @version 0.7 - * @since 0.7 - * @module - */ -public class SQLInvalidRecordNumberForDirectAccessException extends SQLNonTransientException { - /** Serial UID. */ - private static final long serialVersionUID = 6828362742568015813L; - - /** Wrong record number. */ - private int wrongRecordNumber; - - /** - * Construct an exception. - * @param number Wrong record number value. - * @param message Message of the exception. - */ - public SQLInvalidRecordNumberForDirectAccessException(int number, String message) { - super(message); - this.wrongRecordNumber = number; - } - - /** - * Construct an exception. - * @param number Wrong record number value. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public SQLInvalidRecordNumberForDirectAccessException(int number, String message, Throwable cause) { - super(message, cause); - this.wrongRecordNumber = number; - } - - /** - * Returns the wrong record number value. - * @return Record number. - */ - public int getWrongRecordNumber() { - return this.wrongRecordNumber; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLNoDirectAccessAvailableException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLNoDirectAccessAvailableException.java deleted file mode 100644 index a0b4d60d09a..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLNoDirectAccessAvailableException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile; - -import java.sql.SQLNonTransientException; - - -/** - * Thrown when a shapefile or a DBase III file cannot allow a direct acces (because it has no index). - * - * @author Marc Le Bihan - * @version 0.7 - * @since 0.7 - * @module - */ -public class SQLNoDirectAccessAvailableException extends SQLNonTransientException { - /** Serial UID. */ - private static final long serialVersionUID = 16719558033196219L; - - /** - * Construct an exception. - * @param message Message of the exception. - */ - public SQLNoDirectAccessAvailableException(String message) { - super(message); - } - - /** - * Construct an exception. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public SQLNoDirectAccessAvailableException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLShapefileNotFoundException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLShapefileNotFoundException.java deleted file mode 100644 index 22aa585eed2..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLShapefileNotFoundException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile; - -import java.sql.SQLNonTransientException; - - -/** - * Thrown when a shapefile has not been found. - * - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class SQLShapefileNotFoundException extends SQLNonTransientException { - /** Serial UID. */ - private static final long serialVersionUID = -3235671561698931817L; - - /** - * Construct an exception. - * @param message Message of the exception. - */ - public SQLShapefileNotFoundException(String message) { - super(message); - } - - /** - * Construct an exception. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public SQLShapefileNotFoundException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java deleted file mode 100644 index 2aa1bb10a50..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java +++ /dev/null @@ -1,465 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile; - -import java.io.*; -import java.nio.ByteOrder; -import java.nio.MappedByteBuffer; -import java.nio.channels.FileChannel; -import java.text.MessageFormat; -import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.sis.feature.DefaultAttributeType; -import org.apache.sis.feature.DefaultFeatureType; -import org.apache.sis.internal.shapefile.jdbc.*; -import org.apache.sis.storage.shapefile.InvalidShapefileFormatException; -import org.apache.sis.storage.shapefile.ShapeTypeEnum; -import org.apache.sis.feature.AbstractFeature; - -import com.esri.core.geometry.*; - -/** - * Reader of a Shapefile Binary content by the way of a {@link java.nio.MappedByteBuffer} - * - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class ShapefileByteReader extends CommonByteReader { - /** Name of the Geometry field. */ - private static final String GEOMETRY_NAME = "geometry"; - - /** Shapefile descriptor. */ - private ShapefileDescriptor shapefileDescriptor; - - /** Database Field descriptors. */ - private List databaseFieldsDescriptors; - - /** Type of the features contained in this shapefile. */ - private DefaultFeatureType featuresType; - - /** Shapefile index. */ - private File shapeFileIndex; - - /** Shapefile indexes (loaded from .SHX file, if any found). */ - private ArrayList indexes; - - /** Shapefile records lengths (loaded from .SHX file, if any found). */ - private ArrayList recordsLengths; - - /** - * Construct a shapefile byte reader. - * @param shapefile Shapefile. - * @param dbaseFile underlying database file name. - * @param shapefileIndex Shapefile index, if any. Null else. - * @throws InvalidShapefileFormatException if the shapefile format is invalid. - * @throws SQLInvalidDbaseFileFormatException if the database file format is invalid. - * @throws SQLShapefileNotFoundException if the shapefile has not been found. - * @throws SQLDbaseFileNotFoundException if the database file has not been found. - */ - public ShapefileByteReader(File shapefile, File dbaseFile, File shapefileIndex) throws InvalidShapefileFormatException, SQLInvalidDbaseFileFormatException, SQLShapefileNotFoundException, SQLDbaseFileNotFoundException { - super(shapefile, InvalidShapefileFormatException.class, SQLShapefileNotFoundException.class); - this.shapeFileIndex = shapefileIndex; - - loadDatabaseFieldDescriptors(dbaseFile); - loadDescriptor(); - - if (this.shapeFileIndex != null) { - loadShapefileIndexes(); - } - - this.featuresType = getFeatureType(shapefile.getName()); - } - - /** - * Returns the DBase 3 fields descriptors. - * @return Fields descriptors. - */ - public List getFieldsDescriptors() { - return this.databaseFieldsDescriptors; - } - - /** - * Returns the shapefile descriptor. - * @return Shapefile descriptor. - */ - public ShapefileDescriptor getShapefileDescriptor() { - return this.shapefileDescriptor; - } - - /** - * Returns the type of the features contained in this shapefile. - * @return Features type. - */ - public DefaultFeatureType getFeaturesType() { - return this.featuresType; - } - - /** - * Create a feature descriptor. - * @param name Name of the field. - * @return The feature type. - */ - private DefaultFeatureType getFeatureType(final String name) { - Objects.requireNonNull(name, "The feature name cannot be null."); - - final int n = this.databaseFieldsDescriptors.size(); - final DefaultAttributeType[] attributes = new DefaultAttributeType[n + 1]; - final Map properties = new HashMap<>(4); - - // Load data field. - for (int i = 0; i < n; i++) { - properties.put(DefaultAttributeType.NAME_KEY, this.databaseFieldsDescriptors.get(i).getName()); - attributes[i] = new DefaultAttributeType<>(properties, String.class, 1, 1, null); - } - - // Add geometry field. - properties.put(DefaultAttributeType.NAME_KEY, GEOMETRY_NAME); - attributes[n] = new DefaultAttributeType<>(properties, Geometry.class, 1, 1, null); - - // Add name. - properties.put(DefaultAttributeType.NAME_KEY, name); - return new DefaultFeatureType(properties, false, null, attributes); - } - - /** - * Load shapefile descriptor. - */ - private void loadDescriptor() { - this.shapefileDescriptor = new ShapefileDescriptor(getByteBuffer()); - } - - /** - * Load shapefile indexes. - * @return true if shapefile indexes has been read, - * false if none where available or a problem occured. - */ - private boolean loadShapefileIndexes() { - if (this.shapeFileIndex == null) { - return false; - } - - try(FileInputStream fis = new FileInputStream(this.shapeFileIndex); FileChannel fc = fis.getChannel()) { - try { - int fsize = (int)fc.size(); - MappedByteBuffer indexesByteBuffer = fc.map(FileChannel.MapMode.READ_ONLY, 0, fsize); - - // Indexes entries follow. - this.indexes = new ArrayList<>(); - this.recordsLengths = new ArrayList<>(); - indexesByteBuffer.position(100); - indexesByteBuffer.order(ByteOrder.BIG_ENDIAN); - - while(indexesByteBuffer.hasRemaining()) { - this.indexes.add(indexesByteBuffer.getInt()); // Data offset : the position of the record in the main shapefile, expressed in words (16 bits). - this.recordsLengths.add(indexesByteBuffer.getInt()); // Length of this shapefile record. - } - - log(Level.INFO, "log.index_has_been_read", this.shapeFileIndex.getAbsolutePath(), this.indexes.size(), this.getFile().getAbsolutePath()); - return true; - } - catch(IOException e) { - log(Level.WARNING, "log.invalid_file_content_for_shapefile_index", this.shapeFileIndex.getAbsolutePath(), e.getMessage()); - this.shapeFileIndex = null; - return false; - } - } - catch(FileNotFoundException e) { - log(Level.WARNING, "log.no_shapefile_index_found_at_location", this.shapeFileIndex.getAbsolutePath(), this.getFile().getAbsolutePath()); - this.shapeFileIndex = null; - return false; - } - catch(IOException e) { - log(Level.WARNING, "log.invalid_file_content_for_shapefile_index", this.shapeFileIndex.getAbsolutePath(), e.getMessage()); - this.shapeFileIndex = null; - return false; - } - } - - /** - * Load database field descriptors. - * @param dbaseFile Database file. - * @throws SQLInvalidDbaseFileFormatException if the database format is incorrect. - * @throws SQLDbaseFileNotFoundException if the database file cannot be found. - */ - private void loadDatabaseFieldDescriptors(File dbaseFile) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException { - MappedByteReader databaseReader = null; - - try { - databaseReader = new MappedByteReader(dbaseFile, null); - this.databaseFieldsDescriptors = databaseReader.getFieldsDescriptors(); - } - finally { - if (databaseReader != null) { - try { - databaseReader.close(); - } - catch(IOException e) { - } - } - } - } - - /** - * Direct access to a feature by its record number. - * @param recordNumber Record number. - * @throws SQLNoDirectAccessAvailableException if this shape file doesn't allow direct acces, because it has no index. - * @throws SQLInvalidRecordNumberForDirectAccessException if the record number asked for is invalid (below the start, after the end). - */ - public void setRowNum(int recordNumber) throws SQLNoDirectAccessAvailableException, SQLInvalidRecordNumberForDirectAccessException { - // Check that the asked record number is not before the first. - if (recordNumber < 1) { - String message = format(Level.SEVERE, "excp.wrong_direct_access_before_start", recordNumber, getFile().getAbsolutePath()); - throw new SQLInvalidRecordNumberForDirectAccessException(recordNumber, message); - } - - // Check that the shapefile allows direct access : it won't if it has no index. - if (this.shapeFileIndex == null) { - String message = format(Level.SEVERE, "excp.no_direct_access", getFile().getAbsolutePath()); - throw new SQLNoDirectAccessAvailableException(message); - } - - int position = this.indexes.get(recordNumber - 1) * 2; // Indexes unit are words (16 bits). - - // Check that the asked record number is not after the last. - if (position >= this.getByteBuffer().capacity()) { - String message = format(Level.SEVERE, "excp.wrong_direct_access_after_last", recordNumber, getFile().getAbsolutePath()); - throw new SQLInvalidRecordNumberForDirectAccessException(recordNumber, message); - } - - try { - getByteBuffer().position(position); - } - catch(IllegalArgumentException e) { - String message = format(Level.SEVERE, "assert.wrong_position", recordNumber, position, getFile().getAbsolutePath(), e.getMessage()); - throw new RuntimeException(message, e); - } - } - - /** - * Complete a feature with shapefile content. - * @param feature Feature to complete. - * @throws InvalidShapefileFormatException if a validation problem occurs. - */ - public void completeFeature(AbstractFeature feature) throws InvalidShapefileFormatException { - // insert points into some type of list - int RecordNumber = getByteBuffer().getInt(); - @SuppressWarnings("unused") - int ContentLength = getByteBuffer().getInt(); - - getByteBuffer().order(ByteOrder.LITTLE_ENDIAN); - int iShapeType = getByteBuffer().getInt(); - - ShapeTypeEnum type = ShapeTypeEnum.get(iShapeType); - - if (type == null) - throw new InvalidShapefileFormatException(MessageFormat.format("The shapefile feature type {0} doesn''t match to any known feature type.", this.featuresType)); - - switch (type) { - case Point: - loadPointFeature(feature); - break; - - case Polygon: - loadPolygonFeature(feature); - break; - - case PolyLine: - loadPolylineFeature(feature); - break; - - default: - throw new InvalidShapefileFormatException("Unsupported shapefile type: " + iShapeType); - } - - getByteBuffer().order(ByteOrder.BIG_ENDIAN); - } - - /** - * Load point feature. - * @param feature Feature to fill. - */ - private void loadPointFeature(AbstractFeature feature) { - double x = getByteBuffer().getDouble(); - double y = getByteBuffer().getDouble(); - Point pnt = new Point(x, y); - feature.setPropertyValue(GEOMETRY_NAME, pnt); - } - - /** - * Load polygon feature. - * @param feature Feature to fill. - */ - private void loadPolygonFeature(AbstractFeature feature) { - /* double xmin = */getByteBuffer().getDouble(); - /* double ymin = */getByteBuffer().getDouble(); - /* double xmax = */getByteBuffer().getDouble(); - /* double ymax = */getByteBuffer().getDouble(); - int numParts = getByteBuffer().getInt(); - int numPoints = getByteBuffer().getInt(); - - Polygon poly; - - // Handle multiple polygon parts. - if (numParts > 1) { - Logger log = AutoChecker.LOGGER; - - if (log.isLoggable(Level.FINER)) { - String format = "Polygon with multiple linear rings encountered at position {0,number} with {1,number} parts."; - String message = MessageFormat.format(format, getByteBuffer().position(), numParts); - log.finer(message); - } - - poly = readMultiplePolygonParts(numParts, numPoints); - } - else { - // Polygon with an unique part. - poly = readUniquePolygonPart(numPoints); - } - - feature.setPropertyValue(GEOMETRY_NAME, poly); - } - - /** - * Read a polygon that has a unique part. - * @param numPoints Number of the points of the polygon. - * @return Polygon. - */ - @Deprecated // As soon as the readMultiplePolygonParts method proofs working well, this readUniquePolygonPart method can be removed and all calls be deferred to readMultiplePolygonParts. - private Polygon readUniquePolygonPart(int numPoints) { - /*int part = */ getByteBuffer().getInt(); - Polygon poly = new Polygon(); - - // create a line from the points - double xpnt = getByteBuffer().getDouble(); - double ypnt = getByteBuffer().getDouble(); - - poly.startPath(xpnt, ypnt); - - for (int j = 0; j < numPoints - 1; j++) { - xpnt = getByteBuffer().getDouble(); - ypnt = getByteBuffer().getDouble(); - poly.lineTo(xpnt, ypnt); - } - - return poly; - } - - /** - * Read a polygon that has multiple parts. - * @param numParts Number of parts of this polygon. - * @param numPoints Total number of points of this polygon, all parts considered. - * @return a multiple part polygon. - */ - private Polygon readMultiplePolygonParts(int numParts, int numPoints) { - /** - * From ESRI Specification : - * Parts : 0 5 (meaning : 0 designs the first v1, 5 designs the first v5 on the points list below). - * Points : v1 v2 v3 v4 v1 v5 v8 v7 v6 v5 - * - * POSITION FIELD VALUE TYPE NUMBER ORDER - * Byte 0 Shape Type 5 Integer 1 Little - * Byte 4 Box Box Double 4 Little - * Byte 36 NumParts NumParts Integer 1 Little - * Byte 40 NumPoints NumPoints Integer 1 Little - * Byte 44 Parts Parts Integer NumParts Little - * Byte X Points Points Point NumPoints Little - */ - int[] partsIndexes = new int[numParts]; - - // Read all the parts indexes (starting at byte 44). - for(int index=0; index < numParts; index ++) { - partsIndexes[index] = getByteBuffer().getInt(); - } - - // Read all the points. - double[] xPoints = new double[numPoints]; - double[] yPoints = new double[numPoints]; - - for(int index=0; index < numPoints; index ++) { - xPoints[index] = getByteBuffer().getDouble(); - yPoints[index] = getByteBuffer().getDouble(); - } - - // Create the polygon from the points. - Polygon poly = new Polygon(); - - // create a line from the points - for(int index=0; index < numPoints; index ++) { - // Check if this index is one that begins a new part. - boolean newPolygon = false; - - for(int j=0; j < partsIndexes.length; j ++) { - if (partsIndexes[j] == index) { - newPolygon = true; - break; - } - } - - if (newPolygon) { - poly.startPath(xPoints[index], yPoints[index]); - } - else { - poly.lineTo(xPoints[index], yPoints[index]); - } - } - - return poly; - } - - /** - * Load polyline feature. - * @param feature Feature to fill. - */ - private void loadPolylineFeature(AbstractFeature feature) { - /* double xmin = */getByteBuffer().getDouble(); - /* double ymin = */getByteBuffer().getDouble(); - /* double xmax = */getByteBuffer().getDouble(); - /* double ymax = */getByteBuffer().getDouble(); - - int NumParts = getByteBuffer().getInt(); - int NumPoints = getByteBuffer().getInt(); - - int[] NumPartArr = new int[NumParts + 1]; - - for (int n = 0; n < NumParts; n++) { - int idx = getByteBuffer().getInt(); - NumPartArr[n] = idx; - } - NumPartArr[NumParts] = NumPoints; - - double xpnt, ypnt; - Polyline ply = new Polyline(); - - for (int m = 0; m < NumParts; m++) { - xpnt = getByteBuffer().getDouble(); - ypnt = getByteBuffer().getDouble(); - ply.startPath(xpnt, ypnt); - - for (int j = NumPartArr[m]; j < NumPartArr[m + 1] - 1; j++) { - xpnt = getByteBuffer().getDouble(); - ypnt = getByteBuffer().getDouble(); - ply.lineTo(xpnt, ypnt); - } - } - - feature.setPropertyValue(GEOMETRY_NAME, ply); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java deleted file mode 100644 index c3ab8bbfcb8..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile; - -import java.nio.ByteOrder; -import java.nio.MappedByteBuffer; - -import org.apache.sis.storage.shapefile.ShapeTypeEnum; - -/** - * Shapefile Descriptor. - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class ShapefileDescriptor { - /** File code. */ - private int fileCode; // big - - /** File length. */ - private int fileLength; // big // The value for file length is the total length of the file in 16-bit words - - /** File version. */ - private int version; // little - - /** Shapefile type. */ - private ShapeTypeEnum shapeType; // little - - /** X Min. */ - private double xmin; // little - - /** Y Min. */ - private double ymin; // little - - /** X Max. */ - private double xmax; // little - - /** Y Max. */ - private double ymax; // little - - /** Z Min. */ - private double zmin; // little - - /** Z Max. */ - private double zmax; // little - - /** M Min. */ - private double mmin; // little - - /** M Max. */ - private double mmax; // little - - /** - * Create a shapefile descriptor. - * @param byteBuffer Source Bytebuffer. - */ - public ShapefileDescriptor(MappedByteBuffer byteBuffer) { - this.fileCode = byteBuffer.getInt(); - byteBuffer.getInt(); - byteBuffer.getInt(); - byteBuffer.getInt(); - byteBuffer.getInt(); - byteBuffer.getInt(); - this.fileLength = byteBuffer.getInt() * 2; - - byteBuffer.order(ByteOrder.LITTLE_ENDIAN); - this.version = byteBuffer.getInt(); - this.shapeType = ShapeTypeEnum.get(byteBuffer.getInt()); - this.xmin = byteBuffer.getDouble(); - this.ymin = byteBuffer.getDouble(); - this.xmax = byteBuffer.getDouble(); - this.ymax = byteBuffer.getDouble(); - this.zmin = byteBuffer.getDouble(); - this.zmax = byteBuffer.getDouble(); - this.mmin = byteBuffer.getDouble(); - this.mmax = byteBuffer.getDouble(); - byteBuffer.order(ByteOrder.BIG_ENDIAN); - - //dbf.byteBuffer.get(); // should be 0d for field terminator - } - - /** - * Returns the version of the shapefile. - * @return Version. - */ - public int getVersion() { - return this.version; - } - - /** - * Returns the ESRI shape type in the shapefile. - * @return Shape type. - */ - public ShapeTypeEnum getShapeType() { - return this.shapeType; - } - - /** - * Returns the X Min property. - * @return XMin. - */ - public double getXmin() { - return this.xmin; - } - - /** - * Returns the Y Min property. - * @return YMin. - */ - public double getYmin() { - return this.ymin; - } - - /** - * Returns the X Max property. - * @return XMax. - */ - public double getXmax() { - return this.xmax; - } - - /** - * Returns the Y Max property. - * @return YMax. - */ - public double getYmax() { - return this.ymax; - } - - /** - * Returns the Z Min property. - * @return ZMin. - */ - public double getZmin() { - return this.zmin; - } - - /** - * Returns the Z Max property. - * @return ZMax. - */ - public double getZmax() { - return this.zmax; - } - - /** - * Returns the M Min property. - * @return M min. - */ - public double getMmin() { - return this.mmin; - } - - /** - * Returns the M Max property. - * @return M Max. - */ - public double getMmax(){ - return this.mmax; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder s = new StringBuilder(); - String lineSeparator = System.lineSeparator(); - - s.append("FileCode: ").append(this.fileCode).append(lineSeparator); - s.append("FileLength: ").append(this.fileLength).append(lineSeparator); - s.append("Version: ").append(this.version).append(lineSeparator); - s.append("ShapeType: ").append(this.shapeType).append(lineSeparator); - s.append("xmin: ").append(this.xmin).append(lineSeparator); - s.append("ymin: ").append(this.ymin).append(lineSeparator); - s.append("xmax: ").append(this.xmax).append(lineSeparator); - s.append("ymax: ").append(this.ymax).append(lineSeparator); - s.append("zmin: ").append(this.zmin).append(lineSeparator); - s.append("zmax: ").append(this.zmax).append(lineSeparator); - s.append("mmin: ").append(this.mmin).append(lineSeparator); - s.append("mmax: ").append(this.mmax).append(lineSeparator); - s.append("------------------------").append(lineSeparator); - - return s.toString(); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java deleted file mode 100644 index d05aec99368..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.io.File; -import java.nio.charset.Charset; -import java.nio.charset.UnsupportedCharsetException; -import java.text.MessageFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Objects; -import java.util.logging.Level; - -/** - * The Abstract Byte Reader. - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -abstract class AbstractDbase3ByteReader extends CommonByteReader implements Dbase3ByteReader { - /** First data record position, in bytes. */ - protected short firstRecordPosition; - - /** Size of one record, in bytes. */ - protected short recordLength; - - /** Reserved (dBASE IV) Filled with 00h. */ - protected byte[] reservedFiller1 = new byte[2]; - - /** - * Reserved : Incomplete transaction (dBASE IV). - * 00h : Transaction ended (or rolled back). - * 01h : Transaction started. - */ - protected byte reservedIncompleteTransaction; - - /** - * Reserved : Encryption flag (dBASE IV). - * 00h : Not encrypted. - * 01h : Data encrypted. - */ - protected byte reservedEncryptionFlag; - - /** Reserved : Free record thread (for LAN only). */ - protected byte[] reservedFreeRecordThread = new byte[4]; - - /** Reserved : For multi-user (DBase 3+). */ - protected byte[] reservedMultiUser = new byte[8]; - - /** Reserved : MDX flag (dBASE IV). */ - protected byte reservedMDXFlag; - - /** Binary code page value. */ - protected byte codePage; - - /** Reserved (dBASE IV) Filled with 00h. */ - protected byte[] reservedFiller2 = new byte[2]; - - /** Marks the end of the descriptor : must be 0x0D. */ - protected byte descriptorTerminator; - - /** Valid dBASE III PLUS table file (03h without a memo .DBT file; 83h with a memo). */ - protected byte dbaseVersion; - - /** Number of records in the table. */ - protected int rowCount; - - /** Database charset. */ - protected Charset charset; - - /** Date of last update; in YYMMDD format. */ - protected byte[] dbaseLastUpdate = new byte[3]; - - /** - * Map a dbf file. - * @param file Database file. - * @throws SQLDbaseFileNotFoundException if the DBF file has not been found. - * @throws SQLInvalidDbaseFileFormatException if the database has an invalid format. - */ - public AbstractDbase3ByteReader(File file) throws SQLDbaseFileNotFoundException, SQLInvalidDbaseFileFormatException { - super(file, SQLInvalidDbaseFileFormatException.class, SQLDbaseFileNotFoundException.class); - } - - /** - * Returns the charset. - * @return Charset. - */ - @Override public Charset getCharset() { - return this.charset; - } - - /** - * Returns the database last update date. - * @return Date of the last update. - */ - @Override public Date getDateOfLastUpdate() { - return toDate(this.dbaseLastUpdate); - } - - /** - * Returns the first record position, in bytes, in the DBase file. - * @return First record position. - */ - @Override public short getFirstRecordPosition() { - return this.firstRecordPosition; - } - - /** - * Returns the length (in bytes) of one record in this DBase file, including the delete flag. - * @return Record length. - */ - @Override public short getRecordLength() { - return this.recordLength; - } - - /** - * Returns the record count. - * @return Record count. - */ - @Override public int getRowCount() { - return this.rowCount; - } - - /** - * Convert the binary code page value of the Dbase 3 file to a recent Charset. - * @param codePageBinaryValue page code binary value. - * @return Charset. - * @throws UnsupportedCharsetException if the code page as no representation in recents Charset (legacy DOS or macintosh charsets). - */ - protected Charset toCharset(byte codePageBinaryValue) throws UnsupportedCharsetException { - // Attempt to find a known conversion. - String dbfCodePage = toCodePage(codePageBinaryValue); - - // If no conversion has been found, decide if the cause is an unsupported value or an illegal value to choose the good exception to return. - if (dbfCodePage == null) { - switch(Byte.toUnsignedInt(codePageBinaryValue)) { - case 0x04: dbfCodePage = "unsupported"; break; - case 0x68: dbfCodePage = "unsupported"; break; // Kamenicky (Czech) MS-DOS - case 0x69: dbfCodePage = "unsupported"; break; // Mazovia (Polish) MS-DOS - case 0x96: dbfCodePage = "unsupported"; break; // russian mac - case 0x97: dbfCodePage = "unsupported"; break; // eastern european macintosh - case 0x98: dbfCodePage = "unsupported"; break; // greek macintosh - case 0xC8: dbfCodePage = "unsupported"; break; // windows ee - default: dbfCodePage = "unsupported"; break; - } - } - - assert dbfCodePage != null; - - // If the code page cannot find a match for a more recent Charset, we wont be able to handle this DBF. - if (dbfCodePage.equals("unsupported")) { - String message = format(Level.WARNING, "excp.unsupported_codepage", codePageBinaryValue, getFile().getAbsolutePath()); - throw new UnsupportedCharsetException(message); - } - - try { - return Charset.forName(dbfCodePage); - } - catch(IllegalArgumentException e) { - // If this happens here, it means that we have selected a wrong charset. We have a bug. - String message = format(Level.WARNING, "assert.wrong_charset_selection", dbfCodePage, getFile().getAbsolutePath()); - throw new RuntimeException(message); - } - } - - /** - * Return a Charset code page from a binary code page value. - * @param pageCodeBinaryValue binary code page value. - * @return Page code. - */ - private String toCodePage(byte pageCodeBinaryValue) { - // From http://trac.osgeo.org/gdal/ticket/2864 - HashMap knownConversions = new HashMap<>(); - knownConversions.put(0x01, "cp437"); // U.S. MS–DOS - knownConversions.put(0x02, "cp850"); // International MS–DOS - knownConversions.put(0x03, "cp1252"); // Windows ANSI - knownConversions.put(0x08, "cp865"); // Danish OEM - knownConversions.put(0x09, "cp437"); // Dutch OEM - knownConversions.put(0x0a, "cp850"); // Dutch OEM* - knownConversions.put(0x0b, "cp437"); // Finnish OEM - knownConversions.put(0x0d, "cp437"); // French OEM - knownConversions.put(0x0e, "cp850"); // French OEM* - knownConversions.put(0x0f, "cp437"); // German OEM - knownConversions.put(0x10, "cp850"); // German OEM* - knownConversions.put(0x11, "cp437"); // Italian OEM - knownConversions.put(0x12, "cp850"); // Italian OEM* - knownConversions.put(0x13, "cp932"); // Japanese Shift-JIS - knownConversions.put(0x14, "cp850"); // Spanish OEM* - knownConversions.put(0x15, "cp437"); // Swedish OEM - knownConversions.put(0x16, "cp850"); // Swedish OEM* - knownConversions.put(0x17, "cp865"); // Norwegian OEM - knownConversions.put(0x18, "cp437"); // Spanish OEM - knownConversions.put(0x19, "cp437"); // English OEM (Britain) - knownConversions.put(0x1a, "cp850"); // English OEM (Britain)* - knownConversions.put(0x1b, "cp437"); // English OEM (U.S.) - knownConversions.put(0x1c, "cp863"); // French OEM (Canada) - knownConversions.put(0x1d, "cp850"); // French OEM* - knownConversions.put(0x1f, "cp852"); // Czech OEM - knownConversions.put(0x22, "cp852"); // Hungarian OEM - knownConversions.put(0x23, "cp852"); // Polish OEM - knownConversions.put(0x24, "cp860"); // Portuguese OEM - knownConversions.put(0x25, "cp850"); // Portuguese OEM* - knownConversions.put(0x26, "cp866"); // Russian OEM - knownConversions.put(0x37, "cp850"); // English OEM (U.S.)* - knownConversions.put(0x40, "cp852"); // Romanian OEM - knownConversions.put(0x4d, "cp936"); // Chinese GBK (PRC) - knownConversions.put(0x4e, "cp949"); // Korean (ANSI/OEM) - knownConversions.put(0x4f, "cp950"); // Chinese Big5 (Taiwan) - knownConversions.put(0x50, "cp874"); // Thai (ANSI/OEM) - knownConversions.put(0x57, "cp1252"); // ANSI - knownConversions.put(0x58, "cp1252"); // Western European ANSI - knownConversions.put(0x59, "cp1252"); // Spanish ANSI - knownConversions.put(0x64, "cp852"); // Eastern European MS–DOS - knownConversions.put(0x65, "cp866"); // Russian MS–DOS - knownConversions.put(0x66, "cp865"); // Nordic MS–DOS - knownConversions.put(0x67, "cp861"); // Icelandic MS–DOS - knownConversions.put(0x6a, "cp737"); // Greek MS–DOS (437G) - knownConversions.put(0x6b, "cp857"); // Turkish MS–DOS - knownConversions.put(0x6c, "cp863"); // French–Canadian MS–DOS - knownConversions.put(0x78, "cp950"); // Taiwan Big 5 - knownConversions.put(0x79, "cp949"); // Hangul (Wansung) - knownConversions.put(0x7a, "cp936"); // PRC GBK - knownConversions.put(0x7b, "cp932"); // Japanese Shift-JIS - knownConversions.put(0x7c, "cp874"); // Thai Windows/MS–DOS - knownConversions.put(0x86, "cp737"); // Greek OEM - knownConversions.put(0x87, "cp852"); // Slovenian OEM - knownConversions.put(0x88, "cp857"); // Turkish OEM - knownConversions.put(0xc8, "cp1250"); // Eastern European Windows - knownConversions.put(0xc9, "cp1251"); // Russian Windows - knownConversions.put(0xca, "cp1254"); // Turkish Windows - knownConversions.put(0xcb, "cp1253"); // Greek Windows - knownConversions.put(0xcc, "cp1257"); // Baltic Windows - - return(knownConversions.get(Byte.toUnsignedInt(pageCodeBinaryValue))); - } - - /** - * Set a charset. - * @param cs Charset. - */ - public void setCharset(Charset cs) { - this.charset = cs; - } - - /** - * Return a date from a byte array. - * @param yymmdd byte[3] with byte[0] = year (2 digits), [1] = month, [2] = day. - * @return Date. - */ - private Date toDate(byte[] yymmdd) { - Objects.requireNonNull(yymmdd, "the yymmdd bytes cannot be null"); - - if (yymmdd.length != 3) - throw new IllegalArgumentException(MessageFormat.format("Database:toDate() works only on a 3 bytes YY MM DD date. this array has {0} length", yymmdd.length)); - - Objects.requireNonNull(yymmdd[0], "the year byte cannot be null"); - Objects.requireNonNull(yymmdd[1], "the month byte cannot be null"); - Objects.requireNonNull(yymmdd[2], "the day byte cannot be null"); - - int year = yymmdd[0] < 70 ? 100 + yymmdd[0] : yymmdd[0]; - int month = yymmdd[1]; - int day = yymmdd[2]; - - @SuppressWarnings("deprecation") // But everything is deprecated in DBF files... - Date date = new Date(year, month, day); - return date; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java deleted file mode 100644 index b0223a39db1..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.io.File; -import java.sql.*; -import java.util.logging.Level; - -import org.apache.sis.internal.shapefile.AutoChecker; - - -/** - * Base class for each JDBC class. - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public abstract class AbstractJDBC extends AutoChecker implements Wrapper { - /** - * Constructs a new instance of a JDBC interface. - */ - public AbstractJDBC() { - } - - /** - * Returns the JDBC interface implemented by this class. - * This is used for formatting error messages. - * @return The JDBC interface implemented by this class. - */ - abstract protected Class getInterface(); - - /** - * Unsupported by default. - * @param iface the type of the wrapped object. - * @return The wrapped object. - */ - @Override - public T unwrap(Class iface) throws SQLException { - throw unsupportedOperation("unwrap", iface); - } - - /** - * Defaults to {@code null}. - * @return SQL Warning. - */ - public SQLWarning getWarnings() { - return null; - } - - /** - * Defaults to nothing, since there are no SQL warnings. - */ - public void clearWarnings() { - } - - /** - * Returns an unsupported operation exception to be thrown. - * @param methodOrWishedFeatureName The feature / call the caller attempted. - * @return the not supported feature exception. - * @throws SQLFeatureNotSupportedException the not supported feature. - */ - public final SQLFeatureNotSupportedException unsupportedOperation(final String methodOrWishedFeatureName) throws SQLFeatureNotSupportedException { - String message = format(Level.WARNING, "excp.unsupportedDriverFeature", getInterface(), methodOrWishedFeatureName, getClass().getSimpleName()); - throw new SQLFeatureNotSupportedException(message); - } - - /** - * Returns an unsupported operation exception to be thrown : this exception add parameters sent to the method that isn't implemented. - * @param methodOrWishedFeatureName The feature / call the caller attempted. - * @param args Arguments that where sent to the unimplemented function. - * @return the not supported feature exception. - * @throws SQLFeatureNotSupportedException the not supported feature. - */ - public final SQLFeatureNotSupportedException unsupportedOperation(final String methodOrWishedFeatureName, Object... args) throws SQLFeatureNotSupportedException { - StringBuffer arguments = new StringBuffer(); - - for(Object arg : args) { - arguments.append(arguments.length() == 0 ? "" : ", "); // Separator if needed. - arguments.append(arg instanceof String ? "\"" : ""); // Enclosing " for String, if needed. - arguments.append(arg == null ? "null" : arg.toString()); // String value of the argument. - arguments.append(arg instanceof String ? "\"" : ""); // Enclosing " for String, if needed. - } - - String message = format(Level.WARNING, "excp.unsupportedDriverFeature_with_arguments", getInterface(), methodOrWishedFeatureName, getClass().getSimpleName(), arguments.toString()); - throw new SQLFeatureNotSupportedException(message); - } - - /** - * log a function call in the driver : very verbose. - * @param methodName The call the caller attempted. - */ - public void logStep(final String methodName) { - log(Level.FINER, "log.step", methodName, getClass().getSimpleName()); - } - - /** - * log a function call in the driver : very verbose. - * @param methodName The call the caller attempted. - * @param args Arguments that where sent to the unimplemented function. - */ - public void logStep(final String methodName, Object... args) { - if (isLoggable(Level.FINER)) { // Avoid resolution of arguments(...) if not needed. - log(Level.FINER, "log.step_with_arguments", methodName, getClass().getSimpleName(), arguments(args)); - } - } - - /** - * log an unsupported feature as a warning. - * @param methodName The call the caller attempted. - */ - public void logUnsupportedOperation(final String methodName) { - log(Level.WARNING, "excp.unsupportedDriverFeature", getInterface(), methodName, getClass().getSimpleName()); - } - - /** - * log an unsupported feature as a warning. - * @param methodName The call the caller attempted. - * @param args Arguments that where sent to the unimplemented function. - */ - public void logUnsupportedOperation(final String methodName, Object... args) { - log(Level.WARNING, "excp.unsupportedDriverFeature_with_arguments", getInterface(), methodName, getClass().getSimpleName(), arguments(args)); - } - - /** - * Returns the Database File. - * @return Database File. - */ - abstract protected File getFile(); - - /** - * Concat arguments in a StringBuffer. - * @param args arguments. - * @return Arguments. - */ - private StringBuffer arguments(Object... args) { - StringBuffer arguments = new StringBuffer(); - - for(Object arg : args) { - arguments.append(arguments.length() == 0 ? "" : ", "); // Separator if needed. - arguments.append(arg instanceof String ? "\"" : ""); // Enclosing " for String, if needed. - arguments.append(arg == null ? "null" : arg.toString()); // String value of the argument. - arguments.append(arg instanceof String ? "\"" : ""); // Enclosing " for String, if needed. - } - - return arguments; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java deleted file mode 100644 index e1fadd7ffe3..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.io.*; -import java.nio.MappedByteBuffer; -import java.nio.channels.FileChannel; -import java.util.Objects; -import java.util.logging.Level; - -import org.apache.sis.internal.shapefile.AutoChecker; - -/** - * Common byte reader. - * @author Marc Le Bihan - * @version 0.5 - * @param Invalid format Exception to throw in case of trouble. - * @param File not found Exception to throw in case of missing file. - * @since 0.5 - * @module - */ -public abstract class CommonByteReader extends AutoChecker implements AutoCloseable { - /** The File. */ - private File file; - - /** Input Stream on the DBF. */ - private FileInputStream fis; - - /** File channel on the file. */ - private FileChannel fc; - - /** Buffer reader. */ - private MappedByteBuffer byteBuffer; - - /** Indicates if the byte buffer is closed. */ - private boolean isClosed = false; - - /** Invalid Exception to throw in case of invalid file format. */ - private Class classInvalidFormatException; - - /** Invalid Exception to throw in case of file not found exception. */ - private Class classFNFException; - - /** - * Create and open a byte reader based on a file. - * @param f File. - * @param invalidFormatException Invalid Exception to throw in case of invalid file format. - * @param fileNotFoundException Invalid Exception to throw in case of file not found exception. - * @throws FNFException if the file cannot be opened. - * @throws InvalidFormatException if the file format is invalid. - */ - public CommonByteReader(File f, Class invalidFormatException, Class fileNotFoundException) throws FNFException, InvalidFormatException { - Objects.requireNonNull(f, "The file cannot be null."); - this.classInvalidFormatException = invalidFormatException; - this.classFNFException = fileNotFoundException; - - this.file = f; - - try { - this.fis = new FileInputStream(this.file); - } - catch(FileNotFoundException e) { - throwException(this.classInvalidFormatException, e.getMessage(), e); - throw new RuntimeException("this place should not be reached."); - } - - this.fc = this.fis.getChannel(); - - try { - int fsize = (int)this.fc.size(); - this.byteBuffer = this.fc.map(FileChannel.MapMode.READ_ONLY, 0, fsize); - } - catch(IOException e) { - String message = format(Level.WARNING, "excp.reader_cannot_be_created", this.file.getAbsolutePath(), e.getMessage()); - throwException(this.classFNFException, message, e); - throw new RuntimeException("this place should not be reached."); - } - } - - /** - * Close the MappedByteReader. - * @throws IOException if the close operation fails. - */ - @Override - public void close() throws IOException { - if (this.fc != null) - this.fc.close(); - - if (this.fis != null) - this.fis.close(); - - this.isClosed = true; - } - - /** - * Returns the closed state of this binary reader. - * @return true if it is closed. - */ - public boolean isClosed() { - return this.isClosed; - } - - /** - * Returns the byte buffer. - * @return Byte Buffer. - */ - public MappedByteBuffer getByteBuffer() { - return this.byteBuffer; - } - - /** - * Return the file mapped. - * @return File. - */ - public File getFile() { - return this.file; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java deleted file mode 100644 index 198ffa7d3af..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.io.File; -import java.sql.Connection; -import java.sql.Driver; -import java.sql.DriverPropertyInfo; -import java.util.Objects; -import java.util.Properties; -import java.util.logging.Logger; - -import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection; -import org.apache.sis.internal.system.Modules; - - -/** - * Database driver for DBF 3. - * - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class DBFDriver extends AbstractJDBC implements Driver { - /** - * Creates a new driver. - */ - public DBFDriver() { - } - - /** - * @see java.sql.Wrapper#isWrapperFor(java.lang.Class) - */ - @Override - public boolean isWrapperFor(Class iface) { - return iface.isAssignableFrom(getInterface()); - } - - /** - * Returns the JDBC interface implemented by this class. - * This is used for formatting error messages. - */ - @Override - final protected Class getInterface() { - return Driver.class; - } - - /** - * Attempts to make a database connection to the given filename. - * - * @param url The path to a {@code .dbf} file. - * @param info Properties to ask for special features, behavior, or compatibility. - * @return A connection to the given DBF file. - * @throws SQLInvalidDbaseFileFormatException if the database file format is invalid. - * @throws SQLDbaseFileNotFoundException if the database file doesn't exist. - * @throws SQLInvalidDbaseFileFormatException if the database file has a wrong format. - */ - @Override - @SuppressWarnings("resource") // the function opens a connection. - public Connection connect(final String url, Properties info) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException { - Objects.requireNonNull(url, "the DBase3 url cannot be null"); - File file = new File(url); - return new DBFConnection(file, new MappedByteReader(file, info)); - } - - /** - * Returns {@code true} if this driver thinks that it can open the given URL. - */ - @Override - public boolean acceptsURL(final String url) { - if (!url.endsWith(".dbf")) { - return false; - } - - final File datafile = new File(url); - return datafile.isFile(); // Future version should check for magic number. - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#getFile() - */ - @Override protected File getFile() { - return null; - } - - /** - * Gets information about the possible properties for this driver. - * The current version has none. - */ - @Override - public DriverPropertyInfo[] getPropertyInfo(@SuppressWarnings("unused") String url, @SuppressWarnings("unused") Properties info) { - return new DriverPropertyInfo[0]; - } - - /** - * The major version number of this driver. - * This is set to the Apache SIS version. - */ - @Override - public int getMajorVersion() { - return Modules.MAJOR_VERSION; - } - - /** - * The minor version number of this driver. - * This is set to the Apache SIS version. - */ - @Override - public int getMinorVersion() { - return Modules.MINOR_VERSION; - } - - /** - * This driver is currently not compliant. - * It has to succeed these tests first: - * Compliance tests. - */ - @Override - public boolean jdbcCompliant() { - return false; // No, and for some time... - } - - /** - * The logger used by this driver. - */ - @Override - public Logger getParentLogger() { - return super.getLogger(); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java deleted file mode 100644 index 3f10500d136..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.nio.MappedByteBuffer; - -import org.apache.sis.internal.shapefile.AutoChecker; - - -/** - * Field descriptor. - * - * @author Travis L. Pinney - * @version 0.5 - * @since 0.5 - * @module - */ -public class DBase3FieldDescriptor extends AutoChecker { - /** Field name. */ - private byte[] fieldName = new byte[11]; - - /** Field name as String, for performance issues. */ - private String stringFieldName; - - /** Field type. */ - private DBaseDataType fieldType; - - /** Field address (Field data address (address is set in memory; not useful on disk). */ - private byte[] fieldAddress = new byte[4]; - - /** Field length. */ - private byte fieldLength; - - /** Decimal count. */ - private byte fieldDecimalCount; - - /** Reserved 2. */ - private byte[] dbasePlusLanReserved2 = new byte[2]; - - /** Work area id. */ - @SuppressWarnings("unused") // Kept in case of later ALTER TABLE sql calls. - private byte workAreaID; - - /** Reserved 3. */ - private byte[] dbasePlusLanReserved3 = new byte[2]; - - /** Undocumented use. */ - @SuppressWarnings("unused") // Kept in case of later ALTER TABLE sql calls. - private byte setFields; - - /** - * Create a field descriptor from the current position of the binary stream. - * @param byteBuffer ByteBuffer. - */ - public DBase3FieldDescriptor(MappedByteBuffer byteBuffer) { - // Field name. - byteBuffer.get(this.fieldName); - - // Field type. - char dt = (char)byteBuffer.get(); - this.fieldType = DBaseDataType.valueOfDataType(dt); - - // Field address. - byteBuffer.get(this.fieldAddress); - - // Length and scale. - this.fieldLength = byteBuffer.get(); - this.fieldDecimalCount = byteBuffer.get(); - - byteBuffer.getShort(); // reserved - - byteBuffer.get(this.dbasePlusLanReserved2); - - // Work area id. - this.workAreaID = byteBuffer.get(); - - byteBuffer.get(this.dbasePlusLanReserved3); - - // Fields. - this.setFields = byteBuffer.get(); - - byte[] data = new byte[6]; - byteBuffer.get(data); // reserved - } - - /** - * Returns the decimal count of that field. - * @return Decimal count. - */ - public int getDecimalCount() { - return Byte.toUnsignedInt(this.fieldDecimalCount); - } - - /** - * Returns the field length. - * @return field length. - */ - public int getLength() { - return Byte.toUnsignedInt(this.fieldLength); - } - - /** - * Return the field name. - * @return Field name. - */ - public String getName() { - // Converting bytes to String takes time. Only do that once. - if (this.stringFieldName == null) { - int length = this.fieldName.length; - while (length != 0 && Byte.toUnsignedInt(this.fieldName[length - 1]) <= ' ') { - length--; - } - - this.stringFieldName = new String(this.fieldName, 0, length); - } - - return this.stringFieldName; - } - - /** - * Return the field data type. - * @return Data type. - */ - public DBaseDataType getType() { - return(this.fieldType); - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - String text = format("toString", getName(), this.fieldType, Byte.toUnsignedInt(this.fieldLength), Byte.toUnsignedInt(this.fieldDecimalCount)); - return text; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBaseDataType.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBaseDataType.java deleted file mode 100644 index 6078a9a4c50..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBaseDataType.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - - -/** - * Provides a simple DataType class. - * - * @author Travis L. Pinney - * @version 0.5 - * - * @see Xbase Data Types - * - * @since 0.5 - * @module - */ -public enum DBaseDataType { - /** Character (less than 254 characters). */ - Character('C'), - - /** Number (less than 18 characters, can include sign and decimal). */ - Number('N'), - - /** Logical (3 way, ? Y,y,T,t N,n,F,f). */ - Logical('L'), - - /** Date (YYYYMMDD format). */ - Date('D'), - - /** Memo (Pointer to ASCII text field). */ - Memo('M'), - - /** Floating point (20 digits). */ - FloatingPoint('F'), - - // CharacterNameVariable("?"), //1-254 Characters - - /** Picture (memo). */ - Picture('P'), - - /** Currency (Foxpro). */ - Currency('Y'), - - /** Date time (32 bit little-endian Julian date, 32 byte little endian milliseconds since midnight). */ - DateTime('T'), - - /** Integer (4 byte little endian). */ - Integer('I'), - - /** Varifield (???). */ - VariField('V'), - - /** Variant (???). */ - Variant('X'), - - /** Time stamp (see url). */ - TimeStamp('@'), - - /** Double. */ - Double('O'), - - /** Auto increment. */ - AutoIncrement('+'); - - /** Data type. */ - public final char datatype; - - /** - * Construct a datatype. - * @param type Data type. - */ - DBaseDataType(char type) { - this.datatype = type; - } - - /** - * Return the Datatype enum of a code. - * @param code Character code describing the dbf datatype. - * @return Datatype. - */ - public static DBaseDataType valueOfDataType(char code) { - for (DBaseDataType v : values()) { - if (v.datatype == code) { - return v; - } - } - throw new IllegalArgumentException("Enum datatype is incorrect"); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java deleted file mode 100644 index d9fecf9c2e0..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.apache.sis.internal.shapefile.jdbc.resultset.SQLIllegalColumnIndexException; -import org.apache.sis.internal.shapefile.jdbc.resultset.SQLNoSuchFieldException; -import org.apache.sis.feature.AbstractFeature; - -/** - * Database byte reader contract. Used to allow refactoring of core byte management of a DBase file. - * @author Marc LE BIHAN - */ -public interface Dbase3ByteReader { - /** - * Close the MappedByteReader. - * @throws IOException if the close operation fails. - */ - public void close() throws IOException; - - /** - * Checks if the ByteReader is closed. - * @return true if it is closed. - */ - public boolean isClosed(); - - /** - * Returns the fields descriptors in their binary format. - * @return Fields descriptors. - */ - public List getFieldsDescriptors(); - - /** - * Returns the column index for the given column name. - * The default implementation of all methods expecting a column label will invoke this method. - * @param columnLabel The name of the column. - * @param sql For information, the SQL statement that is attempted. - * @return The index of the given column name : first column is 1. - * @throws SQLNoSuchFieldException if there is no field with this name in the query. - */ - public int findColumn(String columnLabel, String sql) throws SQLNoSuchFieldException; - - /** - * Returns the charset. - * @return Charset. - */ - public Charset getCharset(); - - /** - * Returns the column count of the unique table of the DBase 3. - * @return Column count. - */ - public int getColumnCount(); - - /** - * Return a field name. - * @param columnIndex Column index. - * @param sql For information, the SQL statement that is attempted. - * @return Field Name. - * @throws SQLIllegalColumnIndexException if the index is out of bounds. - */ - public String getFieldName(int columnIndex, String sql) throws SQLIllegalColumnIndexException; - - /** - * Returns the database last update date. - * @return Date of the last update. - */ - public Date getDateOfLastUpdate(); - - /** - * Returns the first record position, in bytes, in the DBase file. - * @return First record position. - */ - public short getFirstRecordPosition(); - - /** - * Returns the length (in bytes) of one record in this DBase file, including the delete flag. - * @return Record length. - */ - public short getRecordLength(); - - /** - * Returns the record count. - * @return Record count. - */ - public int getRowCount(); - - /** - * Returns the current record number. - * @return Current record number. - */ - public int getRowNum(); - - /** - * Load a row into a feature. - * @param feature Feature to fill. - */ - public void loadRowIntoFeature(AbstractFeature feature); - - /** - * Checks if a next row is available. Warning : it may be a deleted one. - * @return true if a next row is available. - */ - public boolean nextRowAvailable(); - - /** - * Read the next row as a set of objects. - * @return Map of field name / object value. - */ - public Map readNextRowAsObjects(); -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java deleted file mode 100644 index 294be4af277..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.io.File; -import java.nio.BufferUnderflowException; -import java.nio.ByteOrder; -import java.nio.charset.Charset; -import java.nio.charset.UnsupportedCharsetException; -import java.util.*; -import java.util.logging.Level; - -import org.apache.sis.internal.shapefile.jdbc.resultset.SQLIllegalColumnIndexException; -import org.apache.sis.internal.shapefile.jdbc.resultset.SQLNoSuchFieldException; -import org.apache.sis.feature.AbstractFeature; - - -/** - * Reader of a Database Binary content by the way of a {@link java.nio.MappedByteBuffer} - * - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class MappedByteReader extends AbstractDbase3ByteReader implements AutoCloseable { - /** List of field descriptors. */ - private List fieldsDescriptors = new ArrayList<>(); - - /** Connection properties. */ - private Properties info; - - /** - * Construct a mapped byte reader on a file. - * @param dbase3File File. - * @param connectionInfos Connection properties, maybe null. - * @throws SQLInvalidDbaseFileFormatException if the database seems to be invalid. - * @throws SQLDbaseFileNotFoundException if the Dbase file has not been found. - */ - public MappedByteReader(File dbase3File, Properties connectionInfos) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException { - super(dbase3File); - this.info = connectionInfos; - - // React to special features asked. - if (this.info != null) { - // Sometimes, DBF files have a wrong charset, or more often : none, and you have to specify it. - String recordCharset = (String)this.info.get("record_charset"); - - if (recordCharset != null) { - Charset cs = Charset.forName(recordCharset); - setCharset(cs); - } - } - - loadDescriptor(); - } - - /** - * Load a row into a feature. - * @param feature Feature to fill. - */ - @Override public void loadRowIntoFeature(AbstractFeature feature) { - // TODO: ignore deleted records - getByteBuffer().get(); // denotes whether deleted or current - // read first part of record - - for (DBase3FieldDescriptor fd : this.fieldsDescriptors) { - byte[] data = new byte[fd.getLength()]; - getByteBuffer().get(data); - - int length = data.length; - while (length != 0 && Byte.toUnsignedInt(data[length - 1]) <= ' ') { - length--; - } - - String value = new String(data, 0, length); - feature.setPropertyValue(fd.getName(), value); - } - } - - /** - * Checks if a next row is available. Warning : it may be a deleted one. - * @return true if a next row is available. - */ - @Override - public boolean nextRowAvailable() { - // 1) Check for remaining bytes. - if (getByteBuffer().hasRemaining() == false) { - return false; - } - - // 2) Check that the immediate next byte read isn't the EOF signal. - byte eofCheck = getByteBuffer().get(); - - boolean isEOF = (eofCheck == 0x1A); - this.log(Level.FINER, "log.delete_status", getRowNum(), eofCheck, isEOF ? "EOF" : "Active"); - - if (eofCheck == 0x1A) { - return false; - } - else { - // Return one byte back. - int position = getByteBuffer().position(); - getByteBuffer().position(position-1); - return true; - } - } - - /** - * Returns the record number of the last record red. - * @return The record number. - */ - @Override public int getRowNum() { - int position = getByteBuffer().position(); - int recordNumber = (position - Short.toUnsignedInt(this.firstRecordPosition)) / Short.toUnsignedInt(this.recordLength); - return recordNumber; - } - - /** - * Read the next row as a set of objects. - * @return Map of field name / object value. - */ - @Override - public Map readNextRowAsObjects() { - // TODO: ignore deleted records - /* byte isDeleted = */ getByteBuffer().get(); // denotes whether deleted or current - - // read first part of record - HashMap fieldsValues = new HashMap<>(); - - for (DBase3FieldDescriptor fd : this.fieldsDescriptors) { - byte[] data = new byte[fd.getLength()]; - getByteBuffer().get(data); - - // Trim the bytes right. - int length = data.length; - - while (length != 0 && Byte.toUnsignedInt(data[length - 1]) <= ' ') { - length--; - } - - if (length != data.length) { - byte[] dataTrimmed = new byte[length]; - - for(int index=0; index < length; index ++) { - dataTrimmed[index] = data[index]; - } - - fieldsValues.put(fd.getName(), dataTrimmed); - } - else { - fieldsValues.put(fd.getName(), data); - } - } - - return fieldsValues; - } - - /** - * Loading the database file content from binary .dbf file. - * @throws SQLInvalidDbaseFileFormatException if descriptor is not readable. - */ - private void loadDescriptor() throws SQLInvalidDbaseFileFormatException { - try { - this.dbaseVersion = getByteBuffer().get(); - getByteBuffer().get(this.dbaseLastUpdate); - - getByteBuffer().order(ByteOrder.LITTLE_ENDIAN); - this.rowCount = getByteBuffer().getInt(); - this.firstRecordPosition = getByteBuffer().getShort(); - this.recordLength = getByteBuffer().getShort(); - getByteBuffer().order(ByteOrder.BIG_ENDIAN); - - getByteBuffer().get(this.reservedFiller1); - this.reservedIncompleteTransaction = getByteBuffer().get(); - this.reservedEncryptionFlag = getByteBuffer().get(); - getByteBuffer().get(this.reservedFreeRecordThread); - getByteBuffer().get(this.reservedMultiUser); - this.reservedMDXFlag = getByteBuffer().get(); - - // Translate code page value to a known charset. - this.codePage = getByteBuffer().get(); - - if (this.charset == null) { - try { - this.charset = toCharset(this.codePage); - } - catch(UnsupportedCharsetException e) { - // Warn the caller that he will have to perform is own conversions. - log(Level.WARNING, "log.no_valid_charset", getFile().getAbsolutePath(), e.getMessage()); - } - } - else { - log(Level.INFO, "log.record_charset", this.charset.name()); - } - - getByteBuffer().get(this.reservedFiller2); - - while(getByteBuffer().position() < this.firstRecordPosition - 1) { - DBase3FieldDescriptor fd = new DBase3FieldDescriptor(getByteBuffer()); - this.fieldsDescriptors.add(fd); - // loop until you hit the 0Dh field terminator - } - - this.descriptorTerminator = getByteBuffer().get(); - - // If the last character read after the field descriptor isn't 0x0D, the expected mark has not been found and the DBF is corrupted. - if (this.descriptorTerminator != 0x0D) { - String message = format(Level.WARNING, "excp.filedescriptor_problem", getFile().getAbsolutePath(), "Character marking the end of the fields descriptors (0x0D) has not been found."); - throw new SQLInvalidDbaseFileFormatException(message); - } - } - catch(BufferUnderflowException e) { - // This exception doesn't denote a trouble of file opening because the file has been checked before - // the calling of this private function. - // Therefore, an internal structure problem cause maybe a premature End of file or anything else, but the only thing - // we can conclude is : we are not before a device trouble, but a file format trouble. - String message = format(Level.WARNING, "excp.filedescriptor_problem", getFile().getAbsolutePath(), e.getMessage()); - throw new SQLInvalidDbaseFileFormatException(message); - } - } - - /** - * Returns the fields descriptors in their binary format. - * @return Fields descriptors. - */ - @Override - public List getFieldsDescriptors() { - return this.fieldsDescriptors; - } - - /** - * Return a field name. - * @param columnIndex Column index. - * @param sql For information, the SQL statement that is attempted. - * @return Field Name. - * @throws SQLIllegalColumnIndexException if the index is out of bounds. - */ - @Override - public String getFieldName(int columnIndex, String sql) throws SQLIllegalColumnIndexException { - return getField(columnIndex, sql).getName(); - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.Dbase3ByteReader#getColumnCount() - */ - @Override - public int getColumnCount() { - return this.fieldsDescriptors.size(); - } - - /** - * Returns the column index for the given column name. - * The default implementation of all methods expecting a column label will invoke this method. - * @param columnLabel The name of the column. - * @param sql For information, the SQL statement that is attempted. - * @return The index of the given column name : first column is 1. - * @throws SQLNoSuchFieldException if there is no field with this name in the query. - */ - @Override - public int findColumn(String columnLabel, String sql) throws SQLNoSuchFieldException { - // If the column name is null, no search is needed. - if (columnLabel == null) { - String message = format(Level.WARNING, "excp.no_such_column_in_resultset", columnLabel, sql, getFile().getName()); - throw new SQLNoSuchFieldException(message, sql, getFile(), columnLabel); - } - - // Search the field among the fields descriptors. - for(int index=0; index < this.fieldsDescriptors.size(); index ++) { - if (this.fieldsDescriptors.get(index).getName().equals(columnLabel)) { - return index + 1; - } - } - - // If we are here, we haven't found our field. Throw an exception. - String message = format(Level.WARNING, "excp.no_such_column_in_resultset", columnLabel, sql, getFile().getName()); - throw new SQLNoSuchFieldException(message, sql, getFile(), columnLabel); - } - - /** - * Returns the field descriptor of a given ResultSet column index. - * @param columnIndex Column index, first column is 1, second is 2, etc. - * @param sql For information, the SQL statement that is attempted. - * @return Field Descriptor. - * @throws SQLIllegalColumnIndexException if the index is out of bounds. - */ - private DBase3FieldDescriptor getField(int columnIndex, String sql) throws SQLIllegalColumnIndexException { - if (columnIndex < 1 || columnIndex > getColumnCount()) { - String message = format(Level.WARNING, "excp.illegal_column_index", columnIndex, getColumnCount()); - throw new SQLIllegalColumnIndexException(message, sql, getFile(), columnIndex); - } - - return this.fieldsDescriptors.get(columnIndex-1); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java deleted file mode 100644 index 118f6d9a6d6..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.io.File; -import java.sql.SQLException; - -/** - * Exception thrown when a connection is closed. - * @author Marc LE BIHAN - */ -public class SQLConnectionClosedException extends SQLException { - /** Serial ID. */ - private static final long serialVersionUID = -7806101485624353416L; - - /** The SQL Statement that whas attempted (if known). */ - private String sql; - - /** The database file. */ - private File database; - - /** - * Build the exception. - * @param message Exception message. - * @param sqlStatement SQL Statement who encountered the trouble, if known. - * @param dbf The database that was queried. - */ - public SQLConnectionClosedException(String message, String sqlStatement, File dbf) { - super(message); - this.sql = sqlStatement; - this.database = dbf; - } - - /** - * Returns the SQL statement who encountered the "connection closed" alert, if known. - * @return SQL statement or null. - */ - public String getSQL() { - return this.sql; - } - - /** - * Returns the database file that is not opened for connection. - * @return Database file. - */ - public File getDatabase() { - return this.database; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLDbaseFileNotFoundException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLDbaseFileNotFoundException.java deleted file mode 100644 index 73572f4c127..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLDbaseFileNotFoundException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.sql.SQLNonTransientException; - - -/** - * Thrown when a DBF file has not been found. - * - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class SQLDbaseFileNotFoundException extends SQLNonTransientException { - /** Serial UID. */ - private static final long serialVersionUID = 2572691456125734352L; - - /** - * Construct an exception. - * @param message Message of the exception. - */ - public SQLDbaseFileNotFoundException(String message) { - super(message); - } - - /** - * Construct an exception. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public SQLDbaseFileNotFoundException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLInvalidDbaseFileFormatException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLInvalidDbaseFileFormatException.java deleted file mode 100644 index ba449806d3b..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLInvalidDbaseFileFormatException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.sql.SQLNonTransientException; - - -/** - * Thrown when the DBF file format seems to be invalid. - * - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class SQLInvalidDbaseFileFormatException extends SQLNonTransientException { - /** Serial UID. */ - private static final long serialVersionUID = 3924612615300490837L; - - /** - * Construct an exception. - * @param message Message of the exception. - */ - public SQLInvalidDbaseFileFormatException(String message) { - super(message); - } - - /** - * Construct an exception. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public SQLInvalidDbaseFileFormatException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java deleted file mode 100644 index 89d18455331..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java +++ /dev/null @@ -1,418 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.connection; - -import java.sql.*; -import java.util.Collections; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.Executor; -import java.util.logging.Level; - -import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC; - - -/** - * This base class holds most of the unimplemented feature of a {@code Connection}. - * This is used in order to avoid having a Connection implementation of thousand lines and unreadable. - * - * - * - * - * - * - * - * - * - * - * - * - *
Connection default values
Property Value
{@link #isReadOnly()} {@code false}
{@link #getAutoCommit()} {@code true}
{@link #getNetworkTimeout()} 0
{@link #getTransactionIsolation()} {@link #TRANSACTION_NONE}
{@link #getTypeMap()} Empty map
{@link #nativeSQL(String)} No change
{@link #getWarnings()} {@code null}
{@link #clearWarnings()} Ignored
- * - * @author Marc Le Bihan - * @author Martin Desruisseaux (Geomatys) - * @version 0.5 - * @since 0.5 - * @module - */ -@SuppressWarnings("unused") -abstract class AbstractConnection extends AbstractJDBC implements Connection { - /** - * Constructs a new {@code Connection} instance. - */ - AbstractConnection() { - } - - /** - * Unsupported by default. - */ - @Override - public void setCatalog(String catalog) { - logUnsupportedOperation("setCatalog"); - } - - /** - * Unsupported by default. - */ - @Override - public String getSchema() throws SQLException { - throw unsupportedOperation("getSchema"); - } - - /** - * Unsupported by default. - */ - @Override - public void setSchema(String schema) throws SQLException { - throw unsupportedOperation("setSchema"); - } - - /** - * Unsupported by default. - */ - @Override - public Map> getTypeMap() { - return Collections.emptyMap(); - } - - /** - * Unsupported by default. - */ - @Override - public void setTypeMap(Map> map) { - if (!map.isEmpty()) { - throw new UnsupportedOperationException("setTypeMap"); - } - } - - /** - * Returns {@code true} by default, assuming a driver without write capabilities. - */ - @Override - public boolean isReadOnly() { - return true; - } - - /** - * Unsupported by default. - */ - @Override - public void setReadOnly(boolean readOnly) { - if (!readOnly) { - throw new UnsupportedOperationException("setReadOnly"); - } - } - - /** - * Defaults to {@link #TRANSACTION_NONE}. - */ - @Override - public int getTransactionIsolation() { - return TRANSACTION_NONE; // No guarantees of anything. - } - - /** - * Unsupported by default. - */ - @Override - public void setTransactionIsolation(int level) { - if (level != TRANSACTION_NONE) { - throw new UnsupportedOperationException("setTransactionIsolation"); - } - } - - /** - * Defaults to {@code true}, assuming that auto-commit state is not handled. - */ - @Override - public boolean getAutoCommit() { - return true; - } - - /** - * Defaults to ignoring the commit / rollback. - * The auto-commit mode is assumed fixed to {@code true}. - */ - @Override - public void setAutoCommit(boolean autoCommit) { - log(Level.FINE, "log.auto_commit_ignored", autoCommit); - } - - /** - * Unsupported by default. - */ - @Override - public void commit() { - log(Level.FINE, "log.commit_rollback_ignored"); - } - - /** - * Unsupported by default. - */ - @Override - public void rollback() { - log(Level.FINE, "log.commit_rollback_ignored"); - } - - /** - * Unsupported by default. - */ - @Override - public void rollback(Savepoint savepoint) throws SQLException { - throw unsupportedOperation("rollback"); - } - - /** - * Unsupported by default. - */ - @Override - public Savepoint setSavepoint() throws SQLException { - throw unsupportedOperation("setSavepoint"); - } - - /** - * Unsupported by default. - */ - @Override - public Savepoint setSavepoint(String name) throws SQLException { - throw unsupportedOperation("setSavepoint"); - } - - /** - * Unsupported by default. - */ - @Override - public void releaseSavepoint(Savepoint savepoint) throws SQLException { - throw unsupportedOperation("releaseSavepoint"); - } - - /** - * Unsupported by default. - */ - @Override - public int getHoldability() throws SQLException { - throw unsupportedOperation("getHoldability"); - } - - /** - * Unsupported by default. - */ - @Override - public void setHoldability(int holdability) { - logUnsupportedOperation("setHoldability"); - } - - /** - * Returns the given string unchanged by default. - */ - @Override - public String nativeSQL(String sql) { - return sql; // We do nothing at the moment. - } - - /** - * Unsupported by default. - */ - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { - throw unsupportedOperation("createStatement"); - } - - /** - * Unsupported by default. - */ - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - throw unsupportedOperation("createStatement"); - } - - /** - * Unsupported by default. - */ - @Override - public PreparedStatement prepareStatement(String sql) throws SQLException { - throw unsupportedOperation("prepareStatement"); - } - - /** - * Unsupported by default. - */ - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { - throw unsupportedOperation("prepareStatement"); - } - - /** - * Unsupported by default. - */ - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - throw unsupportedOperation("prepareStatement"); - } - - /** - * Unsupported by default. - */ - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - throw unsupportedOperation("prepareCall"); - } - - /** - * Unsupported by default. - */ - @Override - public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { - throw unsupportedOperation("prepareStatement"); - } - - /** - * Unsupported by default. - */ - @Override - public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { - throw unsupportedOperation("prepareStatement"); - } - - /** - * Unsupported by default. - */ - @Override - public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { - throw unsupportedOperation("prepareStatement"); - } - - /** - * Unsupported by default. - */ - @Override - public CallableStatement prepareCall(String sql) throws SQLException { - throw unsupportedOperation("prepareCall"); - } - - /** - * Unsupported by default. - */ - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { - throw unsupportedOperation("prepareCall"); - } - - /** - * Unsupported by default. - */ - @Override - public Clob createClob() throws SQLException { - throw unsupportedOperation("createClob"); - } - - /** - * Unsupported by default. - */ - @Override - public Blob createBlob() throws SQLException { - throw unsupportedOperation("createBlob"); - } - - /** - * Unsupported by default. - */ - @Override - public NClob createNClob() throws SQLException { - throw unsupportedOperation("createNClob"); - } - - /** - * Unsupported by default. - */ - @Override - public SQLXML createSQLXML() throws SQLException { - throw unsupportedOperation("createSQLXML"); - } - - /** - * Unsupported by default. - */ - @Override - public Array createArrayOf(String typeName, Object[] elements) throws SQLException { - throw unsupportedOperation("createArrayOf"); - } - - /** - * Unsupported by default. - */ - @Override - public Struct createStruct(String typeName, Object[] attributes) throws SQLException { - throw unsupportedOperation("createStruct"); - } - - /** - * Unsupported by default. - */ - @Override - public String getClientInfo(String name) throws SQLException { - throw unsupportedOperation("getClientInfo"); - } - - /** - * Unsupported by default. - */ - @Override - public Properties getClientInfo() throws SQLException { - throw unsupportedOperation("getClientInfo"); - } - - /** - * Unsupported by default. - */ - @Override - public void setClientInfo(String name, String value) { - logUnsupportedOperation("setClientInfo"); - } - - /** - * Unsupported by default. - */ - @Override - public void setClientInfo(Properties properties) { - logUnsupportedOperation("setClientInfo"); - } - - /** - * Defaults to 0, which means there is no limit. - */ - @Override - public int getNetworkTimeout() { - return 0; // Means there is no limt. - } - - /** - * Unsupported by default. - */ - @Override - public void setNetworkTimeout(Executor executor, int milliseconds) { - logUnsupportedOperation("setNetworkTimeout"); - } - - /** - * Unsupported by default. - */ - @Override - public void abort(Executor executor) throws SQLException { - throw unsupportedOperation("abort"); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java deleted file mode 100644 index cd60673bd70..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.connection; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.sql.*; -import java.util.*; -import java.util.logging.Level; -import java.util.stream.Collectors; - -import org.apache.sis.internal.shapefile.jdbc.*; -import org.apache.sis.internal.shapefile.jdbc.metadata.DBFDatabaseMetaData; -import org.apache.sis.internal.shapefile.jdbc.resultset.*; -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; - - -/** - * Connection to a DBF database. - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class DBFConnection extends AbstractConnection { - /** The object to use for reading the database content. */ - final File databaseFile; - - /** Opened statement. */ - private HashSet openedStatements = new HashSet<>(); - - /** ByteReader. */ - private Dbase3ByteReader byteReader; - - /** - * Constructs a connection to the given database. - * @param datafile Data file ({@code .dbf} extension). - * @param br Byte reader to use for reading binary content. - * @throws SQLDbaseFileNotFoundException if the Database file cannot be found or is not a file. - */ - public DBFConnection(final File datafile, Dbase3ByteReader br) throws SQLDbaseFileNotFoundException { - // Check that file exists. - if (!datafile.exists()) { - throw new SQLDbaseFileNotFoundException(format(Level.WARNING, "excp.file_not_found", datafile.getAbsolutePath())); - } - - // Check that its not a directory. - if (datafile.isDirectory()) { - throw new SQLDbaseFileNotFoundException(format(Level.WARNING, "excp.directory_not_expected", datafile.getAbsolutePath())); - } - - this.databaseFile = datafile; - this.byteReader = br; - log(Level.FINE, "log.database_connection_opened", this.databaseFile.getAbsolutePath(), "FIXME : column desc."); - } - - /** - * Closes the connection to the database. - */ - @Override - public void close() { - if (isClosed()) - return; - - try { - // Check if all the underlying connections that has been opened with this connection has been closed. - // If not, we log a warning to help the developer. - if (this.openedStatements.size() > 0) { - log(Level.WARNING, "log.statements_left_opened", this.openedStatements.size(), this.openedStatements.stream().map(DBFStatement::toString).collect(Collectors.joining(", "))); - } - - this.byteReader.close(); - } catch (IOException e) { - log(Level.FINE, e.getMessage(), e); - } - } - - /** - * Creates an object for sending SQL statements to the database. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override - public Statement createStatement() throws SQLConnectionClosedException { - assertNotClosed(); - - DBFStatement stmt = new DBFStatement(this); - this.openedStatements.add(stmt); - return stmt; - } - - /** - * @see java.sql.Connection#getCatalog() - */ - @Override - public String getCatalog() { - return null; // DBase 3 offers no catalog. - } - - /** - * Returns the charset. - * @return Charset. - */ - public Charset getCharset() { - return this.byteReader.getCharset(); - } - - /** - * Returns the database File. - * @return File. - */ - @Override - public File getFile() { - return this.databaseFile; - } - - /** - * Returns the JDBC interface implemented by this class. - * This is used for formatting error messages. - */ - @Override - final protected Class getInterface() { - return Connection.class; - } - - /** - * @see java.sql.Connection#getMetaData() - */ - @Override - public DatabaseMetaData getMetaData() { - return new DBFDatabaseMetaData(this); - } - - /** - * Returns {@code true} if this connection has been closed. - */ - @Override - public boolean isClosed() { - return this.byteReader.isClosed(); - } - - /** - * Returns {@code true} if the connection has not been closed and is still valid. - * The timeout parameter is ignored and this method bases itself only on {@link #isClosed()} state. - */ - @Override - public boolean isValid(@SuppressWarnings("unused") int timeout) { - return !isClosed(); - } - - /** - * @see java.sql.Wrapper#isWrapperFor(java.lang.Class) - */ - @Override - public boolean isWrapperFor(Class iface) { - return iface.isAssignableFrom(getInterface()); - } - - /** - * Asserts that the connection is opened. - * @throws SQLConnectionClosedException if the connection is closed. - */ - public void assertNotClosed() throws SQLConnectionClosedException { - // If closed throw an exception specifying the name if the DBF that is closed. - if (isClosed()) { - throw new SQLConnectionClosedException(format(Level.WARNING, "excp.closed_connection", getFile().getName()), null, getFile()); - } - } - - /** - * Method called by Statement class to notity this connection that a statement has been closed. - * @param stmt Statement that has been closed. - */ - public void notifyCloseStatement(DBFStatement stmt) { - Objects.requireNonNull(stmt, "The statement notified being closed cannot be null."); - - if (this.openedStatements.remove(stmt) == false) { - throw new RuntimeException(format(Level.SEVERE, "assert.statement_not_opened_by_me", stmt, toString())); - } - } - - /** - * Returns the column index for the given column name. - * The default implementation of all methods expecting a column label will invoke this method. - * @param columnLabel The name of the column. - * @param sql For information, the SQL statement that is attempted. - * @return The index of the given column name : first column is 1. - * @throws SQLNoSuchFieldException if there is no field with this name in the query. - */ - public int findColumn(String columnLabel, String sql) throws SQLNoSuchFieldException { - return this.byteReader.findColumn(columnLabel, sql); - } - - /** - * Returns the column count of the table of the database. - * @return Column count. - */ - public int getColumnCount() { - return this.byteReader.getColumnCount(); - } - - /** - * Get a field description. - * @param columnLabel Column label. - * @param sql SQL Statement. - * @return ResultSet with current row set on the wished field. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if no column with that name exists. - */ - public ResultSet getFieldDesc(String columnLabel, String sql) throws SQLConnectionClosedException, SQLNoSuchFieldException { - Objects.requireNonNull(columnLabel, "The column name cannot be null."); - - DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)((DBFDatabaseMetaData)getMetaData()).getColumns(null, null, null, null); - - try { - while(rs.next()) { - try { - if (rs.getString("COLUMN_NAME").equalsIgnoreCase(columnLabel)) { - return rs; - } - } - catch(SQLNoSuchFieldException e) { - // if it is the COLUMN_NAME column that has not been found in the desc ResultSet, we have an internal error. - rs.close(); - throw new RuntimeException(e.getMessage(), e); - } - } - } - catch(SQLNoResultException e) { - // if we run out of bound of the ResultSet, the boolean returned by next() has not been checked well, and it's an internal error. - rs.close(); - throw new RuntimeException(e.getMessage(), e); - } - - // But if we are here, we have not found the column with this name, and we have to throw an SQLNoSuchFieldException exception ourselves. - String message = format("excp.no_such_column_in_resultset", columnLabel, sql, getFile().getName()); - throw new SQLNoSuchFieldException(message, sql, getFile(), columnLabel); - } - - /** - * Get a field description. - * @param column Column index. - * @param sql SQL Statement. - * @return ResultSet with current row set on the wished field. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLIllegalColumnIndexException if the column index is out of bounds. - */ - public ResultSet getFieldDesc(int column, String sql) throws SQLConnectionClosedException, SQLIllegalColumnIndexException { - DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)((DBFDatabaseMetaData)getMetaData()).getColumns(null, null, null, null); - - if (column <= 0 || column > getColumnCount()) { - rs.close(); - String message = format("excp.illegal_column_index_metadata", column, getColumnCount()); - throw new SQLIllegalColumnIndexException(message, sql, getFile(), column); - } - - // TODO Implements ResultSet:absolute(int) instead. - for(int index=1; index <= column; index ++) { - try { - rs.next(); - } - catch(SQLNoResultException e) { - // We encounter an internal API error in this case. - rs.close(); - throw new RuntimeException(e.getMessage(), e); - } - } - - return rs; - } - - /** - * Returns the fields descriptors in their binary format. - * @return Fields descriptors. - */ - public List getFieldsDescriptors() { - return this.byteReader.getFieldsDescriptors(); - } - - /** - * Return a field name. - * @param columnIndex Column index. - * @param sql For information, the SQL statement that is attempted. - * @return Field Name. - * @throws SQLIllegalColumnIndexException if the index is out of bounds. - */ - public String getFieldName(int columnIndex, String sql) throws SQLIllegalColumnIndexException { - return this.byteReader.getFieldName(columnIndex, sql); - } - - /** - * Checks if a next row is available. Warning : it may be a deleted one. - * @return true if a next row is available. - */ - public boolean nextRowAvailable() { - return this.byteReader.nextRowAvailable(); - } - - /** - * Read the next row as a set of objects. - * @return Map of field name / object value, or null if EoF has been encountered. - */ - public Map readNextRowAsObjects() { - return this.byteReader.readNextRowAsObjects(); - } - - /** - * Returns the record number of the last record red. - * @return The record number. - */ - public int getRowNum() { - return this.byteReader.getRowNum(); - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return format("toString", this.databaseFile.getAbsolutePath(), isClosed() == false); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java deleted file mode 100644 index e20e58c967a..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.connection; - -import java.io.File; -import java.sql.SQLException; - -/** - * Exception thrown when a connection cannot be closed due to an environement trouble. - * @author Marc LE BIHAN - */ -public class SQLClosingIOFailureException extends SQLException { - /** Serial ID. */ - private static final long serialVersionUID = -3327372119927661463L; - - /** The SQL Statement that whas attempted (if known). */ - private String sql; - - /** The database file. */ - private File database; - - /** - * Build the exception. - * @param message Exception message. - * @param sqlStatement SQL Statement who encountered the trouble, if known. - * @param dbf The database that was queried. - */ - public SQLClosingIOFailureException(String message, String sqlStatement, File dbf) { - super(message); - this.sql = sqlStatement; - this.database = dbf; - } - - /** - * Returns the SQL statement who encountered the "connection closed" alert, if known. - * @return SQL statement or null. - */ - public String getSQL() { - return this.sql; - } - - /** - * Returns the database file that is not opened for connection. - * @return Database file. - */ - public File getDatabase() { - return this.database; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/package-info.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/package-info.java deleted file mode 100644 index e10322c3cac..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** Connections */ -package org.apache.sis.internal.shapefile.jdbc.connection; diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java deleted file mode 100644 index 91d0f0dec75..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.metadata; - -import java.sql.*; - -import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC; - -/** - * Unimplemented methods of DatabaseMetaData. - * @author Marc LE BIHAN - */ -public abstract class AbstractDatabaseMetaData extends AbstractJDBC implements DatabaseMetaData { - /** - * @see java.sql.DatabaseMetaData#getAttributes(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) throws SQLException { - throw unsupportedOperation("getAttributes", catalog, schemaPattern, typeNamePattern, attributeNamePattern); - } - - /** - * @see java.sql.DatabaseMetaData#getBestRowIdentifier(java.lang.String, java.lang.String, java.lang.String, int, boolean) - */ - @Override public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException { - throw unsupportedOperation("getBestRowIdentifier", catalog, schema, table, scope, nullable); - } - - /** - * @see java.sql.DatabaseMetaData#getClientInfoProperties() - */ - @Override public ResultSet getClientInfoProperties() throws SQLException { - throw unsupportedOperation("getClientInfoProperties"); - } - - /** - * @see java.sql.DatabaseMetaData#getColumnPrivileges(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException { - throw unsupportedOperation("getColumnPrivileges", catalog, schema, table, columnNamePattern); - } - - /** - * @see java.sql.DatabaseMetaData#getCrossReference(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException { - throw unsupportedOperation("getCrossReference", parentCatalog, parentSchema, parentTable, foreignCatalog, foreignSchema, foreignTable); - } - - /** - * @see java.sql.DatabaseMetaData#getExportedKeys(java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException { - throw unsupportedOperation("getExportedKeys", catalog, schema, table); - } - - /** - * @see java.sql.DatabaseMetaData#getFunctions(java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) throws SQLException { - throw unsupportedOperation("getFunctions", catalog, schemaPattern, functionNamePattern); - } - - /** - * @see java.sql.DatabaseMetaData#getFunctionColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException { - throw unsupportedOperation("getFunctionColumns", catalog, schemaPattern, functionNamePattern, columnNamePattern); - } - - /** - * @see java.sql.DatabaseMetaData#getIndexInfo(java.lang.String, java.lang.String, java.lang.String, boolean, boolean) - */ - @Override public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException { - throw unsupportedOperation("getIndexInfo", catalog, schema, table, unique, approximate); - } - - /** - * @see java.sql.DatabaseMetaData#getImportedKeys(java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException { - throw unsupportedOperation("getImportedKeys", catalog, schema, table); - } - - /** - * @see java.sql.DatabaseMetaData#getPrimaryKeys(java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { - throw unsupportedOperation("getPrimaryKeys", catalog, schema, table); - } - - /** - * @see java.sql.DatabaseMetaData#getProcedures(java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException { - throw unsupportedOperation("getProcedures", catalog, schemaPattern, procedureNamePattern); - } - - /** - * @see java.sql.DatabaseMetaData#getProcedureColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException{ - throw unsupportedOperation("getProcedureColumns", catalog, schemaPattern, procedureNamePattern, columnNamePattern); - } - - /** - * @see java.sql.DatabaseMetaData#getPseudoColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException { - throw unsupportedOperation("getPseudoColumns", catalog, schemaPattern, tableNamePattern, columnNamePattern); - } - - /** - * @see java.sql.DatabaseMetaData#getRowIdLifetime() - */ - @Override public RowIdLifetime getRowIdLifetime() throws SQLException { - throw unsupportedOperation("getRowIdLifetime"); - } - - /** - * @see java.sql.DatabaseMetaData#getSchemas(java.lang.String, java.lang.String) - */ - @Override public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { - throw unsupportedOperation("getSchemas", catalog, schemaPattern); - } - - /** - * @see java.sql.DatabaseMetaData#getSearchStringEscape() - */ - @Override public String getSearchStringEscape() throws SQLException { - throw unsupportedOperation("getSearchStringEscape"); - } - - /** - * @see java.sql.DatabaseMetaData#getSQLStateType() - */ - @Override public int getSQLStateType() throws SQLException { - throw unsupportedOperation("getSQLStateType"); - } - - /** - * @see java.sql.DatabaseMetaData#getSuperTypes(java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException { - throw unsupportedOperation("getSuperTypes", catalog, schemaPattern, typeNamePattern); - } - - /** - * @see java.sql.DatabaseMetaData#getSuperTables(java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { - throw unsupportedOperation("getSuperTables", catalog, schemaPattern, tableNamePattern); - } - - /** - * @see java.sql.DatabaseMetaData#getTablePrivileges(java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { - throw unsupportedOperation("getTablePrivileges", catalog, schemaPattern, tableNamePattern); - } - - /** - * @see java.sql.DatabaseMetaData#getTypeInfo() - */ - @Override public ResultSet getTypeInfo() throws SQLException { - throw unsupportedOperation("getTypeInfo"); - } - - /** - * @see java.sql.DatabaseMetaData#getUDTs(java.lang.String, java.lang.String, java.lang.String, int[]) - */ - @Override public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException { - throw unsupportedOperation("getUDTs", catalog, schemaPattern, typeNamePattern, types); - } - - /** - * @see java.sql.DatabaseMetaData#getVersionColumns(java.lang.String, java.lang.String, java.lang.String) - */ - @Override public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException { - throw unsupportedOperation("getVersionColumns", catalog, schema, table); - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#unwrap(java.lang.Class) - */ - @Override public T unwrap(Class iface) throws SQLFeatureNotSupportedException { - throw unsupportedOperation("unwrap", iface); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java deleted file mode 100644 index 931ed87e350..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java +++ /dev/null @@ -1,1300 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.metadata; - -import java.io.File; -import java.sql.*; -import java.util.Arrays; -import java.util.Objects; - -import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException; -import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection; -import org.apache.sis.internal.shapefile.jdbc.resultset.*; -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; - -/** - * Database Metadata. - * @author Marc LE BIHAN - */ -public class DBFDatabaseMetaData extends AbstractDatabaseMetaData { - /** Connection. */ - private DBFConnection connection; - - /** - * Construct a database Metadata. - * @param cnt Connection. - */ - public DBFDatabaseMetaData(DBFConnection cnt) { - Objects.requireNonNull(cnt, "The database connection used to create Database metadata cannot be null."); - this.connection = cnt; - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#isWrapperFor(java.lang.Class) - */ - @Override public boolean isWrapperFor(Class iface) { - logStep("isWrapperFor", iface); - return getInterface().isAssignableFrom(iface); - } - - /** - * @see java.sql.DatabaseMetaData#allProceduresAreCallable() - */ - @Override public boolean allProceduresAreCallable() { - logStep("allProceduresAreCallable"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#allTablesAreSelectable() - */ - @Override public boolean allTablesAreSelectable() { - logStep("allTablesAreSelectable"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#getColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String) - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override - public ResultSet getColumns(@SuppressWarnings("unused") String catalog, @SuppressWarnings("unused") String schemaPattern, @SuppressWarnings("unused") String tableNamePattern, @SuppressWarnings("unused") String columnNamePattern) throws SQLConnectionClosedException { - try(DBFStatement stmt = (DBFStatement)this.connection.createStatement()) { - return new DBFBuiltInMemoryResultSetForColumnsListing(stmt, this.connection.getFieldsDescriptors()); - } - } - - /** - * Returns the Database File. - * @return Database File. - */ - @Override - public File getFile() { - return this.connection.getFile(); - } - - /** - * @see java.sql.DatabaseMetaData#getURL() - */ - @Override public String getURL() { - logStep("getURL"); - return getFile().getAbsolutePath(); - } - - /** - * @see java.sql.DatabaseMetaData#getUserName() - */ - @Override public String getUserName() { - logStep("getUserName"); - return null; - } - - /** - * @see java.sql.DatabaseMetaData#isReadOnly() - */ - @Override public boolean isReadOnly() { - logStep("isReadOnly"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#nullsAreSortedHigh() - */ - @Override public boolean nullsAreSortedHigh() { - logStep("nullsAreSortedHigh"); - return false; // TODO : Check in documentation about this. - } - - /** - * @see java.sql.DatabaseMetaData#nullsAreSortedLow() - */ - @Override public boolean nullsAreSortedLow() { - logStep("nullsAreSortedLow"); - return false; // TODO : Check in documentation about this. - } - - /** - * @see java.sql.DatabaseMetaData#nullsAreSortedAtStart() - */ - @Override public boolean nullsAreSortedAtStart() { - logStep("nullsAreSortedAtStart"); - return false; // TODO : Check in documentation about this. - } - - /** - * @see java.sql.DatabaseMetaData#nullsAreSortedAtEnd() - */ - @Override public boolean nullsAreSortedAtEnd() { - logStep("nullsAreSortedAtEnd"); - return false; // TODO : Check in documentation about this. - } - - /** - * @see java.sql.DatabaseMetaData#getDatabaseProductName() - */ - @Override public String getDatabaseProductName() { - logStep("getDatabaseProductName"); - return "DBase 3"; - } - - /** - * @see java.sql.DatabaseMetaData#getDatabaseProductVersion() - */ - @Override public String getDatabaseProductVersion() { - logStep("getDatabaseProductVersion"); - return "3"; - } - - /** - * @see java.sql.DatabaseMetaData#getDriverName() - */ - @Override public String getDriverName() { - logStep("getDriverName"); - return "Apache SIS DBase 3 JDBC driver"; - } - - /** - * @see java.sql.DatabaseMetaData#getDriverVersion() - */ - @Override public String getDriverVersion() { - logStep("getDriverVersion"); - return "1.0"; - } - - /** - * @see java.sql.DatabaseMetaData#getDriverMajorVersion() - */ - @Override public int getDriverMajorVersion() { - logStep("getDriverMajorVersion"); - return 1; - } - - /** - * @see java.sql.DatabaseMetaData#getDriverMinorVersion() - */ - @Override public int getDriverMinorVersion() { - logStep("getDriverMinorVersion"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#usesLocalFiles() - */ - @Override public boolean usesLocalFiles() { - logStep("usesLocalFiles"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#usesLocalFilePerTable() - */ - @Override public boolean usesLocalFilePerTable() { - logStep("usesLocalFilePerTable"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#supportsMixedCaseIdentifiers() - */ - @Override public boolean supportsMixedCaseIdentifiers() { - logStep("supportsMixedCaseIdentifiers"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#storesUpperCaseIdentifiers() - */ - @Override public boolean storesUpperCaseIdentifiers() { - logStep("storesUpperCaseIdentifiers"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#storesLowerCaseIdentifiers() - */ - @Override public boolean storesLowerCaseIdentifiers() { - logStep("storesLowerCaseIdentifiers"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#storesMixedCaseIdentifiers() - */ - @Override public boolean storesMixedCaseIdentifiers() { - logStep("storesMixedCaseIdentifiers"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#supportsMixedCaseQuotedIdentifiers() - */ - @Override public boolean supportsMixedCaseQuotedIdentifiers() { - logStep("supportsMixedCaseQuotedIdentifiers"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#storesUpperCaseQuotedIdentifiers() - */ - @Override public boolean storesUpperCaseQuotedIdentifiers() { - logStep("storesUpperCaseQuotedIdentifiers"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#storesLowerCaseQuotedIdentifiers() - */ - @Override public boolean storesLowerCaseQuotedIdentifiers() { - logStep("storesLowerCaseQuotedIdentifiers"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#storesMixedCaseQuotedIdentifiers() - */ - @Override public boolean storesMixedCaseQuotedIdentifiers() { - logStep("storesMixedCaseQuotedIdentifiers"); - return true; - } - - /** - * @see java.sql.DatabaseMetaData#getIdentifierQuoteString() - */ - @Override public String getIdentifierQuoteString() { - logStep("getIdentifierQuoteString"); - return " "; - } - - /** - * @see java.sql.DatabaseMetaData#getSQLKeywords() - */ - @Override public String getSQLKeywords() { - logStep("getSQLKeywords"); - return ""; // We don't have special Keywords yet. - } - - /** - * @see java.sql.DatabaseMetaData#getNumericFunctions() - */ - @Override public String getNumericFunctions() { - logStep("getNumericFunctions"); - return ""; - } - - /** - * @see java.sql.DatabaseMetaData#getStringFunctions() - */ - @Override public String getStringFunctions() { - logStep("getStringFunctions"); - return ""; - } - - /** - * @see java.sql.DatabaseMetaData#getSystemFunctions() - */ - @Override public String getSystemFunctions() { - logStep("getSystemFunctions"); - return ""; - } - - /** - * @see java.sql.DatabaseMetaData#getTimeDateFunctions() - */ - @Override public String getTimeDateFunctions() { - logStep("getTimeDateFunctions"); - return ""; - } - - /** - * @see java.sql.DatabaseMetaData#getExtraNameCharacters() - */ - @Override public String getExtraNameCharacters() { - logStep("getExtraNameCharacters"); - return ""; - } - - /** - * @see java.sql.DatabaseMetaData#supportsAlterTableWithAddColumn() - */ - @Override public boolean supportsAlterTableWithAddColumn() { - logStep("supportsAlterTableWithAddColumn"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsAlterTableWithDropColumn() - */ - @Override public boolean supportsAlterTableWithDropColumn() { - logStep("supportsAlterTableWithDropColumn"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsColumnAliasing() - */ - @Override public boolean supportsColumnAliasing() { - logStep("supportsColumnAliasing"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#nullPlusNonNullIsNull() - */ - @Override public boolean nullPlusNonNullIsNull() { - logStep("nullPlusNonNullIsNull"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsConvert() - */ - @Override public boolean supportsConvert() { - logStep("supportsConvert"); - return false; // We can promote internally types, but not offer the keyword. - } - - /** - * @see java.sql.DatabaseMetaData#supportsConvert(int, int) - */ - @Override public boolean supportsConvert(int fromType, int toType) { - logStep("supportsConvert", fromType, toType); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsTableCorrelationNames() - */ - @Override public boolean supportsTableCorrelationNames() { - logStep("supportsTableCorrelationNames"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsDifferentTableCorrelationNames() - */ - @Override public boolean supportsDifferentTableCorrelationNames() { - logStep("supportsDifferentTableCorrelationNames"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsExpressionsInOrderBy() - */ - @Override public boolean supportsExpressionsInOrderBy() { - logStep("supportsExpressionsInOrderBy"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsOrderByUnrelated() - */ - @Override public boolean supportsOrderByUnrelated() { - logStep("supportsOrderByUnrelated"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsGroupBy() - */ - @Override public boolean supportsGroupBy() { - logStep("supportsGroupBy"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsGroupByUnrelated() - */ - @Override public boolean supportsGroupByUnrelated() { - logStep("supportsGroupByUnrelated"); - return false; - } - /** - * @see java.sql.DatabaseMetaData#supportsGroupByBeyondSelect() - */ - @Override public boolean supportsGroupByBeyondSelect() { - logStep("supportsGroupByBeyondSelect"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsLikeEscapeClause() - */ - @Override public boolean supportsLikeEscapeClause() { - logStep("supportsLikeEscapeClause"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsMultipleResultSets() - */ - @Override public boolean supportsMultipleResultSets() { - logStep("supportsMultipleResultSets"); - return false; // Even if the code allow creating multiple ResultSet from a statement. - } - - /** - * @see java.sql.DatabaseMetaData#supportsMultipleTransactions() - */ - @Override public boolean supportsMultipleTransactions() { - logStep("supportsMultipleTransactions"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsNonNullableColumns() - */ - @Override public boolean supportsNonNullableColumns() { - logStep("supportsNonNullableColumns"); - return false; // TODO Check in documentation. - } - - /** - * @see java.sql.DatabaseMetaData#supportsMinimumSQLGrammar() - */ - @Override public boolean supportsMinimumSQLGrammar() { - logStep("supportsMinimumSQLGrammar"); - return false; // Check what is the ODBC SQL minimum grammar. - } - - /** - * @see java.sql.DatabaseMetaData#supportsCoreSQLGrammar() - */ - @Override public boolean supportsCoreSQLGrammar() { - logStep("supportsCoreSQLGrammar"); - return false; // Check what is the core SQL grammar. - } - - /** - * @see java.sql.DatabaseMetaData#supportsExtendedSQLGrammar() - */ - @Override public boolean supportsExtendedSQLGrammar() { - logStep("supportsExtendedSQLGrammar"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsANSI92EntryLevelSQL() - */ - @Override public boolean supportsANSI92EntryLevelSQL() { - logStep("supportsANSI92EntryLevelSQL"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsANSI92IntermediateSQL() - */ - @Override public boolean supportsANSI92IntermediateSQL() { - logStep("supportsANSI92IntermediateSQL"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsANSI92FullSQL() - */ - @Override public boolean supportsANSI92FullSQL() { - logStep("supportsANSI92FullSQL"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsIntegrityEnhancementFacility() - */ - @Override public boolean supportsIntegrityEnhancementFacility() { - logStep("supportsIntegrityEnhancementFacility"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsOuterJoins() - */ - @Override public boolean supportsOuterJoins() { - logStep("supportsOuterJoins"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsFullOuterJoins() - */ - @Override public boolean supportsFullOuterJoins() { - logStep("supportsFullOuterJoins"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsLimitedOuterJoins() - */ - @Override public boolean supportsLimitedOuterJoins() { - logStep("supportsLimitedOuterJoins"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#getSchemaTerm() - */ - @Override public String getSchemaTerm() { - logStep("getSchemaTerm"); - return ""; - } - - /** - * @see java.sql.DatabaseMetaData#getProcedureTerm() - */ - @Override public String getProcedureTerm() { - logStep("getProcedureTerm"); - return ""; - } - - /** - * @see java.sql.DatabaseMetaData#getCatalogTerm() - */ - @Override public String getCatalogTerm() { - logStep("getCatalogTerm"); - return ""; - } - - /** - * @see java.sql.DatabaseMetaData#isCatalogAtStart() - */ - @Override public boolean isCatalogAtStart() { - logStep("isCatalogAtStart"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#getCatalogSeparator() - */ - @Override public String getCatalogSeparator() { - logStep("getCatalogSeparator"); - return ""; - } - - /** - * @see java.sql.DatabaseMetaData#supportsSchemasInDataManipulation() - */ - @Override public boolean supportsSchemasInDataManipulation() { - logStep("supportsSchemasInDataManipulation"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsSchemasInProcedureCalls() - */ - @Override public boolean supportsSchemasInProcedureCalls() { - logStep("supportsSchemasInProcedureCalls"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsSchemasInTableDefinitions() - */ - @Override public boolean supportsSchemasInTableDefinitions() { - logStep("supportsSchemasInTableDefinitions"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsSchemasInIndexDefinitions() - */ - @Override public boolean supportsSchemasInIndexDefinitions() { - logStep("supportsSchemasInIndexDefinitions"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsSchemasInPrivilegeDefinitions() - */ - @Override public boolean supportsSchemasInPrivilegeDefinitions() { - logStep("supportsSchemasInPrivilegeDefinitions"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsCatalogsInDataManipulation() - */ - @Override public boolean supportsCatalogsInDataManipulation() { - logStep("supportsCatalogsInDataManipulation"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsCatalogsInProcedureCalls() - */ - @Override public boolean supportsCatalogsInProcedureCalls() { - logStep("supportsCatalogsInProcedureCalls"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsCatalogsInTableDefinitions() - */ - @Override public boolean supportsCatalogsInTableDefinitions() { - logStep("supportsCatalogsInTableDefinitions"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsCatalogsInIndexDefinitions() - */ - @Override public boolean supportsCatalogsInIndexDefinitions() { - logStep("supportsCatalogsInIndexDefinitions"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsCatalogsInPrivilegeDefinitions() - */ - @Override public boolean supportsCatalogsInPrivilegeDefinitions() { - logStep("supportsCatalogsInPrivilegeDefinitions"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsPositionedDelete() - */ - @Override public boolean supportsPositionedDelete() { - logStep("supportsPositionedDelete"); - return false; // TODO not yet, but might later. - } - - /** - * @see java.sql.DatabaseMetaData#supportsPositionedUpdate() - */ - @Override public boolean supportsPositionedUpdate() { - logStep("supportsPositionedUpdate"); - return false; // TODO not yet, but might later. - } - - /** - * @see java.sql.DatabaseMetaData#supportsSelectForUpdate() - */ - @Override public boolean supportsSelectForUpdate() { - logStep("supportsSelectForUpdate"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsStoredProcedures() - */ - @Override public boolean supportsStoredProcedures() { - logStep("supportsStoredProcedures"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsSubqueriesInComparisons() - */ - @Override public boolean supportsSubqueriesInComparisons() { - logStep("supportsStoredProcedures"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsSubqueriesInExists() - */ - @Override public boolean supportsSubqueriesInExists() { - logStep("supportsSubqueriesInExists"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsSubqueriesInIns() - */ - @Override public boolean supportsSubqueriesInIns() { - logStep("supportsSubqueriesInIns"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsSubqueriesInQuantifieds() - */ - @Override public boolean supportsSubqueriesInQuantifieds() { - logStep("supportsSubqueriesInQuantifieds"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsCorrelatedSubqueries() - */ - @Override public boolean supportsCorrelatedSubqueries() { - logStep("supportsCorrelatedSubqueries"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsUnion() - */ - @Override public boolean supportsUnion() { - logStep("supportsUnion"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsUnionAll() - */ - @Override public boolean supportsUnionAll() { - logStep("supportsUnionAll"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsOpenCursorsAcrossCommit() - */ - @Override public boolean supportsOpenCursorsAcrossCommit() { - logStep("supportsOpenCursorsAcrossCommit"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsOpenCursorsAcrossRollback() - */ - @Override public boolean supportsOpenCursorsAcrossRollback() { - logStep("supportsOpenCursorsAcrossRollback"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsOpenStatementsAcrossCommit() - */ - @Override public boolean supportsOpenStatementsAcrossCommit() { - logStep("supportsOpenStatementsAcrossCommit"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsOpenStatementsAcrossRollback() - */ - @Override public boolean supportsOpenStatementsAcrossRollback() { - logStep("supportsOpenStatementsAcrossRollback"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxBinaryLiteralLength() - */ - @Override public int getMaxBinaryLiteralLength() { - logStep("getMaxBinaryLiteralLength"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxCharLiteralLength() - */ - @Override public int getMaxCharLiteralLength() { - logStep("getMaxCharLiteralLength"); - return 254; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxColumnNameLength() - */ - @Override public int getMaxColumnNameLength() { - logStep("getMaxColumnNameLength"); - return 10; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxColumnsInGroupBy() - */ - @Override public int getMaxColumnsInGroupBy() { - logStep("getMaxColumnsInGroupBy"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxColumnsInIndex() - */ - @Override public int getMaxColumnsInIndex() { - logStep("getMaxColumnsInIndex"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxColumnsInOrderBy() - */ - @Override public int getMaxColumnsInOrderBy() { - logStep("getMaxColumnsInOrderBy"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxColumnsInSelect() - */ - @Override public int getMaxColumnsInSelect() { - logStep("getMaxColumnsInSelect"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxColumnsInTable() - */ - @Override public int getMaxColumnsInTable() { - logStep("getMaxColumnsInTable"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxConnections() - */ - @Override public int getMaxConnections() { - logStep("getMaxConnections"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxCursorNameLength() - */ - @Override public int getMaxCursorNameLength() { - logStep("getMaxCursorNameLength"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxIndexLength() - */ - @Override public int getMaxIndexLength() { - logStep("getMaxIndexLength"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxSchemaNameLength() - */ - @Override public int getMaxSchemaNameLength() { - logStep("getMaxSchemaNameLength"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxProcedureNameLength() - */ - @Override public int getMaxProcedureNameLength() { - logStep("getMaxProcedureNameLength"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxCatalogNameLength() - */ - @Override public int getMaxCatalogNameLength() { - logStep("getMaxCatalogNameLength"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxRowSize() - */ - @Override public int getMaxRowSize() { - logStep("getMaxRowSize"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#doesMaxRowSizeIncludeBlobs() - */ - @Override public boolean doesMaxRowSizeIncludeBlobs() { - logStep("doesMaxRowSizeIncludeBlobs"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxStatementLength() - */ - @Override public int getMaxStatementLength() { - logStep("getMaxStatementLength"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxStatements() - */ - @Override public int getMaxStatements() { - logStep("getMaxStatements"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxTableNameLength() - */ - @Override public int getMaxTableNameLength() { - logStep("getMaxTableNameLength"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getMaxTablesInSelect() - */ - @Override public int getMaxTablesInSelect() { - logStep("getMaxTablesInSelect"); - return 1; // We only handle one table at this time. - } - - /** - * @see java.sql.DatabaseMetaData#getMaxUserNameLength() - */ - @Override public int getMaxUserNameLength() { - logStep("getMaxUserNameLength"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getDefaultTransactionIsolation() - */ - @Override public int getDefaultTransactionIsolation() { - logStep("getDefaultTransactionIsolation"); - return 0; // No guaranties of anything. - } - - /** - * @see java.sql.DatabaseMetaData#supportsTransactions() - */ - @Override public boolean supportsTransactions() { - logStep("supportsTransactions"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsTransactionIsolationLevel(int) - */ - @Override public boolean supportsTransactionIsolationLevel(int level) { - logStep("supportsTransactionIsolationLevel", level); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsDataDefinitionAndDataManipulationTransactions() - */ - @Override public boolean supportsDataDefinitionAndDataManipulationTransactions() { - logStep("supportsDataDefinitionAndDataManipulationTransactions"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsDataManipulationTransactionsOnly() - */ - @Override public boolean supportsDataManipulationTransactionsOnly() { - logStep("supportsDataManipulationTransactionsOnly"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#dataDefinitionCausesTransactionCommit() - */ - @Override public boolean dataDefinitionCausesTransactionCommit() { - logStep("dataDefinitionCausesTransactionCommit"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#dataDefinitionIgnoredInTransactions() - */ - @Override public boolean dataDefinitionIgnoredInTransactions() { - logStep("dataDefinitionIgnoredInTransactions"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#getTables(java.lang.String, java.lang.String, java.lang.String, java.lang.String[]) - */ - @SuppressWarnings("resource") // The statement will be closed by the caller. - @Override public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) { - logStep("getTables", catalog, schemaPattern, tableNamePattern, types != null ? Arrays.asList(types) : null); - - DBFStatement stmt = new DBFStatement(this.connection); - DBFBuiltInMemoryResultSetForTablesListing tables = new DBFBuiltInMemoryResultSetForTablesListing(stmt); - stmt.registerResultSet(tables); - return tables; - } - - /** - * @see java.sql.DatabaseMetaData#getSchemas() - */ - @SuppressWarnings("resource") // The statement will be closed by the caller. - @Override public ResultSet getSchemas() { - logStep("getSchemas"); - - DBFStatement stmt = new DBFStatement(this.connection); - DBFBuiltInMemoryResultSetForSchemaListing schemas = new DBFBuiltInMemoryResultSetForSchemaListing(stmt); - stmt.registerResultSet(schemas); - return schemas; - } - - /** - * @see java.sql.DatabaseMetaData#getCatalogs() - */ - @SuppressWarnings("resource") // The statement will be closed by the caller. - @Override public ResultSet getCatalogs() { - logStep("getCatalogs"); - - DBFStatement stmt = new DBFStatement(this.connection); - DBFBuiltInMemoryResultSetForCatalogNamesListing catalogNames = new DBFBuiltInMemoryResultSetForCatalogNamesListing(stmt); - stmt.registerResultSet(catalogNames); - return catalogNames; - } - - /** - * @see java.sql.DatabaseMetaData#getTableTypes() - */ - @SuppressWarnings("resource") // The statement will be closed by the caller. - @Override public ResultSet getTableTypes() { - logStep("getTableTypes"); - - DBFStatement stmt = new DBFStatement(this.connection); - DBFBuiltInMemoryResultSetForTablesTypesListing tablesTypes = new DBFBuiltInMemoryResultSetForTablesTypesListing(stmt); - stmt.registerResultSet(tablesTypes); - return tablesTypes; - } - - /** - * @see java.sql.DatabaseMetaData#supportsResultSetType(int) - */ - @Override public boolean supportsResultSetType(int type) { - logStep("supportsResultSetType", type); - - switch(type) { - case ResultSet.FETCH_FORWARD: - case ResultSet.FETCH_UNKNOWN: - case ResultSet.TYPE_FORWARD_ONLY: - return true; - - default : - return false; - } - } - - /** - * @see java.sql.DatabaseMetaData#supportsResultSetConcurrency(int, int) - */ - @Override public boolean supportsResultSetConcurrency(int type, int concurrency) { - logStep("supportsResultSetConcurrency", type, concurrency); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#ownUpdatesAreVisible(int) - */ - @Override public boolean ownUpdatesAreVisible(int type) { - logStep("ownUpdatesAreVisible", type); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#ownDeletesAreVisible(int) - */ - @Override public boolean ownDeletesAreVisible(int type) { - logStep("ownDeletesAreVisible", type); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#ownInsertsAreVisible(int) - */ - @Override public boolean ownInsertsAreVisible(int type) { - logStep("ownInsertsAreVisible", type); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#othersUpdatesAreVisible(int) - */ - @Override public boolean othersUpdatesAreVisible(int type) { - logStep("othersUpdatesAreVisible", type); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#othersDeletesAreVisible(int) - */ - @Override public boolean othersDeletesAreVisible(int type) { - logStep("othersDeletesAreVisible", type); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#othersInsertsAreVisible(int) - */ - @Override public boolean othersInsertsAreVisible(int type) { - logStep("othersInsertsAreVisible", type); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#updatesAreDetected(int) - */ - @Override public boolean updatesAreDetected(int type) { - logStep("updatesAreDetected", type); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#deletesAreDetected(int) - */ - @Override public boolean deletesAreDetected(int type) { - logStep("deletesAreDetected", type); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#insertsAreDetected(int) - */ - @Override public boolean insertsAreDetected(int type) { - logStep("insertsAreDetected", type); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsBatchUpdates() - */ - @Override public boolean supportsBatchUpdates() { - logStep("supportsBatchUpdates"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#getConnection() - */ - @Override public Connection getConnection() { - logStep("getConnection"); - return this.connection; - } - - /** - * @see java.sql.DatabaseMetaData#supportsSavepoints() - */ - @Override public boolean supportsSavepoints() { - logStep("supportsSavepoints"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsNamedParameters() - */ - @Override public boolean supportsNamedParameters() { - logStep("supportsNamedParameters"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsMultipleOpenResults() - */ - @Override public boolean supportsMultipleOpenResults() { - logStep("supportsMultipleOpenResults"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsGetGeneratedKeys() - */ - @Override public boolean supportsGetGeneratedKeys() { - logStep("supportsGetGeneratedKeys"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsResultSetHoldability(int) - */ - @Override public boolean supportsResultSetHoldability(int holdability) { - logStep("supportsResultSetHoldability", holdability); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#getResultSetHoldability() - */ - @Override public int getResultSetHoldability() { - logStep("getResultSetHoldability"); - return ResultSet.HOLD_CURSORS_OVER_COMMIT; // TODO : No matters, as we don't handle transactions. - } - - /** - * @see java.sql.DatabaseMetaData#getDatabaseMajorVersion() - */ - @Override public int getDatabaseMajorVersion() { - logStep("getDatabaseMajorVersion"); - return 3; - } - - /** - * @see java.sql.DatabaseMetaData#getDatabaseMinorVersion() - */ - @Override public int getDatabaseMinorVersion() { - logStep("getDatabaseMinorVersion"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#getJDBCMajorVersion() - */ - @Override public int getJDBCMajorVersion() { - logStep("getJDBCMajorVersion"); - return 1; - } - - /** - * @see java.sql.DatabaseMetaData#getJDBCMinorVersion() - */ - @Override public int getJDBCMinorVersion() { - logStep("getJDBCMinorVersion"); - return 0; - } - - /** - * @see java.sql.DatabaseMetaData#locatorsUpdateCopy() - */ - @Override public boolean locatorsUpdateCopy() { - logStep("locatorsUpdateCopy"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsStatementPooling() - */ - @Override public boolean supportsStatementPooling() { - logStep("supportsStatementPooling"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#supportsStoredFunctionsUsingCallSyntax() - */ - @Override public boolean supportsStoredFunctionsUsingCallSyntax() { - logStep("supportsStoredFunctionsUsingCallSyntax"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#autoCommitFailureClosesAllResultSets() - */ - @Override public boolean autoCommitFailureClosesAllResultSets() { - logStep("autoCommitFailureClosesAllResultSets"); - return false; - } - - /** - * @see java.sql.DatabaseMetaData#generatedKeyAlwaysReturned() - */ - @Override public boolean generatedKeyAlwaysReturned() { - logStep("generatedKeyAlwaysReturned"); - return false; - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#getInterface() - */ - @Override protected Class getInterface() { - return DatabaseMetaData.class; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java deleted file mode 100644 index f3ae694fbae..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java +++ /dev/null @@ -1,473 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.metadata; - -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; -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; -import org.apache.sis.internal.shapefile.jdbc.resultset.*; - -/** - * ResultSet Metadata. - * @author Marc LE BIHAN - */ -public class DBFResultSetMataData extends AbstractJDBC implements ResultSetMetaData { - /** ResultSet. */ - private DBFRecordBasedResultSet rs; - - /** Database metadata. */ - private DBFDatabaseMetaData metadata; - - /** - * Construct a ResultSetMetaData. - * @param resultset ResultSet. - */ - public DBFResultSetMataData(DBFRecordBasedResultSet resultset) { - Objects.requireNonNull(resultset, "A non null ResultSet is required."); - this.rs = resultset; - - try { - this.metadata = (DBFDatabaseMetaData)resultset.getStatement().getConnection().getMetaData(); - } - catch(SQLException e) { - throw new RuntimeException(e.getMessage(), e); - } - } - - /** - * @see java.sql.Wrapper#unwrap(java.lang.Class) - */ - @Override public T unwrap(Class iface) throws SQLFeatureNotSupportedException { - throw unsupportedOperation("unwrap", iface); - } - - /** - * @see java.sql.Wrapper#isWrapperFor(java.lang.Class) - */ - @Override - public boolean isWrapperFor(Class iface) { - logStep("isWrapperFor", iface); - return iface.isAssignableFrom(getInterface()); - } - - /** - * @see java.sql.ResultSetMetaData#getColumnCount() - * @throws SQLConnectionClosedException if the connection is closed. - */ - @SuppressWarnings("resource") // The current connection is only used and has not to be closed. - @Override public int getColumnCount() throws SQLConnectionClosedException { - logStep("getColumnCount"); - DBFConnection cnt = (DBFConnection)(((DBFStatement)this.rs.getStatement()).getConnection()); - - return cnt.getColumnCount(); - } - - /** - * @see java.sql.ResultSetMetaData#isAutoIncrement(int) - * @throws SQLIllegalColumnIndexException if the column index is illegal. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override public boolean isAutoIncrement(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException { - logStep("isAutoIncrement", column); - - 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); - } - } - - /** - * @see java.sql.ResultSetMetaData#isCaseSensitive(int) - */ - @Override public boolean isCaseSensitive(int column) { - logStep("isCaseSensitive", column); - return true; // Yes, because behind, there's a HashMap. - } - - /** - * @see java.sql.ResultSetMetaData#isSearchable(int) - */ - @Override public boolean isSearchable(int column) { - logStep("isSearchable", column); - return true; // All currently are searcheable. - } - - /** - * @see java.sql.ResultSetMetaData#isCurrency(int) - * @throws SQLIllegalColumnIndexException if the column index is illegal. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override public boolean isCurrency(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException { - logStep("isCurrency", column); - - 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); - } - } - - /** - * @see java.sql.ResultSetMetaData#isNullable(int) - */ - @Override public int isNullable(int column) { - logStep("isNullable", column); - return ResultSetMetaData.columnNullableUnknown; // TODO Check if somes settings exists for that in field descriptor. - } - - /** - * @see java.sql.ResultSetMetaData#isSigned(int) - */ - @Override public boolean isSigned(int column) { - logStep("isSigned", column); - return true; // TODO Check if somes settings exists for that in field descriptor. - } - - /** - * @see java.sql.ResultSetMetaData#getColumnDisplaySize(int) - * @throws SQLIllegalColumnIndexException if the column index is illegal. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override public int getColumnDisplaySize(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException { - logStep("getColumnDisplaySize", column); - - 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. - 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. - 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"); - } - } - catch(SQLNoSuchFieldException e) { - String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage()); - throw new RuntimeException(message, e); - } - } - - /** - * @see java.sql.ResultSetMetaData#getColumnLabel(int) - * @throws SQLIllegalColumnIndexException if the column index is illegal. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override public String getColumnLabel(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException { - logStep("getColumnLabel", column); - - 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); - } - } - - /** - * @see java.sql.ResultSetMetaData#getColumnName(int) - * @throws SQLIllegalColumnIndexException if the column index is illegal. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override public String getColumnName(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException { - logStep("getColumnName", column); - - 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); - } - } - - /** - * @see java.sql.ResultSetMetaData#getSchemaName(int) - */ - @Override public String getSchemaName(int column) { - logStep("getSchemaName", column); - return ""; // No schema name in DBase 3. - } - - /** - * @see java.sql.ResultSetMetaData#getPrecision(int) - * @throws SQLIllegalColumnIndexException if the column index is illegal. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override public int getPrecision(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException { - logStep("getPrecision", column); - - 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); - } - } - - /** - * @see java.sql.ResultSetMetaData#getScale(int) - * @throws SQLIllegalColumnIndexException if the column index is illegal. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override public int getScale(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException { - logStep("getScale", column); - - 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); - } - } - - /** - * @see java.sql.ResultSetMetaData#getTableName(int) - */ - @Override public String getTableName(int column) { - logStep("getTableName", column); - - // The table default to the file name (without its extension .dbf). - String fileName = this.rs.getFile().getName(); - int indexDBF = fileName.lastIndexOf("."); - String tableName = fileName.substring(0, indexDBF); - - return tableName; - } - - /** - * @see java.sql.ResultSetMetaData#getCatalogName(int) - */ - @Override public String getCatalogName(int column) { - logStep("getCatalogName", column); - return ""; - } - - /** - * @see java.sql.ResultSetMetaData#getColumnType(int) - * @throws SQLIllegalColumnIndexException if the column index is illegal. - */ - @Override public int getColumnType(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException { - logStep("getColumnType", column); - - 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); - } - } - - /** - * @see java.sql.ResultSetMetaData#getColumnTypeName(int) - * @throws SQLIllegalColumnIndexException if the column index is illegal. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override public String getColumnTypeName(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException { - logStep("getColumnTypeName", column); - - 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); - } - } - - /** - * @see java.sql.ResultSetMetaData#isReadOnly(int) - */ - @Override public boolean isReadOnly(int column) { - logStep("isReadOnly", column); - return false; // TODO Check if somes settings exists for that in field descriptor. - } - - /** - * @see java.sql.ResultSetMetaData#isWritable(int) - */ - @Override public boolean isWritable(int column) { - logStep("isWritable", column); - return true; // TODO Check if somes settings exists for that in field descriptor. - } - - /** - * @see java.sql.ResultSetMetaData#isDefinitelyWritable(int) - */ - @Override public boolean isDefinitelyWritable(int column) { - logStep("isDefinitelyWritable", column); - return true; // TODO Check if somes settings exists for that in field descriptor. - } - - /** - * @see java.sql.ResultSetMetaData#getColumnClassName(int) - * @throws SQLFeatureNotSupportedException if underlying class implementing a type isn't currently set. - * @throws SQLIllegalColumnIndexException if the column index is illegal. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override public String getColumnClassName(int column) throws SQLFeatureNotSupportedException, SQLIllegalColumnIndexException, SQLConnectionClosedException { - logStep("getColumnClassName", column); - - try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) { - switch(rsDatabase.getString("TYPE_NAME")) { - case "AUTO_INCREMENT": - return Integer.class.getName(); - - case "CHAR": - return String.class.getName(); - - case "INTEGER": - return Integer.class.getName(); - - case "DATE": - return java.sql.Date.class.getName(); - - case "DOUBLE": - return Double.class.getName(); - - case "FLOAT": - return Float.class.getName(); - - case "DECIMAL": - return Double.class.getName(); - - case "BOOLEAN": - return Boolean.class.getName(); - - case "CURRENCY": - return Double.class.getName(); - - case "DATETIME": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime"); - - case "TIMESTAMP": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp"); - - case "MEMO": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo"); - - case "PICTURE": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture"); - - case "VARIFIELD": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField"); - - case "VARIANT": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant"); - - case "UNKNOWN": - 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); - } - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#getInterface() - */ - @Override protected Class getInterface() { - return ResultSetMetaData.class; - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#getFile() - */ - @Override - protected File getFile() { - return this.rs.getFile(); - } - - /** - * Returns a ResultSet set on the wished column. - * @param column Column. - * @return ResultSet describing to wished column? - * @throws SQLIllegalColumnIndexException if the column index is out of bounds. - * @throws SQLConnectionClosedException if the underlying connection is closed. - */ - private DBFBuiltInMemoryResultSetForColumnsListing desc(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException { - DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = (DBFBuiltInMemoryResultSetForColumnsListing)this.metadata.getColumns(null, null, null, null); - - if (column > getColumnCount()) { - rsDatabase.close(); - String message = format(Level.WARNING, "excp.illegal_column_index_metadata", column, getColumnCount()); - throw new SQLIllegalColumnIndexException(message, this.rs.getSQL(), getFile(), column); - } - - // TODO Implements ResultSet:absolute(int) instead. - for(int index=1; index <= column; index ++) { - try { - rsDatabase.next(); - } - 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()); - throw new RuntimeException(message, e); - } - } - - return rsDatabase; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/package-info.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/package-info.java deleted file mode 100644 index 68e310daee8..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Metadata classes and dedicated forged ResultSets for JDBC DBase 3 driver. - */ -package org.apache.sis.internal.shapefile.jdbc.metadata; diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java deleted file mode 100644 index fc8155d1fb4..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Allows access to the DBase3 part of a shapefile through JDBC driver. - * Many exceptions are declared inside this package, to help trouble descriptions and permit precise unit tests. - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -package org.apache.sis.internal.shapefile.jdbc; diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java deleted file mode 100644 index 5e39543eab6..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.java +++ /dev/null @@ -1,707 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.io.InputStream; -import java.io.Reader; -import java.math.BigDecimal; -import java.net.URL; -import java.sql.*; -import java.util.Calendar; -import java.util.Map; - -import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC; - - -/** - * Holds all the unimplemented feature of a {@code ResultSet}. - * This is in order to avoid having a ResultSet implementation of thousand lines and unreadable. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Connection default values
Property Value
{@link #getType()} {@link Statement#getResultSetType()}
{@link #getConcurrency()} {@link Statement#getResultSetConcurrency()}
{@link #getHoldability()} {@link Statement#getResultSetHoldability()}
{@link #getFetchDirection()} {@link Statement#getFetchDirection()}
{@link #getFetchSize()} {@link Statement#getFetchSize()}
{@link #isBeforeFirst()} Compute from {@link #getRow()}
{@link #isFirst()} Compute from {@link #getRow()}
{@link #relative(int)} Use {@link #absolute(int)}
{@link #beforeFirst()} Use {@link #absolute(int)}
{@link #first()} Use {@link #absolute(int)}
{@link #last()} Use {@link #absolute(int)}
{@link #afterLast()} Use {@link #absolute(int)}
{@link #previous()} Use {@link #relative(int)}
{@link #getNString(int)} {@link #getString(int)}
{@link #getNCharacterStream(int)} {@link #getCharacterStream(int)}
{@link #getWarnings()} {@code null}
{@link #clearWarnings()} Ignored
- * - * Furthermore, most methods expecting a column label of type {@code String} first invoke {@link #findColumn(String)}, - * then invoke the method of the same name expecting a column index as an {@code int}. - * - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public abstract class AbstractResultSet extends AbstractJDBC implements ResultSet { - /* - * Note to developers : this class only offers methods that return unsupported exceptions : methods that are not implemented anywhere. - * if any implementation is done, even a redirection to another class or method, please move the implementation on the next subclass. - */ - - /** - * Constructs a new {@code ResultSet} instance. - */ - public AbstractResultSet() { - } - - /** - * @see java.sql.ResultSet#getBoolean(java.lang.String) - */ - @Override - public boolean getBoolean(String columnLabel) throws SQLException { - throw unsupportedOperation("getBoolean", columnLabel); - } - - /** - * @see java.sql.ResultSet#getByte(java.lang.String) - */ - @Override - public byte getByte(String columnLabel) throws SQLException { - throw unsupportedOperation("getByte", columnLabel); - } - - /** - * @see java.sql.ResultSet#getBytes(java.lang.String) - */ - @Override - public byte[] getBytes(String columnLabel) throws SQLException { - throw unsupportedOperation("getBytes", columnLabel); - } - - /** - * @see java.sql.ResultSet#getTime(java.lang.String) - */ - @Override - public Time getTime(String columnLabel) throws SQLException { - throw unsupportedOperation("getTime", columnLabel); - } - - /** - * Unsupported by default. - */ - @Override - public void setFetchDirection(int direction) throws SQLException { - throw unsupportedOperation("setFetchDirection", direction); - } - - /** - * Unsupported by default. - */ - @Override - public void setFetchSize(int rows) throws SQLException { - throw unsupportedOperation("setFetchSize", rows); - } - - /** - * Unsupported by default. - */ - @Override - public String getCursorName() throws SQLException { - throw unsupportedOperation("getCursorName"); - } - - /** - * Retrieves the current row number (first row is 1). This method is unsupported by default. - * Implementing this method will allow {@link #relative(int)} and other methods to work with - * their default implementation. - */ - @Override - public int getRow() throws SQLException { - throw unsupportedOperation("getRow"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean isLast() throws SQLException { - throw unsupportedOperation("isLast"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean isAfterLast() throws SQLException { - throw unsupportedOperation("isAfterLast"); - } - - /** - * Moves the cursor to the given row number (first row is 1). - * Special cases: - *
    - *
  • Negative numbers move to an absolute row position with respect to the end of the result set.
  • - *
  • -1 moves on the last row.
  • - *
  • 0 moves the cursor before the first row.
  • - *
- * - * This method is unsupported by default. Implementing this method will allow - * {@link #relative(int)} and other methods to work with their default implementation. - * - * @return {@code true} if the cursor is on a row. - */ - @Override - public boolean absolute(int row) throws SQLException { - throw unsupportedOperation("absolute", row); - } - - /** - * Unsupported by default. - */ - @Override - public RowId getRowId(int columnIndex) throws SQLException { - throw unsupportedOperation("getRowId", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public boolean getBoolean(int columnIndex) throws SQLException { - throw unsupportedOperation("getBoolean", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public byte getByte(int columnIndex) throws SQLException { - throw unsupportedOperation("getByte", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public byte[] getBytes(int columnIndex) throws SQLException { - throw unsupportedOperation("getBytes", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public Date getDate(int columnIndex, Calendar cal) throws SQLException { - throw unsupportedOperation("getDate", columnIndex, cal); - } - - /** - * Unsupported by default. - */ - @Override - public Time getTime(int columnIndex) throws SQLException { - throw unsupportedOperation("getTime", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public Time getTime(int columnIndex, Calendar cal) throws SQLException { - throw unsupportedOperation("getTime", columnIndex, cal); - } - - /** - * Unsupported by default. - */ - @Override - public Timestamp getTimestamp(int columnIndex) throws SQLException { - throw unsupportedOperation("getTimestamp", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { - throw unsupportedOperation("getTimestamp", columnIndex, cal); - } - - /** - * Unsupported by default. - */ - @Override - public URL getURL(int columnIndex) throws SQLException { - throw unsupportedOperation("getURL", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public Array getArray(int columnIndex) throws SQLException { - throw unsupportedOperation("getArray", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public SQLXML getSQLXML(int columnIndex) throws SQLException { - throw unsupportedOperation("getSQLXML", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public Object getObject(int columnIndex) throws SQLException { - throw unsupportedOperation("getObject", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public Object getObject(int columnIndex, Map> map) throws SQLException { - throw unsupportedOperation("getObject", columnIndex, map); - } - - /** - * Unsupported by default. - */ - @Override - public T getObject(int columnIndex, Class type) throws SQLException { - throw unsupportedOperation("getObject", columnIndex, type); - } - - /** - * Unsupported by default. - */ - @Override - public Ref getRef(int columnIndex) throws SQLException { - throw unsupportedOperation("getRef", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public Blob getBlob(int columnIndex) throws SQLException { - throw unsupportedOperation("getBlob", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public Clob getClob(int columnIndex) throws SQLException { - throw unsupportedOperation("getClob", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public NClob getNClob(int columnIndex) throws SQLException { - throw unsupportedOperation("getNClob", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public NClob getNClob(String columnLabel) throws SQLException { - throw unsupportedOperation("getNClob", columnLabel); - } - - /** - * Unsupported by default. - */ - @Override - public InputStream getAsciiStream(int columnIndex) throws SQLException { - throw unsupportedOperation("getAsciiStream", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public Reader getCharacterStream(int columnIndex) throws SQLException { - throw unsupportedOperation("getCharacterStream", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - @Deprecated - public InputStream getUnicodeStream(int columnIndex) throws SQLException { - throw unsupportedOperation("getUnicodeStream", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public InputStream getBinaryStream(int columnIndex) throws SQLException { - throw unsupportedOperation("getBinaryStream", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public void updateNull(int columnIndex) throws SQLException { - throw unsupportedOperation("updateNull", columnIndex); - } - - /** - * Unsupported by default. - */ - @Override - public void updateRowId(int columnIndex, RowId x) throws SQLException { - throw unsupportedOperation("updateRowId", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateString(int columnIndex, String x) throws SQLException { - throw unsupportedOperation("updateString", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateBoolean(int columnIndex, boolean x) throws SQLException { - throw unsupportedOperation("updateBoolean", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateByte(int columnIndex, byte x) throws SQLException { - throw unsupportedOperation("updateByte", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateBytes(int columnIndex, byte[] x) throws SQLException { - throw unsupportedOperation("updateBytes", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateShort(int columnIndex, short x) throws SQLException { - throw unsupportedOperation("updateShort", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateInt(int columnIndex, int x) throws SQLException { - throw unsupportedOperation("updateInt", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateLong(int columnIndex, long x) throws SQLException { - throw unsupportedOperation("updateLong", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateFloat(int columnIndex, float x) throws SQLException { - throw unsupportedOperation("updateFloat", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateDouble(int columnIndex, double x) throws SQLException { - throw unsupportedOperation("updateDouble", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { - throw unsupportedOperation("updateBigDecimal", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateDate(int columnIndex, Date x) throws SQLException { - throw unsupportedOperation("updateDate", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateTime(int columnIndex, Time x) throws SQLException { - throw unsupportedOperation("updateTime", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { - throw unsupportedOperation("updateTimestamp", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateArray(int columnIndex, Array x) throws SQLException { - throw unsupportedOperation("updateArray", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateObject(int columnIndex, Object x) throws SQLException { - throw unsupportedOperation("updateObject", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { - throw unsupportedOperation("updateObject", columnIndex, x, scaleOrLength); - } - - /** - * Unsupported by default. - */ - @Override - public void updateSQLXML(int columnIndex, SQLXML x) throws SQLException { - throw unsupportedOperation("updateSQLXML", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateRef(int columnIndex, Ref x) throws SQLException { - throw unsupportedOperation("updateRef", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateBlob(int columnIndex, Blob x) throws SQLException { - throw unsupportedOperation("updateBlob", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException { - throw unsupportedOperation("updateBlob", columnIndex, inputStream, length); - } - - /** - * Unsupported by default. - */ - @Override - public void updateClob(int columnIndex, Clob x) throws SQLException { - throw unsupportedOperation("updateClob", columnIndex, x); - } - - /** - * @see java.sql.ResultSet#updateClob(int, java.io.Reader, long) - */ - @Override - public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { - throw unsupportedOperation("updateClob", columnIndex, reader, length); - } - - /** - * Unsupported by default. - */ - @Override - public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { - throw unsupportedOperation("updateAsciiStream", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { - throw unsupportedOperation("updateAsciiStream", columnIndex, x, length); - } - - /** - * Unsupported by default. - */ - @Override - public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { - throw unsupportedOperation("updateCharacterStream", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { - throw unsupportedOperation("updateCharacterStream", columnIndex, x, length); - } - - - /** - * Unsupported by default. - */ - @Override - public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { - throw unsupportedOperation("updateBinaryStream", columnIndex, x); - } - - - /** - * Unsupported by default. - */ - @Override - public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { - throw unsupportedOperation("updateBinaryStream", columnIndex, x, length); - } - - /** - * Unsupported by default. - */ - @Override - public void updateBlob(int columnIndex, InputStream x) throws SQLException { - throw unsupportedOperation("updateBlob", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void updateClob(int columnIndex, Reader x) throws SQLException { - throw unsupportedOperation("updateClob", columnIndex, x); - } - - /** - * Unsupported by default. - */ - @Override - public void insertRow() throws SQLException { - throw unsupportedOperation("insertRow"); - } - - /** - * Unsupported by default. - */ - @Override - public void updateRow() throws SQLException { - throw unsupportedOperation("updateRow"); - } - - /** - * Unsupported by default. - */ - @Override - public void deleteRow() throws SQLException { - throw unsupportedOperation("deleteRow"); - } - - /** - * Unsupported by default. - */ - @Override - public void refreshRow() throws SQLException { - throw unsupportedOperation("refreshRow"); - } - - /** - * Unsupported by default. - */ - @Override - public void cancelRowUpdates() throws SQLException { - throw unsupportedOperation("cancelRowUpdates"); - } - - /** - * Unsupported by default. - */ - @Override - public void moveToInsertRow() throws SQLException { - throw unsupportedOperation("moveToInsertRow"); - } - - /** - * Unsupported by default. - */ - @Override - public void moveToCurrentRow() throws SQLException { - throw unsupportedOperation("moveToCurrentRow"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean rowUpdated() throws SQLException { - throw unsupportedOperation("rowUpdated"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean rowInserted() throws SQLException { - throw unsupportedOperation("rowInserted"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean rowDeleted() throws SQLException { - throw unsupportedOperation("rowDeleted"); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/BuiltInMemoryResultSet.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/BuiltInMemoryResultSet.java deleted file mode 100644 index 91a11c4c7a4..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/BuiltInMemoryResultSet.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.math.BigDecimal; -import java.sql.Date; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; - -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; - - -/** - * This Base ResultSet is only used for Descriptions function (getTables(..) and others functions in in Metadata). - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public abstract class BuiltInMemoryResultSet extends DBFResultSet { - /** - * Construct a ResultSet for descriptions. - * @param stmt Statement. - * @param sqlQuery SQLQuery. - */ - public BuiltInMemoryResultSet(DBFStatement stmt, String sqlQuery) { - super(stmt, sqlQuery); - } - - /** - * @see java.sql.ResultSet#getBigDecimal(java.lang.String, int) - * @deprecated Deprecated API (from ResultSet Interface) - */ - @Deprecated @Override - public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { - throw unsupportedOperation("BigDecimal", columnLabel, scale); - } - - /** - * @see java.sql.ResultSet#getBigDecimal(int) - */ - @Override - public BigDecimal getBigDecimal(int columnIndex) throws SQLException { - return getBigDecimal(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getBigDecimal(java.lang.String) - */ - @Override - public BigDecimal getBigDecimal(String columnLabel) throws SQLException { - throw unsupportedOperation("getBigDecimal", columnLabel); - } - - /** - * @see java.sql.ResultSet#getDate(int) - */ - @Override - public Date getDate(int columnIndex) throws SQLException { - return getDate(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getDate(java.lang.String) - */ - @Override - public Date getDate(String columnLabel) throws SQLException { - throw unsupportedOperation("getDate", columnLabel); - } - - /** - * @see java.sql.ResultSet#getDouble(java.lang.String) - */ - @Override - public double getDouble(String columnLabel) throws SQLException { - throw unsupportedOperation("getDouble", columnLabel); - } - - /** - * @see java.sql.ResultSet#getDouble(int) - */ - @Override - public double getDouble(int columnIndex) throws SQLException { - return getDouble(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getFloat(int) - */ - @Override - public float getFloat(int columnIndex) throws SQLException { - return getFloat(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getFloat(java.lang.String) - */ - @Override - public float getFloat(String columnLabel) throws SQLException { - throw unsupportedOperation("getFloat", columnLabel); - } - - /** - * @see java.sql.ResultSet#getInt(java.lang.String) - */ - @Override - public int getInt(String columnLabel) throws SQLException { - throw unsupportedOperation("getInt", columnLabel); - } - - /** - * @see java.sql.ResultSet#getInt(int) - */ - @Override - public int getInt(int columnIndex) throws SQLException { - return getInt(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getLong(java.lang.String) - */ - @Override public long getLong(String columnLabel) throws SQLException { - throw unsupportedOperation("getLong", columnLabel); - } - - /** - * @see java.sql.ResultSet#getLong(int) - */ - @Override public long getLong(int columnIndex) throws SQLException { - return getLong(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getShort(java.lang.String) - */ - @Override public short getShort(String columnLabel) throws SQLException { - throw unsupportedOperation("getShort", columnLabel); - } - - /** - * @see java.sql.ResultSet#getShort(int) - */ - @Override - public short getShort(int columnIndex) throws SQLException { - return getShort(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getString(java.lang.String) - */ - @Override public String getString(String columnLabel) throws SQLException { - throw unsupportedOperation("getString", columnLabel); - } - - /** - * @see java.sql.ResultSet#getString(int) - */ - @Override - public String getString(int columnIndex) throws SQLException { - return(getString(getFieldName(columnIndex, this.sql))); - } - - /** - * @see java.sql.ResultSet#getMetaData() - */ - @Override public ResultSetMetaData getMetaData() throws SQLException { - throw unsupportedOperation("getMetaData"); - } - - /** - * Returns the table name. - * @return Table Name. - */ - protected String getTableName() { - // The table default to the file name (without its extension .dbf). - String fileName = getFile().getName(); - int indexDBF = fileName.lastIndexOf("."); - String tableName = fileName.substring(0, indexDBF); - - return tableName; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForCatalogNamesListing.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForCatalogNamesListing.java deleted file mode 100644 index 9e211db7ffe..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForCatalogNamesListing.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; - - -/** - * Special ResultSet listing tables types contained in this DBase 3 (none). - * @author Marc LE BIHAN - */ -public class DBFBuiltInMemoryResultSetForCatalogNamesListing extends BuiltInMemoryResultSet { - /** - * Construct a ResultSet listing the catalog names of a database. - * @param stmt Statement. - */ - public DBFBuiltInMemoryResultSetForCatalogNamesListing(DBFStatement stmt) { - super(stmt, "driver list catalog names"); - } - - /** - * @see java.sql.ResultSet#next() - */ - @Override public boolean next() { - logStep("next"); - return false; - } - - /** - * @see java.sql.ResultSet#wasNull() - */ - @Override - public boolean wasNull() { - logStep("wasNull"); - return true; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java deleted file mode 100644 index de9a111edea..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java +++ /dev/null @@ -1,460 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.sql.DatabaseMetaData; -import java.sql.Types; -import java.text.MessageFormat; -import java.util.Iterator; -import java.util.List; -import java.util.logging.Level; - -import org.apache.sis.internal.shapefile.jdbc.DBase3FieldDescriptor; -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; - -/** - * Special ResultSet listing columns contained in this DBase 3. - * @author Marc LE BIHAN - */ -public class DBFBuiltInMemoryResultSetForColumnsListing extends BuiltInMemoryResultSet { - /** Current field descriptor. */ - private DBase3FieldDescriptor current; - - /** Iterator. */ - private Iterator itDescriptor; - - /** Column index. */ - private int columnIndex; - - /** Indicates if the ResultSet is set after the last record. */ - private boolean afterLast = false; - - /** - * Construct a ResultSet. - * @param stmt Statement. - * @param fieldsDescriptors Fields descriptors. - */ - public DBFBuiltInMemoryResultSetForColumnsListing(DBFStatement stmt, List fieldsDescriptors) { - super(stmt, "driver list columns in this DBase 3 file"); - this.itDescriptor = fieldsDescriptors.iterator(); - } - - /** - * @see java.sql.ResultSet#getString(java.lang.String) - * @throws SQLNoSuchFieldException if the column does not exist. - */ - @Override public String getString(String columnLabel) throws SQLNoSuchFieldException { - logStep("getString", columnLabel); - - switch(columnLabel) { - // String => table name - case "TABLE_NAME": { - String tableName = getTableName(); - this.wasNull = (tableName == null); - return tableName; - } - - // String => 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 - case "TYPE_NAME": { - String typeName = this.current.getType() != null ? toColumnTypeName() : null; - this.wasNull = (typeName == null); - return typeName; - } - - /** - * Columns responding to features that aren't handled by DBase 3. - * and return always a default value NULL or "NO"... - */ - - // String => table catalog (may be null) - case "TABLE_CAT": { - this.wasNull = true; - return null; - } - - // String => table schema (may be null) - case "TABLE_SCHEM": { - this.wasNull = true; - return null; - } - - // String => comment describing column (may be null) - 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) - 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) - 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) - 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) - case "SCOPE_TABLE": { - this.wasNull = true; - return null; - } - - /** - * String => Indicates whether this column is auto incremented - * YES --- if the column is auto incremented - * NO --- if the column is not auto incremented - * empty string --- if it cannot be determined whether the column is auto incremented - */ - case "IS_AUTOINCREMENT": { - this.wasNull = false; - return "NO"; - } - - /** - * String => Indicates whether this is a generated column - * YES --- if this a generated column - * NO --- if this not a generated column - * empty string --- if it cannot be determined whether this is a generated column - */ - case "IS_GENERATEDCOLUMN": { - this.wasNull = false; - return "NO"; - } - - 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. - } - } - } - - /** - * @see java.sql.ResultSet#getInt(java.lang.String) - * @throws SQLNoSuchFieldException if the column does not exist. - */ - @Override public int getInt(String columnLabel) throws SQLNoSuchFieldException { - logStep("getInt", columnLabel); - - switch(columnLabel) { - // int => SQL type from java.sql.Types - case "DATA_TYPE": { - this.wasNull = false; - return toSQLDataType(); - } - - // int => 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. - case "DECIMAL_DIGITS": { - int scale = toScale(); - this.wasNull = toScale() == -1; - return scale == -1 ? 0 : scale; - } - - // int => Radix (typically either 10 or 2) - case "NUM_PREC_RADIX": { - return 10; - } - - /** - * int => is NULL allowed. - * columnNoNulls - might not allow NULL values - * columnNullable - definitely allows NULL values - * columnNullableUnknown - nullability unknown - */ - case "NULLABLE": { - this.wasNull = false; - return DatabaseMetaData.columnNullableUnknown; - } - - // int => unused - case "SQL_DATA_TYPE": { - this.wasNull = false; - return toSQLDataType(); - } - - // int => for char types the maximum number of bytes in the column - case "CHAR_OCTET_LENGTH": { - if (toSQLDataType() == Types.CHAR) { - return toPrecision(); - } - - return 0; - } - - // int => index of column in table (starting at 1) - case "ORDINAL_POSITION": { - return this.columnIndex; - } - - /** - * Columns responding to features that aren't handled by DBase 3. - * and return always a default value NULL or "NO"... - */ - - // 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) - case "SOURCE_DATA_TYPE": { - this.wasNull = true; - return 0; - } - - // is not used. - case "BUFFER_LENGTH": { - this.wasNull = false; - return 0; - } - - // int => unused - case "SQL_DATETIME_SUB": { - this.wasNull = false; - return 0; - } - - 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); - } - } - - /** - * @see java.sql.ResultSet#next() - */ - @Override public boolean next() throws SQLNoResultException { - if (this.itDescriptor.hasNext()) { - this.current = this.itDescriptor.next(); - this.columnIndex ++; - return true; - } - else { - if (this.afterLast) { - // The ResultSet has no more records and has been call one time too much. - this.afterLast = true; - - String message = format(Level.WARNING, "excp.no_more_desc", getTableName()); - throw new SQLNoResultException(message, "asking columns desc", getFile()); - } - else { - return false; - } - } - } - - /** - * Returns the SQL Datatype of the DBase 3 type for the current field. - * @return SQL Datatype. - */ - private int toSQLDataType() { - switch(this.current.getType()) { - case AutoIncrement: - return Types.INTEGER; - - case Character: - return Types.CHAR; - - case Integer: - return Types.INTEGER; - - case Date: - return Types.DATE; - - case Double: - return Types.DOUBLE; - - case FloatingPoint: - return Types.FLOAT; - - case Number: - return Types.DECIMAL; - - case Logical: - return Types.BOOLEAN; - - case Currency: - return Types.NUMERIC; - - case DateTime: - return Types.TIMESTAMP; // TODO : I think ? - - case TimeStamp: - return Types.TIMESTAMP; - - case Memo: - return Types.BLOB; - - case Picture: - return Types.BLOB; - - case VariField: - return Types.OTHER; - - case Variant: - return Types.OTHER; - - default: - return Types.OTHER; - } - } - - /** - * Returns the column type name of the current field. - * @return Column type name. - */ - private String toColumnTypeName() { - switch(this.current.getType()) { - case AutoIncrement: - return "AUTO_INCREMENT"; - - case Character: - return "CHAR"; - - case Integer: - return "INTEGER"; - - case Date: - return "DATE"; - - case Double: - return "DOUBLE"; - - case FloatingPoint: - return "FLOAT"; - - case Number: - return "DECIMAL"; - - case Logical: - return "BOOLEAN"; - - case Currency: - return "CURRENCY"; - - case DateTime: - return "DATETIME"; - - case TimeStamp: - return "TIMESTAMP"; - - case Memo: - return "MEMO"; - - case Picture: - return "PICTURE"; - - case VariField: - return "VARIFIELD"; - - case Variant: - return "VARIANT"; - - default: - return "UNKNOWN"; - } - } - - /** - * Returns the precision of the current field. - * @return Precision of the current field. - */ - public int toPrecision() { - switch(this.current.getType()) { - case AutoIncrement: - case Character: - case Integer: - return this.current.getLength(); - - case Date: - return 8; - - case Double: - case FloatingPoint: - case Number: - return this.current.getLength(); - - case Logical: - return 0; - - case Currency: - case DateTime: - case TimeStamp: - return this.current.getLength(); - - case Memo: - case Picture: - case VariField: - case Variant: - return 0; - - default: - return this.current.getLength(); - } - } - - /** - * Returns the scale of the current field. - * @return Scale of the current field, -1 means : this field is not numeric. - */ - private int toScale() { - switch(this.current.getType()) { - case AutoIncrement: - case Logical: - return 0; - - case Integer: - case Double: - case FloatingPoint: - case Number: - case Currency: - return this.current.getDecimalCount(); - - case Character: - case Date: - case DateTime: - case TimeStamp: - case Memo: - case Picture: - case VariField: - case Variant: - return -1; - - default: - return -1; - } - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForSchemaListing.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForSchemaListing.java deleted file mode 100644 index 69301e2f2ee..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForSchemaListing.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; - - -/** - * Special ResultSet listing schemas contained in this DBase 3 (they are none). - * @author Marc LE BIHAN - */ -public class DBFBuiltInMemoryResultSetForSchemaListing extends BuiltInMemoryResultSet { - /** - * Construct a ResultSet listing the tables of a database. - * @param stmt Statement. - */ - public DBFBuiltInMemoryResultSetForSchemaListing(DBFStatement stmt) { - super(stmt, "driver list schemas in this DBase file"); - } - - /** - * @see java.sql.ResultSet#next() - */ - @Override public boolean next() { - logStep("next"); - return false; - } - - /** - * @see java.sql.ResultSet#wasNull() - */ - @Override - public boolean wasNull() { - logStep("wasNull"); - return true; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java deleted file mode 100644 index 6b0cb607de5..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.util.logging.Level; - -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; - -/** - * Special ResultSet listing tables contained in this DBase 3 (a single table). - * @author Marc LE BIHAN - */ -public class DBFBuiltInMemoryResultSetForTablesListing extends BuiltInMemoryResultSet { - /** There's only one result in this ResultSet. */ - private int index = 0; - - /** - * Construct a ResultSet. - * @param stmt Statement. - */ - public DBFBuiltInMemoryResultSetForTablesListing(DBFStatement stmt) { - super(stmt, "driver list tables in this DBase 3 file"); - } - - /** - * @see java.sql.ResultSet#getString(java.lang.String) - */ - @Override public String getString(String columnLabel) { - logStep("getString", columnLabel); - - switch(columnLabel) { - case "TABLE_NAME": // String => table name. - { - String tableName = getTableName(); - this.wasNull = (tableName == null); - return tableName; - } - - case "TABLE_TYPE": // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". - this.wasNull = false; - return "TABLE"; - - 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; - - default: - this.wasNull = true; - return null; - } - } - - /** - * @see java.sql.ResultSet#next() - */ - @Override public boolean next() throws SQLNoResultException - { - logStep("next"); - - if (this.index > 1) { - throw new SQLNoResultException(format(Level.WARNING, "excp.only_one_table_per_dbf"), "Driver manager asks for table listing", getFile()); - } - - this.index ++; - return (this.index == 1) ? true : false; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java deleted file mode 100644 index 60676c9ef5f..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.util.logging.Level; - -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; - -/** - * Special ResultSet listing tables types contained in this DBase 3 (only tables). - * @author Marc LE BIHAN - */ -public class DBFBuiltInMemoryResultSetForTablesTypesListing extends BuiltInMemoryResultSet { - /** There's only one result in this ResultSet. */ - private int index = 0; - - /** - * Construct a ResultSet listing the tables types of a database. - * @param stmt Statement. - */ - public DBFBuiltInMemoryResultSetForTablesTypesListing(DBFStatement stmt) { - super(stmt, "driver list tables types handled by DBase 3"); - } - - /** - * @see java.sql.ResultSet#getString(java.lang.String) - */ - @Override public String getString(String columnLabel) { - logStep("getString", columnLabel); - - 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"; - - 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. - - default: - this.wasNull = true; - return null; - } - } - - /** - * @see java.sql.ResultSet#next() - */ - @Override public boolean next() throws SQLNoResultException - { - logStep("next"); - - if (this.index > 1) { - throw new SQLNoResultException(format(Level.WARNING, "excp.only_one_table_type_handled"), "Driver manager asks for table types listing", getFile()); - } - - this.index ++; - return (this.index == 1) ? true : false; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java deleted file mode 100644 index 47514167d49..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java +++ /dev/null @@ -1,609 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.math.BigDecimal; -import java.math.MathContext; -import java.math.RoundingMode; -import java.nio.charset.Charset; -import java.sql.Date; -import java.sql.ResultSetMetaData; -import java.sql.SQLFeatureNotSupportedException; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.Map; -import java.util.function.Function; -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.metadata.DBFResultSetMataData; -import org.apache.sis.internal.shapefile.jdbc.sql.*; -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; - -/** - * A ResultSet based on a record. - * @author Marc LE BIHAN - */ -public class DBFRecordBasedResultSet extends DBFResultSet { - /** The current record. */ - private Map record; - - /** Condition of where clause (currently, only one is handled). */ - private ConditionalClauseResolver singleConditionOfWhereClause; - - /** 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. - * @param sqlQuery SQL Statment that produced this ResultSet. - * @throws SQLInvalidStatementException if the SQL Statement is invalid. - */ - public DBFRecordBasedResultSet(final DBFStatement stmt, String sqlQuery) throws SQLInvalidStatementException { - super(stmt, sqlQuery); - this.singleConditionOfWhereClause = new CrudeSQLParser(this).parse(); - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.resultset.AbstractResultSet#getBigDecimal(java.lang.String) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - */ - @Override - public BigDecimal getBigDecimal(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException { - logStep("getBigDecimal", columnLabel); - - assertNotClosed(); - - // Act as if we were a double, but store the result in a pre-created BigDecimal at the end. - try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql)) { - MathContext mc = new MathContext(field.getInt("DECIMAL_DIGITS"), RoundingMode.HALF_EVEN); - Double doubleValue = getDouble(columnLabel); - - if (doubleValue != null) { - BigDecimal number = new BigDecimal(doubleValue, mc); - this.wasNull = false; - return number; - } - else { - this.wasNull = true; - return null; - } - } - } - - /** - * @see java.sql.ResultSet#getBigDecimal(int) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - * @throws SQLIllegalColumnIndexException if the column index has an illegal value. - */ - @Override - public BigDecimal getBigDecimal(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException { - logStep("getBigDecimal", columnIndex); - return getBigDecimal(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getBigDecimal(java.lang.String, int) - * @deprecated Deprecated API (from ResultSet Interface) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - */ - @Deprecated @Override - public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException { - logStep("getBigDecimal", columnLabel, scale); - assertNotClosed(); - - // Act as if we were a double, but store the result in a pre-created BigDecimal at the end. - MathContext mc = new MathContext(scale, RoundingMode.HALF_EVEN); - Double doubleValue = getDouble(columnLabel); - - if (doubleValue != null) { - BigDecimal number = new BigDecimal(getDouble(columnLabel), mc); - this.wasNull = false; - return number; - } - else { - this.wasNull = true; - return null; - } - } - - /** - * @see java.sql.ResultSet#getDate(java.lang.String) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotDateException if the field is not a date. - */ - @Override - public Date getDate(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotDateException { - logStep("getDate", columnLabel); - assertNotClosed(); - - String value = getString(columnLabel); - - if (value == null || value.equals("00000000")) { // "00000000" is stored in Database to represent a null value too. - this.wasNull = true; - return null; // The ResultSet:getDate() contract is to return null when a null date is encountered. - } - else { - 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, this.sql, value); - throw new SQLNotDateException(message, this.sql, getFile(), columnLabel, value); - } - - // Extract the date parts. - int year, month, dayOfMonth; - - try { - year = Integer.parseInt(value.substring(0, 4)); - month = Integer.parseInt(value.substring(5, 7)); - dayOfMonth = Integer.parseInt(value.substring(7)); - } - catch(NumberFormatException e) { - 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. - Calendar calendar = new GregorianCalendar(year, month-1, dayOfMonth, 0, 0, 0); - Date sqlDate = new Date(calendar.getTimeInMillis()); - return sqlDate; - } - - /** - * @see java.sql.ResultSet#getDate(int) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotDateException if the field is not a date. - * @throws SQLIllegalColumnIndexException if the column index has an illegal value. - */ - @Override - public Date getDate(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotDateException, SQLIllegalColumnIndexException { - logStep("getDate", columnIndex); - return getDate(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getDouble(java.lang.String) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - */ - @Override - public double getDouble(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException { - logStep("getDouble", columnLabel); - - Double value = getNumeric(columnLabel, Double::parseDouble); - 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. - } - - /** - * @see java.sql.ResultSet#getDouble(int) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - * @throws SQLIllegalColumnIndexException if the column index has an illegal value. - */ - @Override - public double getDouble(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException { - logStep("getDouble", columnIndex); - return getDouble(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getFloat(java.lang.String) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - */ - @Override - public float getFloat(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException { - logStep("getFloat", columnLabel); - - Float value = getNumeric(columnLabel, Float::parseFloat); - this.wasNull = (value == null); - return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered. - } - - /** - * @see java.sql.ResultSet#getFloat(int) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - * @throws SQLIllegalColumnIndexException if the column index has an illegal value. - */ - @Override - public float getFloat(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException { - logStep("getFloat", columnIndex); - return getFloat(getFieldName(columnIndex, this.sql)); - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.resultset.AbstractResultSet#getInt(java.lang.String) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - */ - @Override - public int getInt(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException { - logStep("getInt", columnLabel); - - Integer value = getNumeric(columnLabel, Integer::parseInt); - this.wasNull = (value == null); - return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered. - } - - /** - * @see java.sql.ResultSet#getInt(int) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - * @throws SQLIllegalColumnIndexException if the column index has an illegal value. - */ - @Override - public int getInt(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException { - logStep("getInt", columnIndex); - return getInt(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getLong(java.lang.String) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - */ - @Override - public long getLong(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException { - logStep("getLong", columnLabel); - - Long value = getNumeric(columnLabel, Long::parseLong); - this.wasNull = (value == null); - return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered. - } - - /** - * @see java.sql.ResultSet#getLong(int) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric. - * @throws SQLIllegalColumnIndexException if the column index has an illegal value. - */ - @Override public long getLong(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException { - logStep("getLong", columnIndex); - return getLong(getFieldName(columnIndex, this.sql)); - } - - /** - * @see java.sql.ResultSet#getMetaData() - */ - @Override - public ResultSetMetaData getMetaData() { - logStep("getMetaData"); - - DBFResultSetMataData meta = new DBFResultSetMataData(this); - return meta; - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.resultset.AbstractResultSet#getObject(int) - */ - @Override - public Object getObject(int column) throws SQLConnectionClosedException, SQLIllegalColumnIndexException, SQLFeatureNotSupportedException, SQLNoSuchFieldException, SQLNotNumericException, SQLNotDateException { - try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(column, this.sql)) { - String fieldType; - - try { - fieldType = field.getString("TYPE_NAME"); - } - catch(SQLNoSuchFieldException e) { - // This is an internal trouble because the field type must be found. - throw new RuntimeException(e.getMessage(), e); - } - - switch(fieldType) { - case "AUTO_INCREMENT": - case "INTEGER": - return getInt(column); - - case "CHAR": - return getString(column); - - case "DATE": - return getDate(column); - - 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 getInt(column); - else - return getLong(column); - } - - return getDouble(column); - } - - case "DOUBLE": - case "CURRENCY": - return getDouble(column); - - case "FLOAT": - return getFloat(column); - - case "BOOLEAN": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Boolean"); - - case "DATETIME": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime"); - - case "TIMESTAMP": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp"); - - case "MEMO": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo"); - - case "PICTURE": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture"); - - case "VARIFIELD": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField"); - - case "VARIANT": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant"); - - case "UNKNOWN": - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + fieldType); - - default: - throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + fieldType); - } - } - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.resultset.DBFResultSet#getObject(java.lang.String) - */ - @Override - public Object getObject(String columnLabel) throws SQLConnectionClosedException, SQLFeatureNotSupportedException, SQLNoSuchFieldException, SQLNotNumericException, SQLNotDateException { - int index = -1; - - try { - index = findColumn(columnLabel); - return getObject(index); - } - catch(SQLIllegalColumnIndexException e) { - String message = format(Level.SEVERE, "assert.wrong_index_for_column_name", index, columnLabel); - throw new RuntimeException(message, e); - } - } - - /** - * 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. - * @throws SQLNotNumericException if the field value is not numeric or has a NULL value. - */ - @Override - public short getShort(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException { - logStep("getShort", columnLabel); - - Short value = getNumeric(columnLabel, Short::parseShort); - this.wasNull = (value == null); - return value != null ? value : 0; // The ResultSet contract for numbers is to return 0 when a null value is encountered. - } - - /** - * @see java.sql.ResultSet#getShort(int) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric or has a NULL value. - * @throws SQLIllegalColumnIndexException if the column index has an illegal value. - */ - @Override - public short getShort(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLIllegalColumnIndexException { - logStep("getShort", columnIndex); - return getShort(getFieldName(columnIndex, this.sql)); - } - - /** - * Returns the value in the current row for the given column. - * @param columnLabel Column name. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field does not exist. - */ - @Override - @SuppressWarnings("resource") // Only read the current connection to get the Charset. - public String getString(String columnLabel) throws SQLConnectionClosedException, SQLNoSuchFieldException { - logStep("getString", columnLabel); - assertNotClosed(); - - 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) { - this.wasNull = true; - return null; - } - else { - this.wasNull = false; - } - - // 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); - } - else { - String withDatabaseCharset = new String(bytes, charset); - log(Level.FINER, "log.string_field_charset", columnLabel, withDatabaseCharset, charset); - return withDatabaseCharset; - } - } - - /** - * @see java.sql.ResultSet#getString(int) - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLIllegalColumnIndexException if the column index has an illegal value. - */ - @Override - public String getString(int columnIndex) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLIllegalColumnIndexException { - logStep("getString", columnIndex); - return(getString(getFieldName(columnIndex, this.sql))); - } - - /** - * Moves the cursor forward one row from its current position. - * @throws SQLInvalidStatementException if the SQL statement is invalid. - * @throws SQLIllegalParameterException if the value of one parameter of a condition is invalid. - * @throws SQLNoSuchFieldException if a field mentionned in the condition doesn't exist. - * @throws SQLUnsupportedParsingFeatureException if the caller asked for a not yet supported feature of the driver. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNotNumericException if a value or data expected to be numeric isn't. - * @throws SQLNotDateException if a value or data expected to be a date isn't. - */ - @Override - @SuppressWarnings("resource") // Only read the current connection to find if a next row is available and read it. - public boolean next() throws SQLNoResultException, SQLConnectionClosedException, SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLNotNumericException, SQLNotDateException { - logStep("next"); - assertNotClosed(); - - DBFConnection cnt = (DBFConnection)((DBFStatement)getStatement()).getConnection(); - - // 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", this.sql, getFile().getName()), this.sql, getFile()); - } - else { - this.lastResultSetRecordAlreadyReturned = true; - return false; - } - } - - return nextRecordMatchingConditions(); - } - - /** - * Find the next record that match the where condition. - * @return true if a record has been found. - * @throws SQLInvalidStatementException if the SQL statement is invalid. - * @throws SQLIllegalParameterException if the value of one parameter of a condition is invalid. - * @throws SQLNoSuchFieldException if a field mentionned in the condition doesn't exist. - * @throws SQLUnsupportedParsingFeatureException if the caller asked for a not yet supported feature of the driver. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNotNumericException if a value or data expected to be numeric isn't. - * @throws SQLNotDateException if a value or data expected to be a date isn't. - */ - @SuppressWarnings("resource") // Only read the current connection to find if a next row is available and read it. - private boolean nextRecordMatchingConditions() throws SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLConnectionClosedException, SQLNotNumericException, SQLNotDateException { - boolean recordMatchesConditions = false; - DBFConnection cnt = (DBFConnection)((DBFStatement)getStatement()).getConnection(); - - while(cnt.nextRowAvailable() && recordMatchesConditions == false) { - this.record = cnt.readNextRowAsObjects(); - this.recordNumber = cnt.getRowNum(); - recordMatchesConditions = this.singleConditionOfWhereClause == null || this.singleConditionOfWhereClause.isVerified(this); - } - - return recordMatchesConditions; - } - - /** - * @see java.sql.Wrapper#isWrapperFor(java.lang.Class) - */ - @Override - public boolean isWrapperFor(Class iface) { - logStep("isWrapperFor", iface); - return iface.isAssignableFrom(getInterface()); - } - - /** - * @see java.sql.ResultSet#wasNull() - */ - @Override - public boolean wasNull() { - logStep("wasNull"); - return this.wasNull; - } - - /** - * Get a numeric value. - * @param Type of the number. - * @param columnLabel Column Label. - * @param parse Parsing function : Integer.parseInt, Float.parseFloat, Long.parseLong, ... - * @return The expected value or null if null was encountered. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if the field looked for doesn't exist. - * @throws SQLNotNumericException if the field value is not numeric or has a NULL value. - */ - private T getNumeric(String columnLabel, Function parse) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException { - assertNotClosed(); - - try(DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, this.sql)) { - String textValue = getString(columnLabel); - - if (textValue == null) { - return null; - } - - try { - textValue = textValue.trim(); // Field must be trimed before being converted. - T value = parse.apply(textValue); - return(value); - } - catch(NumberFormatException e) { - 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); - } - } - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return format("toString", this.statement != null ? this.statement.toString() : null, this.sql, isClosed() == false); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java deleted file mode 100644 index 1e664a55bab..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java +++ /dev/null @@ -1,965 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.io.File; -import java.io.InputStream; -import java.io.Reader; -import java.math.BigDecimal; -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; - -/** - * Common implemented features of all ResultSets : those based on a record, but also those returning results forged in memory. - * @author Marc LE BIHAN - */ -public abstract class DBFResultSet extends AbstractResultSet { - /** Indicates if the ResultSet is closed. */ - protected boolean isClosed; - - /** SQL Statement. */ - protected String sql; - - /** true, if the last column had the SQL NULL value (for the ResultSet.wasNull() method). */ - protected boolean wasNull; - - /** Parent statement. */ - protected DBFStatement statement; - - /** - * Constructs a result set. - * @param stmt Parent statement. - * @param sqlQuery SQL Statment that produced this ResultSet. - */ - public DBFResultSet(final DBFStatement stmt, String sqlQuery) { - Objects.requireNonNull(stmt, "the statement referred by the ResultSet cannot be null."); - - this.statement = stmt; - this.sql = sqlQuery; - } - - /** - * Defaults to {@link #last()} followed by {@link #next()}. - */ - @Override - public void afterLast() throws SQLException { - if (last()) next(); - } - - /** - * Asserts that the connection, statement and result set are together opened. - * @throws SQLConnectionClosedException if one of them is closed. - */ - protected void assertNotClosed() throws SQLConnectionClosedException { - this.statement.assertNotClosed(); - - if (this.isClosed) { - throw new SQLConnectionClosedException(format(Level.WARNING, "excp.closed_resultset", this.sql, getFile().getName()), this.sql, getFile()); - } - } - - /** - * Defaults to {@link #absolute(int)}. - */ - @Override - public void beforeFirst() throws SQLException { - absolute(0); - } - - /** - * @see java.sql.ResultSet#close() - */ - @Override - public void close() { - if (isClosed()) - return; - - this.statement.notifyCloseResultSet(this); - this.isClosed = true; - } - - /** - * Returns the column index for the given column name. - * The default implementation of all methods expecting a column label will invoke this method. - * @param columnLabel The name of the column. - * @return The index of the given column name : first column is 1. - * @throws SQLNoSuchFieldException if there is no field with this name in the query. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override - @SuppressWarnings("resource") // The connection is only used to get the column index. - public int findColumn(String columnLabel) throws SQLNoSuchFieldException, SQLConnectionClosedException { - DBFConnection cnt = (DBFConnection)this.statement.getConnection(); - return cnt.findColumn(columnLabel, getSQL()); - } - - /** - * Defaults to {@link #absolute(int)}. - */ - @Override - public boolean first() throws SQLException { - return absolute(1); - } - - /** - * 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 Array getArray(String columnLabel) throws SQLException { - return getArray(findColumn(columnLabel)); - } - - /** - * 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 InputStream getAsciiStream(String columnLabel) throws SQLException { - return getAsciiStream(findColumn(columnLabel)); - } - - /** - * @deprecated Replaced by {@link #getBigDecimal(int)}. - * Defaults to {@link #getBigDecimal(int)} followed by {@link BigDecimal#setScale(int)}. - */ - @Override - @Deprecated - public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { - final BigDecimal d = getBigDecimal(columnIndex); - return (d != null) ? d.setScale(scale) : null; - } - - /** - * 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 InputStream getBinaryStream(String columnLabel) throws SQLException { - return getBinaryStream(findColumn(columnLabel)); - } - - /** - * 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 Blob getBlob(String columnLabel) throws SQLException { - return getBlob(findColumn(columnLabel)); - } - - /** - * 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 Reader getCharacterStream(String columnLabel) throws SQLException { - return getCharacterStream(findColumn(columnLabel)); - } - - /** - * 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 Clob getClob(String columnLabel) throws SQLException { - return getClob(findColumn(columnLabel)); - } - - /** - * Defaults to {@link Statement#getResultSetConcurrency()}. - */ - @Override - public int getConcurrency() throws SQLException { - return getStatement().getResultSetConcurrency(); - } - - /** - * 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 Date getDate(String columnLabel, Calendar cal) throws SQLException { - return getDate(findColumn(columnLabel), cal); - } - - /** - * Defaults to {@link Statement#getFetchDirection()}. - */ - @Override - public int getFetchDirection() throws SQLException { - return getStatement().getFetchDirection(); - } - - /** - * @see java.sql.ResultSet#getFetchSize() - */ - @Override - public int getFetchSize() throws SQLException { - return getStatement().getFetchSize(); - } - - /** - * Return a field name. - * @param columnIndex Column index. - * @param sqlStatement For information, the SQL statement that is attempted. - * @return Field Name. - * @throws SQLIllegalColumnIndexException if the index is out of bounds. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @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)this.statement.getConnection(); - return cnt.getFieldName(columnIndex, sqlStatement); - } - - /** - * Returns the Database File. - * @return Database File. - */ - @Override - public File getFile() { - return this.statement.getFile(); - } - - /** - * Defaults to {@link Statement#getResultSetHoldability()}. - */ - @Override - public int getHoldability() throws SQLException { - return getStatement().getResultSetHoldability(); - } - - /** - * Returns the JDBC interface implemented by this class. - * This is used for formatting error messages. - */ - @Override - public Class getInterface() { - return ResultSet.class; - } - - /** - * Defaults to {@link #getCharacterStream(int)} on the assumption that the fact that Java use UTF-16 internally - * makes the two methods identical in behavior. - */ - @Override - public Reader getNCharacterStream(int columnIndex) throws SQLException { - return getCharacterStream(columnIndex); - } - - /** - * 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 Reader getNCharacterStream(String columnLabel) throws SQLException { - return getNCharacterStream(findColumn(columnLabel)); - } - - /** - * Defaults to {@link #getString(int)} on the assumption that the fact that - * Java use UTF-16 internally makes the two methods identical in behavior. - */ - @Override - public String getNString(int columnIndex) throws SQLException { - return getString(columnIndex); - } - - /** - * 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 String getNString(String columnLabel) throws SQLException { - return getNString(findColumn(columnLabel)); - } - - /** - * 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 RowId getRowId(String columnLabel) throws SQLException { - return getRowId(findColumn(columnLabel)); - } - - /** - * 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 Time getTime(String columnLabel, Calendar cal) throws SQLException { - return getTime(findColumn(columnLabel), cal); - } - - /** - * 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 Timestamp getTimestamp(String columnLabel) throws SQLException { - return getTimestamp(findColumn(columnLabel)); - } - - /** - * 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 Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { - return getTimestamp(findColumn(columnLabel), cal); - } - - /** - * 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 URL getURL(String columnLabel) throws SQLException { - return getURL(findColumn(columnLabel)); - } - - /** - * @see java.sql.Wrapper#isWrapperFor(java.lang.Class) - */ - @Override - public boolean isWrapperFor(Class iface) { - return iface.isAssignableFrom(getInterface()); - } - - /** - * 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 Object getObject(String columnLabel) throws SQLException { - return getObject(findColumn(columnLabel)); - } - - /** - * 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 Object getObject(String columnLabel, Map> map) throws SQLException { - return getObject(findColumn(columnLabel), map); - } - - /** - * 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 getObject(String columnLabel, Class type) throws SQLException { - return getObject(findColumn(columnLabel), type); - } - - /** - * 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 Ref getRef(String columnLabel) throws SQLException { - return getRef(findColumn(columnLabel)); - } - - /** - * Returns the SQL query that created that ResultSet. - * @return SQL query. - */ - public String getSQL() { - return this.sql; - } - - /** - * 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 SQLXML getSQLXML(String columnLabel) throws SQLException { - return getSQLXML(findColumn(columnLabel)); - } - - /** - * Returns the parent statement. - * @throws SQLConnectionClosedException if the statement is closed. - */ - @Override - public Statement getStatement() throws SQLConnectionClosedException { - assertNotClosed(); - return this.statement; - } - - /** - * Defaults to {@link Statement#getResultSetType()}. - */ - @Override - public int getType() throws SQLException { - return getStatement().getResultSetType(); - } - - /** - * Defaults to the index-based version of this method. - * The given column name is mapped to a column index by {@link #findColumn(String)}. - */ - @Override - @Deprecated - public InputStream getUnicodeStream(String columnLabel) throws SQLException { - return getUnicodeStream(findColumn(columnLabel)); - } - - /** - * @see java.sql.ResultSet#isBeforeFirst() - */ - @Override - public boolean isBeforeFirst() throws SQLException { - return getRow() == 0; - } - - /** - * Returns {@code true} if this result set has been closed. - * @return true if the database is closed. - */ - @Override - public boolean isClosed() { - return this.isClosed || this.statement.isClosed(); - } - - /** - * @see java.sql.ResultSet#isFirst() - */ - @Override - public boolean isFirst() throws SQLException { - return getRow() == 1; - } - - /** - * Defaults to {@link #absolute(int)}. - */ - @Override - public boolean last() throws SQLException { - return absolute(-1); - } - - /** - * Defaults to {@link #relative(int)}. - */ - @Override - public boolean previous() throws SQLException { - return relative(-1); - } - - /** - * Defaults to {@link #absolute(int)} with an offset computed from {@link #getRow()}. - */ - @Override - public boolean relative(int rows) throws SQLException { - return absolute(rows - getRow()); - } - - /** - * 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 void updateArray(String columnLabel, Array x) throws SQLException { - updateArray(findColumn(columnLabel), x); - } - - /** - * 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 void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { - updateAsciiStream(findColumn(columnLabel), x); - } - - /** - * Delegates to {@link #updateAsciiStream(int, InputStream, long)} - */ - @Override - public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { - updateAsciiStream(columnIndex, x, (long) length); - } - - /** - * Delegates to {@link #updateAsciiStream(String, InputStream, long)} - */ - @Override - public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException { - updateAsciiStream(columnLabel, x, (long) length); - } - - /** - * 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 void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException { - updateAsciiStream(findColumn(columnLabel), x, length); - } - - /** - * 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 void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { - updateBigDecimal(findColumn(columnLabel), x); - } - - /** - * 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 void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { - updateBinaryStream(findColumn(columnLabel), x); - } - - /** - * Delegates to {@link #updateBinaryStream(int, InputStream, long)}. - */ - @Override - public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { - updateBinaryStream(columnIndex, x, (long) length); - } - - /** - * Delegates to {@link #updateBinaryStream(String, InputStream, long)}. - */ - @Override - public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException { - updateBinaryStream(columnLabel, x, (long) length); - } - - /** - * 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 void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException { - updateBinaryStream(findColumn(columnLabel), x, length); - } - - /** - * 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 void updateBlob(String columnLabel, Blob x) throws SQLException { - updateBlob(findColumn(columnLabel), x); - } - - /** - * 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 void updateBlob(String columnLabel, InputStream x, long length) throws SQLException { - updateBlob(findColumn(columnLabel), x, length); - } - - /** - * 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 void updateBlob(String columnLabel, InputStream x) throws SQLException { - updateBlob(findColumn(columnLabel), x); - } - - /** - * 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 void updateBoolean(String columnLabel, boolean x) throws SQLException { - updateBoolean(findColumn(columnLabel), x); - } - - /** - * 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 void updateByte(String columnLabel, byte x) throws SQLException { - updateByte(findColumn(columnLabel), x); - } - - /** - * 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 void updateBytes(String columnLabel, byte[] x) throws SQLException { - updateBytes(findColumn(columnLabel), x); - } - - /** - * 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 void updateCharacterStream(String columnLabel, Reader x) throws SQLException { - updateCharacterStream(findColumn(columnLabel), x); - } - - /** - * Delegates to {@link #updateCharacterStream(int, Reader, long)} - */ - @Override - public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { - updateCharacterStream(columnIndex, x, (long) length); - } - - /** - * Delegates to {@link #updateCharacterStream(String, Reader, long)} - */ - @Override - public void updateCharacterStream(String columnLabel, Reader x, int length) throws SQLException { - updateCharacterStream(columnLabel, x, (long) length); - } - - /** - * 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 void updateClob(String columnLabel, Clob x) throws SQLException { - updateClob(findColumn(columnLabel), x); - } - - /** - * 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 void updateClob(String columnLabel, Reader x, long length) throws SQLException { - updateClob(findColumn(columnLabel), x, length); - } - - /** - * 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 void updateClob(String columnLabel, Reader x) throws SQLException { - updateClob(findColumn(columnLabel), x); - } - - /** - * 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 void updateCharacterStream(String columnLabel, Reader x, long length) throws SQLException { - updateCharacterStream(findColumn(columnLabel), x, length); - } - - /** - * Defaults to {@link #updateCharacterStream(int, Reader)} on the assumption that the fact that - * Java use UTF-16 internally makes the two methods identical in behavior. - */ - @Override - public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { - updateCharacterStream(columnIndex, x); - } - - /** - * Defaults to {@link #updateCharacterStream(String, Reader)} on the assumption that the fact that - * Java use UTF-16 internally makes the two methods identical in behavior. - */ - @Override - public void updateNCharacterStream(String columnLabel, Reader x) throws SQLException { - updateCharacterStream(columnLabel, x); - } - - /** - * Defaults to {@link #updateCharacterStream(int, Reader, int)} on the assumption that the fact that - * Java use UTF-16 internally makes the two methods identical in behavior. - */ - @Override - public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { - updateCharacterStream(columnIndex, x, length); - } - - /** - * Defaults to {@link #updateCharacterStream(String, Reader, int)} on the assumption that the fact that - * Java use UTF-16 internally makes the two methods identical in behavior. - */ - @Override - public void updateNCharacterStream(String columnLabel, Reader x, long length) throws SQLException { - updateCharacterStream(columnLabel, x, length); - } - /** - * Defaults to {@link #updateClob(int, Clob)} on the assumption that the fact that Java use UTF-16 internally - * makes the two methods identical in behavior. - */ - @Override - public void updateNClob(int columnIndex, NClob x) throws SQLException { - updateClob(columnIndex, x); - } - - /** - * 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 void updateNClob(String columnLabel, NClob x) throws SQLException { - updateNClob(findColumn(columnLabel), x); - } - - /** - * Defaults to {@link #updateClob(int, Reader, long)} on the assumption that the fact that Java use UTF-16 internally - * makes the two methods identical in behavior. - */ - @Override - public void updateNClob(int columnIndex, Reader x, long length) throws SQLException { - updateClob(columnIndex, x, length); - } - - /** - * Defaults to {@link #updateClob(String, Reader, long)} on the assumption that the fact that Java use UTF-16 internally - * makes the two methods identical in behavior. - */ - @Override - public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { - updateClob(columnLabel, reader, length); - } - - /** - * Defaults to {@link #updateClob(int, Reader)} on the assumption that the fact that - * Java use UTF-16 internally makes the two methods identical in behavior. - */ - @Override - public void updateNClob(int columnIndex, Reader reader) throws SQLException { - updateClob(columnIndex, reader); - } - - /** - * Defaults to {@link #updateClob(String, Reader)} on the assumption that the fact that - * Java use UTF-16 internally makes the two methods identical in behavior. - */ - @Override - public void updateNClob(String columnLabel, Reader reader) throws SQLException { - updateClob(columnLabel, reader); - } - - /** - * 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 void updateDate(String columnLabel, Date x) throws SQLException { - updateDate(findColumn(columnLabel), x); - } - - /** - * 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 void updateDouble(String columnLabel, double x) throws SQLException { - updateDouble(findColumn(columnLabel), x); - } - - /** - * 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 void updateFloat(String columnLabel, float x) throws SQLException { - updateFloat(findColumn(columnLabel), x); - } - - /** - * 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 void updateInt(String columnLabel, int x) throws SQLException { - updateInt(findColumn(columnLabel), x); - } - - /** - * 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 void updateLong(String columnLabel, long x) throws SQLException { - updateLong(findColumn(columnLabel), x); - } - - /** - * 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 void updateNull(String columnLabel) throws SQLException { - updateNull(findColumn(columnLabel)); - } - - /** - * 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 void updateObject(String columnLabel, Object x) throws SQLException { - updateObject(findColumn(columnLabel), x); - } - - /** - * 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 void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { - updateObject(findColumn(columnLabel), x, scaleOrLength); - } - - /** - * 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 void updateRef(String columnLabel, Ref x) throws SQLException { - updateRef(findColumn(columnLabel), x); - } - - /** - * 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 void updateRowId(String columnLabel, RowId x) throws SQLException { - updateRowId(findColumn(columnLabel), x); - } - - /** - * 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 void updateShort(String columnLabel, short x) throws SQLException { - updateShort(findColumn(columnLabel), x); - } - - /** - * 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 void updateSQLXML(String columnLabel, SQLXML x) throws SQLException { - updateSQLXML(findColumn(columnLabel), x); - } - - /** - * 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 void updateString(String columnLabel, String x) throws SQLException { - updateString(findColumn(columnLabel), x); - } - - /** - * Defaults to {@link #updateString(int, String)} on the assumption that the fact that - * Java use UTF-16 internally makes the two methods identical in behavior. - */ - @Override - public void updateNString(int columnIndex, String nString) throws SQLException { - updateString(columnIndex, nString); - } - - /** - * Defaults to {@link #updateString(String, String)} on the assumption that the fact that - * Java use UTF-16 internally makes the two methods identical in behavior. - */ - @Override - public void updateNString(String columnLabel, String nString) throws SQLException { - updateString(columnLabel, nString); - } - - /** - * 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 void updateTime(String columnLabel, Time x) throws SQLException { - updateTime(findColumn(columnLabel), x); - } - - /** - * 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 void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { - updateTimestamp(findColumn(columnLabel), x); - } - - /** - * @see java.sql.ResultSet#wasNull() - */ - @Override - public boolean wasNull() { - return this.wasNull; - } - - /** - * Get a field description. - * @param columnLabel Column label. - * @param sqlStatement SQL Statement. - * @return ResultSet with current row set on the wished field. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLNoSuchFieldException if no column with that name exists. - */ - public ResultSet getFieldDesc(String columnLabel, String sqlStatement) throws SQLConnectionClosedException, SQLNoSuchFieldException { - return ((DBFConnection)((DBFStatement)getStatement()).getConnection()).getFieldDesc(columnLabel, sqlStatement); - } - - /** - * Get a field description. - * @param column Column index. - * @param sqlStatement SQL Statement. - * @return ResultSet with current row set on the wished field. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLIllegalColumnIndexException if the column index is out of bounds. - */ - public ResultSet getFieldDesc(int column, String sqlStatement) throws SQLConnectionClosedException, SQLIllegalColumnIndexException { - return ((DBFConnection)((DBFStatement)getStatement()).getConnection()).getFieldDesc(column, sqlStatement); - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return format("toString", this.statement != null ? this.statement.toString() : null, this.sql, isClosed() == false); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLIllegalColumnIndexException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLIllegalColumnIndexException.java deleted file mode 100644 index b8efa6b7900..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLIllegalColumnIndexException.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.io.File; -import java.sql.SQLException; - -/** - * Exception thrown when a column index is invalid. - * @author Marc LE BIHAN - */ -public class SQLIllegalColumnIndexException extends SQLException { - /** Serial ID. */ - private static final long serialVersionUID = 7525295716068215255L; - - /** The SQL Statement (if known). */ - private String sql; - - /** The database file. */ - private File database; - - /** Column Index that is invalid. */ - private int columnIndex; - - /** - * Build the exception. - * @param message Exception message. - * @param sqlStatement SQL Statement who encountered the trouble, if known. - * @param dbf The database that was queried. - * @param colIndex The column index that is invalid. - */ - public SQLIllegalColumnIndexException(String message, String sqlStatement, File dbf, int colIndex) { - super(message); - this.sql = sqlStatement; - this.database = dbf; - this.columnIndex = colIndex; - } - - /** - * Returns the SQL statement. - * @return SQL statement or null. - */ - public String getSQL() { - return this.sql; - } - - /** - * Returns the column index. - * @return Column index. - */ - public int getColumnIndex() { - return this.columnIndex; - } - - /** - * Returns the database file. - * @return Database file. - */ - public File getDatabase() { - return this.database; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoResultException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoResultException.java deleted file mode 100644 index 4756da3b3dc..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoResultException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.io.File; -import java.sql.SQLException; - -/** - * Exception thrown when there is no more result. - * @author Marc LE BIHAN - */ -public class SQLNoResultException extends SQLException { - /** Serial ID. */ - private static final long serialVersionUID = -6685966109486353932L; - - /** The SQL Statement that whas attempted. */ - private String sql; - - /** The database that was queried. */ - private File database; - - /** - * Build the exception. - * @param message Exception message. - * @param sqlStatement SQL Statement who encountered the trouble. - * @param dbf The database that was queried. - */ - public SQLNoResultException(String message, String sqlStatement, File dbf) { - super(message); - this.sql = sqlStatement; - this.database = dbf; - } - - /** - * Returns the SQL statement who encountered the "end of data" alert. - * @return SQL statement. - */ - public String getSQL() { - return this.sql; - } - - /** - * Returns the database file that was queried. - * @return The database that was queried. - */ - public File getDatabase() { - return this.database; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoSuchFieldException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoSuchFieldException.java deleted file mode 100644 index 337a8bbcd4a..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoSuchFieldException.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.io.File; -import java.sql.SQLException; - -/** - * Exception thrown when a column name is not found in a request or in the database structure. - * @author Marc LE BIHAN - */ -public class SQLNoSuchFieldException extends SQLException { - /** Serial ID. */ - private static final long serialVersionUID = 1118679516090878177L; - - /** The SQL Statement (if known). */ - private String sql; - - /** The database file. */ - private File database; - - /** Column name that doesn't exist. */ - private String columnName; - - /** - * Build the exception. - * @param message Exception message. - * @param sqlStatement SQL Statement who encountered the trouble, if known. - * @param dbf The database that was queried. - * @param colName The column name that doesn't exist. - */ - public SQLNoSuchFieldException(String message, String sqlStatement, File dbf, String colName) { - super(message); - this.sql = sqlStatement; - this.database = dbf; - this.columnName = colName; - } - - /** - * Returns the SQL statement. - * @return SQL statement or null. - */ - public String getSQL() { - return this.sql; - } - - /** - * Returns the column name that doesn't exist. - * @return Column name. - */ - public String getColumnName() { - return this.columnName; - } - - /** - * Returns the database file. - * @return Database file. - */ - public File getDatabase() { - return this.database; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotDateException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotDateException.java deleted file mode 100644 index 3baeefa228b..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotDateException.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.io.File; -import java.sql.SQLException; - -/** - * Exception thrown when a column value was expected to be a date but wasn't. - * @author Marc LE BIHAN - */ -public class SQLNotDateException extends SQLException { - /** Serial ID. */ - private static final long serialVersionUID = 848673127131548693L; - - /** The SQL Statement (if known). */ - private String sql; - - /** The database file. */ - private File database; - - /** Column name. */ - private String columnName; - - /** The value that is not numeric. */ - private String value; - - /** - * Build the exception. - * @param message Exception message. - * @param sqlStatement SQL Statement who encountered the trouble, if known. - * @param dbf The database that was queried. - * @param colName The column name that has a non numeric value. - * @param wrongValue The wrong value. - */ - public SQLNotDateException(String message, String sqlStatement, File dbf, String colName, String wrongValue) { - super(message); - this.sql = sqlStatement; - this.database = dbf; - this.columnName = colName; - this.value = wrongValue; - } - - /** - * Returns the SQL statement. - * @return SQL statement or null. - */ - public String getSQL() { - return this.sql; - } - - /** - * Returns the column name. - * @return Column name. - */ - public String getColumnName() { - return this.columnName; - } - - /** - * Returns the value that is not numeric. - * @return Value. - */ - public String getValue() { - return this.value; - } - - /** - * Returns the database file. - * @return Database file. - */ - public File getDatabase() { - return this.database; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotNumericException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotNumericException.java deleted file mode 100644 index 82afb4e3e3b..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotNumericException.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; - -import java.io.File; -import java.sql.SQLException; - -/** - * Exception thrown when a column value was expected numeric but wasn't. - * @author Marc LE BIHAN - */ -public class SQLNotNumericException extends SQLException { - /** Serial ID. */ - private static final long serialVersionUID = -1065338463289030584L; - - /** The SQL Statement (if known). */ - private String sql; - - /** The database file. */ - private File database; - - /** Column name. */ - private String columnName; - - /** The value that is not numeric. */ - private String value; - - /** - * Build the exception. - * @param message Exception message. - * @param sqlStatement SQL Statement who encountered the trouble, if known. - * @param dbf The database that was queried. - * @param colName The column name that has a non numeric value. - * @param wrongValue The wrong value. - */ - public SQLNotNumericException(String message, String sqlStatement, File dbf, String colName, String wrongValue) { - super(message); - this.sql = sqlStatement; - this.database = dbf; - this.columnName = colName; - this.value = wrongValue; - } - - /** - * Returns the SQL statement. - * @return SQL statement or null. - */ - public String getSQL() { - return this.sql; - } - - /** - * Returns the column name. - * @return Column name. - */ - public String getColumnName() { - return this.columnName; - } - - /** - * Returns the value that is not numeric. - * @return Value. - */ - public String getValue() { - return this.value; - } - - /** - * Returns the database file. - * @return Database file. - */ - public File getDatabase() { - return this.database; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/package-info.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/package-info.java deleted file mode 100644 index af21cf71e54..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Result sets for SQL statements and DB Metadata querying. - */ -package org.apache.sis.internal.shapefile.jdbc.resultset; diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java deleted file mode 100644 index fa92bd2d204..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.sql; - -import java.util.Objects; -import java.util.function.Function; -import java.util.logging.Level; - -import org.apache.sis.internal.shapefile.AutoChecker; -import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException; -import org.apache.sis.internal.shapefile.jdbc.resultset.*; - -/** - * Base class for clause resolver. - * @author Marc LE BIHAN - */ -public abstract class ClauseResolver extends AutoChecker { - /** First comparand. */ - private Object comparand1; - - /** Second comparand. */ - private Object comparand2; - - /** Operator. */ - private String operator; - - /** - * Construct a where clause resolver. - * @param cmp1 The first comparand that might be a primitive or a Field. - * @param cmp2 The second comparand that might be a primitive or a Field. - * @param op The operator to apply. - */ - public ClauseResolver(Object cmp1, Object cmp2, String op) { - this.comparand1 = cmp1; - this.comparand2 = cmp2; - this.operator = op; - } - - /** - * Returns first comparand. - * @return First comparand. - */ - public Object getComparand1() { - return this.comparand1; - } - - /** - * Returns second comparand. - * @return Second comparand. - */ - public Object getComparand2() { - return this.comparand2; - } - - /** - * Returns operator. - * @return Operator. - */ - public String getOperator() { - return this.operator; - } - - /** - * Set the first comparand. - * @param comparand First comparand. - */ - public void setComparand1(Object comparand) { - this.comparand1 = comparand; - } - - /** - * Set the second comparand. - * @param comparand Second comparand. - */ - public void setComparand2(Object comparand) { - this.comparand2 = comparand; - } - - /** - * Set the operator. - * @param op Operator. - */ - public void setOperator(String op) { - this.operator = op; - } - - /** - * Check if a condition is verified. - * @param rs ResultSet where the value shall be taken. - * @return true if the current record of the ResultSet matches this condition. - * @throws SQLInvalidStatementException if the operator is not valid. - * @throws SQLIllegalParameterException if a parameter has a value that is not parsable. - * @throws SQLNoSuchFieldException if a field name doesn't exist in the query. - * @throws SQLUnsupportedParsingFeatureException if our implementation of the driver still not handle this data type. - * @throws SQLNotDateException if a field announced being a date isn't. - * @throws SQLUnsupportedParsingFeatureException if the driver encounter a type it cannot handle. - * @throws SQLNotNumericException if a field doesn't carry a numeric value when expected to. - * @throws SQLConnectionClosedException if the connection is closed. - */ - public boolean isVerified(DBFRecordBasedResultSet rs) throws SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLConnectionClosedException, SQLNotNumericException, SQLNotDateException { - switch(getOperator()) { - case "=" : - return compare(rs) == 0; - - case ">" : - return compare(rs) > 0; - - case ">=" : - return compare(rs) >= 0; - - case "<" : - return compare(rs) < 0; - - case "<=" : - return compare(rs) <= 0; - - default : - String message = format(Level.WARNING, "excp.invalid_statement_operator", getOperator(), rs.getSQL()); - throw new SQLInvalidStatementException(message, rs.getSQL(), rs.getFile()); - } - } - - /** - * Returns true if this condition is verified. - * @param rs The record containing the values to extract, if needed. - * @return true if it is the case. - * @throws SQLIllegalParameterException if a parameter has a value that is not parsable. - * @throws SQLNoSuchFieldException if a field name doesn't exist in the query. - * @throws SQLUnsupportedParsingFeatureException if our implementation of the driver still not handle this data type. - * @throws SQLNotDateException if a field announced being a date isn't. - * @throws SQLUnsupportedParsingFeatureException if the driver encounter a type it cannot handle. - * @throws SQLNotNumericException if a field doesn't carry a numeric value when expected to. - * @throws SQLConnectionClosedException if the connection is closed. - */ - private int compare(DBFRecordBasedResultSet rs) throws SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLConnectionClosedException, SQLNotNumericException, SQLNotDateException { - Object value1 = valueOf(rs, getComparand1()); - Object value2 = valueOf(rs, getComparand2()); - - // Handle NULL value cases. - if (value1 == null && value2 == null) - return 0; - else - { - if (value1 == null) - return -1; - else - { - if (value2 == null) - return 1; - } - } - - assert(value1 != null && value2 != null) : "Null values should have been handled in comparison."; - - // If comparands have already the same type, compare them immediately. - if (value1.getClass().equals(value2.getClass())) { - return compare(rs, value1, value2); - } - else { - // Else, attempt to promote their types to something equivalent on the two sides. - - // Promote Short to Integer, Long, Float or Double. - Integer compare = compareIfPromoted(rs, value1, value2, Short.class, Integer.class, Integer::valueOf); - compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Short.class, Long.class, Long::valueOf); - compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Short.class, Float.class, Float::valueOf); - compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Short.class, Double.class, Double::valueOf); - - // Promote Integer to Long, Float or Double. - compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Integer.class, Long.class, Long::valueOf); - compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Integer.class, Float.class, Float::valueOf); - compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Integer.class, Double.class, Double::valueOf); - - // Promote Long to Float or Double. - compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Long.class, Float.class, Float::valueOf); - compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Long.class, Double.class, Double::valueOf); - - // Promote Float to Double. - compare = compare != null ? compare : compareIfPromoted(rs, value1, value2, Float.class, Double.class, Double::valueOf); - - // if we are here with still a null value in comparison result, we have found no matching at all. - // Default to String comparison. - if (compare == null) { - String default1 = value1.toString(); - String default2 = value2.toString(); - return compare(rs, default1, default2); - } - else - return compare; - } - } - - /** - * Perform a comparison after having attempted to promote compared types : one of the parameter must belongs to one class and the other - * one to the second one to allow the conversion and comparison to be done, else a null value will be returned, meaning that no promotion were possible. - * @param the worst class expected, the one that will be promoted to the best class through the mean of the promoter function. - * @param the best class expected : one of the parameter will be promoted to this class to allow comparison to be done. - * @param rs ResultSet where field values has been taken. - * @param value1 First value. - * @param value2 Second value. - * @param worstHas The worst class expected. - * @param bestHas The best class expected. - * @param promoter Promoting function. - * @return Comparison result, or null if no comparison can be done because a parameter value cannot be promoted. - * @throws SQLUnsupportedParsingFeatureException if a comparison fails eventually on a Java type not belonging to {link #java.lang.Comparable}. - */ - private Integer compareIfPromoted(DBFRecordBasedResultSet rs, Object value1, Object value2, Class worstHas, Class bestHas, Function promoter) throws SQLUnsupportedParsingFeatureException { - boolean w1 = value1.getClass().equals(worstHas); - boolean b1 = value1.getClass().equals(bestHas); - boolean w2 = value2.getClass().equals(worstHas); - boolean b2 = value2.getClass().equals(bestHas); - - // if the values has the same class, they should have been already compared. But let's to it. - if ((w1 && w2) || (b1 && b2)) - return compare(rs, value1, value2); - else - { - // if one value doesn't match to a type, we can't perform the comparison. - if ((w1 == false && b1 == false) || (w2 == false && b2 == false)) - return null; - else { - assert((w1 != b1 && w2 != b2) && (w1 != w2 && b1 != b2)) : "Parameters are not of different types."; - - // Suppress the warnings because we have done the checkings before. - @SuppressWarnings("unchecked") B sameType1 = w1 ? promoter.apply((W)value1) : (B)value1; - @SuppressWarnings("unchecked") B sameType2 = w2 ? promoter.apply((W)value2) : (B)value2; - return compare(rs, sameType1, sameType2); - } - } - } - - /** - * Compare two values of the same type. - * @param Class of their type. - * @param rs ResultSet where field values has been taken. - * @param value1 First comparand. - * @param value2 Second comparand. - * @return Result of the comparison. - * @throws SQLUnsupportedParsingFeatureException if this type doesn't implements {link #java.lang.Comparable} and cannot be handled by this driver. - */ - @SuppressWarnings({"rawtypes", "unchecked"}) // Wished : Types are checked by the caller. - private int compare(DBFRecordBasedResultSet rs, T value1, T value2) throws SQLUnsupportedParsingFeatureException { - Comparable comparable1 = null; - Comparable comparable2 = null; - - if (value1 instanceof Comparable) { - comparable1 = (Comparable)value1; - } - - if (value2 instanceof Comparable) { - comparable2 = (Comparable)value2; - } - - // If one of the comparands doesn't belong to java.lang.Comparable, our driver is taken short. - if (comparable1 == null) { - String message = format(Level.WARNING, "excp.uncomparable_type", value1, value1.getClass().getName(), rs.getSQL()); - throw new SQLUnsupportedParsingFeatureException(message, rs.getSQL(), rs.getFile()); - } - - if (comparable2 == null) { - String message = format(Level.WARNING, "excp.uncomparable_type", value2, value2.getClass().getName(), rs.getSQL()); - throw new SQLUnsupportedParsingFeatureException(message, rs.getSQL(), rs.getFile()); - } - - return comparable1.compareTo(comparable2); - } - - /** - * Returns the value of a comparand. - * @param rs ResultSet. - * @param comparand Comparand. - * @return Value of that comparand : - *
- itself, it is a primitive type or an enclosed string. - *
-a field value if the given string is not enclosed by ' characters : the parser see it a field name, then. - * @throws SQLIllegalParameterException if a literal string value is not well enclosed by '...'. - * @throws SQLNoSuchFieldException if the comparand designs a field name that doesn't exist. - * @throws SQLNotDateException if a field announced being a date isn't. - * @throws SQLUnsupportedParsingFeatureException if the driver encounter a type it cannot handle. - * @throws SQLNotNumericException if a field doesn't carry a numeric value when expected to. - * @throws SQLConnectionClosedException if the connection is closed. - */ - private Object valueOf(DBFRecordBasedResultSet rs, Object comparand) throws SQLIllegalParameterException, SQLNoSuchFieldException, SQLConnectionClosedException, SQLNotNumericException, SQLUnsupportedParsingFeatureException, SQLNotDateException { - Objects.requireNonNull(rs, "ResultSet cannot be null when taking the value of a ResultSet comparand."); - Objects.requireNonNull(comparand, "Comparand cannot be null."); - - // All comparands that are litterals are returned as they are. - if (comparand instanceof String == false) - return comparand; - - String text = (String)comparand; - text = text.trim(); - - // If the field is enclosed by ' characters, it is considered a litteral too, but these ' are removed before returning the string. - boolean wannaBeLiteral = text.startsWith("'") || text.endsWith("'"); // A ' at the beginning or the end. - boolean uncompleteLiteral = text.startsWith("'") == false || text.endsWith("'") == false || text.length() < 2; // But not at the two sides, or a string made of a single one. - - if (wannaBeLiteral) { - if (wannaBeLiteral && uncompleteLiteral) { - String message = format(Level.WARNING, "excp.illegal_parameter_where", text, rs.getSQL()); - throw new SQLIllegalParameterException(message, rs.getSQL(), rs.getFile(), "literal", text); - } - - assert(text.indexOf("'") == 0 && text.indexOf("'") < text.lastIndexOf("'") && text.lastIndexOf("'") == text.length()-1 && text.length() >= 2) : "The litteral string is not enclosed into '...'"; - - String literal = text.substring(1, text.length()-1); - return literal; - } - else { - // The string designs a field name, return its value. - try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)rs.getFieldDesc(text, rs.getSQL())) { - return valueOf(rs, field); - } - } - } - - /** - * Returns the field value in a ResultSet. - * @param rs ResultSet. - * @param field Field. - * @return Field value. - * @throws SQLNotNumericException if the value of a numeric field queried isn't numeric. - * @throws SQLNoSuchFieldException if a field name doesn't exist in the query. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLUnsupportedParsingFeatureException if our implementation of the driver still not handle this data type. - * @throws SQLNotDateException if the value of a date field is not a date. - */ - private Object valueOf(DBFRecordBasedResultSet rs, DBFBuiltInMemoryResultSetForColumnsListing field) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException, SQLUnsupportedParsingFeatureException, SQLNotDateException { - String columnName = field.getString("COLUMN_NAME"); - - switch(field.getString("TYPE_NAME")) { - case "AUTO_INCREMENT": - return rs.getInt(columnName); - - case "CHAR": - return rs.getString(columnName); - - case "INTEGER": - return rs.getInt(columnName); - - case "DATE": - return rs.getDate(columnName); - - case "DOUBLE": - return rs.getDouble(columnName); - - case "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); - } - - 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()); - - default: - throw new RuntimeException(format(Level.WARNING, "assert.unknown_field_type", field.getString("TYPE_NAME"))); - } - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ConditionalClauseResolver.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ConditionalClauseResolver.java deleted file mode 100644 index 526a805ca0e..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ConditionalClauseResolver.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.sql; - -/** - * Conditional Clause resolver : resolves a single part of an expression : - *
- Only resolve comparison of simple statements like F = 2, not those involving intermediate calculations (F + 4 = 6). - *
- Only resolve a part of an expression : in "A = 5 and (B = 3 or C = 6)" will treat A = 5, for example. - *
- If many clauseResolvers are chained, operator precedence checking has to be done by the caller. - *
- This class is only here temporary, and will be replaced by a good SQL parser as soon as possible. - * @author Marc LE BIHAN - */ -public class ConditionalClauseResolver extends ClauseResolver -{ - /** - * Construct a where clause resolver. - * @param comparand1 The first comparand that might be a primitive or a Field. - * @param comparand2 The second comparand that might be a primitive or a Field. - * @param operator The operator to apply. - */ - public ConditionalClauseResolver(Object comparand1, Object comparand2, String operator) { - super(comparand1, comparand2, operator); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java deleted file mode 100644 index 6e9785e0560..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.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; - -/** - * Simple and temporary SQL parser. - * @author Marc LE BIHAN - */ -public class CrudeSQLParser extends AbstractJDBC { - /** ResultSet followed straight forward. */ - private DBFRecordBasedResultSet rs; - - /** - * Construct a crude SQL parser. - * @param resultset Target ResultSet. - */ - public CrudeSQLParser(DBFRecordBasedResultSet resultset) { - Objects.requireNonNull(resultset, "The ResultSet given to the SQL parser cannot be null."); - this.rs = resultset; - } - - /** - * Get the unique conditional statement contained in an SQL statement. - * @return Conditional clause or null if the statement wasn't accompanied by a where clause. - * @throws SQLInvalidStatementException if the SQL statement is invalid. - */ - public ConditionalClauseResolver parse() throws SQLInvalidStatementException { - logStep("parse"); - - 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, this.rs.getSQL(), this.rs.getFile()); - } - - final String whereWord = " where "; - int whereIndex = sql.toLowerCase().indexOf(whereWord); - - // If the where clause has not been found, its not an error : there is no condition to set, that's all. - if (whereIndex == -1) - return null; - - // Get the conditions. - int endOfwhereClause = whereIndex + whereWord.length(); - String whereCondition = sql.substring(endOfwhereClause).trim(); - - // 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, this.rs.getSQL(), this.rs.getFile()); - } - - // Currently, all the condition are made of three parts : - // - // i.e. : A < 5, CITY = 'Kratie', B >= 15.3 - // Spaces are currently expected between parts of the conditional expression. - String[] parts = whereCondition.split(" "); - - if (parts.length != 3) { - String message = format(Level.WARNING, "excp.limited_feature_conditional_parsing", whereCondition, sql); - throw new SQLInvalidStatementException(message, this.rs.getSQL(), this.rs.getFile()); - } - - // Detect and promote litterals in parameters to their best types. - Object comparand1 = convertToNearestParameterType(parts[0]); - Object comparand2 = convertToNearestParameterType(parts[2]); - String operand = parts[1]; - - ConditionalClauseResolver resolver = new ConditionalClauseResolver(comparand1, comparand2, operand); - return resolver; - } - - /** - * Promote a value to the best parameter available : Integer, then Double, then String. - * TODO Convert to Date, and admit null values. - * @param value Value. - * @return Converted value or value kept as String if no convertion applies. - */ - private Object convertToNearestParameterType(String value) { - try { - return Integer.parseInt(value); - } - catch(NumberFormatException e) { - try { - return Double.parseDouble(value); - } - catch(NumberFormatException ex) { - return value; - } - } - } - - /** - * @see java.sql.Wrapper#isWrapperFor(java.lang.Class) - */ - @Override public boolean isWrapperFor(Class iface) { - logStep("isWrapperFor", iface); - return false; - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#getFile() - */ - @Override protected File getFile() { - return this.rs.getFile(); - } - - /** - * @see org.apache.sis.internal.shapefile.jdbc.AbstractJDBC#getInterface() - */ - @Override protected Class getInterface() { - logStep("getInterface"); - return getClass(); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLIllegalParameterException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLIllegalParameterException.java deleted file mode 100644 index 14e6dc6df39..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLIllegalParameterException.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.sql; - -import java.io.File; -import java.sql.SQLException; - -/** - * Exception thrown when a parameter is invalid. - * @author Marc LE BIHAN - */ -public class SQLIllegalParameterException extends SQLException { - /** Serial ID. */ - private static final long serialVersionUID = -3173798942882143448L; - - /** The SQL Statement (if known). */ - private String sql; - - /** The database file. */ - private File database; - - /** Parameter name (if known) that is invalid. */ - private String parameterName; - - /** Parameter value that is invalid. */ - private String parameterValue; - - /** - * Build the exception. - * @param message Exception message. - * @param sqlStatement SQL Statement who encountered the trouble, if known. - * @param dbf The database that was queried. - * @param name The parameter name that is invalid. - * @param value The parameter value that is invalid. - */ - public SQLIllegalParameterException(String message, String sqlStatement, File dbf, String name, String value) { - super(message); - this.sql = sqlStatement; - this.database = dbf; - this.parameterName = name; - this.parameterValue = value; - } - - /** - * Returns the SQL statement. - * @return SQL statement or null. - */ - public String getSQL() { - return this.sql; - } - - /** - * Returns the parameter name that is invalid, if known. - * @return Parameter name. - */ - public String geParameterName() { - return this.parameterName; - } - - /** - * Returns the parameter value that is invalid. - * @return Parameter name. - */ - public String geParameterValue() { - return this.parameterValue; - } - - /** - * Returns the database file. - * @return Database file. - */ - public File getDatabase() { - return this.database; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLInvalidStatementException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLInvalidStatementException.java deleted file mode 100644 index 8ec7679b8e6..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLInvalidStatementException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.sql; - -import java.io.File; -import java.sql.SQLException; - -/** - * Exception thrown when a statement is invalid. - * @author Marc LE BIHAN - */ -public class SQLInvalidStatementException extends SQLException { - /** Serial ID. */ - private static final long serialVersionUID = -1807300055143449480L; - - /** The SQL Statement (if known). */ - private String sql; - - /** The database file. */ - private File database; - - /** - * Build the exception. - * @param message Exception message. - * @param sqlStatement SQL Statement who encountered the trouble, if known. - * @param dbf The database that was queried. - */ - public SQLInvalidStatementException(String message, String sqlStatement, File dbf) { - super(message); - this.sql = sqlStatement; - this.database = dbf; - } - - /** - * Returns the SQL statement. - * @return SQL statement or null. - */ - public String getSQL() { - return this.sql; - } - - /** - * Returns the database file. - * @return Database file. - */ - public File getDatabase() { - return this.database; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLUnsupportedParsingFeatureException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLUnsupportedParsingFeatureException.java deleted file mode 100644 index 19dc898630e..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLUnsupportedParsingFeatureException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.sql; - -import java.io.File; -import java.sql.SQLException; - -/** - * Exception thrown when a parsing feature is not supported. - * @author Marc LE BIHAN - */ -public class SQLUnsupportedParsingFeatureException extends SQLException { - /** Serial ID. */ - private static final long serialVersionUID = 6944940576163675495L; - - /** The SQL Statement that whas attempted. */ - private String sql; - - /** The database that was queried. */ - private File database; - - /** - * Build the exception. - * @param message Exception message. - * @param sqlStatement SQL Statement who encountered the trouble. - * @param dbf The database that was queried. - */ - public SQLUnsupportedParsingFeatureException(String message, String sqlStatement, File dbf) { - super(message); - this.sql = sqlStatement; - this.database = dbf; - } - - /** - * Returns the SQL statement who encountered the "end of data" alert. - * @return SQL statement. - */ - public String getSQL() { - return this.sql; - } - - /** - * Returns the database file that was queried. - * @return The database that was queried. - */ - public File getDatabase() { - return this.database; - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/package-info.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/package-info.java deleted file mode 100644 index 45c3f806173..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * SQL Parser. - */ -package org.apache.sis.internal.shapefile.jdbc.sql; diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java deleted file mode 100644 index 1374a02c256..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/AbstractStatement.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.statement; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import org.apache.sis.internal.shapefile.jdbc.AbstractJDBC; - - -/** - * This base class holds most of the unimplemented feature of a {@code Statement}. - * This is used in order to avoid having a Statement implementation of thousand lines and unreadable. - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Connection default values
Property Value
{@link #getResultSetType()} {@link ResultSet#TYPE_SCROLL_SENSITIVE}
{@link #getResultSetConcurrency()} {@link ResultSet#CONCUR_READ_ONLY}
{@link #getResultSetHoldability()} {@link ResultSet#CLOSE_CURSORS_AT_COMMIT}
{@link #getFetchDirection()} {@link ResultSet#FETCH_FORWARD}
{@link #getQueryTimeout()} 0
{@link #isPoolable()} {@code false}
{@link #setPoolable(boolean)} Ignored
{@link #getWarnings()} {@code null}
{@link #clearWarnings()} Ignored
- * - * @author Marc Le Bihan - * @author Martin Desruisseaux (Geomatys) - * @version 0.5 - * @since 0.5 - * @module - */ -@SuppressWarnings("unused") -abstract class AbstractStatement extends AbstractJDBC implements Statement { - /** - * Constructs a new {@code Statement} instance. - */ - AbstractStatement() { - } - - /** - * Default to {@link ResultSet#TYPE_SCROLL_SENSITIVE}, meaning that a change in the underlying - * database may affect the result set. - */ - @Override - public int getResultSetType() throws SQLException { - return ResultSet.TYPE_SCROLL_SENSITIVE; - } - - /** - * Default to {@link ResultSet#CONCUR_READ_ONLY}, which is a conservative vale meaning - * that the underlying database should not be updated while we iterate in a result set. - */ - @Override - public int getResultSetConcurrency() throws SQLException { - return ResultSet.CONCUR_READ_ONLY; - } - - /** - * Defaults to {@link ResultSet#CLOSE_CURSORS_AT_COMMIT}, which seems the most conservative option. - */ - @Override - public int getResultSetHoldability() throws SQLException { - return ResultSet.CLOSE_CURSORS_AT_COMMIT; - } - - /** - * Unsupported by default. - */ - @Override - public int getMaxFieldSize() throws SQLException { - throw unsupportedOperation("getMaxFieldSize"); - } - - /** - * Unsupported by default. - */ - @Override - public void setMaxFieldSize(int max) throws SQLException { - throw unsupportedOperation("setMaxFieldSize"); - } - - /** - * Unsupported by default. - */ - @Override - public int getFetchSize() throws SQLException { - throw unsupportedOperation("getFetchSize"); - } - - /** - * Unsupported by default. - */ - @Override - public void setFetchSize(int rows) throws SQLException { - throw unsupportedOperation("setFetchSize"); - } - - /** - * Defaults to {@link ResultSet#FETCH_FORWARD}. - */ - @Override - public int getFetchDirection() throws SQLException { - return ResultSet.FETCH_FORWARD; - } - - /** - * Unsupported by default. - */ - @Override - public void setFetchDirection(int direction) throws SQLException { - if (direction != ResultSet.FETCH_FORWARD) { - throw unsupportedOperation("setFetchDirection"); - } - } - - /** - * Defaults to 0, meaning to limit. - */ - @Override - public int getQueryTimeout() throws SQLException { - return 0; - } - - /** - * Unsupported by default. - */ - @Override - public void setQueryTimeout(int seconds) throws SQLException { - throw unsupportedOperation("setQueryTimeout"); - } - - /** - * Unsupported by default. - */ - @Override - public void setEscapeProcessing(boolean enable) throws SQLException { - throw unsupportedOperation("setEscapeProcessing"); - } - - /** - * Unsupported by default. - */ - @Override - public void setCursorName(String name) throws SQLException { - throw unsupportedOperation("setCursorName"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { - throw unsupportedOperation("execute with autoGeneratedKeys"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean execute(String sql, int[] columnIndexes) throws SQLException { - throw unsupportedOperation("execute with columnIndexes"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean execute(String sql, String[] columnNames) throws SQLException { - throw unsupportedOperation("execute with columnNames"); - } - - /** - * Unsupported by default. - */ - @Override - public int executeUpdate(String sql) throws SQLException { - throw unsupportedOperation("executeUpdate"); - } - - /** - * Unsupported by default. - */ - @Override - public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { - throw unsupportedOperation("executeUpdate"); - } - - /** - * Unsupported by default. - */ - @Override - public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { - throw unsupportedOperation("executeUpdate"); - } - - /** - * Unsupported by default. - */ - @Override - public int executeUpdate(String sql, String[] columnNames) throws SQLException { - throw unsupportedOperation("executeUpdate"); - } - - /** - * Unsupported by default. - */ - @Override - public void addBatch(String sql) throws SQLException { - throw unsupportedOperation("addBatch"); - } - - /** - * Unsupported by default. - */ - @Override - public void clearBatch() throws SQLException { - throw unsupportedOperation("clearBatch"); - } - - /** - * Unsupported by default. - */ - @Override - public int[] executeBatch() throws SQLException { - throw unsupportedOperation("executeBatch"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean getMoreResults() throws SQLException { - throw unsupportedOperation("getMoreResults"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean getMoreResults(int current) throws SQLException { - throw unsupportedOperation("getMoreResults"); - } - - /** - * Unsupported by default. - */ - @Override - public ResultSet getGeneratedKeys() throws SQLException { - throw unsupportedOperation("getGeneratedKeys"); - } - - /** - * Defaults to {@code false} since simple statement imlementations are not poolable. - */ - @Override - public boolean isPoolable() throws SQLException { - return false; - } - - /** - * Ignored by default since this method is only a hint. - */ - @Override - public void setPoolable(boolean poolable) throws SQLException { - } - - /** - * Unsupported by default. - */ - @Override - public void cancel() throws SQLException { - throw unsupportedOperation("cancel"); - } - - /** - * Unsupported by default. - */ - @Override - public void closeOnCompletion() throws SQLException { - throw unsupportedOperation("closeOnCompletion"); - } - - /** - * Unsupported by default. - */ - @Override - public boolean isCloseOnCompletion() throws SQLException { - throw unsupportedOperation("isCloseOnCompletion"); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java deleted file mode 100644 index 2a8cf369530..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.statement; - -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 java.util.stream.Collectors; - -import org.apache.sis.internal.shapefile.jdbc.SQLConnectionClosedException; -import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection; -import org.apache.sis.internal.shapefile.jdbc.resultset.DBFResultSet; -import org.apache.sis.internal.shapefile.jdbc.resultset.DBFRecordBasedResultSet; -import org.apache.sis.internal.shapefile.jdbc.sql.SQLInvalidStatementException; - - -/** - * DBF Statement. - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class DBFStatement extends AbstractStatement { - /** Connection this statement is relying on. */ - private DBFConnection connection; - - /** ResultSets that are currently opened. */ - private HashSet openedResultSets = new HashSet<>(); - - /** The current result set, or {@code null} if none. */ - private DBFResultSet currentResultSet; - - /** Indicates if the statement is currently closed. */ - private boolean isClosed; - - /** - * Constructs a statement. - * @param cnt Connection associated to this statement. - */ - public DBFStatement(DBFConnection cnt) { - this.connection = cnt; - } - - /** - * Returns the connection. - * @return Connection. - * @throws SQLConnectionClosedException if the connection is closed. - */ - @Override - public Connection getConnection() throws SQLConnectionClosedException { - assertNotClosed(); - return this.connection; - } - - /** - * Returns the Database File. - * @return Database File. - */ - @Override - public File getFile() { - return this.connection.getFile(); - } - - /** - * @see java.sql.Statement#execute(java.lang.String) - */ - @Override - public boolean execute(String sql) throws SQLException { - // We are only able to handle SQL Queries at this time. - if (sql.trim().toLowerCase().startsWith("select")) { - executeQuery(sql); - return true; // The result is a ResultSet. - } - else - throw unsupportedOperation("execute something else than a SELECT statement"); - } - - /** - * Executes the given SQL statement. - * @return SQL Statement. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLInvalidStatementException if the SQL Statement is invalid. - */ - @Override - public ResultSet executeQuery(final String sql) throws SQLConnectionClosedException, SQLInvalidStatementException { - Objects.requireNonNull(sql, "The SQL query cannot be null."); - assertNotClosed(); - - DBFRecordBasedResultSet rs = new DBFRecordBasedResultSet(this, sql); - registerResultSet(rs); - return rs; - } - - /** - * Returns the JDBC interface implemented by this class. - * This is used for formatting error messages. - */ - @Override - final protected Class getInterface() { - return Statement.class; - } - - /** - * @see java.sql.Statement#getMaxRows() - */ - @Override - public int getMaxRows() { - return 0; - } - - /** - * Returns the result set created by the last call to {@link #executeQuery(String)}. - * @return ResultSet. - */ - @Override - public ResultSet getResultSet() throws SQLConnectionClosedException { - assertNotClosed(); - return this.currentResultSet; - } - - /** - * @see java.sql.Statement#getUpdateCount() - */ - @Override - public int getUpdateCount() { - return 0; // We currently only handle select statements. - } - - /** - * @see java.sql.Statement#close() - */ - @Override - public void close() { - if (isClosed()) - return; - - if (this.currentResultSet != null) { - // Inform that this ResultSet could have been closed but that we are handling this : - // Some developers may expect their ResultSet should have been closed before in their program. - log(Level.FINE, "log.closing_underlying_resultset", this.currentResultSet); - this.currentResultSet.close(); - - 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 developer. - if (this.openedResultSets.size() > 0) { - log(Level.WARNING, "log.resultsets_left_opened", this.openedResultSets.size(), this.openedResultSets.stream().map(DBFResultSet::toString).collect(Collectors.joining(", "))); - } - - this.isClosed = true; - this.connection.notifyCloseStatement(this); - } - - /** - * Returns {@code true} if this statement has been closed or if the underlying connection is closed. - * @return true if the database is closed. - */ - @Override - public boolean isClosed() { - return this.isClosed || this.connection.isClosed(); - } - - /** - * Asserts that the connection and the statement are together opened. - * @throws SQLConnectionClosedException if one of them is closed. - */ - public void assertNotClosed() throws SQLConnectionClosedException { - this.connection.assertNotClosed(); // First, the underlying shall not be closed. - - // Then, this statement shouldn't be closed too. - if (this.isClosed) { - throw new SQLConnectionClosedException(format(Level.WARNING, "excp.closed_statement", this.connection.getFile().getName()), null, this.connection.getFile()); - } - } - - /** - * @see java.sql.Wrapper#isWrapperFor(java.lang.Class) - */ - @Override - public boolean isWrapperFor(Class iface) { - return iface.isAssignableFrom(getInterface()); - } - - /** - * Method called by ResultSet class to notity this statement that a resultSet has been closed. - * @param rs ResultSet that has been closed. - */ - public void notifyCloseResultSet(DBFResultSet rs) { - 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 (this.currentResultSet == rs) - this.currentResultSet = null; - - if (this.openedResultSets.remove(rs) == false) { - throw new RuntimeException(format(Level.SEVERE, "assert.resultset_not_opened_by_me", rs, toString())); - } - } - - /** - * Register a ResultSet as opened. - * @param rs Result Set. - */ - public void registerResultSet(DBFResultSet rs) { - this.currentResultSet = rs; - this.openedResultSets.add(rs); - } - - /** - * @see java.sql.Statement#setMaxRows(int) - */ - @Override - public void setMaxRows(int max) { - this.logUnsupportedOperation(MessageFormat.format("setMaxRows({0,number})", max)); - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return format("toString", this.connection != null ? this.connection.toString() : null, isClosed() == false); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/package-info.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/package-info.java deleted file mode 100644 index e9c92455154..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/package-info.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** Statements */ -package org.apache.sis.internal.shapefile.jdbc.statement; diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/package-info.java b/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/package-info.java deleted file mode 100644 index 01525a52826..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/package-info.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Function to describe and access to {@link org.apache.sis.storage.shapefile}. - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -package org.apache.sis.internal.shapefile; diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DataStoreQueryException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DataStoreQueryException.java deleted file mode 100644 index 2308655b13c..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DataStoreQueryException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.shapefile; - -import org.apache.sis.storage.DataStoreException; - - -/** - * Thrown when a query is invalid. - * - *
This is an experimental class, - * not yet target for any Apache SIS release at this time.
- * - * @author Marc Le Bihan - * @version 0.6 - * @since 0.6 - * @module - */ -public class DataStoreQueryException extends DataStoreException { - /** Serial UID. */ - private static final long serialVersionUID = 6927412997473246611L; - - /** - * Construct an exception. - * @param message Message of the exception. - */ - public DataStoreQueryException(String message) { - super(message); - } - - /** - * Construct an exception. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public DataStoreQueryException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DataStoreQueryResultException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DataStoreQueryResultException.java deleted file mode 100644 index f619b1bddee..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DataStoreQueryResultException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.shapefile; - -import org.apache.sis.storage.DataStoreException; - - -/** - * Thrown when a query result is invalid (for example : because the data found has a wrong format). - * - *
This is an experimental class, - * not yet target for any Apache SIS release at this time.
- * - * @author Marc Le Bihan - * @version 0.6 - * @since 0.6 - * @module - */ -public class DataStoreQueryResultException extends DataStoreException { - /** Serial UID. */ - private static final long serialVersionUID = 8397640365245240930L; - - /** - * Construct an exception. - * @param message Message of the exception. - */ - public DataStoreQueryResultException(String message) { - super(message); - } - - /** - * Construct an exception. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public DataStoreQueryResultException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DbaseFileNotFoundException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DbaseFileNotFoundException.java deleted file mode 100644 index 1784d74b637..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/DbaseFileNotFoundException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.shapefile; - -import org.apache.sis.storage.DataStoreException; - - -/** - * Thrown when a DBF file has not been found. - * - *
This is an experimental class, - * not yet target for any Apache SIS release at this time.
- * - * @author Marc Le Bihan - * @version 0.6 - * @since 0.6 - * @module - */ -public class DbaseFileNotFoundException extends DataStoreException { - /** Serial UID. */ - private static final long serialVersionUID = 5930300852780537859L; - - /** - * Construct an exception. - * @param message Message of the exception. - */ - public DbaseFileNotFoundException(String message) { - super(message); - } - - /** - * Construct an exception. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public DbaseFileNotFoundException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java deleted file mode 100644 index 93efbfb4ccd..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.shapefile; - -import java.io.File; -import java.io.InputStream; -import java.sql.SQLFeatureNotSupportedException; -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.*; -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; -import org.apache.sis.internal.shapefile.jdbc.resultset.*; -import org.apache.sis.internal.shapefile.jdbc.sql.SQLIllegalParameterException; -import org.apache.sis.internal.shapefile.jdbc.sql.SQLInvalidStatementException; -import org.apache.sis.internal.shapefile.jdbc.sql.SQLUnsupportedParsingFeatureException; -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; -import org.apache.sis.internal.system.Modules; -import org.apache.sis.storage.DataStoreClosedException; -import org.apache.sis.util.logging.Logging; -import org.apache.sis.feature.AbstractFeature; - -/** - * Input Stream of features. - * - *
This is an experimental class, - * not yet target for any Apache SIS release at this time.
- * - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class InputFeatureStream extends InputStream { - /** Logger. */ - private static final Logger LOGGER = Logging.getLogger(Modules.SHAPEFILE); - - /** Resource bundle. */ - private ResourceBundle rsc = ResourceBundle.getBundle(InputFeatureStream.class.getName()); - - /** Dedicated connection to DBF. */ - private DBFConnection connection; - - /** Statement. */ - private DBFStatement stmt; - - /** ResultSet. */ - private DBFRecordBasedResultSet rs; - - /** SQL Statement executed. */ - private String sql; - - /** Marks the end of file. */ - private boolean endOfFile; - - /** Shapefile. */ - private File shapefile; - - /** 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; - - /** Shapefile reader. */ - private ShapefileByteReader shapefileReader; - - /** - * 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, 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; - } - else { - this.hasShapefileIndex = false; - } - - this.shapefileReader = new ShapefileByteReader(this.shapefile, this.databaseFile, this.shapefileIndex); - this.featuresType = this.shapefileReader.getFeaturesType(); - - try { - executeQuery(); - } - catch(SQLConnectionClosedException e) { - // This would be an internal trouble because in this function (at least) it should be open. - throw new RuntimeException(e.getMessage(), e); - } - catch(SQLInvalidStatementException e) { - // This would be an internal trouble because if any SQL statement is executed for the dbase file initialization, it should has a correct syntax or grammar. - throw new RuntimeException(e.getMessage(), e); - } - } - catch(SQLInvalidDbaseFileFormatException ex) { - // Promote this exception to an DataStoreException compatible exception. - throw new InvalidDbaseFileFormatException(ex.getMessage(), ex); - } - catch(SQLDbaseFileNotFoundException ex) { - // Promote this exception to an DataStoreException compatible exception. - throw new DbaseFileNotFoundException(ex.getMessage(), ex); - } - catch(SQLShapefileNotFoundException ex) { - // Promote this exception to an DataStoreException compatible exception. - 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 - public int read() { - throw new UnsupportedOperationException("InputFeatureStream doesn't allow the use of read(). Use readFeature() instead."); - } - - /** - * @see java.io.InputStream#available() - */ - @Override - public int available() { - throw new UnsupportedOperationException("InputFeatureStream doesn't allow the use of available(). Use readFeature() will return null when feature are no more available."); - } - - /** - * @see java.io.InputStream#close() - */ - @Override - public void 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, 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. - */ - public AbstractFeature readFeature() throws DataStoreClosedException, DataStoreQueryException, DataStoreQueryResultException, InvalidShapefileFormatException { - try { - return internalReadFeature(); - } - catch(SQLConnectionClosedException e) { - throw new DataStoreClosedException(e.getMessage(), e); - } - catch(SQLInvalidStatementException | SQLIllegalParameterException | SQLNoSuchFieldException | SQLUnsupportedParsingFeatureException | SQLFeatureNotSupportedException e) { - throw new DataStoreQueryException(e.getMessage(), e); - } - 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() { - return this.featuresType; - } - - /** - * Returns the shapefile descriptor. - * @return Shapefile descriptor. - */ - public ShapefileDescriptor getShapefileDescriptor() { - return this.shapefileReader.getShapefileDescriptor(); - } - - /** - * Returns the database fields descriptors. - * @return List of fields descriptors. - */ - public List 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. - * @throws SQLNotDateException if a field expected of date kind, isn't. - * @throws SQLNoSuchFieldException if a field doesn't exist. - * @throws SQLIllegalParameterException if a parameter is illegal in the query. - * @throws SQLInvalidStatementException if the SQL statement is invalid. - * @throws SQLConnectionClosedException if the connection is closed. - * @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 AbstractFeature internalReadFeature() throws SQLConnectionClosedException, SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLNotNumericException, SQLNotDateException, SQLFeatureNotSupportedException, InvalidShapefileFormatException, SQLNoDirectAccessAvailableException { - try { - if (this.endOfFile) { - return null; - } - - 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) { - // 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})); - } - } - - AbstractFeature 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 = 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; - - if (fieldValue == null) { - stringValue = null; - } - else { - if (fieldValue instanceof Integer || fieldValue instanceof Long) { - stringValue = MessageFormat.format("{0,number,#0}", fieldValue); // Avoid thousand separator. - } - else { - if (fieldValue instanceof Double || fieldValue instanceof Float) { - // Avoid thousand separator. - DecimalFormat df = new DecimalFormat(); - df.setGroupingUsed(false); - stringValue = df.format(fieldValue); - } - else - stringValue = fieldValue.toString(); - } - } - - feature.setPropertyValue(fieldName, stringValue); - } - - return feature; - } - catch(SQLNoResultException e) { - // This an internal trouble, if it occurs. - throw new RuntimeException(e.getMessage(), e); - } - } - catch(SQLNoResultException e) { - // We are trying to prevent this. If it occurs, we have an internal problem. - throw new RuntimeException(e.getMessage(), e); - } - } - - /** - * Execute the wished SQL query. - * @throws SQLConnectionClosedException if the connection is closed. - * @throws SQLInvalidStatementException if the given SQL Statement is invalid. - */ - private void executeQuery() throws SQLConnectionClosedException, SQLInvalidStatementException { - this.stmt = (DBFStatement)this.connection.createStatement(); - this.rs = (DBFRecordBasedResultSet)this.stmt.executeQuery(this.sql); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InvalidDbaseFileFormatException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InvalidDbaseFileFormatException.java deleted file mode 100644 index 29e2cb2c8b3..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InvalidDbaseFileFormatException.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.apache.sis.storage.shapefile; - -import org.apache.sis.storage.DataStoreException; - -/** - * Thrown when the DBF file format seems to be invalid. - * - *
This is an experimental class, - * not yet target for any Apache SIS release at this time.
- * - * @author Marc LE BIHAN - * @version 0.6 - * @since 0.6 - * @module - */ -public class InvalidDbaseFileFormatException extends DataStoreException { - /** Serial ID. */ - private static final long serialVersionUID = 7152705402305259568L; - - /** - * Construct an exception. - * @param message Message of the exception. - */ - public InvalidDbaseFileFormatException(String message) { - super(message); - } - - /** - * Construct an exception. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public InvalidDbaseFileFormatException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InvalidShapefileFormatException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InvalidShapefileFormatException.java deleted file mode 100644 index 7ace0cd0748..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InvalidShapefileFormatException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.shapefile; - -import org.apache.sis.storage.DataStoreException; - -/** - * Thrown when the Shapefile format seems to be invalid. - * - *
This is an experimental class, - * not yet target for any Apache SIS release at this time.
- * - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class InvalidShapefileFormatException extends DataStoreException { - /** Serial UID. */ - private static final long serialVersionUID = -2724950178838120005L; - - /** - * Construct an exception. - * @param message Message of the exception. - */ - public InvalidShapefileFormatException(String message) { - super(message); - } - - /** - * Construct an exception. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public InvalidShapefileFormatException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java deleted file mode 100644 index 65b6e6e70d3..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.shapefile; - -import java.io.File; -import java.util.List; -import java.util.Objects; - -import org.apache.sis.feature.DefaultFeatureType; -import org.apache.sis.internal.shapefile.ShapefileDescriptor; -import org.apache.sis.internal.shapefile.jdbc.DBase3FieldDescriptor; - -/** - * Provides a ShapeFile Reader. - * - *
This is an experimental class, - * not yet target for any Apache SIS release at this time.
- * - * @author Travis L. Pinney - * @version 0.5 - * - * @see ESRI Shapefile Specification - * @see dBASE III File Structure - * - * @since 0.5 - * @module - */ -public class ShapeFile { - /** Shapefile. */ - private File shapeFile; - - /** Database file. */ - private File databaseFile; - - /** Shapefile index, if any. */ - private File shapeFileIndex; - - /** Type of the features contained in this shapefile. */ - private DefaultFeatureType featuresType; - - /** Shapefile descriptor. */ - private ShapefileDescriptor shapefileDescriptor; - - /** Database field descriptors. */ - private List databaseFieldsDescriptors; - - /** - * Construct a Shapefile from a file. - * @param shpfile file to read. - */ - public ShapeFile(String shpfile) { - Objects.requireNonNull(shpfile, "The shapefile to load cannot be null."); - - 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); - - String dbfSuffix = null; - dbfSuffix = shpfile.endsWith("shp") ? "dbf" : dbfSuffix; - dbfSuffix = shpfile.endsWith("SHP") ? "DBF" : dbfSuffix; - dbfSuffix = shpfile.endsWith("Shp") ? "Dbf" : dbfSuffix; - dbfSuffix = (dbfSuffix == null) ? "dbf" : dbfSuffix; - - dbfFileName.replace(shpfile.length() - 3, shpfile.length(), dbfSuffix); - 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()); - } - - /** - * Construct a Shapefile from a file. - * @param shpfile file to read. - * @param dbasefile Associated DBase file. - */ - public ShapeFile(String shpfile, String dbasefile) { - Objects.requireNonNull(shpfile, "The shapefile to load cannot be null."); - Objects.requireNonNull(dbasefile, "The DBase III file to load cannot be null."); - - 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. - * @return Feature type. - */ - public DefaultFeatureType getFeaturesType() { - return this.featuresType; - } - - /** - * Returns the shapefile descriptor. - * @return Shapefile descriptor. - */ - public ShapefileDescriptor getShapefileDescriptor() { - return this.shapefileDescriptor; - } - - /** - * Returns the database fields descriptors. - * @return List of fields descriptors. - */ - public List getDatabaseFieldsDescriptors() { - return this.databaseFieldsDescriptors; - } - - /** - * 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. - * @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 findAll() throws InvalidDbaseFileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException, InvalidShapefileFormatException { - 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(); - return is; - } - - /** - * Load shapefile descriptors : features types, shapefileDescriptor, database field descriptors : - * this is also automatically done when executing a query on it, by findAll. - * @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 void loadDescriptors() throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException { - // Doing an simple query will init the internal descriptors. - // It prepares a SELECT * FROM but don't read a record by itself. - try(InputFeatureStream is = findAll()) { - } - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeTypeEnum.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeTypeEnum.java deleted file mode 100644 index 682b5618c6a..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeTypeEnum.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.shapefile; - -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; - - -/** - * Provides a ShapefileType Enumeration - * - *
This is an experimental class, - * not yet target for any Apache SIS release at this time.
- * - * @author Travis L. Pinney - * @version 0.5 - * - * @see ESRI Shapefile Specification - * - * @since 0.5 - * @module - */ -public enum ShapeTypeEnum { - - NullShape (0), - Point(1), - PolyLine(3), - Polygon(5), - MultiPoint(8), - PointZ(11), - PolyLineZ(13), - PolygonZ(15), - MultiPointZ(18), - PointM(21), - PolyLineM(23), - PolygonM(25), - MultiPointM(28), - MultiPatch(31); - - // used for initializing the enumeration - private int value; - - private ShapeTypeEnum (int value ) { - this.value = value; - } - - public int getValue() { - return value; - } - - private static final Map lookup = new HashMap(); - - static { - for (ShapeTypeEnum ste : EnumSet.allOf(ShapeTypeEnum.class)) { - lookup.put(ste.getValue(), ste); - } - } - - public static ShapeTypeEnum get(int value) { - return lookup.get(value); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapefileNotFoundException.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapefileNotFoundException.java deleted file mode 100644 index 84e2ee5c3ce..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapefileNotFoundException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.shapefile; - -import org.apache.sis.storage.DataStoreException; - - -/** - * Thrown when a shapefile has not been found. - * - *
This is an experimental class, - * not yet target for any Apache SIS release at this time.
- * - * @author Marc Le Bihan - * @version 0.6 - * @since 0.6 - * @module - */ -public class ShapefileNotFoundException extends DataStoreException { - /** Serial UID. */ - private static final long serialVersionUID = -6186994116188421967L; - - /** - * Construct an exception. - * @param message Message of the exception. - */ - public ShapefileNotFoundException(String message) { - super(message); - } - - /** - * Construct an exception. - * @param message Message of the exception. - * @param cause Root cause of the exception. - */ - public ShapefileNotFoundException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/cpg/CpgFiles.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/cpg/CpgFiles.java deleted file mode 100644 index 8fa06f756b3..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/cpg/CpgFiles.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.shapefile.cpg; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import org.apache.sis.util.Static; - - -/** - * CPG files utilities. - * {@code *.cpg} files contains a single word for the name of the DBF character encoding. - * - * @author Johann Sorel (Geomatys) - * @version 2.0 - * @since 2.0 - * @module - */ -public final class CpgFiles extends Static { - /** - * Do not allow instantiation of this class. - */ - private CpgFiles(){} - - /** - * Reads the character set from given stream. - * If the file is empty, then the default character set is returned. - * - * @param in input channel from which to read the character set. - * @return the character set from the given stream. - * @throws IOException if the file does not exist or cannot be read. - */ - public static Charset read(final ReadableByteChannel in) throws IOException { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(Channels.newInputStream(in), StandardCharsets.US_ASCII))) { - String line; - while ((line = reader.readLine()) != null) { - if (!(line = line.trim()).isEmpty()) { - return Charset.forName(line); - } - } - } - return Charset.defaultCharset(); - } - - /** - * Writes the character set to given file. - * - * @param cs character set to write. - * @param file output file. - * @throws IOException if an error occurred while writing the file. - */ - public static void write(final Charset cs, final Path file) throws IOException { - try (BufferedWriter writer = Files.newBufferedWriter(file, StandardCharsets.US_ASCII)) { - writer.write(cs.name()); - } - } -} diff --git a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/package-info.java b/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/package-info.java deleted file mode 100644 index bea1a7876d1..00000000000 --- a/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/package-info.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Shapefile. - * - *
This is an experimental package, - * not yet target for any Apache SIS release at this time.
- * - * @author Travis L. Pinney - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -package org.apache.sis.storage.shapefile; diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader.properties deleted file mode 100644 index cbc38610a91..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader.properties +++ /dev/null @@ -1,36 +0,0 @@ -# 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}. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader_fr.properties deleted file mode 100644 index 73dc0a6cf02..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader_fr.properties +++ /dev/null @@ -1,36 +0,0 @@ -# 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}. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.properties deleted file mode 100644 index c3246acabf7..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.properties +++ /dev/null @@ -1,14 +0,0 @@ -# Exception thrown when a binary code page value is illegal. -#0 : Illegal value. -#1 : DBase 3 file that causes the problem. -excp.illegal_codepage=The DBase 3 code page binary value {0} doesn''t match a legal binary code page. The DBF file ''{1}'' seems corrupted. - -# Exception thrown when a binary code page value is not supported. -#0 : Unsupported value. -#1 : DBase 3 file that causes the problem. -excp.unsupported_codepage=The DBase 3 legacy code page {0} doesn''t have a translation to an known charset. This DBF ''{1}'' cannot be handled. - -# Assertion : when this exception occurs, the involved code that produced it is sure to have a bug. -#0 : Charset that as been asked for and that is wrong. -#1 : Root cause message. -assert.wrong_charset_selection=[Internal API trouble] : The Database::toCharset(..) method has selected a wrong charset ''{0}'' that is eventually refused : {1}. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader_fr.properties deleted file mode 100644 index 2f7410f561e..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader_fr.properties +++ /dev/null @@ -1,14 +0,0 @@ -# Exception thrown when a binary code page value is illegal. -#0 : Illegal value. -#1 : DBase 3 file that causes the problem. -excp.illegal_codepage=La valeur binaire du code page DBase 3, {0}, ne correspond pas à un code page binaire légal. Le fichier DBF ''{1}'' semble corrompu. - -# Exception thrown when a binary code page value is not supported. -#0 : Unsupported value. -#1 : DBase 3 file that causes the problem. -excp.unsupported_codepage=Le code page de la DBase 3, {0}, est ancien et n''a pas de traduction dans un jeu de caractères récent. Ce fichier DBF ''{1}'' ne peut pas être pris en charge. - -# Assertion : when this exception occurs, the involved code that produced it is sure to have a bug. -#0 : Charset that as been asked for and that is wrong. -#1 : Root cause message. -assert.wrong_charset_selection=[Problème interne de l''API] : La méthode Database::toCharset(..) a sélectionné un mauvais charset ''{0}'' qui est finalement refusé : {1}. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.properties deleted file mode 100644 index 7440e9b59c7..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.properties +++ /dev/null @@ -1,23 +0,0 @@ -# Exception thrown when the driver cannot handle a feature. -#0: Interface that is not implemented. -#1: Method name (or goal / feature asked for). -#2: Simple class name. -excp.unsupportedDriverFeature=Internal JDBC driver currently does not support the {0} ability/calls in the {2}.{1}() method. - -# Exception thrown when the driver cannot handle a feature. -#0: Interface that is not implemented. -#1: Method name (or goal / feature asked for). -#2: Simple class name. -#3: Method arguments. -excp.unsupportedDriverFeature_with_arguments=Internal JDBC driver currently does not support the {0} ability/calls in the {2}.{1}({3}) method. - -# Log a function call without arguments. -#0: Method name (or goal / feature asked for). -#1: Simple class name. -log.step=[DBase 3 Driver] {1}.{0}()... - -# Log a function call with arguments. -#0: Method name (or goal / feature asked for). -#1: Simple class name. -#2: Method arguments. -log.step_with_arguments=[DBase 3 Driver] {1}.{0}({2})... diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC_fr.properties deleted file mode 100644 index 8b137891791..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC_fr.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.properties deleted file mode 100644 index 7cc0b42fee3..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Exception : no reader can be created on the file. -#0 : File. -excp.reader_cannot_be_created=No byte reader can be created over the file {0}. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.properties deleted file mode 100644 index 9642977e41d..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.properties +++ /dev/null @@ -1,7 +0,0 @@ -# toString() representation of a Field descriptor. -#0 : Field name. -#1 : Field type. -# Field Address skipped (address is set in memory; not useful on disk). -#3 : Field length (Integer). -#4 : Decimal positions (Integer). -toString='{'Field name : {0}, Type : {1}, Field length : {2,number,integer}, Decimal positions : {3,number,integer}'}' diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor_fr.properties deleted file mode 100644 index 8b137891791..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor_fr.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties deleted file mode 100644 index 2e2792f9be8..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.properties +++ /dev/null @@ -1,30 +0,0 @@ -# Exception thrown when there is a file descriptor problem. -#0 : DBase 3 File who causes trouble. -#1 : Root cause message. -excp.filedescriptor_problem=The file descriptor of the ''{0}'' database file is not readable : {1}. Its DBF format seems corrupted. - -# Exception : illegal column index. -#0 : The index that is illegal. -#1, number : The number of column in that ResultSet. -excp.illegal_column_index=Illegal column index {0}. The query returned a ResultSet with {1,number} columns. - -# Exception thrown when a column doesn't exist in the result set. -#0 : Column name. -#1 : SQL Query that was attempted but failed. -#2 : Database name. -excp.no_such_column_in_resultset=There is no ''{0}'' column in this SQL query ''{1}'' on database {2}. - -# Log : status of deletion of a record. -#0 : Record number. -#1 : Byte status. -#2 : Meaning of this status. -log.delete_status=rownum {0,number} : record byte status is {1}, meaning : {2}. - -# Log : no valid charset found on DBase file. None will be used. -#0 : Database name. -#1 : Error message received that explains the problem. -log.no_valid_charset=No valid charset has been found on this {0} file : (error message : ''{1}'') and ResultSet.getString(...) methods will provide characters as they are. Reader might have to perform his own conversions. - -# Log : A given charset overrides the Dbase file one. -#0 : Overriding charset. -log.record_charset=A given record charset ''{0}'' has been set from the connection and will override the Dbase file one. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties deleted file mode 100644 index 95800c415e4..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/MappedByteReader_fr.properties +++ /dev/null @@ -1,30 +0,0 @@ -# Exception thrown when there is a file descriptor problem. -#0 : DBase 3 File who causes trouble. -#1 : Root cause message. -excp.filedescriptor_problem=Le descripteur du fichier base de données ''{0}'' n''est pas lisible : {1}. Le format de ce DBF semble corrompu. - -# Exception : illegal column index. -#0 : The index that is illegal. -#1, number : The number of column in that ResultSet. -excp.illegal_column_index=Index de colonne {0} illégal. La requête a renvoyé un ResultSet avec {1,number} colonnes. - -# Exception thrown when a column doesn't exist in the result set. -#0: Column name. -#1: SQL Query that was attempted but failed. -#2: Database name. -excp.no_such_column_in_resultset=Il n''y a pas de colonne ''{0}'' dans cette requête SQL ''{1}'' sur la base de données {2}. - -# Log : status of deletion of a record. -#0 : Record number. -#1 : Byte status. -#2 : Meaning of this status. -log.delete_status=rownum {0,number} : l''octet de statut d''enregistrement vaut {1}, signifiant : {2}. - -# Log : no valid charset found on DBase file. None will be used. -#0 : Database name. -#1 : Error message received that explains the problem. -log.no_valid_charset=Aucun jeu de caractères valide n''a été trouvé dans le fichier {0} : (message d''erreur : ''{1}'') et les méthodes ResultSet.getString(...) vont fournir les caractères comme ils sont. Le lecteur pourra devoir réaliser ses propres conversions. - -# Log : A given charset overrides the Dbase file one. -#0 : Overriding charset. -log.record_charset=Un charset ''{0}'' a été défini dans la connection et va remplacer celui du fichier DBase. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.properties deleted file mode 100644 index ed9df1772d1..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.properties +++ /dev/null @@ -1,6 +0,0 @@ -# The auto commit has no effect. -#0: true / false. -log.auto_commit_ignored=The auto-commit \u2018{0}\u2019 value is currently ignored (not implemented): auto-commit is always true. - -# Log to warn that the rollback has no effect. -log.commit_rollback_ignored=Commit and rollback has no effect (currently not implemented): auto-commit is always true. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection_fr.properties deleted file mode 100644 index 05c69ed57bc..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection_fr.properties +++ /dev/null @@ -1,6 +0,0 @@ -# Exception thrown if th auto commit has no effect. -#0: true / false. -log.auto_commit_ignored=L\u2019auto-commit \u2018{0}\u2019 est actuellement ignor\u00e9 (non impl\u00e9ment\u00e9)\u202f: L\u2019auto-commit vaut toujours \u2018vrai\u2019. - -# Log to warn that the rollback has no effect. -log.commit_rollback_ignored=Les commit et rollback n'ont pas d\u2019effet (ils ne sont pas actuellement impl\u00e9ment\u00e9s)\u202f: l\u2019auto-commit vaut toujours \u2018vrai\u2019. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.properties deleted file mode 100644 index 8a494c2c82f..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.properties +++ /dev/null @@ -1,49 +0,0 @@ -# Asserttion : the statement has not been found opened by this connection when it was searched for. -#0 : the statement that should had been found opened by this connection. -#1 : The connection. -assert.statement_not_opened_by_me=[Internal API trouble] The Statement {0} has not been opened by the connection {1}. - -# Exception thrown if the connection is closed -#0 : DBF File name. -excp.closed_connection=The connection to the DBase 3 file {0} is closed. - -# Exception : a directory has been given instead of a file. -#0 : Directory name. -excp.directory_not_expected=Your file ''{0}'' points to a directory instead of a file. - -# Exception : the file has not been found. -#0 : File that has not been found. -excp.file_not_found=The DBF file ''{0}'' has not been found. - -# Exception : illegal column index for metadata querying. -#0 : The index that is illegal. -#1, number : The number of column in that ResultSet. -excp.illegal_column_index_metadata=Illegal column index {0} for metadata. The query returned a ResultSet with {1,number} columns. - -# Exception thrown when a column doesn't exist in the result set. -#0 : Column name. -#1 : SQL Query that was attempted but failed. -#2 : Database name. -excp.no_such_column_in_resultset=There is no ''{0}'' column in this SQL query ''{1}'' on database {2}. - -# Warning : autocommit isn't implemented. -#0 : true / false. -log.autocommit_ignored=The autocommit {0} is currently ignored (not implemented) : autocommit is always true. - -# Warning : commit and rollback are not implemented : autocommit is always true. -log.commit_rollback_ignored=Commit and rollback has no effect (currently not implemented) : autocommit is always true. - -# Information : Connection opened. -#0 : DBF File opened. -#1 : Header information. -log.database_connection_opened=Database connection to {0} opened. DBase 3 descriptor of this dbf file is : {1}. - -# Warning : At the time the caller is closing this connection, he has left some statements opened. -#0, number : Number of statements that are left opened. -#1 : Opened statements. -log.statements_left_opened={0,number,integer} {0,choice,1#statement is|2#statements are} left opened at the time you are closing this connection : {1}. - -# toString() -#0 : Database file. -#1 : Open state (true, false). -toString='{'{0}, connection open state : {1}'}' diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection_fr.properties deleted file mode 100644 index 6739dd22f51..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection_fr.properties +++ /dev/null @@ -1,39 +0,0 @@ -# Exception thrown if the connection is closed -#0: DBF File name. -excp.closed_connection=La connexion à {0} est fermée. - -# Exception : a directory has been given instead of a file. -#0 : Directory name. -excp.directory_not_expected=Votre fichier ''{0}'' désigne un répertoire et non un fichier. - -# Exception : the file has not been found. -#0 : File that has not been found. -excp.file_not_found=Le fichier DBF ''{0}'' n''a pas été trouvé. - -# Exception : illegal column index for metadata querying. -#0 : The index that is illegal. -#1, number : The number of column in that ResultSet. -excp.illegal_column_index_metadata=Index de colonne {0} illégal pour des meta-données. La requête a retourné un ResultSet avec {1,number} colonnes. - -# Exception thrown when a column doesn't exist in the result set. -#0: Column name. -#1: SQL Query that was attempted but failed. -#2: Database name. -excp.no_such_column_in_resultset=Il n''y a pas de colonne ''{0}'' dans cette requête SQL ''{1}'' sur la base de données {2}. - -# Warning : autocommit isn't implemented. -#0 : true / false. -log.autocommit_ignored=L''autocommit {0} est actuellement ignoré (non implémenté) : L''autocommit vaut toujours true. - -# Warning : commit and rollback are not implemented : autocommit is always true. -log.commit_rollback_ignored=Les commit et rollback n'ont pas d''effet (ils ne sont pas actuellement implémentés) : l''autocommit vaut toujours true. - -# Warning : At the time the caller is closing this connection, he has left some statements opened. -#0, number : Number of statements that are left opened. -#1 : Opened statements. -log.statements_left_opened={0,number,integer} {0,choice,1#statement est resté ouvert|2#statements sont restés ouverts} au moment où vous fermez cette connexion : {1}. - -# Information : Connection opened. -#0 : DBF File opened. -#1 : Header information. -log.database_connection_opened=Connexion à la base de données {0} ouverte. Le descripteur DBase 3 de ce fichier dbf est : {1}. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.properties deleted file mode 100644 index e96091a26c6..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.properties +++ /dev/null @@ -1,14 +0,0 @@ -# Assert : Cannot find an expected column in database metadata. -#0 : DatabaseMetaData column searched for. -#1 : Root exception message. -assert.expected_databasemetadata_not_found=[Internal API trouble] An expected column {0} in the DatabaseMetaData has not been found : {1}. - -# Assert : Cannot find an expected column index in database metadata. -#0 : DatabaseMetaData column index missing. -#1 : Root exception message. -assert.less_column_in_metadata_than_expected=[Internal API trouble] DatabaseMetaData ran out of columns when asked for column index {0} that should exists : {1}. - -# Exception : illegal column index for metadata querying. -#0 : The index that is illegal. -#1, number : The number of column in that ResultSet. -excp.illegal_column_index_metadata=Illegal column index {0} for metadata. The query returned a ResultSet with {1,number} columns. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData_fr.properties deleted file mode 100644 index 372199af71b..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData_fr.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Exception : illegal column index for metadata querying. -#0 : The index that is illegal. -#1, number : The number of column in that ResultSet. -excp.illegal_column_index_metadata=Index de colonne {0} illégal pour des meta-données. La requête a retourné un ResultSet avec {1,number} colonnes. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.properties deleted file mode 100644 index 8b137891791..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet_fr.properties deleted file mode 100644 index 8b137891791..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/AbstractResultSet_fr.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.properties deleted file mode 100644 index c19830037e3..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Exception : A field does not exist in desc definition. -#0 : Column label that doesn't exist. -#1 : Table name. -excp.no_desc_field=The ResultSet doesn''t present a field {0} to describe columns for the table {1}. - -# Exception : all the fields has been listed in desc definition. -#0 : Table name. -excp.no_more_desc=No more columns available in the table {0} : all have been described. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing_fr.properties deleted file mode 100644 index 193efc79a37..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing_fr.properties +++ /dev/null @@ -1,8 +0,0 @@ -# Exception : A field does not exist in desc definition. -#0 : Column label that doesn't exist. -#1 : Table name. -excp.no_desc_field=Le ResultSet ne propose pas de champ {0} pour décrire la définition des colonnes de la table {1}. - -# Exception : all the fields has been listed in desc definition. -#0 : Table name. -excp.no_more_desc=Plus de colonnes disponibles dans la table {0} : toutes ont été décrites. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.properties deleted file mode 100644 index 799150b164e..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.properties +++ /dev/null @@ -1,2 +0,0 @@ -# The ResultSet listing the tables has only one result. -excp.only_one_table_per_dbf=DBase 3 files contain only one table. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.properties deleted file mode 100644 index fce524c3508..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.properties +++ /dev/null @@ -1,2 +0,0 @@ -# The ResultSet listing the tables types has only one result. -excp.only_one_table_type_handled=DBase 3 only handles TABLE types. No more results available. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties deleted file mode 100644 index fea16735807..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties +++ /dev/null @@ -1,28 +0,0 @@ -# Assertion : if this exception is thrown, the involved code that produced it is sure to have a bug. -#0 : Wrong index returned by findColumn. -#1 : Field name that caused the wrong calculation. -assert.wrong_index_for_column_name=[Erreur interne de l''API] The column index {0}, illegal, has been returned by findColumn for the field ''{1}''. - -# Exception : field is not a date. -#0 : Field name. -#1 : SQL Query. -#2 : Field value that is not a date. -excp.field_is_not_a_date=The field {0} in the query ''{1}'' has a ''{2}'' value that is not a date. - -# Exception : field is not numeric. -#0 : Field name. -#1 : Field type. -#2 : SQL Query. -#3 : Field value that is not a number. -excp.field_is_not_numeric=The field {0} of type {1} in the query ''{2}'' has a ''{3}'' value that is not numeric. - -# Exception thrown when the resultset has no more results. -#0 : SQL Query that was attempted but failed. -#1 : Database name. -excp.no_more_results=The result set has no more results for the SQL request ''{0}'' on database {1}. - -# Log : a string value has been converted with a charset. -#0 : Field name. -#1 : Field value after being converted with the charset. -#2 : Charset used. -log.string_field_charset=String field name ''{0}'' bytes values converted to ''{1}'' using charset {2}. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties deleted file mode 100644 index 6fd6387a6ba..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties +++ /dev/null @@ -1,28 +0,0 @@ -# Assertion : if this exception is thrown, the involved code that produced it is sure to have a bug. -#0 : Wrong index returned by findColumn. -#1 : Field name that caused the wrong calculation. -assert.wrong_index_for_column_name=[Erreur interne de l''API] L''index de colonne {0}, illégal, a été renvoyé par findColumn pour le champ ''{1}''. - -# Exception : field is not a date. -#0 : Field name. -#1 : SQL Query. -#2 : Field value that is not a date. -excp.field_is_not_a_date=Le champ {0} dans la requête ''{1}'' a une valeur ''{2}'' qui n''est pas une date. - -# Exception : field is not numeric. -#0 : Field name. -#1 : Field type. -#2 : SQL Query. -#3 : Field value that is not a number. -excp.field_is_not_numeric=Le champ {0} de type {1} dans la requête ''{2}'' a une valeur ''{3}'' qui n''est pas numérique. - -# Exception : the result set has no more results. -#0: SQL Query that was attempted but failed. -#1: Database name. -excp.no_more_results=Le ResultSet n''a plus de résultats pour la requête SQL ''{0}'' sur la base de données {1}. - -# Log : a string value has been converted with a charset. -#0 : Field name. -#1 : Field value after being converted with the charset. -#2 : Charset used. -log.string_field_charset=Les octets du champ de nom ''{0}'' ont été converties en ''{1}'' en utilisant le jeu de caractères {2}. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.properties deleted file mode 100644 index f691a179b45..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.properties +++ /dev/null @@ -1,10 +0,0 @@ -# Exception : attempting to get a connection from a closed connection. -#0 : SQL Query that can no more be queryied. -#1 : Database name. -excp.closed_resultset=The ResultSet connection is closed, and querying data for SQL request ''{0}'' on database {1} is no longer possible. - -# toString() -#0 : Underlying statement. -#1 : SQL Query. -#2 : Open state. -toString='{'(based on statement : {0}), sql query : {1}, result set open state : {2}'}' diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet_fr.properties deleted file mode 100644 index 8a4791723a4..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet_fr.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Exception : attempting to get a connection from a closed connection. -#0: SQL Query that can no more be queryied. -#1: Database name. -excp.closed_resultset=Le ResultSet est fermé, et requêter des données pour la requête SQL ''{0}'' sur la base de données {1} n''est plus possible. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.properties deleted file mode 100644 index c9b612f9a41..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.properties +++ /dev/null @@ -1,25 +0,0 @@ -# A field type is not known. -#0 : Field type. -assert.unknown_field_type=[Internal API Error] The field type {0} is not known among the DBase 3 type. - -# Illegal parameter in a where clause. -#0 : Illegal parameter value. -#1 : SQL Query that failed. -excp.illegal_parameter_where=The where clause contains a parameter that has an illegal value : {0}. The query that failed is : {1}. - -# An operator in a statement is invalid. -#0 : Invalid operator. -#1 : SQL Query that failed. -excp.invalid_statement_operator=The operator {0} in the where clause of the SQL Query {1} is invalid. - -# A type encountered while translating literals and fields value to java types is not Comparable. -#0 : Value. -#1 : Java type. -#2 : SQL Query. -excp.uncomparable_type=The field or literal value {0} belongs to a Java type {1} that is not Comparable, and this driver cannot handle it during a comparison. The SQL Query that encountered the problem is : {2}. - -# A field type is currently not supported. -#0 : Field name. -#1 : Unparsable field type. -#2 : SQL Query that failed. -excp.unparsable_field_type=The field {0} has a type {1} that is not currently parsable (unsupported yet) in the ''{2}'' query. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver_fr.properties deleted file mode 100644 index b673d6a71f2..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver_fr.properties +++ /dev/null @@ -1,16 +0,0 @@ -# Illegal parameter in a where clause. -#0 : Illegal parameter value. -#1 : SQL Query that failed. -excp.illegal_parameter_where=La clause where contient un paramètre qui a une valeur illégale : {0}. La requête SQL qui a échoué est : {1}. - -# A type encountered while translating literals and fields value to java types is not Comparable. -#0 : Value. -#1 : Java type. -#2 : SQL Query. -excp.uncomparable_type=La valeur du champ ou du littéral {0} appartient au type Java {1} qui n''est pas Comparable, et ce driver ne peut pas le prendre en charge durant une comparaison. La requête SQL qui a rencontré ce problème est : {2}. - -# A field type is currently not supported. -#0 : Field name. -#1 : Unparsable field type. -#2 : SQL Query that failed. -excp.unparsable_field_type=Le champ {0} a un type {1} qui n'est pas analysable (non supporté actuellement) dans la requête ''{2}''. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.properties deleted file mode 100644 index bfb13679603..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.properties +++ /dev/null @@ -1,12 +0,0 @@ -# Exception thrown when the SQL parser only accepts a degraded request. -#0 : Request parsed. -excp.limited_feature_syntax=The SQL parser is yet limited, and only accepts statements starting exactly with ''SELECT * FROM '', use spaces and not tabs. Your statement ''{0}'' doesn''t match. - -# Exception thrown when the parser had not been able to split a condition in three parts (comparand operator comparand) to analyze it. -#0 : Condition that wasn't parsed. -#1 : Request parsed. -excp.limited_feature_conditional_parsing=The SQL parser is limited yet and is only able to parse conditional expressions that are constituted in three parts : comparand1 operator comparand2, separated by spaces. A string containing spaces inside might not be well parsed yet. Your where condition ''{0}'' has been rejected in your SQL statement {1}. - -# Exception thrown when a WHERE clause is not followed by one or more conditions. -#0 : Request parsed. -excp.where_without_conditions=The WHERE clause has not been followed by a/some condition(s) in your SQL statement : ''{0}''. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.properties deleted file mode 100644 index 87e3887f6c3..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.properties +++ /dev/null @@ -1,22 +0,0 @@ -# Asserttion : the ResultSet has not been found opened by this statement when it was searched for. -#0 : the ResultSet that should had been found opened by this statement. -#1 : The statement. -assert.resultset_not_opened_by_me=[Internal API trouble] The ResultSet {0} has not been opened by the Statement {1}. - -# Exception thrown if the statement is closed. -#0 : Underlying DBF File name. -excp.closed_statement=The statement to the DBase 3 File {0} is closed. - -# Warning : At the time the caller is closing this statement, he has left some ResultSets opened. -#0, number : Number of ResultSets that are left opened. -#1 : Opened ResultSets. -log.resultsets_left_opened={0,number,integer} {0,choice,1#ResultSet is|2#ResultSets are} left opened at the time you are closing this statement : {1}. - -# Information : At the time the caller is closing this statement, the current ResultSet was still opened, but this statement will close it. -#0 : Closed ResultSet. -log.closing_underlying_resultset=The ResultSet {0} that was left open is closed by this statement. - -# toString() -#0 : Underlying connection. -#1 : Open state. -toString='{'(based on connection : {0}), statement open state : {1}'}' diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement_fr.properties deleted file mode 100644 index 11b1acd64b0..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement_fr.properties +++ /dev/null @@ -1,12 +0,0 @@ -# Exception thrown if the statement is closed. -#0 : Underlying DBF File name. -excp.closed_statement=Le statement au fichier DBase 3 {0} est fermée. - -# Warning : At the time the caller is closing this statement, he has left some ResultSets opened. -#0, number : Number of ResultSets that are left opened. -#1 : Opened ResultSets. -log.resultsets_left_opened={0,number,integer} {0,choice,1#ResultSet est|2#ResultSets sont} restés ouverts au moment où vous fermez ce statement : {1}. - -# Information : At the time the caller is closing this statement, the current ResultSet was still opened, but this statement will close it. -#0 : Closed ResultSet. -log.closing_underlying_resultset=Le ResultSet {0} qui était resté ouvert est fermé par cette fermeture de statement. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream.properties deleted file mode 100644 index 804dea10a1c..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream.properties +++ /dev/null @@ -1,9 +0,0 @@ -# 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}. diff --git a/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream_fr.properties b/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream_fr.properties deleted file mode 100644 index 3e886609bbb..00000000000 --- a/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream_fr.properties +++ /dev/null @@ -1,9 +0,0 @@ -# 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}. diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java deleted file mode 100644 index ffa22200547..00000000000 --- a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.net.URISyntaxException; -import java.net.URL; -import java.sql.Connection; -import java.sql.Driver; -import java.sql.SQLException; -import java.util.logging.Logger; - -import org.apache.sis.storage.shapefile.ShapeFileTest; -import org.apache.sis.test.TestCase; -import org.apache.sis.util.logging.Logging; -import org.junit.Before; - -/** - * Base class to settle a common environment to all the JDBC tests : - * all these tests are currently based on the SignedBikeRoute_4326_clipped.dbf DBase 3 file. - * @author Marc LE BIHAN - */ -public abstract class AbstractTestBaseForInternalJDBC extends TestCase { - /** Logger. */ - protected Logger log = Logging.getLogger(getClass()); - - /** The database file to use for testing purpose. */ - protected File dbfFile; - - /** - * Connect to test database. - * @return Connection to database. - * @throws SQLException if the connection failed. - */ - public Connection connect() throws SQLException { - final Driver driver = new DBFDriver(); - return driver.connect(this.dbfFile.getAbsolutePath(), null); - } - - /** - * Test setup. - * @throws URISyntaxException If an error occurred while getting the file to the test database. - */ - @Before - public void setup() throws URISyntaxException { - final URL url = ShapeFileTest.class.getResource("SignedBikeRoute_4326_clipped.dbf"); - assertNotNull("The database file used for testing doesn't exist.", url); - this.dbfFile = new File(url.toURI()); - assertTrue(this.dbfFile.isFile()); - } -} diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java deleted file mode 100644 index 7493a89cd99..00000000000 --- a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.sql.*; -import java.util.Properties; - -import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection; -import org.apache.sis.test.DependsOnMethod; -import org.junit.*; - -import static org.junit.Assert.*; - - -/** - * Tests {@link DBFConnection}. - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class DBFConnectionTest extends AbstractTestBaseForInternalJDBC { - /** - * Open and close a connection. - * @throws SQLException if an error occurred while opening the database. - */ - @Test - public void openCloseConnection() throws SQLException { - final Driver driver = new DBFDriver(); - final Connection connection = driver.connect(this.dbfFile.getAbsolutePath(), null); - assertFalse("Connection should be opened", connection.isClosed()); - assertTrue ("Connection should be valid", connection.isValid(0)); - - connection.close(); - assertTrue ("Connection should be closed", connection.isClosed()); - assertFalse("Connection should no more be valid", connection.isValid(0)); - } - - /** - * Open and close a connection. - * @throws SQLException if an error occurred while opening the database. - */ - @Test - public void openCloseConnectionWithAnotherCharset() throws SQLException { - Properties info = new Properties(); - info.put("record_charset", "UTF-8"); - - final Driver driver = new DBFDriver(); - final Connection connection = driver.connect(this.dbfFile.getAbsolutePath(), info); - assertFalse("Connection should be opened", connection.isClosed()); - assertTrue ("Connection should be valid", connection.isValid(0)); - - connection.close(); - assertTrue ("Connection should be closed", connection.isClosed()); - assertFalse("Connection should no more be valid", connection.isValid(0)); - } - - /** - * An attempt to use a closed connection must fail with the correct exception. - * @throws SQLException if an error occurred while opening the database. - */ - @Test(expected=SQLConnectionClosedException.class) - @DependsOnMethod("openCloseConnection") - public void connectionClosed() throws SQLException { - // Open and close an connection. - final Driver driver = new DBFDriver(); - 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(), this.dbfFile.getName()); - throw e; - } - } -} diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java deleted file mode 100644 index e51038e6cad..00000000000 --- a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.sql.*; -import java.text.MessageFormat; -import java.util.ArrayList; - -import org.apache.sis.internal.shapefile.jdbc.resultset.DBFRecordBasedResultSet; -import org.apache.sis.test.DependsOnMethod; -import org.junit.Test; - - -/** - * Tests {@link DBFRecordBasedResultSet}. - * - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class DBFResultSetTest extends AbstractTestBaseForInternalJDBC { - /** - * Reads the first record. - * @throws SQLException if an error occurred while querying the database. - */ - @Test - public void readFirstRecord() throws SQLException { - 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) - } - } - - /** - * Read all the DBF records. - * @throws SQLException if an error occurred while querying the database. - */ - @Test - @DependsOnMethod("readFirstRecord") - public void readAllRecords() throws SQLException { - try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM SignedBikeRoute")) { - int count = 0; - - while(rs.next()) { - ArrayList 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 - record.add(rs.getLong("TNODE_")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getLong("LPOLY_")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getLong("RPOLY_")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getLong("SCL_")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getLong("SCL_ID")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getLong("SCL_CODE")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getString("DXF_LAYER")); // Type : Character, Field length : 16, Decimal positions : 0 - record.add(rs.getString("SIS_ID")); // Type : Character, Field length : 12, Decimal positions : 0 - record.add(rs.getString("QUAD_CODE")); // Type : Character, Field length : 1, Decimal positions : 0 - record.add(rs.getString("PRIME_ST")); // Type : Character, Field length : 4, Decimal positions : 0 - record.add(rs.getString("INT_SEQ")); // Type : Character, Field length : 3, Decimal positions : 0 - record.add(rs.getString("ST_NAME")); // Type : Character, Field length : 29, Decimal positions : 0 - record.add(rs.getString("FDPRE")); // Type : Character, Field length : 2, Decimal positions : 0 - record.add(rs.getString("FNAME")); // Type : Character, Field length : 30, Decimal positions : 0 - record.add(rs.getString("FTYPE")); // Type : Character, Field length : 4, Decimal positions : 0 - record.add(rs.getString("FDSUF")); // Type : Character, Field length : 2, Decimal positions : 0 - record.add(rs.getLong("LEFTRANGE1")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getLong("LEFTRANGE2")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getLong("RGTRANGE1")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getLong("RGTRANGE2")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getString("STREET")); // Type : Character, Field length : 26, Decimal positions : 0 - record.add(rs.getString("QUAD")); // Type : Character, Field length : 2, Decimal positions : 0 - record.add(rs.getString("FROM_ST")); // Type : Character, Field length : 100, Decimal positions : 0 - record.add(rs.getString("TO_ST")); // Type : Character, Field length : 100, Decimal positions : 0 - record.add(rs.getString("ODD_WARD")); // Type : Character, Field length : 1, Decimal positions : 0 - record.add(rs.getString("EVEN_WARD")); // Type : Character, Field length : 1, Decimal positions : 0 - record.add(rs.getString("WARD")); // Type : Character, Field length : 3, Decimal positions : 0 - record.add(rs.getString("FC")); // Type : Character, Field length : 40, Decimal positions : 0 - record.add(rs.getInt("NHS")); // Type : Number, Field length : 5, Decimal positions : 0 - record.add(rs.getString("SIGNEDRTE1")); // Type : Character, Field length : 5, Decimal positions : 0 - record.add(rs.getString("RTETYPE1")); // Type : Character, Field length : 10, Decimal positions : 0 - record.add(rs.getString("SIGNEDRTE2")); // Type : Character, Field length : 5, Decimal positions : 0 - record.add(rs.getString("RTETYPE2")); // Type : Character, Field length : 10, Decimal positions : 0 - record.add(rs.getBigDecimal("AADT")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getBigDecimal("AADT_YEAR")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getBigDecimal("COM_SING_P")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getBigDecimal("COM_SING_A")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getBigDecimal("COM_COMB_P")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getBigDecimal("COM_COMB_A")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getString("IS_ONEWAY")); // Type : Number, Field length : 5, Decimal positions : 0 - record.add(rs.getString("TRAVEL_DIR")); // Type : Character, Field length : 20, Decimal positions : 0 - record.add(rs.getBigDecimal("LEN_MI")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getLong("STUDY_NET")); // Type : Number, Field length : 10, Decimal positions : 0 - record.add(rs.getDate("TR_DATE")); // Type : Date, Field length : 8, Decimal positions : 0 - record.add(rs.getBigDecimal("AADT_2")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getBigDecimal("AADT_FINAL")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getBigDecimal("ROUTENET")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getString("NOTES")); // Type : Character, Field length : 50, Decimal positions : 0 - record.add(rs.getBigDecimal("LENGTH_MI")); // Type : Number, Field length : 19, Decimal positions : 8 - record.add(rs.getInt("NET_MARCH")); // Type : Number, Field length : 5, Decimal positions : 0 - record.add(rs.getString("SIGNED_JOI")); // Type : Character, Field length : 5, Decimal positions : 0 - record.add(rs.getString("SIGNED_FAC")); // Type : Character, Field length : 30, Decimal positions : 0 - record.add(rs.getString("NEW_USE")); // Type : Character, Field length : 30, Decimal positions : 0 - record.add(rs.getBigDecimal("SHAPE_LEN")); // Type : Number, Field length : 19, Decimal positions : 11 - - count ++; - 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); - } - } - - /** - * An attempt to use a closed resultSet must fail with the correct exception and message. - * @throws SQLException if an error occurred while opening the database, the statement or the resultset. - */ - @Test - public void resultSetClosed() throws SQLException { - // 1) Open a connection, open a statement, open and close a ResultSet. - String sql = "SELECT * FROM SignedBikeRoute"; - - try(Connection connection = connect(); Statement stmt = connection.createStatement()) { - // Then, attempt to use it. - try { - ResultSet rs = stmt.executeQuery(sql); - rs.close(); - } - catch(SQLConnectionClosedException e) { - 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) { - fail("Not the expected exception for using a closed ResultSet."); - } - } - - // 2) Same, but we close the connection instead. - 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. - - // Then, attempt to use it. - try { - rs.next(); - } - catch(SQLConnectionClosedException e) { - 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."); - } - finally { - rs.close(); - stmt.close(); - } - - // 3) Same, but we close the statement instead . - try(Connection cnt = connect()) { - stmt = cnt.createStatement(); - rs = stmt.executeQuery(sql); - - stmt.close(); // At this time, you expect also a information message on the console, telling that the statement has closed its current ResultSet. - - // Then, attempt to use it. - try { - rs.next(); - } - catch(SQLConnectionClosedException e) { - 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."); - } - finally { - rs.close(); - stmt.close(); - } - } - } -} diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java deleted file mode 100644 index 0eb9d4674a1..00000000000 --- a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc; - -import java.sql.*; - -import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement; -import org.apache.sis.test.DependsOnMethod; -import org.junit.*; - -import static org.junit.Assert.*; - - -/** - * Tests {@link DBFStatement}. - * @author Marc Le Bihan - * @version 0.5 - * @since 0.5 - * @module - */ -public class DBFStatementTest extends AbstractTestBaseForInternalJDBC { - /** - * Open and close a statement. - * @throws SQLException if an error occurred while opening the database or the statement. - */ - @Test - public void openCloseStatement() throws SQLException { - final Driver driver = new DBFDriver(); - - 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()); - } - } - - /** - * An attempt to use a closed statement must fail with the correct exception. - * @throws SQLException if an error occurred while opening the database or the statement. - */ - @Test - @DependsOnMethod("openCloseStatement") - public void statementClosed() throws SQLException { - // Open a connection, open and close a statement. - try(Connection connection = connect()) { - final Statement stmt = connection.createStatement(); - stmt.close(); - - // Then, attempt to use it. - try { - 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(), this.dbfFile.getName()); - } - catch(SQLException e) { - fail("Not the expected exception for using a closed statement."); - } - } - - // Same, but we close the connection instead. - 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. - - // Then, attempt to use it. - try { - 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(), this.dbfFile.getName()); - } - catch(SQLException e) { - fail("Not the expected exception for using a closed statement."); - } - finally { - stmt.close(); - } - } -} diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/readme.txt b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/readme.txt deleted file mode 100644 index 2cad8137dad..00000000000 --- a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/readme.txt +++ /dev/null @@ -1,58 +0,0 @@ -The SignedBikeRoute_4326_clipped.dbf used for testing in this package has this description : - -Field name : OBJECTID, Type : Number, Field length : 10, Decimal positions : 0 -Field name : FNODE_, Type : Number, Field length : 10, Decimal positions : 0 -Field name : TNODE_, Type : Number, Field length : 10, Decimal positions : 0 -Field name : LPOLY_, Type : Number, Field length : 10, Decimal positions : 0 -Field name : RPOLY_, Type : Number, Field length : 10, Decimal positions : 0 -Field name : SCL_, Type : Number, Field length : 10, Decimal positions : 0 -Field name : SCL_ID, Type : Number, Field length : 10, Decimal positions : 0 -Field name : SCL_CODE, Type : Number, Field length : 10, Decimal positions : 0 -Field name : DXF_LAYER, Type : Character, Field length : 16, Decimal positions : 0 -Field name : SIS_ID, Type : Character, Field length : 12, Decimal positions : 0 -Field name : QUAD_CODE, Type : Character, Field length : 1, Decimal positions : 0 -Field name : PRIME_ST, Type : Character, Field length : 4, Decimal positions : 0 -Field name : INT_SEQ, Type : Character, Field length : 3, Decimal positions : 0 -Field name : ST_NAME, Type : Character, Field length : 29, Decimal positions : 0 -Field name : FDPRE, Type : Character, Field length : 2, Decimal positions : 0 -Field name : FNAME, Type : Character, Field length : 30, Decimal positions : 0 -Field name : FTYPE, Type : Character, Field length : 4, Decimal positions : 0 -Field name : FDSUF, Type : Character, Field length : 2, Decimal positions : 0 -Field name : LEFTRANGE1, Type : Number, Field length : 10, Decimal positions : 0 -Field name : LEFTRANGE2, Type : Number, Field length : 10, Decimal positions : 0 -Field name : RGTRANGE1, Type : Number, Field length : 10, Decimal positions : 0 -Field name : RGTRANGE2, Type : Number, Field length : 10, Decimal positions : 0 -Field name : STREET, Type : Character, Field length : 26, Decimal positions : 0 -Field name : QUAD, Type : Character, Field length : 2, Decimal positions : 0 -Field name : FROM_ST, Type : Character, Field length : 100, Decimal positions : 0 -Field name : TO_ST, Type : Character, Field length : 100, Decimal positions : 0 -Field name : ODD_WARD, Type : Character, Field length : 1, Decimal positions : 0 -Field name : EVEN_WARD, Type : Character, Field length : 1, Decimal positions : 0 -Field name : WARD, Type : Character, Field length : 3, Decimal positions : 0 -Field name : FC, Type : Character, Field length : 40, Decimal positions : 0 -Field name : NHS, Type : Number, Field length : 5, Decimal positions : 0 -Field name : SIGNEDRTE1, Type : Character, Field length : 5, Decimal positions : 0 -Field name : RTETYPE1, Type : Character, Field length : 10, Decimal positions : 0 -Field name : SIGNEDRTE2, Type : Character, Field length : 5, Decimal positions : 0 -Field name : RTETYPE2, Type : Character, Field length : 10, Decimal positions : 0 -Field name : AADT, Type : Number, Field length : 19, Decimal positions : 8 -Field name : AADT_YEAR, Type : Number, Field length : 19, Decimal positions : 8 -Field name : COM_SING_P, Type : Number, Field length : 19, Decimal positions : 8 -Field name : COM_SING_A, Type : Number, Field length : 19, Decimal positions : 8 -Field name : COM_COMB_P, Type : Number, Field length : 19, Decimal positions : 8 -Field name : COM_COMB_A, Type : Number, Field length : 19, Decimal positions : 8 -Field name : IS_ONEWAY, Type : Number, Field length : 5, Decimal positions : 0 -Field name : TRAVEL_DIR, Type : Character, Field length : 20, Decimal positions : 0 -Field name : LEN_MI, Type : Number, Field length : 19, Decimal positions : 8 -Field name : STUDY_NET, Type : Number, Field length : 10, Decimal positions : 0 -Field name : TR_DATE, Type : Date, Field length : 8, Decimal positions : 0 -Field name : AADT_2, Type : Number, Field length : 19, Decimal positions : 8 -Field name : AADT_FINAL, Type : Number, Field length : 19, Decimal positions : 8 -Field name : ROUTENET, Type : Number, Field length : 19, Decimal positions : 8 -Field name : NOTES, Type : Character, Field length : 50, Decimal positions : 0 -Field name : LENGTH_MI, Type : Number, Field length : 19, Decimal positions : 8 -Field name : NET_MARCH, Type : Number, Field length : 5, Decimal positions : 0 -Field name : SIGNED_JOI, Type : Character, Field length : 5, Decimal positions : 0 -Field name : SIGNED_FAC, Type : Character, Field length : 30, Decimal positions : 0 -Field name : NEW_USE, Type : Character, Field length : 30, Decimal positions : 0 -Field name : SHAPE_LEN, Type : Number, Field length : 19, Decimal positions : 11 diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java b/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java deleted file mode 100644 index 5d39dd0cd87..00000000000 --- a/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/sql/WhereClauseTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.internal.shapefile.jdbc.sql; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; - -import java.sql.*; - -import org.apache.sis.internal.shapefile.jdbc.AbstractTestBaseForInternalJDBC; -import org.apache.sis.internal.shapefile.jdbc.resultset.DBFRecordBasedResultSet; -import org.junit.Test; - -/** - * Testing of the WHERE clause in SQL Statements. - */ -public class WhereClauseTest extends AbstractTestBaseForInternalJDBC { - /** - * Test operators. - * @throws SQLException if a trouble occurs : all tests shall pass. - */ - @Test - public void operators() throws SQLException { - 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)); - assertFalse("FNODE_ > 1199", new ConditionalClauseResolver("FNODE_", 1199L, ">").isVerified(rs)); - assertFalse("FNODE_ < 1199", new ConditionalClauseResolver("FNODE_", 1199L, "<").isVerified(rs)); - assertTrue("FNODE_ >= 1199", new ConditionalClauseResolver("FNODE_", 1199L, ">=").isVerified(rs)); - assertTrue("FNODE_ <= 1199", new ConditionalClauseResolver("FNODE_", 1199L, "<=").isVerified(rs)); - - assertTrue("FNODE_ > 1198", new ConditionalClauseResolver("FNODE_", 1198L, ">").isVerified(rs)); - assertFalse("FNODE_ < 1198", new ConditionalClauseResolver("FNODE_", 1198L, "<").isVerified(rs)); - assertTrue("FNODE_ >= 1198", new ConditionalClauseResolver("FNODE_", 1198L, ">=").isVerified(rs)); - assertFalse("FNODE_ <= 1198", new ConditionalClauseResolver("FNODE_", 1198L, "<=").isVerified(rs)); - - assertFalse("FNODE_ > 1200", new ConditionalClauseResolver("FNODE_", 1200L, ">").isVerified(rs)); - assertTrue("FNODE_ < 1200", new ConditionalClauseResolver("FNODE_", 1200L, "<").isVerified(rs)); - assertFalse("FNODE_ >= 1200", new ConditionalClauseResolver("FNODE_", 1200L, ">=").isVerified(rs)); - assertTrue("FNODE_ <= 1200", new ConditionalClauseResolver("FNODE_", 1200L, "<=").isVerified(rs)); - - assertTrue("ST_NAME = '36TH ST'", new ConditionalClauseResolver("ST_NAME", "'36TH ST'", "=").isVerified(rs)); - - 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)); - } - } - - /** - * Test where conditions : field [operator] integer. - * @throws SQLException if a trouble occurs : all tests shall pass. - */ - @Test - public void whereCondition_field_literal_int() throws SQLException { - checkAndCount("FNODE_ < 2000", rs -> rs.getInt("FNODE_") < 2000, 3); - } - - /** - * Test where conditions : field [operator] integer. - * @throws SQLException if a trouble occurs : all tests shall pass. - */ - @Test - public void whereCondition_field_literal_double() throws SQLException { - checkAndCount("SHAPE_LEN < 70.5", rs -> rs.getDouble("SHAPE_LEN") < 70.5, 3); - } - - /** - * Test where conditions : field [operator] String value. - * @throws SQLException if a trouble occurs : all tests shall pass. - */ - @Test - public void whereCondition_field_literal_string() throws SQLException { - checkAndCount("FNAME = '36TH'", rs -> rs.getString("FNAME").equals("36TH"), 1); - } - - /** - * Test where conditions : field [operator] field. - * @throws SQLException if a trouble occurs : all tests shall pass. - */ - @Test - public void whereCondition_field_field() throws SQLException { - checkAndCount("FNODE_ < TNODE_", rs -> rs.getInt("FNODE_") < rs.getInt("TNODE_"), 1); - } - - /** - * Trick suggested by AdiGuba (Forum des développeurs) to avoid the exception thrown by ResultSet:getInt(), - * unhandlable by a simple Predicate. - * @param Type used. - */ - @FunctionalInterface - public interface ResultSetPredicate { - /** - * Test a condition. - * @param condition Condition. - * @return true is the condition passed. - * @throws SQLException if a trouble occurs. - */ - boolean test(T condition) throws SQLException; - } - - /** - * Check that all records match the conditions and count them. - * @param whereCondition The where condition to add to a "SELECT * FROM SignedBikeRoute WHERE " statement. - * @param condition Condition. - * @param countExpected Count Expected, -1 if you don't want to count them. - * @throws SQLException if a trouble occurs : all tests shall pass. - */ - private void checkAndCount(String whereCondition, ResultSetPredicate condition, int countExpected) throws SQLException { - String sql = "SELECT * FROM SignedBikeRoute WHERE " + whereCondition; - - try(Connection connection = connect(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery(sql)) { - int count = 0; - - while(rs.next()) { - count ++; - assertTrue(sql, condition.test(rs)); - } - - if (countExpected != -1) - assertEquals("Wrong number of records red by : " + sql, countExpected, count); - } - } -} diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java b/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java deleted file mode 100644 index ad42bdf0d37..00000000000 --- a/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.shapefile; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.net.URISyntaxException; -import java.text.MessageFormat; -import java.util.logging.Logger; - -import org.apache.sis.storage.DataStoreException; -import org.apache.sis.test.TestCase; -import org.junit.Ignore; -import org.junit.Test; -import org.apache.sis.feature.AbstractFeature; -import org.apache.sis.feature.AbstractAttribute; - - -/** - * Tests the {@link ShapeFile} class. - * - * @author Travis L. Pinney - * @version 0.5 - * @since 0.5 - * @module - */ -public final strictfp class ShapeFileTest extends TestCase { - /** - * Returns URI path to a resource. - * @param name Resource name. - * @return URI path. - * @throws URISyntaxException if the resource name is incorrect. - */ - private static String path(final String name) throws URISyntaxException { - return new File(ShapeFileTest.class.getResource(name).toURI()).getPath(); - } - - /** - * Test polylines count. - * @throws URISyntaxException if the resource name is incorrect. - * @throws DataStoreException if a general file reading trouble occurs. - */ - @Test - public void testPolyineCount() throws URISyntaxException, DataStoreException { - ShapeFile shp = new ShapeFile(path("SignedBikeRoute_4326_clipped.shp")); - readAll(shp); - } - - /** - * Test polygon count. - * @throws URISyntaxException if the resource name is incorrect. - * @throws DataStoreException if a general file reading trouble occurs. - */ - @Test - @Ignore("Shapefile removed from history (SIS-422)") - public void testPolygonCount() throws URISyntaxException, DataStoreException { - ShapeFile shp = new ShapeFile(path("ANC90Ply_4326.shp")); - readAll(shp); - } - - /** - * Test point count. - * @throws URISyntaxException if the resource name is incorrect. - * @throws DataStoreException if a general file reading trouble occurs. - */ - @Test - public void testPointCount() throws URISyntaxException, DataStoreException { - ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp")); - readAll(shp); - } - - /** - * 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); - - 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. - * @throws DataStoreException if a general file reading trouble occurs. - */ - @Test @Ignore // TODO Adapt with another shapefile. - public void testHandleEofNotification() throws URISyntaxException, DataStoreException { - ShapeFile shp = new ShapeFile(path("DEPARTEMENT.SHP")); - AbstractFeature first = null, last = null; - - Logger log = org.apache.sis.util.logging.Logging.getLogger(ShapeFileTest.class); - - try(InputFeatureStream is = shp.findAll()) { - AbstractFeature feature = is.readFeature(); - - // Read and retain the first and the last feature. - while(feature != null) { - 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); - - last = feature; - feature = is.readFeature(); - } - } - - 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 - public void testDirectAcces() throws DataStoreException, URISyntaxException { - ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp")); - - // 1) Find the third record, sequentially. - AbstractFeature 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)(((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. - AbstractFeature 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)(((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 { - try(InputFeatureStream is = shp.findAll()) { - AbstractFeature feature = is.readFeature(); - - while(feature != null) { - feature = is.readFeature(); - } - } - } -} diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java b/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java deleted file mode 100644 index f7de34db8b0..00000000000 --- a/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/ShapefileTestSuite.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.test.suite; - -import org.apache.sis.test.TestSuite; -import org.junit.runners.Suite; -import org.junit.BeforeClass; - - -/** - * All tests from the {@code sis-shapefile} module, in rough dependency order. - */ -@Suite.SuiteClasses({ - org.apache.sis.storage.shapefile.ShapeFileTest.class, - org.apache.sis.internal.shapefile.jdbc.DBFConnectionTest.class, - org.apache.sis.internal.shapefile.jdbc.DBFStatementTest.class, - org.apache.sis.internal.shapefile.jdbc.DBFResultSetTest.class, - org.apache.sis.internal.shapefile.jdbc.sql.WhereClauseTest.class -}) -public final strictfp class ShapefileTestSuite extends TestSuite { - /** - * Verifies the list of tests before to run the suite. - * See {@link #verifyTestList(Class, Class[])} for more information. - */ - @BeforeClass - public static void verifyTestList() { - assertNoMissingTest(ShapefileTestSuite.class); - verifyTestList(ShapefileTestSuite.class); - } -} diff --git a/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/package-info.txt b/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/package-info.txt deleted file mode 100644 index ac895b551f9..00000000000 --- a/storage/sis-shapefile/src/test/java/org/apache/sis/test/suite/package-info.txt +++ /dev/null @@ -1,3 +0,0 @@ -Different modules provide classes in this package - be careful about collisions. -This package is initially defined by the sis-utility module, which also provides -the package-info.java file. diff --git a/storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.dbf b/storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.dbf deleted file mode 100644 index d47758395bf9c2247505c88462dcf7176fbec602..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5861 zcmeHKv2KGf5T(kHE}gn{^3*OV!q{Luy5NBd90a6krznaTkkSwlvh?Gt;u2Jn5Ot5a z;V^gdnRh(&xY1(#Fw!(_c{3T;mt&i2THw1}BwWT_>At1wSQ;~rF9ZvDf1X8AU4n`9 z!hSbkNz&Botpq{a^02m)8R7I?}b?gAFYChOj-wT1+n zz?}-g-PCtyDPV70%s3EpRr+8Oiin{b2a~W7wW#Ch#A;$P1d)R=)QQ=I!u`6+xBGHi z>{KMrK`SY89N8SjEGpJ{m9KW-5k#eO1UN-M0sdyCt3rW6D^+>Z=Qu3`T8e9>Z4yLJ zv=UJp>8Puf7#TL!2^zGrCQ+-E#75_oy81|%mFuE<+JSJntFm&NXDfw%m>TqQyi{?r x9JKQ4KkthGp#@Da14$Zlo+>m={x!tJCN!)Qt+Xj7x@8~Dm4wuDB^|U9fFF;q2%!J~ diff --git a/storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.prj b/storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.prj deleted file mode 100644 index a30c00a55de..00000000000 --- a/storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.prj +++ /dev/null @@ -1 +0,0 @@ -GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.shp b/storage/sis-shapefile/src/test/resources/org/apache/sis/storage/shapefile/ABRALicenseePt_4326_clipped.shp deleted file mode 100644 index e133be1b3a8a3cb5facbb3e71c1a4575ed0e3495..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 184 zcmZQzQ0HR64q{#~GcYg$DicHu~_q}211;HE}nEVTmL>DK)# z`)7CjwiwDu8h3h-Pxs>;?@0c5q>t(+PrvE)dcQyU_XvL4&$QRePhO^RHA(=;2>4yQ zMQ@PhNm^5-5wGsR$CG?K+hbqcftT@^S$D)oa2ov{Jcbk?17rNjAA@=v&C;URi%FJ0 z(Nxu|9F@X9#eYx`m0q1kNzFQ-_!k;JDMn{$T~?r`_*WV}%Bs3dUlA?Ek2Jij>MS}V z;WPYK4Idtny9fhkqF39~Ai+n;tg4Z>1#@s+^Gv2_6b6e6G#gACG@;#th`bni{5@A9%EQN-y@2|xd|1C$SS(+3T%n!BKaX`ol zK+v4xI{&3T-fIujW44c?gv}10zn{Nt2T1UGmPWuo8o!RmWO_!~X+60EkGgU2ak9^z z;vM!t|2#{l(TvBZj~}ew*Xg)UMg`0Nmv(x+F--s2h$@ZwmDPDNt245Mjr&to)JarP zhSGJc4PTFr9~u3Q@uT=)ltp9n_!RkhmD29bc$QZwUtx58u&!u-^ac5yRzsSiF+Xr! zpG8GH>=-|`zUr6x$h^KdK8Rw5>-!hXO?_U{@uBhQcsYzFX$?_|@%diGPNW|#_8=UF zTtZ6fV-8!EtxLY`I83J`WZO2|k>asvk8H=c-H^5wvg21ntE@y5{g=YJQhpP=Y|1{t zuPdamFC@fMal__RloU6s)#75iytvs~(TByOe03Q+ zWG2SV#r&$Pg{D`NsR7!jeGC&y9|?Ru)&8KMUmUbUad>RX@P5G|nbqR&=4N~E34*S8|72*;Ob$?|kc!SaTUf4hZ1?-f4Y3y>kroP&$4ori_J!nd9ej(1 zQVK$ZSUV*dsTm^d+nCxTE>EL!2=%7QGbvepyPpo6inxv zOBnoZv$EplTKFKp*%UkLw}h9^vgfND=aiezrU&l~W7t9`>*eZV zc@6Z8*4xE;xsRu6e7bW*A@&2gh*>)fWYAOq97u&mE9<1WS-myJM5v%q6G0Jy1?8}8 zP~Y_x>8KBbis)6VD2c80;^JYXWZ^+PF54QY%ZzFFy(jDDy4ftu=`lm!K1Thp-^W1^ z_Qk@+kOqe_;cr7Hux7CX{|z;yoTB z5OU{0dp6%}<`+*L`6ZZ;wEM32|J*gZ@4CA=Jx+cwHScqvrN_s6Q4>}v ze`Fe;q7q9{I%x^u5wjDdRJW;Vh}WPZ#ws{QP3iC<0*QxZOJC598Nj8>O`ki1|i$xKZTb{9cSE|2r`)8R>8gtbsv5;8xBmClouKirTuShp(&vjc9Eu; zQ;W6<>BI}E&{86($<&#P5Clmg(~ACBSf*g1MbA4sU>_cKE`EET_dU-!-@|cg8Mok) zBz;=Markkc@7rIS3}(+oOP}MNMc^;ZoR7b`)9i_jt!Ysg2>gQW|Nj{TJV3L4KFm$F z?J|36rSfO%(d*_KZ5A+_MZ%^3dd1piZupxO+SVr7i4Ev&wfcIAjf1m>aBz<4H%F{_ zTvZx<|BSS@V$~)>;*O?*mm;Wk$+sK7tEgb zuY3dLR)JS{yB=x4$3{z!)`3YQ$EHP1QtS||Zbc$AZk4P21~lRs;(Am`)k@NvUOEH% zp?=pg;@-;mD(V;O#U37nmPN-wzol<=8hHxR740Rq^C1S}JpV+s7R=w4dTYU>ab12L zxbsh)l-OD0n2ZO?WMblsF8`p%27X)$fZ(@l4&*0$zHwi~^(kuEoJ)S-lpcjnFN2$Qxuz-$)FqxRz) zFX=Hd7(3vDWp_I7RynV=iF8@54m{rnt1+!pRWeRm%k_q=C}>xeZMNyb z^)eGY1k98(;@2a(2M3 h9Yxd#$cq5tJ|LdLz`&>mq#b~C7L;BGr9S~_4*(q276kwR From 8491f5f027bb8a64ea01e5e83699d4055dc0a976 Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Mon, 9 May 2022 17:26:15 +0200 Subject: [PATCH 2/8] Set version number to 1.2. --- application/pom.xml | 2 +- application/sis-console/pom.xml | 2 +- .../sis-console/src/main/artifact/bin/sis | 2 +- application/sis-javafx/pom.xml | 2 +- .../sis-javafx/src/main/artifact/bin/sisfx | 2 +- .../src/main/artifact/bin/sisfx.bat | 2 +- application/sis-openoffice/pom.xml | 2 +- .../src/main/unopkg/build-instruction.html | 2 +- application/sis-webapp/pom.xml | 2 +- cloud/pom.xml | 2 +- cloud/sis-cloud-aws/pom.xml | 2 +- core/pom.xml | 2 +- core/sis-build-helper/pom.xml | 2 +- .../src/main/ant/prepare-release.xml | 44 ------------------- core/sis-feature/pom.xml | 2 +- core/sis-metadata/pom.xml | 2 +- core/sis-portrayal/pom.xml | 2 +- core/sis-referencing-by-identifiers/pom.xml | 2 +- core/sis-referencing/pom.xml | 2 +- .../referencing/factory/sql/epsg/package.html | 2 +- core/sis-utility/pom.xml | 2 +- .../java/org/apache/sis/util/Version.java | 2 +- pom.xml | 22 +--------- profiles/pom.xml | 2 +- profiles/sis-french-profile/pom.xml | 2 +- profiles/sis-japan-profile/pom.xml | 2 +- storage/pom.xml | 2 +- storage/sis-earth-observation/pom.xml | 2 +- storage/sis-geotiff/pom.xml | 2 +- storage/sis-netcdf/pom.xml | 2 +- storage/sis-sqlstore/pom.xml | 2 +- storage/sis-storage/pom.xml | 2 +- storage/sis-xmlstore/pom.xml | 2 +- 33 files changed, 32 insertions(+), 96 deletions(-) delete mode 100644 core/sis-build-helper/src/main/ant/prepare-release.xml diff --git a/application/pom.xml b/application/pom.xml index 8c89a038583..fe551b2d5dd 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -28,7 +28,7 @@ org.apache.sis parent - 1.2-SNAPSHOT + 1.2 diff --git a/application/sis-console/pom.xml b/application/sis-console/pom.xml index fa0b9d22291..bb4c49ea9d4 100644 --- a/application/sis-console/pom.xml +++ b/application/sis-console/pom.xml @@ -28,7 +28,7 @@ org.apache.sis application - 1.2-SNAPSHOT + 1.2 diff --git a/application/sis-console/src/main/artifact/bin/sis b/application/sis-console/src/main/artifact/bin/sis index 81857313843..de625073b9c 100755 --- a/application/sis-console/src/main/artifact/bin/sis +++ b/application/sis-console/src/main/artifact/bin/sis @@ -24,7 +24,7 @@ SIS_DATA="${SIS_DATA:-$BASE_DIR/data}" export SIS_DATA # Execute SIS with any optional JAR that the user may put in the 'lib' directory. -java -classpath "$BASE_DIR/lib/sis-console-1.2-SNAPSHOT.jar" \ +java -classpath "$BASE_DIR/lib/sis-console-1.2.jar" \ -Djava.util.logging.config.file="$BASE_DIR/conf/logging.properties" \ -Dderby.stream.error.file="$BASE_DIR/log/derby.log" \ org.apache.sis.console.Command $SIS_OPTS "$@" diff --git a/application/sis-javafx/pom.xml b/application/sis-javafx/pom.xml index 6b05851f587..f8a25309ac5 100644 --- a/application/sis-javafx/pom.xml +++ b/application/sis-javafx/pom.xml @@ -28,7 +28,7 @@ org.apache.sis application - 1.2-SNAPSHOT + 1.2 diff --git a/application/sis-javafx/src/main/artifact/bin/sisfx b/application/sis-javafx/src/main/artifact/bin/sisfx index a6070b8bacb..54328b7d453 100755 --- a/application/sis-javafx/src/main/artifact/bin/sisfx +++ b/application/sis-javafx/src/main/artifact/bin/sisfx @@ -38,7 +38,7 @@ fi java -splash:"$BASE_DIR/lib/logo.jpg" \ --add-modules javafx.graphics,javafx.controls,javafx.web \ --module-path "$PATH_TO_FX" \ - --class-path "$BASE_DIR/lib/sis-javafx-1.2-SNAPSHOT.jar" \ + --class-path "$BASE_DIR/lib/sis-javafx-1.2.jar" \ -Djava.util.logging.config.class="org.apache.sis.internal.setup.LoggingConfiguration" \ -Djava.util.logging.config.file="$BASE_DIR/conf/logging.properties" \ -Dderby.stream.error.file="$BASE_DIR/log/derby.log" \ diff --git a/application/sis-javafx/src/main/artifact/bin/sisfx.bat b/application/sis-javafx/src/main/artifact/bin/sisfx.bat index 28ce060e7a6..bf4b77862db 100644 --- a/application/sis-javafx/src/main/artifact/bin/sisfx.bat +++ b/application/sis-javafx/src/main/artifact/bin/sisfx.bat @@ -29,7 +29,7 @@ IF "%PATH_TO_FX%"=="" ( java -splash:"%BASE_DIR%\lib\logo.jpg"^ --add-modules javafx.graphics,javafx.controls,javafx.web^ --module-path "%PATH_TO_FX%"^ - --class-path "%BASE_DIR%\lib\sis-javafx-1.2-SNAPSHOT.jar"^ + --class-path "%BASE_DIR%\lib\sis-javafx-1.2.jar"^ -Djava.util.logging.config.class=org.apache.sis.internal.setup.LoggingConfiguration^ -Djava.util.logging.config.file="%BASE_DIR%\conf\logging.properties"^ -Dderby.stream.error.file="%BASE_DIR%\log\derby.log"^ diff --git a/application/sis-openoffice/pom.xml b/application/sis-openoffice/pom.xml index 59a1c5487eb..75c5649db71 100644 --- a/application/sis-openoffice/pom.xml +++ b/application/sis-openoffice/pom.xml @@ -28,7 +28,7 @@ org.apache.sis application - 1.2-SNAPSHOT + 1.2 diff --git a/application/sis-openoffice/src/main/unopkg/build-instruction.html b/application/sis-openoffice/src/main/unopkg/build-instruction.html index a9e05382c0f..3c3fdbfb435 100644 --- a/application/sis-openoffice/src/main/unopkg/build-instruction.html +++ b/application/sis-openoffice/src/main/unopkg/build-instruction.html @@ -100,7 +100,7 @@

Build:

Test in Apache OpenOffice:

Launch:

cd target
-unopkg add apache-sis-1.2-SNAPSHOT.oxt --log-file log.txt
+unopkg add apache-sis-1.2.oxt --log-file log.txt
 scalc -env:RTL_LOGFILE=log.txt

If not already done, configure Java runtime with diff --git a/application/sis-webapp/pom.xml b/application/sis-webapp/pom.xml index aac4a08bc87..3e6f5389a6f 100644 --- a/application/sis-webapp/pom.xml +++ b/application/sis-webapp/pom.xml @@ -28,7 +28,7 @@ org.apache.sis application - 1.2-SNAPSHOT + 1.2 org.apache.sis.application diff --git a/cloud/pom.xml b/cloud/pom.xml index b16082f9ded..8c3a2e0c003 100644 --- a/cloud/pom.xml +++ b/cloud/pom.xml @@ -28,7 +28,7 @@ org.apache.sis parent - 1.2-SNAPSHOT + 1.2 diff --git a/cloud/sis-cloud-aws/pom.xml b/cloud/sis-cloud-aws/pom.xml index be8228b179c..73231b88929 100644 --- a/cloud/sis-cloud-aws/pom.xml +++ b/cloud/sis-cloud-aws/pom.xml @@ -28,7 +28,7 @@ org.apache.sis cloud - 1.2-SNAPSHOT + 1.2 diff --git a/core/pom.xml b/core/pom.xml index 7b562a5cd43..92daf663be8 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -28,7 +28,7 @@ org.apache.sis parent - 1.2-SNAPSHOT + 1.2 diff --git a/core/sis-build-helper/pom.xml b/core/sis-build-helper/pom.xml index c6c819feb0c..128297a9924 100644 --- a/core/sis-build-helper/pom.xml +++ b/core/sis-build-helper/pom.xml @@ -32,7 +32,7 @@ org.apache.sis parent - 1.2-SNAPSHOT + 1.2 ../../pom.xml diff --git a/core/sis-build-helper/src/main/ant/prepare-release.xml b/core/sis-build-helper/src/main/ant/prepare-release.xml deleted file mode 100644 index 6fffb54fdfc..00000000000 --- a/core/sis-build-helper/src/main/ant/prepare-release.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/core/sis-feature/pom.xml b/core/sis-feature/pom.xml index 7a63e937f44..561020c2368 100644 --- a/core/sis-feature/pom.xml +++ b/core/sis-feature/pom.xml @@ -28,7 +28,7 @@ org.apache.sis core - 1.2-SNAPSHOT + 1.2 diff --git a/core/sis-metadata/pom.xml b/core/sis-metadata/pom.xml index b64e0cbd5f5..23f2f1afc51 100644 --- a/core/sis-metadata/pom.xml +++ b/core/sis-metadata/pom.xml @@ -28,7 +28,7 @@ org.apache.sis core - 1.2-SNAPSHOT + 1.2 diff --git a/core/sis-portrayal/pom.xml b/core/sis-portrayal/pom.xml index f0baa902c6a..8653d719468 100644 --- a/core/sis-portrayal/pom.xml +++ b/core/sis-portrayal/pom.xml @@ -28,7 +28,7 @@ org.apache.sis core - 1.2-SNAPSHOT + 1.2 diff --git a/core/sis-referencing-by-identifiers/pom.xml b/core/sis-referencing-by-identifiers/pom.xml index 02ed41049f7..5943f29e402 100644 --- a/core/sis-referencing-by-identifiers/pom.xml +++ b/core/sis-referencing-by-identifiers/pom.xml @@ -28,7 +28,7 @@ org.apache.sis core - 1.2-SNAPSHOT + 1.2 org.apache.sis.core diff --git a/core/sis-referencing/pom.xml b/core/sis-referencing/pom.xml index 992fb68803c..8f77f95e1bf 100644 --- a/core/sis-referencing/pom.xml +++ b/core/sis-referencing/pom.xml @@ -28,7 +28,7 @@ org.apache.sis core - 1.2-SNAPSHOT + 1.2 org.apache.sis.core diff --git a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html index 2989413319a..30a37911e83 100644 --- a/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html +++ b/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html @@ -131,7 +131,7 @@

How to apply EPSG geodetic dataset updates

mvn clean install export CLASSPATH=~/.m2/repository/org/apache/derby/derby/10.14.2.0/derby-10.14.2.0.jar export CLASSPATH=$PWD/core/sis-metadata/target/test-classes:$CLASSPATH -export CLASSPATH=$PWD/target/binaries/sis-referencing-1.2-SNAPSHOT.jar:$CLASSPATH +export CLASSPATH=$PWD/target/binaries/sis-referencing-1.2.jar:$CLASSPATH export CLASSPATH=$PWD/core/sis-metadata/target/test-classes:$CLASSPATH export CLASSPATH=$PWD/core/sis-referencing/target/test-classes:$CLASSPATH cd <path to local copy of http://svn.apache.org/repos/asf/sis/data/non-free/> diff --git a/core/sis-utility/pom.xml b/core/sis-utility/pom.xml index 5ee0af329f0..dec340928a6 100644 --- a/core/sis-utility/pom.xml +++ b/core/sis-utility/pom.xml @@ -28,7 +28,7 @@ org.apache.sis core - 1.2-SNAPSHOT + 1.2 diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/Version.java b/core/sis-utility/src/main/java/org/apache/sis/util/Version.java index 500417b1143..7439cf35372 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/util/Version.java +++ b/core/sis-utility/src/main/java/org/apache/sis/util/Version.java @@ -59,7 +59,7 @@ public class Version implements CharSequence, Comparable, Serializable /** * The version of this Apache SIS distribution. */ - public static final Version SIS = new Version(MAJOR_VERSION + "." + MINOR_VERSION + "-SNAPSHOT"); + public static final Version SIS = new Version(MAJOR_VERSION + "." + MINOR_VERSION); /** * A few commonly used version numbers. This list is based on SIS needs, e.g. in {@code DataStore} implementations. diff --git a/pom.xml b/pom.xml index 930831261de..047a3b9f2b6 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ ============================================================== --> org.apache.sis parent - 1.2-SNAPSHOT + 1.2 pom Apache SIS @@ -976,26 +976,6 @@ - - - - - apache.snapshots - Apache Snapshot Repository - http://repository.apache.org/snapshots - - false - - - - - diff --git a/profiles/pom.xml b/profiles/pom.xml index e0a146fbf17..c0c76d70223 100644 --- a/profiles/pom.xml +++ b/profiles/pom.xml @@ -28,7 +28,7 @@ org.apache.sis parent - 1.2-SNAPSHOT + 1.2 diff --git a/profiles/sis-french-profile/pom.xml b/profiles/sis-french-profile/pom.xml index 8596e559c1a..2cc59a741fb 100644 --- a/profiles/sis-french-profile/pom.xml +++ b/profiles/sis-french-profile/pom.xml @@ -28,7 +28,7 @@ org.apache.sis profiles - 1.2-SNAPSHOT + 1.2 diff --git a/profiles/sis-japan-profile/pom.xml b/profiles/sis-japan-profile/pom.xml index dbe0fe67022..c5c60035eb8 100644 --- a/profiles/sis-japan-profile/pom.xml +++ b/profiles/sis-japan-profile/pom.xml @@ -28,7 +28,7 @@ org.apache.sis profiles - 1.2-SNAPSHOT + 1.2 diff --git a/storage/pom.xml b/storage/pom.xml index a69678d0330..0ca5b6066fa 100644 --- a/storage/pom.xml +++ b/storage/pom.xml @@ -28,7 +28,7 @@ org.apache.sis parent - 1.2-SNAPSHOT + 1.2 diff --git a/storage/sis-earth-observation/pom.xml b/storage/sis-earth-observation/pom.xml index b73b394bb6a..3ea0de24005 100644 --- a/storage/sis-earth-observation/pom.xml +++ b/storage/sis-earth-observation/pom.xml @@ -28,7 +28,7 @@ org.apache.sis storage - 1.2-SNAPSHOT + 1.2 diff --git a/storage/sis-geotiff/pom.xml b/storage/sis-geotiff/pom.xml index 81ab5f17be4..fc8567f34b6 100644 --- a/storage/sis-geotiff/pom.xml +++ b/storage/sis-geotiff/pom.xml @@ -28,7 +28,7 @@ org.apache.sis storage - 1.2-SNAPSHOT + 1.2 diff --git a/storage/sis-netcdf/pom.xml b/storage/sis-netcdf/pom.xml index 5aefcd69941..30b83d48212 100644 --- a/storage/sis-netcdf/pom.xml +++ b/storage/sis-netcdf/pom.xml @@ -28,7 +28,7 @@ org.apache.sis storage - 1.2-SNAPSHOT + 1.2 diff --git a/storage/sis-sqlstore/pom.xml b/storage/sis-sqlstore/pom.xml index 7585713515a..a4788eb97f8 100644 --- a/storage/sis-sqlstore/pom.xml +++ b/storage/sis-sqlstore/pom.xml @@ -28,7 +28,7 @@ org.apache.sis storage - 1.2-SNAPSHOT + 1.2 diff --git a/storage/sis-storage/pom.xml b/storage/sis-storage/pom.xml index 28c09737c65..925584461be 100644 --- a/storage/sis-storage/pom.xml +++ b/storage/sis-storage/pom.xml @@ -28,7 +28,7 @@ org.apache.sis storage - 1.2-SNAPSHOT + 1.2 diff --git a/storage/sis-xmlstore/pom.xml b/storage/sis-xmlstore/pom.xml index 2ac3576ac5e..63d7c6340c4 100644 --- a/storage/sis-xmlstore/pom.xml +++ b/storage/sis-xmlstore/pom.xml @@ -28,7 +28,7 @@ org.apache.sis storage - 1.2-SNAPSHOT + 1.2 From 493e6437490030617da0da025a2bf73655cf21d0 Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Tue, 10 May 2022 14:19:57 +0200 Subject: [PATCH 3/8] Fix compilation errors caused by mismatched versions. --- ide-project/NetBeans/nbproject/project.properties | 2 +- pom.xml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ide-project/NetBeans/nbproject/project.properties b/ide-project/NetBeans/nbproject/project.properties index 69e4277c3ac..94a34844d48 100644 --- a/ide-project/NetBeans/nbproject/project.properties +++ b/ide-project/NetBeans/nbproject/project.properties @@ -110,7 +110,7 @@ httpclient.version = 4.5.13 httpcore.version = 4.4.13 cm-logging.version = 1.2 slf4j.version = 1.7.28 -junit.version = 4.13.2 +junit.version = 4.12 hamcrest.version = 1.3 derby.version = 10.14.2.0 hsqldb.version = 2.6.1 diff --git a/pom.xml b/pom.xml index 047a3b9f2b6..f556f8c95df 100644 --- a/pom.xml +++ b/pom.xml @@ -859,7 +859,6 @@ maven-javadoc-plugin 3.4.0 - 17 ${maven.compiler.source} ${project.build.sourceEncoding} ${website.encoding} From 6aa660bd495dd7232fb6ac8c4960959869402feb Mon Sep 17 00:00:00 2001 From: Martin Desruisseaux Date: Tue, 10 May 2022 14:35:15 +0200 Subject: [PATCH 4/8] Remove `sis-webapp` module, since it is not ready. --- application/pom.xml | 1 - application/sis-webapp/pom.xml | 47 ------------------- .../java/org/apache/sis/services/Servlet.java | 26 ---------- .../org/apache/sis/services/package-info.java | 21 --------- .../src/main/webapp/META-INF/context.xml | 26 ---------- .../src/main/webapp/WEB-INF/web.xml | 24 ---------- ide-project/NetBeans/nbproject/build-impl.xml | 25 ++++------ .../NetBeans/nbproject/genfiles.properties | 4 +- .../NetBeans/nbproject/project.properties | 1 - ide-project/NetBeans/nbproject/project.xml | 1 - 10 files changed, 10 insertions(+), 166 deletions(-) delete mode 100644 application/sis-webapp/pom.xml delete mode 100644 application/sis-webapp/src/main/java/org/apache/sis/services/Servlet.java delete mode 100644 application/sis-webapp/src/main/java/org/apache/sis/services/package-info.java delete mode 100644 application/sis-webapp/src/main/webapp/META-INF/context.xml delete mode 100644 application/sis-webapp/src/main/webapp/WEB-INF/web.xml diff --git a/application/pom.xml b/application/pom.xml index fe551b2d5dd..b6dd6152fd9 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -118,7 +118,6 @@ =========================================================== --> sis-console - sis-webapp sis-openoffice diff --git a/application/sis-webapp/pom.xml b/application/sis-webapp/pom.xml deleted file mode 100644 index 3e6f5389a6f..00000000000 --- a/application/sis-webapp/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.sis - application - 1.2 - - - org.apache.sis.application - sis-webapp - war - Apache SIS web services layer - http://sis.apache.org - - - - javax - javaee-api - - - - diff --git a/application/sis-webapp/src/main/java/org/apache/sis/services/Servlet.java b/application/sis-webapp/src/main/java/org/apache/sis/services/Servlet.java deleted file mode 100644 index c3d4b5e1a71..00000000000 --- a/application/sis-webapp/src/main/java/org/apache/sis/services/Servlet.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.services; - - -/** - * Place-holder for future web services. - */ -public final class Servlet { - private Servlet() { - } -} diff --git a/application/sis-webapp/src/main/java/org/apache/sis/services/package-info.java b/application/sis-webapp/src/main/java/org/apache/sis/services/package-info.java deleted file mode 100644 index 25ac79492ae..00000000000 --- a/application/sis-webapp/src/main/java/org/apache/sis/services/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Place-holder for future web services. - */ -package org.apache.sis.services; diff --git a/application/sis-webapp/src/main/webapp/META-INF/context.xml b/application/sis-webapp/src/main/webapp/META-INF/context.xml deleted file mode 100644 index 011866cfd3c..00000000000 --- a/application/sis-webapp/src/main/webapp/META-INF/context.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - diff --git a/application/sis-webapp/src/main/webapp/WEB-INF/web.xml b/application/sis-webapp/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 74993a471f9..00000000000 --- a/application/sis-webapp/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - Apache SIS - diff --git a/ide-project/NetBeans/nbproject/build-impl.xml b/ide-project/NetBeans/nbproject/build-impl.xml index fa02cdab9de..269ab1ad0e5 100644 --- a/ide-project/NetBeans/nbproject/build-impl.xml +++ b/ide-project/NetBeans/nbproject/build-impl.xml @@ -90,7 +90,7 @@ is divided into following sections: - + @@ -201,7 +201,6 @@ is divided into following sections: - @@ -321,7 +320,6 @@ is divided into following sections: Must set src.local-src.dir Must set src.javafx.dir - Must set src.webapp.dir Must set src.console.dir Must set src.portrayal.dir Must set src.earth-obs.dir @@ -372,7 +370,7 @@ is divided into following sections: - + @@ -384,7 +382,7 @@ is divided into following sections: - + @@ -439,7 +437,7 @@ is divided into following sections: - + @@ -482,7 +480,7 @@ is divided into following sections: - + @@ -517,7 +515,7 @@ is divided into following sections: - + @@ -1236,14 +1234,13 @@ is divided into following sections: - + - @@ -1279,7 +1276,7 @@ is divided into following sections: Must select some files in the IDE or set javac.includes - + @@ -1677,9 +1674,6 @@ is divided into following sections: - - - @@ -1739,9 +1733,6 @@ is divided into following sections: - - - diff --git a/ide-project/NetBeans/nbproject/genfiles.properties b/ide-project/NetBeans/nbproject/genfiles.properties index 7dd48539a1e..fd6be5654ed 100644 --- a/ide-project/NetBeans/nbproject/genfiles.properties +++ b/ide-project/NetBeans/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.data.CRC32=58e6b21c build.xml.script.CRC32=462eaba0 build.xml.stylesheet.CRC32=28e38971@1.53.1.46 -nbproject/build-impl.xml.data.CRC32=51b00f24 -nbproject/build-impl.xml.script.CRC32=ef1e5433 +nbproject/build-impl.xml.data.CRC32=241a8d7d +nbproject/build-impl.xml.script.CRC32=60cdcd10 nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.102.0.48 diff --git a/ide-project/NetBeans/nbproject/project.properties b/ide-project/NetBeans/nbproject/project.properties index 94a34844d48..e109aeb1672 100644 --- a/ide-project/NetBeans/nbproject/project.properties +++ b/ide-project/NetBeans/nbproject/project.properties @@ -53,7 +53,6 @@ project.root = ../.. src.local-src.dir = ../local-src src.javafx.dir = ${project.root}/application/sis-javafx/doc test.javafx.dir = ${project.root}/application/sis-javafx/doc -src.webapp.dir = ${project.root}/application/sis-webapp/src/main/java src.console.dir = ${project.root}/application/sis-console/src/main/java test.console.dir = ${project.root}/application/sis-console/src/test/java src.earth-obs.dir = ${project.root}/storage/sis-earth-observation/src/main/java diff --git a/ide-project/NetBeans/nbproject/project.xml b/ide-project/NetBeans/nbproject/project.xml index 11f31f33b31..0ecc31d17c4 100644 --- a/ide-project/NetBeans/nbproject/project.xml +++ b/ide-project/NetBeans/nbproject/project.xml @@ -25,7 +25,6 @@ - From 8efd985250ce46372f8813dc0acf4047b07e4e35 Mon Sep 17 00:00:00 2001 From: Seal Security Date: Mon, 26 Jan 2026 10:29:53 +0000 Subject: [PATCH 5/8] specific library ci From b694cab357c8c8559eb5a913435987a1bd74753d Mon Sep 17 00:00:00 2001 From: Seal Security Date: Mon, 26 Jan 2026 10:29:53 +0000 Subject: [PATCH 6/8] ci pre-run edits 1.2 From 21c50ca2cfbff5845a4b079ea5e4df91ab0795d2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 4 May 2026 13:20:56 +0300 Subject: [PATCH 7/8] Add Dockerfile for Maven/Java build Co-Authored-By: Claude Sonnet 4.6 --- Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..95658fdfa5d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM maven:3.9-eclipse-temurin-17 AS build +WORKDIR /app +COPY . . +RUN mvn install -DskipTests + +FROM eclipse-temurin:17-jre +WORKDIR /app +COPY --from=build /app/target/*.jar app.jar +ENTRYPOINT ["java", "-jar", "app.jar"] From 02affd5d57106c80295a9e29f5767ec6554680c2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 4 May 2026 13:32:26 +0300 Subject: [PATCH 8/8] Update Dockerfile with mvn install, package, verify steps Co-Authored-By: Claude Sonnet 4.6 --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 95658fdfa5d..bcb14360330 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ FROM maven:3.9-eclipse-temurin-17 AS build WORKDIR /app COPY . . -RUN mvn install -DskipTests +RUN mvn install +RUN mvn package +RUN mvn verify FROM eclipse-temurin:17-jre WORKDIR /app