You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by ml...@apache.org on 2015/12/07 11:35:09 UTC
svn commit: r1718297 [1/2] - in /sis/branches/JDK8/storage/sis-shapefile/src:
main/java/org/apache/sis/internal/shapefile/
main/java/org/apache/sis/internal/shapefile/jdbc/
main/java/org/apache/sis/internal/shapefile/jdbc/connection/
main/java/org/apac...
Author: mlebihan
Date: Mon Dec 7 10:35:08 2015
New Revision: 1718297
URL: http://svn.apache.org/viewvc?rev=1718297&view=rev
Log:
SIS-305 : Shapefile reader should be able to use .SHX (shapefile index)
Shapefile receives a new method :
shp.find(String sqlStatment);
that limits the returned features to the ones matching the SQL query.
Added:
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLInvalidRecordNumberForDirectAccessException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLNoDirectAccessAvailableException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader.properties
sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/ShapefileByteReader_fr.properties
sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream.properties
sis/branches/JDK8/storage/sis-shapefile/src/main/resources/org/apache/sis/storage/shapefile/InputFeatureStream_fr.properties
Modified:
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/BuiltInMemoryResultSet.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFResultSet.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLIllegalColumnIndexException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoResultException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNoSuchFieldException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotDateException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/SQLNotNumericException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/ClauseResolver.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/CrudeSQLParser.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLIllegalParameterException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLInvalidStatementException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/sql/SQLUnsupportedParsingFeatureException.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/statement/DBFStatement.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/AbstractTestBaseForInternalJDBC.java
sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFConnectionTest.java
sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFResultSetTest.java
sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/internal/shapefile/jdbc/DBFStatementTest.java
sis/branches/JDK8/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -34,7 +34,7 @@ import org.apache.sis.util.logging.Loggi
*/
public abstract class AutoChecker {
/** Logger. */
- private Logger logger = Logging.getLogger(getClass().getSimpleName());
+ private static Logger LOGGER = Logging.getLogger(AutoChecker.class.getSimpleName());
/**
* Format a resource bundle message.
@@ -95,7 +95,7 @@ public abstract class AutoChecker {
Objects.requireNonNull(logLevel, "The log level cannot be null.");
String message = format(key, args);
- logger.log(logLevel, message);
+ LOGGER.log(logLevel, message);
return(message);
}
@@ -112,11 +112,20 @@ public abstract class AutoChecker {
Objects.requireNonNull(logLevel, "The log level cannot be null.");
String message = format(classForResourceBundleName, key, args);
- logger.log(logLevel, message);
+ 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.
@@ -125,7 +134,7 @@ public abstract class AutoChecker {
final protected void log(Level logLevel, String key, Object... args) {
Objects.requireNonNull(logLevel, "The log level cannot be null.");
- if (logger.isLoggable(logLevel))
+ if (LOGGER.isLoggable(logLevel))
format(logLevel, key, args);
}
@@ -171,6 +180,6 @@ public abstract class AutoChecker {
* @return logger.
*/
public Logger getLogger() {
- return logger;
+ return LOGGER;
}
}
Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLInvalidRecordNumberForDirectAccessException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLInvalidRecordNumberForDirectAccessException.java?rev=1718297&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLInvalidRecordNumberForDirectAccessException.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLInvalidRecordNumberForDirectAccessException.java Mon Dec 7 10:35:08 2015
@@ -0,0 +1,65 @@
+/*
+ * 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;
+ }
+}
Added: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLNoDirectAccessAvailableException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLNoDirectAccessAvailableException.java?rev=1718297&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLNoDirectAccessAvailableException.java (added)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/SQLNoDirectAccessAvailableException.java Mon Dec 7 10:35:08 2015
@@ -0,0 +1,50 @@
+/*
+ * 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);
+ }
+}
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -16,9 +16,10 @@
*/
package org.apache.sis.internal.shapefile;
-import java.io.File;
-import java.io.IOException;
+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;
@@ -54,22 +55,38 @@ public class ShapefileByteReader extends
/** 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<Integer> indexes;
+
+ /** Shapefile records lengths (loaded from .SHX file, if any found). */
+ private ArrayList<Integer> 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) throws InvalidShapefileFormatException, SQLInvalidDbaseFileFormatException, SQLShapefileNotFoundException, SQLDbaseFileNotFoundException {
+ 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();
+ }
- featuresType = getFeatureType(shapefile.getName());
+ this.featuresType = getFeatureType(shapefile.getName());
}
/**
@@ -77,7 +94,7 @@ public class ShapefileByteReader extends
* @return Fields descriptors.
*/
public List<DBase3FieldDescriptor> getFieldsDescriptors() {
- return databaseFieldsDescriptors;
+ return this.databaseFieldsDescriptors;
}
/**
@@ -85,7 +102,7 @@ public class ShapefileByteReader extends
* @return Shapefile descriptor.
*/
public ShapefileDescriptor getShapefileDescriptor() {
- return shapefileDescriptor;
+ return this.shapefileDescriptor;
}
/**
@@ -93,7 +110,7 @@ public class ShapefileByteReader extends
* @return Features type.
*/
public DefaultFeatureType getFeaturesType() {
- return featuresType;
+ return this.featuresType;
}
/**
@@ -104,13 +121,13 @@ public class ShapefileByteReader extends
private DefaultFeatureType getFeatureType(final String name) {
Objects.requireNonNull(name, "The feature name cannot be null.");
- final int n = databaseFieldsDescriptors.size();
+ final int n = this.databaseFieldsDescriptors.size();
final DefaultAttributeType<?>[] attributes = new DefaultAttributeType<?>[n + 1];
final Map<String, Object> properties = new HashMap<>(4);
// Load data field.
for (int i = 0; i < n; i++) {
- properties.put(DefaultAttributeType.NAME_KEY, databaseFieldsDescriptors.get(i).getName());
+ properties.put(DefaultAttributeType.NAME_KEY, this.databaseFieldsDescriptors.get(i).getName());
attributes[i] = new DefaultAttributeType<>(properties, String.class, 1, 1, null);
}
@@ -127,7 +144,54 @@ public class ShapefileByteReader extends
* Load shapefile descriptor.
*/
private void loadDescriptor() {
- shapefileDescriptor = new ShapefileDescriptor(getByteBuffer());
+ 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;
+ }
}
/**
@@ -141,7 +205,7 @@ public class ShapefileByteReader extends
try {
databaseReader = new MappedByteReader(dbaseFile, null);
- databaseFieldsDescriptors = databaseReader.getFieldsDescriptors();
+ this.databaseFieldsDescriptors = databaseReader.getFieldsDescriptors();
}
finally {
if (databaseReader != null) {
@@ -155,6 +219,42 @@ public class ShapefileByteReader extends
}
/**
+ * 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.
@@ -171,7 +271,7 @@ public class ShapefileByteReader extends
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.", featuresType));
+ throw new InvalidShapefileFormatException(MessageFormat.format("The shapefile feature type {0} doesn''t match to any known feature type.", this.featuresType));
switch (type) {
case Point:
@@ -245,7 +345,7 @@ public class ShapefileByteReader extends
*/
@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();
+ /*int part = */ getByteBuffer().getInt();
Polygon poly = new Polygon();
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileDescriptor.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -70,25 +70,25 @@ public class ShapefileDescriptor {
* @param byteBuffer Source Bytebuffer.
*/
public ShapefileDescriptor(MappedByteBuffer byteBuffer) {
- fileCode = byteBuffer.getInt();
+ this.fileCode = byteBuffer.getInt();
byteBuffer.getInt();
byteBuffer.getInt();
byteBuffer.getInt();
byteBuffer.getInt();
byteBuffer.getInt();
- fileLength = byteBuffer.getInt() * 2;
+ this.fileLength = byteBuffer.getInt() * 2;
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
- version = byteBuffer.getInt();
- shapeType = ShapeTypeEnum.get(byteBuffer.getInt());
- xmin = byteBuffer.getDouble();
- ymin = byteBuffer.getDouble();
- xmax = byteBuffer.getDouble();
- ymax = byteBuffer.getDouble();
- zmin = byteBuffer.getDouble();
- zmax = byteBuffer.getDouble();
- mmin = byteBuffer.getDouble();
- mmax = byteBuffer.getDouble();
+ 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
@@ -182,18 +182,18 @@ public class ShapefileDescriptor {
StringBuilder s = new StringBuilder();
String lineSeparator = System.getProperty("line.separator", "\n");
- s.append("FileCode: ").append(fileCode).append(lineSeparator);
- s.append("FileLength: ").append(fileLength).append(lineSeparator);
- s.append("Version: ").append(version).append(lineSeparator);
- s.append("ShapeType: ").append(shapeType).append(lineSeparator);
- s.append("xmin: ").append(xmin).append(lineSeparator);
- s.append("ymin: ").append(ymin).append(lineSeparator);
- s.append("xmax: ").append(xmax).append(lineSeparator);
- s.append("ymax: ").append(ymax).append(lineSeparator);
- s.append("zmin: ").append(zmin).append(lineSeparator);
- s.append("zmax: ").append(zmax).append(lineSeparator);
- s.append("mmin: ").append(mmin).append(lineSeparator);
- s.append("mmax: ").append(mmax).append(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();
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -33,11 +33,11 @@ import java.util.logging.Level;
* @module
*/
abstract class AbstractDbase3ByteReader extends CommonByteReader<SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException> implements Dbase3ByteReader {
- /** Number of bytes in the header. */
- protected short dbaseHeaderBytes;
+ /** First data record position, in bytes. */
+ protected short firstRecordPosition;
- /** Number of bytes in the record. */
- protected short dbaseRecordBytes;
+ /** Size of one record, in bytes. */
+ protected short recordLength;
/** Reserved (dBASE IV) Filled with 00h. */
protected byte[] reservedFiller1 = new byte[2];
@@ -86,9 +86,6 @@ abstract class AbstractDbase3ByteReader
/** Date of last update; in YYMMDD format. */
protected byte[] dbaseLastUpdate = new byte[3];
- /** Current row rumber. */
- protected int rowNum;
-
/**
* Map a dbf file.
* @param file Database file.
@@ -104,7 +101,7 @@ abstract class AbstractDbase3ByteReader
* @return Charset.
*/
@Override public Charset getCharset() {
- return charset;
+ return this.charset;
}
/**
@@ -112,23 +109,31 @@ abstract class AbstractDbase3ByteReader
* @return Date of the last update.
*/
@Override public Date getDateOfLastUpdate() {
- return toDate(dbaseLastUpdate);
+ return toDate(this.dbaseLastUpdate);
}
-
+
/**
- * Returns the record count.
- * @return Record count.
+ * Returns the first record position, in bytes, in the DBase file.
+ * @return First record position.
*/
- @Override public int getRowCount() {
- return rowCount;
+ @Override public short getFirstRecordPosition() {
+ return this.firstRecordPosition;
}
/**
- * Returns the current record number.
- * @return Current record number.
+ * Returns the length (in bytes) of one record in this DBase file, including the delete flag.
+ * @return Record length.
*/
- @Override public int getRowNum() {
- return rowNum;
+ @Override public short getRecordLength() {
+ return this.recordLength;
+ }
+
+ /**
+ * Returns the record count.
+ * @return Record count.
+ */
+ @Override public int getRowCount() {
+ return this.rowCount;
}
/**
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -105,7 +105,7 @@ public abstract class AbstractJDBC exten
* @param methodName The call the caller attempted.
*/
public void logStep(final String methodName) {
- format(Level.FINER, "log.step", methodName, getClass().getSimpleName());
+ log(Level.FINER, "log.step", methodName, getClass().getSimpleName());
}
/**
@@ -114,7 +114,9 @@ public abstract class AbstractJDBC exten
* @param args Arguments that where sent to the unimplemented function.
*/
public void logStep(final String methodName, Object... args) {
- format(Level.FINER, "log.step_with_arguments", methodName, getClass().getSimpleName(), arguments(args));
+ if (isLoggable(Level.FINER)) { // Avoid resolution of arguments(...) if not needed.
+ log(Level.FINER, "log.step_with_arguments", methodName, getClass().getSimpleName(), arguments(args));
+ }
}
/**
@@ -122,7 +124,7 @@ public abstract class AbstractJDBC exten
* @param methodName The call the caller attempted.
*/
public void logUnsupportedOperation(final String methodName) {
- format(Level.WARNING, "excp.unsupportedDriverFeature", getInterface(), methodName, getClass().getSimpleName());
+ log(Level.WARNING, "excp.unsupportedDriverFeature", getInterface(), methodName, getClass().getSimpleName());
}
/**
@@ -131,7 +133,7 @@ public abstract class AbstractJDBC exten
* @param args Arguments that where sent to the unimplemented function.
*/
public void logUnsupportedOperation(final String methodName, Object... args) {
- format(Level.WARNING, "excp.unsupportedDriverFeature_with_arguments", getInterface(), methodName, getClass().getSimpleName(), arguments(args));
+ log(Level.WARNING, "excp.unsupportedDriverFeature_with_arguments", getInterface(), methodName, getClass().getSimpleName(), arguments(args));
}
/**
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -33,7 +33,7 @@ import org.apache.sis.internal.shapefile
* @since 0.5
* @module
*/
-public abstract class CommonByteReader<InvalidFormatException extends Exception, FNFException extends Exception> extends AutoChecker implements AutoCloseable {
+public abstract class CommonByteReader<InvalidFormatException extends Exception, FNFException extends Exception> extends AutoChecker implements AutoCloseable {
/** The File. */
private File file;
@@ -65,28 +65,28 @@ public abstract class CommonByteReader<I
*/
public CommonByteReader(File f, Class<InvalidFormatException> invalidFormatException, Class<FNFException> fileNotFoundException) throws FNFException, InvalidFormatException {
Objects.requireNonNull(f, "The file cannot be null.");
- classInvalidFormatException = invalidFormatException;
- classFNFException = fileNotFoundException;
+ this.classInvalidFormatException = invalidFormatException;
+ this.classFNFException = fileNotFoundException;
- file = f;
+ this.file = f;
try {
- fis = new FileInputStream(file);
+ this.fis = new FileInputStream(this.file);
}
catch(FileNotFoundException e) {
- throwException(classInvalidFormatException, e.getMessage(), e);
+ throwException(this.classInvalidFormatException, e.getMessage(), e);
throw new RuntimeException("this place should not be reached.");
}
- fc = fis.getChannel();
+ this.fc = this.fis.getChannel();
try {
- int fsize = (int)fc.size();
- byteBuffer = fc.map(FileChannel.MapMode.READ_ONLY, 0, fsize);
+ 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", file.getAbsolutePath(), e.getMessage());
- throwException(classFNFException, message, 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.");
}
}
@@ -97,13 +97,13 @@ public abstract class CommonByteReader<I
*/
@Override
public void close() throws IOException {
- if (fc != null)
- fc.close();
+ if (this.fc != null)
+ this.fc.close();
- if (fis != null)
- fis.close();
+ if (this.fis != null)
+ this.fis.close();
- isClosed = true;
+ this.isClosed = true;
}
/**
@@ -111,7 +111,7 @@ public abstract class CommonByteReader<I
* @return true if it is closed.
*/
public boolean isClosed() {
- return isClosed;
+ return this.isClosed;
}
/**
@@ -119,7 +119,7 @@ public abstract class CommonByteReader<I
* @return Byte Buffer.
*/
public MappedByteBuffer getByteBuffer() {
- return byteBuffer;
+ return this.byteBuffer;
}
/**
@@ -127,6 +127,6 @@ public abstract class CommonByteReader<I
* @return File.
*/
public File getFile() {
- return file;
+ return this.file;
}
}
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBase3FieldDescriptor.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -32,6 +32,9 @@ import org.apache.sis.internal.shapefile
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;
@@ -65,30 +68,30 @@ public class DBase3FieldDescriptor exten
*/
public DBase3FieldDescriptor(MappedByteBuffer byteBuffer) {
// Field name.
- byteBuffer.get(fieldName);
+ byteBuffer.get(this.fieldName);
// Field type.
char dt = (char)byteBuffer.get();
- fieldType = DBaseDataType.valueOfDataType(dt);
+ this.fieldType = DBaseDataType.valueOfDataType(dt);
// Field address.
- byteBuffer.get(fieldAddress);
+ byteBuffer.get(this.fieldAddress);
// Length and scale.
- fieldLength = byteBuffer.get();
- fieldDecimalCount = byteBuffer.get();
+ this.fieldLength = byteBuffer.get();
+ this.fieldDecimalCount = byteBuffer.get();
byteBuffer.getShort(); // reserved
- byteBuffer.get(dbasePlusLanReserved2);
+ byteBuffer.get(this.dbasePlusLanReserved2);
// Work area id.
- workAreaID = byteBuffer.get();
+ this.workAreaID = byteBuffer.get();
- byteBuffer.get(dbasePlusLanReserved3);
+ byteBuffer.get(this.dbasePlusLanReserved3);
// Fields.
- setFields = byteBuffer.get();
+ this.setFields = byteBuffer.get();
byte[] data = new byte[6];
byteBuffer.get(data); // reserved
@@ -115,11 +118,17 @@ public class DBase3FieldDescriptor exten
* @return Field name.
*/
public String getName() {
- int length = fieldName.length;
- while (length != 0 && Byte.toUnsignedInt(fieldName[length - 1]) <= ' ') {
- length--;
+ // 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 new String(this.fieldName, 0, length);
+
+ return this.stringFieldName;
}
/**
@@ -127,7 +136,7 @@ public class DBase3FieldDescriptor exten
* @return Data type.
*/
public DBaseDataType getType() {
- return(fieldType);
+ return(this.fieldType);
}
/**
@@ -135,7 +144,7 @@ public class DBase3FieldDescriptor exten
*/
@Override
public String toString() {
- String text = format("toString", getName(), fieldType, Byte.toUnsignedInt(fieldLength), Byte.toUnsignedInt(fieldDecimalCount));
+ String text = format("toString", getName(), this.fieldType, Byte.toUnsignedInt(this.fieldLength), Byte.toUnsignedInt(this.fieldDecimalCount));
return text;
}
}
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/Dbase3ByteReader.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -85,8 +85,20 @@ public interface Dbase3ByteReader {
* @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.
*/
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -56,9 +56,9 @@ public class MappedByteReader extends Ab
this.info = connectionInfos;
// React to special features asked.
- if (info != null) {
+ if (this.info != null) {
// Sometimes, DBF files have a wrong charset, or more often : none, and you have to specify it.
- String recordCharset = (String)info.get("record_charset");
+ String recordCharset = (String)this.info.get("record_charset");
if (recordCharset != null) {
Charset cs = Charset.forName(recordCharset);
@@ -78,7 +78,7 @@ public class MappedByteReader extends Ab
getByteBuffer().get(); // denotes whether deleted or current
// read first part of record
- for (DBase3FieldDescriptor fd : fieldsDescriptors) {
+ for (DBase3FieldDescriptor fd : this.fieldsDescriptors) {
byte[] data = new byte[fd.getLength()];
getByteBuffer().get(data);
@@ -90,8 +90,6 @@ public class MappedByteReader extends Ab
String value = new String(data, 0, length);
feature.setPropertyValue(fd.getName(), value);
}
-
- rowNum ++;
}
/**
@@ -109,7 +107,7 @@ public class MappedByteReader extends Ab
byte eofCheck = getByteBuffer().get();
boolean isEOF = (eofCheck == 0x1A);
- this.log(Level.FINER, "log.delete_status", rowNum, eofCheck, isEOF ? "EOF" : "Active");
+ this.log(Level.FINER, "log.delete_status", getRowNum(), eofCheck, isEOF ? "EOF" : "Active");
if (eofCheck == 0x1A) {
return false;
@@ -123,6 +121,16 @@ public class MappedByteReader extends Ab
}
/**
+ * 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.
*/
@@ -134,7 +142,7 @@ public class MappedByteReader extends Ab
// read first part of record
HashMap<String, byte[]> fieldsValues = new HashMap<>();
- for (DBase3FieldDescriptor fd : fieldsDescriptors) {
+ for (DBase3FieldDescriptor fd : this.fieldsDescriptors) {
byte[] data = new byte[fd.getLength()];
getByteBuffer().get(data);
@@ -159,7 +167,6 @@ public class MappedByteReader extends Ab
}
}
- rowNum ++;
return fieldsValues;
}
@@ -174,16 +181,16 @@ public class MappedByteReader extends Ab
getByteBuffer().order(ByteOrder.LITTLE_ENDIAN);
this.rowCount = getByteBuffer().getInt();
- this.dbaseHeaderBytes = getByteBuffer().getShort();
- this.dbaseRecordBytes = getByteBuffer().getShort();
+ this.firstRecordPosition = getByteBuffer().getShort();
+ this.recordLength = getByteBuffer().getShort();
getByteBuffer().order(ByteOrder.BIG_ENDIAN);
- getByteBuffer().get(reservedFiller1);
+ getByteBuffer().get(this.reservedFiller1);
this.reservedIncompleteTransaction = getByteBuffer().get();
this.reservedEncryptionFlag = getByteBuffer().get();
- getByteBuffer().get(reservedFreeRecordThread);
- getByteBuffer().get(reservedMultiUser);
- reservedMDXFlag = 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();
@@ -194,16 +201,16 @@ public class MappedByteReader extends Ab
}
catch(UnsupportedCharsetException e) {
// Warn the caller that he will have to perform is own conversions.
- format(Level.WARNING, "log.no_valid_charset", getFile().getAbsolutePath(), e.getMessage());
+ log(Level.WARNING, "log.no_valid_charset", getFile().getAbsolutePath(), e.getMessage());
}
}
else {
- format(Level.INFO, "log.record_charset", this.charset.name());
+ log(Level.INFO, "log.record_charset", this.charset.name());
}
- getByteBuffer().get(reservedFiller2);
+ getByteBuffer().get(this.reservedFiller2);
- while(getByteBuffer().position() < this.dbaseHeaderBytes - 1) {
+ while(getByteBuffer().position() < this.firstRecordPosition - 1) {
DBase3FieldDescriptor fd = new DBase3FieldDescriptor(getByteBuffer());
this.fieldsDescriptors.add(fd);
// loop until you hit the 0Dh field terminator
@@ -212,7 +219,7 @@ public class MappedByteReader extends Ab
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 (descriptorTerminator != 0x0D) {
+ 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);
}
@@ -233,7 +240,7 @@ public class MappedByteReader extends Ab
*/
@Override
public List<DBase3FieldDescriptor> getFieldsDescriptors() {
- return fieldsDescriptors;
+ return this.fieldsDescriptors;
}
/**
@@ -253,7 +260,7 @@ public class MappedByteReader extends Ab
*/
@Override
public int getColumnCount() {
- return fieldsDescriptors.size();
+ return this.fieldsDescriptors.size();
}
/**
@@ -273,8 +280,8 @@ public class MappedByteReader extends Ab
}
// Search the field among the fields descriptors.
- for(int index=0; index < fieldsDescriptors.size(); index ++) {
- if (fieldsDescriptors.get(index).getName().equals(columnLabel)) {
+ for(int index=0; index < this.fieldsDescriptors.size(); index ++) {
+ if (this.fieldsDescriptors.get(index).getName().equals(columnLabel)) {
return index + 1;
}
}
@@ -297,6 +304,6 @@ public class MappedByteReader extends Ab
throw new SQLIllegalColumnIndexException(message, sql, getFile(), columnIndex);
}
- return fieldsDescriptors.get(columnIndex-1);
+ return this.fieldsDescriptors.get(columnIndex-1);
}
}
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/SQLConnectionClosedException.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -41,8 +41,8 @@ public class SQLConnectionClosedExceptio
*/
public SQLConnectionClosedException(String message, String sqlStatement, File dbf) {
super(message);
- sql = sqlStatement;
- database = dbf;
+ this.sql = sqlStatement;
+ this.database = dbf;
}
/**
@@ -50,7 +50,7 @@ public class SQLConnectionClosedExceptio
* @return SQL statement or null.
*/
public String getSQL() {
- return sql;
+ return this.sql;
}
/**
@@ -58,6 +58,6 @@ public class SQLConnectionClosedExceptio
* @return Database file.
*/
public File getDatabase() {
- return database;
+ return this.database;
}
}
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -149,7 +149,7 @@ abstract class AbstractConnection extend
*/
@Override
public void setAutoCommit(boolean autoCommit) {
- format(Level.FINE, "log.auto_commit_ignored", autoCommit);
+ log(Level.FINE, "log.auto_commit_ignored", autoCommit);
}
/**
@@ -157,7 +157,7 @@ abstract class AbstractConnection extend
*/
@Override
public void commit() {
- format(Level.FINE, "log.commit_rollback_ignored");
+ log(Level.FINE, "log.commit_rollback_ignored");
}
/**
@@ -165,7 +165,7 @@ abstract class AbstractConnection extend
*/
@Override
public void rollback() {
- format(Level.FINE, "log.commit_rollback_ignored");
+ log(Level.FINE, "log.commit_rollback_ignored");
}
/**
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -64,9 +64,9 @@ public class DBFConnection extends Abstr
throw new SQLDbaseFileNotFoundException(format(Level.WARNING, "excp.directory_not_expected", datafile.getAbsolutePath()));
}
- databaseFile = datafile;
- byteReader = br;
- format(Level.FINE, "log.database_connection_opened", databaseFile.getAbsolutePath(), "FIXME : column desc.");
+ this.databaseFile = datafile;
+ this.byteReader = br;
+ log(Level.FINE, "log.database_connection_opened", this.databaseFile.getAbsolutePath(), "FIXME : column desc.");
}
/**
@@ -80,13 +80,13 @@ public class DBFConnection extends Abstr
try {
// Check if all the underlying connections that has been opened with this connection has been closed.
// If not, we log a warning to help the developper.
- if (openedStatements.size() > 0) {
- format(Level.WARNING, "log.statements_left_opened", openedStatements.size(), openedStatements.stream().map(DBFStatement::toString).collect(Collectors.joining(", ")));
+ if (this.openedStatements.size() > 0) {
+ log(Level.WARNING, "log.statements_left_opened", this.openedStatements.size(), this.openedStatements.stream().map(DBFStatement::toString).collect(Collectors.joining(", ")));
}
- byteReader.close();
+ this.byteReader.close();
} catch (IOException e) {
- format(Level.FINE, e.getMessage(), e);
+ log(Level.FINE, e.getMessage(), e);
}
}
@@ -99,7 +99,7 @@ public class DBFConnection extends Abstr
assertNotClosed();
DBFStatement stmt = new DBFStatement(this);
- openedStatements.add(stmt);
+ this.openedStatements.add(stmt);
return stmt;
}
@@ -116,7 +116,7 @@ public class DBFConnection extends Abstr
* @return Charset.
*/
public Charset getCharset() {
- return byteReader.getCharset();
+ return this.byteReader.getCharset();
}
/**
@@ -125,7 +125,7 @@ public class DBFConnection extends Abstr
*/
@Override
public File getFile() {
- return databaseFile;
+ return this.databaseFile;
}
/**
@@ -150,7 +150,7 @@ public class DBFConnection extends Abstr
*/
@Override
public boolean isClosed() {
- return byteReader.isClosed();
+ return this.byteReader.isClosed();
}
/**
@@ -188,7 +188,7 @@ public class DBFConnection extends Abstr
public void notifyCloseStatement(DBFStatement stmt) {
Objects.requireNonNull(stmt, "The statement notified being closed cannot be null.");
- if (openedStatements.remove(stmt) == false) {
+ if (this.openedStatements.remove(stmt) == false) {
throw new RuntimeException(format(Level.SEVERE, "assert.statement_not_opened_by_me", stmt, toString()));
}
}
@@ -202,7 +202,7 @@ public class DBFConnection extends Abstr
* @throws SQLNoSuchFieldException if there is no field with this name in the query.
*/
public int findColumn(String columnLabel, String sql) throws SQLNoSuchFieldException {
- return byteReader.findColumn(columnLabel, sql);
+ return this.byteReader.findColumn(columnLabel, sql);
}
/**
@@ -210,7 +210,7 @@ public class DBFConnection extends Abstr
* @return Column count.
*/
public int getColumnCount() {
- return byteReader.getColumnCount();
+ return this.byteReader.getColumnCount();
}
/**
@@ -288,7 +288,7 @@ public class DBFConnection extends Abstr
* @return Fields descriptors.
*/
public List<DBase3FieldDescriptor> getFieldsDescriptors() {
- return byteReader.getFieldsDescriptors();
+ return this.byteReader.getFieldsDescriptors();
}
/**
@@ -299,7 +299,7 @@ public class DBFConnection extends Abstr
* @throws SQLIllegalColumnIndexException if the index is out of bounds.
*/
public String getFieldName(int columnIndex, String sql) throws SQLIllegalColumnIndexException {
- return byteReader.getFieldName(columnIndex, sql);
+ return this.byteReader.getFieldName(columnIndex, sql);
}
/**
@@ -307,7 +307,7 @@ public class DBFConnection extends Abstr
* @return true if a next row is available.
*/
public boolean nextRowAvailable() {
- return byteReader.nextRowAvailable();
+ return this.byteReader.nextRowAvailable();
}
/**
@@ -315,7 +315,15 @@ public class DBFConnection extends Abstr
* @return Map of field name / object value, or null if EoF has been encountered.
*/
public Map<String, byte[]> readNextRowAsObjects() {
- return byteReader.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();
}
/**
@@ -323,6 +331,6 @@ public class DBFConnection extends Abstr
*/
@Override
public String toString() {
- return format("toString", databaseFile.getAbsolutePath(), isClosed() == false);
+ return format("toString", this.databaseFile.getAbsolutePath(), isClosed() == false);
}
}
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/SQLClosingIOFailureException.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -41,8 +41,8 @@ public class SQLClosingIOFailureExceptio
*/
public SQLClosingIOFailureException(String message, String sqlStatement, File dbf) {
super(message);
- sql = sqlStatement;
- database = dbf;
+ this.sql = sqlStatement;
+ this.database = dbf;
}
/**
@@ -50,7 +50,7 @@ public class SQLClosingIOFailureExceptio
* @return SQL statement or null.
*/
public String getSQL() {
- return sql;
+ return this.sql;
}
/**
@@ -58,6 +58,6 @@ public class SQLClosingIOFailureExceptio
* @return Database file.
*/
public File getDatabase() {
- return database;
+ return this.database;
}
}
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -40,7 +40,7 @@ public class DBFDatabaseMetaData extends
*/
public DBFDatabaseMetaData(DBFConnection cnt) {
Objects.requireNonNull(cnt, "The database connection used to create Database metadata cannot be null.");
- connection = cnt;
+ this.connection = cnt;
}
/**
@@ -73,8 +73,8 @@ public class DBFDatabaseMetaData extends
*/
@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)connection.createStatement()) {
- return new DBFBuiltInMemoryResultSetForColumnsListing(stmt, connection.getFieldsDescriptors());
+ try(DBFStatement stmt = (DBFStatement)this.connection.createStatement()) {
+ return new DBFBuiltInMemoryResultSetForColumnsListing(stmt, this.connection.getFieldsDescriptors());
}
}
@@ -84,7 +84,7 @@ public class DBFDatabaseMetaData extends
*/
@Override
public File getFile() {
- return connection.getFile();
+ return this.connection.getFile();
}
/**
@@ -1013,7 +1013,7 @@ public class DBFDatabaseMetaData extends
@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(connection);
+ DBFStatement stmt = new DBFStatement(this.connection);
DBFBuiltInMemoryResultSetForTablesListing tables = new DBFBuiltInMemoryResultSetForTablesListing(stmt);
stmt.registerResultSet(tables);
return tables;
@@ -1026,7 +1026,7 @@ public class DBFDatabaseMetaData extends
@Override public ResultSet getSchemas() {
logStep("getSchemas");
- DBFStatement stmt = new DBFStatement(connection);
+ DBFStatement stmt = new DBFStatement(this.connection);
DBFBuiltInMemoryResultSetForSchemaListing schemas = new DBFBuiltInMemoryResultSetForSchemaListing(stmt);
stmt.registerResultSet(schemas);
return schemas;
@@ -1039,7 +1039,7 @@ public class DBFDatabaseMetaData extends
@Override public ResultSet getCatalogs() {
logStep("getCatalogs");
- DBFStatement stmt = new DBFStatement(connection);
+ DBFStatement stmt = new DBFStatement(this.connection);
DBFBuiltInMemoryResultSetForCatalogNamesListing catalogNames = new DBFBuiltInMemoryResultSetForCatalogNamesListing(stmt);
stmt.registerResultSet(catalogNames);
return catalogNames;
@@ -1052,7 +1052,7 @@ public class DBFDatabaseMetaData extends
@Override public ResultSet getTableTypes() {
logStep("getTableTypes");
- DBFStatement stmt = new DBFStatement(connection);
+ DBFStatement stmt = new DBFStatement(this.connection);
DBFBuiltInMemoryResultSetForTablesTypesListing tablesTypes = new DBFBuiltInMemoryResultSetForTablesTypesListing(stmt);
stmt.registerResultSet(tablesTypes);
return tablesTypes;
@@ -1168,7 +1168,7 @@ public class DBFDatabaseMetaData extends
*/
@Override public Connection getConnection() {
logStep("getConnection");
- return connection;
+ return this.connection;
}
/**
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -46,10 +46,10 @@ public class DBFResultSetMataData extend
*/
public DBFResultSetMataData(DBFRecordBasedResultSet resultset) {
Objects.requireNonNull(resultset, "A non null ResultSet is required.");
- rs = resultset;
+ this.rs = resultset;
try {
- metadata = (DBFDatabaseMetaData)resultset.getStatement().getConnection().getMetaData();
+ this.metadata = (DBFDatabaseMetaData)resultset.getStatement().getConnection().getMetaData();
}
catch(SQLException e) {
throw new RuntimeException(e.getMessage(), e);
@@ -79,7 +79,7 @@ public class DBFResultSetMataData extend
@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)rs.getStatement()).getConnection());
+ DBFConnection cnt = (DBFConnection)(((DBFStatement)this.rs.getStatement()).getConnection());
return cnt.getColumnCount();
}
@@ -282,7 +282,7 @@ public class DBFResultSetMataData extend
logStep("getTableName", column);
// The table default to the file name (without its extension .dbf).
- String fileName = rs.getFile().getName();
+ String fileName = this.rs.getFile().getName();
int indexDBF = fileName.lastIndexOf(".");
String tableName = fileName.substring(0, indexDBF);
@@ -436,7 +436,7 @@ public class DBFResultSetMataData extend
*/
@Override
protected File getFile() {
- return rs.getFile();
+ return this.rs.getFile();
}
/**
@@ -447,12 +447,12 @@ public class DBFResultSetMataData extend
* @throws SQLConnectionClosedException if the underlying connection is closed.
*/
private DBFBuiltInMemoryResultSetForColumnsListing desc(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
- DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = (DBFBuiltInMemoryResultSetForColumnsListing)metadata.getColumns(null, null, null, null);
+ 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, rs.getSQL(), getFile(), column);
+ throw new SQLIllegalColumnIndexException(message, this.rs.getSQL(), getFile(), column);
}
// TODO Implements ResultSet:absolute(int) instead.
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/BuiltInMemoryResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/BuiltInMemoryResultSet.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/BuiltInMemoryResultSet.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/BuiltInMemoryResultSet.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -55,7 +55,7 @@ public abstract class BuiltInMemoryResul
*/
@Override
public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
- return getBigDecimal(getFieldName(columnIndex, sql));
+ return getBigDecimal(getFieldName(columnIndex, this.sql));
}
/**
@@ -71,7 +71,7 @@ public abstract class BuiltInMemoryResul
*/
@Override
public Date getDate(int columnIndex) throws SQLException {
- return getDate(getFieldName(columnIndex, sql));
+ return getDate(getFieldName(columnIndex, this.sql));
}
/**
@@ -95,7 +95,7 @@ public abstract class BuiltInMemoryResul
*/
@Override
public double getDouble(int columnIndex) throws SQLException {
- return getDouble(getFieldName(columnIndex, sql));
+ return getDouble(getFieldName(columnIndex, this.sql));
}
/**
@@ -103,7 +103,7 @@ public abstract class BuiltInMemoryResul
*/
@Override
public float getFloat(int columnIndex) throws SQLException {
- return getFloat(getFieldName(columnIndex, sql));
+ return getFloat(getFieldName(columnIndex, this.sql));
}
/**
@@ -127,7 +127,7 @@ public abstract class BuiltInMemoryResul
*/
@Override
public int getInt(int columnIndex) throws SQLException {
- return getInt(getFieldName(columnIndex, sql));
+ return getInt(getFieldName(columnIndex, this.sql));
}
/**
@@ -141,7 +141,7 @@ public abstract class BuiltInMemoryResul
* @see java.sql.ResultSet#getLong(int)
*/
@Override public long getLong(int columnIndex) throws SQLException {
- return getLong(getFieldName(columnIndex, sql));
+ return getLong(getFieldName(columnIndex, this.sql));
}
/**
@@ -156,7 +156,7 @@ public abstract class BuiltInMemoryResul
*/
@Override
public short getShort(int columnIndex) throws SQLException {
- return getShort(getFieldName(columnIndex, sql));
+ return getShort(getFieldName(columnIndex, this.sql));
}
/**
@@ -171,7 +171,7 @@ public abstract class BuiltInMemoryResul
*/
@Override
public String getString(int columnIndex) throws SQLException {
- return(getString(getFieldName(columnIndex, sql)));
+ return(getString(getFieldName(columnIndex, this.sql)));
}
/**
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -50,7 +50,7 @@ public class DBFBuiltInMemoryResultSetFo
*/
public DBFBuiltInMemoryResultSetForColumnsListing(DBFStatement stmt, List<DBase3FieldDescriptor> fieldsDescriptors) {
super(stmt, "driver list columns in this DBase 3 file");
- itDescriptor = fieldsDescriptors.iterator();
+ this.itDescriptor = fieldsDescriptors.iterator();
}
/**
@@ -64,21 +64,21 @@ public class DBFBuiltInMemoryResultSetFo
// String => table name
case "TABLE_NAME": {
String tableName = getTableName();
- wasNull = (tableName == null);
+ this.wasNull = (tableName == null);
return tableName;
}
// String => column name
case "COLUMN_NAME": {
- String columnName = current.getName();
- wasNull = (columnName == null);
+ 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 = current.getType() != null ? toColumnTypeName() : null;
- wasNull = (typeName == null);
+ String typeName = this.current.getType() != null ? toColumnTypeName() : null;
+ this.wasNull = (typeName == null);
return typeName;
}
@@ -89,42 +89,42 @@ public class DBFBuiltInMemoryResultSetFo
// String => table catalog (may be null)
case "TABLE_CAT": {
- wasNull = true;
+ this.wasNull = true;
return null;
}
// String => table schema (may be null)
case "TABLE_SCHEM": {
- wasNull = true;
+ this.wasNull = true;
return null;
}
// String => comment describing column (may be null)
case "REMARKS":
- wasNull = true;
+ 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": {
- wasNull = true;
+ 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": {
- wasNull = true;
+ 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": {
- wasNull = true;
+ 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": {
- wasNull = true;
+ this.wasNull = true;
return null;
}
@@ -135,7 +135,7 @@ public class DBFBuiltInMemoryResultSetFo
* empty string --- if it cannot be determined whether the column is auto incremented
*/
case "IS_AUTOINCREMENT": {
- wasNull = false;
+ this.wasNull = false;
return "NO";
}
@@ -146,7 +146,7 @@ public class DBFBuiltInMemoryResultSetFo
* empty string --- if it cannot be determined whether this is a generated column
*/
case "IS_GENERATEDCOLUMN": {
- wasNull = false;
+ this.wasNull = false;
return "NO";
}
@@ -168,20 +168,20 @@ public class DBFBuiltInMemoryResultSetFo
switch(columnLabel) {
// int => SQL type from java.sql.Types
case "DATA_TYPE": {
- wasNull = false;
+ this.wasNull = false;
return toSQLDataType();
}
// int => column size.
case "COLUMN_SIZE": {
- wasNull = false;
+ 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();
- wasNull = toScale() == -1;
+ this.wasNull = toScale() == -1;
return scale == -1 ? 0 : scale;
}
@@ -197,13 +197,13 @@ public class DBFBuiltInMemoryResultSetFo
* columnNullableUnknown - nullability unknown
*/
case "NULLABLE": {
- wasNull = false;
+ this.wasNull = false;
return DatabaseMetaData.columnNullableUnknown;
}
// int => unused
case "SQL_DATA_TYPE": {
- wasNull = false;
+ this.wasNull = false;
return toSQLDataType();
}
@@ -218,7 +218,7 @@ public class DBFBuiltInMemoryResultSetFo
// int => index of column in table (starting at 1)
case "ORDINAL_POSITION": {
- return columnIndex;
+ return this.columnIndex;
}
/**
@@ -228,19 +228,19 @@ public class DBFBuiltInMemoryResultSetFo
// short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF)
case "SOURCE_DATA_TYPE": {
- wasNull = true;
+ this.wasNull = true;
return 0;
}
// is not used.
case "BUFFER_LENGTH": {
- wasNull = false;
+ this.wasNull = false;
return 0;
}
// int => unused
case "SQL_DATETIME_SUB": {
- wasNull = false;
+ this.wasNull = false;
return 0;
}
@@ -257,15 +257,15 @@ public class DBFBuiltInMemoryResultSetFo
* @see java.sql.ResultSet#next()
*/
@Override public boolean next() throws SQLNoResultException {
- if (itDescriptor.hasNext()) {
- current = itDescriptor.next();
- columnIndex ++;
+ if (this.itDescriptor.hasNext()) {
+ this.current = this.itDescriptor.next();
+ this.columnIndex ++;
return true;
}
else {
- if (afterLast) {
+ if (this.afterLast) {
// The ResultSet has no more records and has been call one time too much.
- afterLast = true;
+ this.afterLast = true;
String message = format(Level.WARNING, "excp.no_more_desc", getTableName());
throw new SQLNoResultException(message, "asking columns desc", getFile());
@@ -281,7 +281,7 @@ public class DBFBuiltInMemoryResultSetFo
* @return SQL Datatype.
*/
private int toSQLDataType() {
- switch(current.getType()) {
+ switch(this.current.getType()) {
case AutoIncrement:
return Types.INTEGER;
@@ -337,7 +337,7 @@ public class DBFBuiltInMemoryResultSetFo
* @return Column type name.
*/
private String toColumnTypeName() {
- switch(current.getType()) {
+ switch(this.current.getType()) {
case AutoIncrement:
return "AUTO_INCREMENT";
@@ -393,11 +393,11 @@ public class DBFBuiltInMemoryResultSetFo
* @return Precision of the current field.
*/
public int toPrecision() {
- switch(current.getType()) {
+ switch(this.current.getType()) {
case AutoIncrement:
case Character:
case Integer:
- return current.getLength();
+ return this.current.getLength();
case Date:
return 8;
@@ -405,7 +405,7 @@ public class DBFBuiltInMemoryResultSetFo
case Double:
case FloatingPoint:
case Number:
- return current.getLength();
+ return this.current.getLength();
case Logical:
return 0;
@@ -413,7 +413,7 @@ public class DBFBuiltInMemoryResultSetFo
case Currency:
case DateTime:
case TimeStamp:
- return current.getLength();
+ return this.current.getLength();
case Memo:
case Picture:
@@ -422,7 +422,7 @@ public class DBFBuiltInMemoryResultSetFo
return 0;
default:
- return current.getLength();
+ return this.current.getLength();
}
}
@@ -431,7 +431,7 @@ public class DBFBuiltInMemoryResultSetFo
* @return Scale of the current field, -1 means : this field is not numeric.
*/
private int toScale() {
- switch(current.getType()) {
+ switch(this.current.getType()) {
case AutoIncrement:
case Logical:
return 0;
@@ -441,7 +441,7 @@ public class DBFBuiltInMemoryResultSetFo
case FloatingPoint:
case Number:
case Currency:
- return current.getDecimalCount();
+ return this.current.getDecimalCount();
case Character:
case Date:
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -46,12 +46,12 @@ public class DBFBuiltInMemoryResultSetFo
case "TABLE_NAME": // String => table name.
{
String tableName = getTableName();
- wasNull = (tableName == null);
+ 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".
- wasNull = false;
+ this.wasNull = false;
return "TABLE";
case "TYPE_NAME": // String => type name (may be null)
@@ -62,11 +62,11 @@ public class DBFBuiltInMemoryResultSetFo
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)
- wasNull = true;
+ this.wasNull = true;
return null;
default:
- wasNull = true;
+ this.wasNull = true;
return null;
}
}
@@ -78,11 +78,11 @@ public class DBFBuiltInMemoryResultSetFo
{
logStep("next");
- if (index > 1) {
+ if (this.index > 1) {
throw new SQLNoResultException(format(Level.WARNING, "excp.only_one_table_per_dbf"), "Driver manager asks for table listing", getFile());
}
- index ++;
- return (index == 1) ? true : false;
+ this.index ++;
+ return (this.index == 1) ? true : false;
}
}
Modified: sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java?rev=1718297&r1=1718296&r2=1718297&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java [UTF-8] Mon Dec 7 10:35:08 2015
@@ -44,15 +44,15 @@ public class DBFBuiltInMemoryResultSetFo
switch(columnLabel) {
case "OBJECTID": // FIXME Documentation of ObjectId for geTabletTypes() has not been found. What are the rules about this field ?
- wasNull = false;
+ this.wasNull = false;
return "1";
case "TABLE_TYPE": // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
- wasNull = false;
+ this.wasNull = false;
return "TABLE"; // and DBase 3 only knows tables.
default:
- wasNull = true;
+ this.wasNull = true;
return null;
}
}
@@ -64,11 +64,11 @@ public class DBFBuiltInMemoryResultSetFo
{
logStep("next");
- if (index > 1) {
+ if (this.index > 1) {
throw new SQLNoResultException(format(Level.WARNING, "excp.only_one_table_type_handled"), "Driver manager asks for table types listing", getFile());
}
- index ++;
- return (index == 1) ? true : false;
+ this.index ++;
+ return (this.index == 1) ? true : false;
}
}