sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1651610 [5/6] - in /sis/branches/JDK6: ./ application/sis-webapp/src/main/java/org/apache/sis/index/tree/ core/sis-build-helper/src/main/java/org/apache/sis/internal/doclet/ core/sis-build-helper/src/main/java/org/apache/sis/util/resources...
Date Wed, 14 Jan 2015 09:53:55 GMT
Modified: sis/branches/JDK6/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java?rev=1651610&r1=1651609&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -69,6 +69,7 @@ import org.apache.sis.internal.netcdf.Gr
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.metadata.Standards;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.measure.Units;
 
 // The following dependency is used only for static final String constants.
 // Consequently the compiled class files should not have this dependency.
@@ -196,6 +197,15 @@ final class MetadataReader {
     }
 
     /**
+     * Returns the localized error resource bundle for the locale given by {@link #getLocale()}.
+     *
+     * @return The localized error resource bundle.
+     */
+    private Errors errors() {
+        return Errors.getResources(decoder.listeners.getLocale());
+    }
+
+    /**
      * Reads the attribute value for the given name, then trims the leading and trailing spaces.
      * If the value is null, empty or contains only spaces, then this method returns {@code null}.
      */
@@ -225,7 +235,7 @@ final class MetadataReader {
     private <T extends Enum<T>> T forEnumName(final Class<T> enumType, final String name) {
         final T code = Types.forEnumName(enumType, name);
         if (code == null && name != null) {
-            decoder.listeners.warning(Errors.format(Errors.Keys.UnknownEnumValue_2, enumType, name), null);
+            decoder.listeners.warning(errors().getString(Errors.Keys.UnknownEnumValue_2, enumType, name), null);
         }
         return code;
     }
@@ -241,7 +251,7 @@ final class MetadataReader {
              * CodeLists are not enums, but using the error message for enums is not completly wrong since
              * if we did not allowed CodeList to create new elements, then we are using it like an enum.
              */
-            decoder.listeners.warning(Errors.format(Errors.Keys.UnknownEnumValue_2, codeType, name), null);
+            decoder.listeners.warning(errors().getString(Errors.Keys.UnknownEnumValue_2, codeType, name), null);
         }
         return code;
     }
@@ -863,9 +873,12 @@ final class MetadataReader {
         if (description != null && !(description = description.trim()).isEmpty() && !description.equals(name)) {
             band.setDescription(new SimpleInternationalString(description));
         }
-//TODO: Can't store the units, because the Band interface restricts it to length.
-//      We need the SampleDimension interface proposed in ISO 19115 revision draft.
-//      band.setUnits(Units.valueOf(variable.getUnitsString()));
+        final String units = variable.getUnitsString();
+        if (units != null) try {
+            band.setUnits(Units.valueOf(units));
+        } catch (IllegalArgumentException e) {
+            decoder.listeners.warning(errors().getString(Errors.Keys.CanNotAssignUnitToDimension_2, name, units), e);
+        }
         return band;
     }
 
@@ -934,7 +947,7 @@ final class MetadataReader {
         metadata.setMetadataIdentifier(identifier);
         final Date creation = decoder.dateValue(METADATA_CREATION);
         if (creation != null) {
-            metadata.setDates(singleton(new DefaultCitationDate(creation, DateType.CREATION)));
+            metadata.setDateInfo(singleton(new DefaultCitationDate(creation, DateType.CREATION)));
         }
         metadata.setMetadataScopes(singleton(new DefaultMetadataScope(ScopeCode.DATASET, null)));
         for (final String service : SERVICES) {

Modified: sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java?rev=1651610&r1=1651609&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-netcdf/src/test/java/org/apache/sis/storage/netcdf/MetadataReaderTest.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -148,6 +148,7 @@ public final strictfp class MetadataRead
             "  │   └─Attribute group\n" +
             "  │       └─Attribute\n" +
             "  │           ├─Sequence identifier……………………………… SST\n" +
+            "  │           ├─Units…………………………………………………………………… K\n" +
             "  │           └─Description…………………………………………………… Sea temperature\n" +
             "  ├─Data quality info\n" +
             "  │   └─Lineage\n" +

Copied: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java (from r1651598, sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java?p2=sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java&p1=sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java&r1=1651598&r2=1651610&rev=1651610&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/AutoChecker.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -19,13 +19,15 @@ package org.apache.sis.internal.shapefil
 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.util.logging.Logging;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
 
 /**
  * Base class for objets having auto-checking abilities

Copied: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java (from r1651598, sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java?p2=sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java&p1=sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java&r1=1651598&r2=1651610&rev=1651610&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -30,6 +30,10 @@ import org.opengis.feature.Feature;
 
 import com.esri.core.geometry.*;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
 /**
  * Reader of a Shapefile Binary content by the way of a {@link java.nio.MappedByteBuffer}
  *
@@ -102,17 +106,17 @@ public class ShapefileByteReader extends
 
         final int n = databaseFieldsDescriptors.size();
         final DefaultAttributeType<?>[] attributes = new DefaultAttributeType<?>[n + 1];
-        final Map<String, Object> properties = new HashMap<>(4);
+        final Map<String, Object> properties = new HashMap<String, Object>(4);
 
         // Load data field.
         for (int i = 0; i < n; i++) {
             properties.put(DefaultAttributeType.NAME_KEY, databaseFieldsDescriptors.get(i).getName());
-            attributes[i] = new DefaultAttributeType<>(properties, String.class, 1, 1, null);
+            attributes[i] = new DefaultAttributeType<String>(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);
+        attributes[n] = new DefaultAttributeType<Geometry>(properties, Geometry.class, 1, 1, null);
 
         // Add name.
         properties.put(DefaultAttributeType.NAME_KEY, name);

Copied: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java (from r1651598, sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java?p2=sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java&p1=sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java&r1=1651598&r2=1651610&rev=1651610&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -22,9 +22,12 @@ import java.nio.charset.UnsupportedChars
 import java.text.MessageFormat;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.Objects;
 import java.util.logging.Level;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
 /**
  * The Abstract Byte Reader.
  * @author  Marc Le Bihan
@@ -188,7 +191,7 @@ abstract class AbstractDbase3ByteReader
      */
     private String toCodePage(byte pageCodeBinaryValue) {
         // From http://trac.osgeo.org/gdal/ticket/2864
-        HashMap<Integer, String> knownConversions = new HashMap<>();
+        HashMap<Integer, String> knownConversions = new HashMap<Integer,String>();
         knownConversions.put(0x01, "cp437"); //  U.S. MS–DOS
         knownConversions.put(0x02, "cp850"); // International MS–DOS
         knownConversions.put(0x03, "cp1252"); // Windows ANSI

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java?rev=1651610&r1=1651609&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractJDBC.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -16,71 +16,47 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
+import java.io.File;
+import java.sql.*;
 import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.logging.LogRecord;
-import java.sql.Wrapper;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.sql.SQLWarning;
-import org.apache.sis.util.logging.Logging;
+
+import org.apache.sis.internal.shapefile.AutoChecker;
 
 
 /**
  * Base class for each JDBC class.
- *
  * @author  Marc Le Bihan
  * @version 0.5
  * @since   0.5
  * @module
  */
-abstract class AbstractJDBC implements Wrapper {
-    /**
-     * The logger for JDBC operations. We use the {@code "org.apache.sis.storage.jdbc"} logger name instead than
-     * the package name because this package is internal and may move in any future SIS version. The logger name
-     * does not need to be the name of an existing package. The important thing is to not change it, because it
-     * can been seen as a kind of public API since user may want to control verbosity level by logger names.
-     */
-    static final Logger LOGGER = Logging.getLogger("org.apache.sis.storage.jdbc");
-
+public abstract class AbstractJDBC extends AutoChecker implements Wrapper {
     /**
      * Constructs a new instance of a JDBC interface.
      */
-    AbstractJDBC() {
+    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 Class<?> getInterface();
+    abstract protected Class<?> getInterface();
 
     /**
      * Unsupported by default.
-     *
-     * @param  iface the type of the wrapped object.
+     * @param iface the type of the wrapped object.
      * @return The wrapped object.
      */
     @Override
     public <T> T unwrap(Class<T> iface) throws SQLException {
-        throw unsupportedOperation("unwrap");
-    }
-
-    /**
-     * Default to {@code false}, assuming that no non-standard features are handled.
-     *
-     * @param  iface the type of the wrapped object.
-     * @return {@code true} if this instance is a wrapper for the given type of object.
-     */
-    @Override
-    public boolean isWrapperFor(Class<?> iface) {
-        return false;
+        throw unsupportedOperation("unwrap", iface);
     }
 
     /**
      * Defaults to {@code null}.
+     * @return SQL Warning.
      */
     public SQLWarning getWarnings() {
         return null;
@@ -94,36 +70,91 @@ abstract class AbstractJDBC implements W
 
     /**
      * Returns an unsupported operation exception to be thrown.
-     *
-     * @param  methodOrWishedFeatureName The feature / call the caller attempted.
-     * @return The exception to throw.
-     */
-    final SQLException unsupportedOperation(final String methodOrWishedFeatureName) {
-        return new SQLFeatureNotSupportedException(Resources.format(Resources.Keys.UnsupportedDriverFeature_2,
-                getInterface(), methodOrWishedFeatureName));
+     * @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) {
+        format(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) {
+        format(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.
      */
-    final void logUnsupportedOperation(final String methodName) {
-        logWarning(methodName, Resources.Keys.UnsupportedDriverFeature_2, getInterface(), methodName);
+    public void logUnsupportedOperation(final String methodName) {
+        format(Level.WARNING, "excp.unsupportedDriverFeature", getInterface(), methodName, getClass().getSimpleName());
     }
 
     /**
-     * Logs a warning with the given resource keys and arguments.
-     *
-     * @param methodName  The name of the method which is emitting the warning.
-     * @param resourceKey One of the {@link org.apache.sis.internal.shapefile.jdbc.Resources.Keys} values.
-     * @param arguments   Arguments to be given to {@link java.text.MessageFormat}, or {@code null} if none.
-     */
-    final void logWarning(final String methodName, final short resourceKey, final Object... arguments) {
-        final LogRecord record = Resources.getResources(null).getLogRecord(Level.WARNING, resourceKey, arguments);
-        record.setSourceClassName(getClass().getCanonicalName());
-        record.setSourceMethodName(methodName);
-        record.setLoggerName(LOGGER.getName());
-        LOGGER.log(record);
+     * 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) {
+        format(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;
     }
 }

Copied: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java (from r1651598, sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java?p2=sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java&p1=sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java&r1=1651598&r2=1651610&rev=1651610&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/CommonByteReader.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -19,11 +19,14 @@ package org.apache.sis.internal.shapefil
 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;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
 /**
  * Common byte reader.
  * @author  Marc Le Bihan
@@ -33,7 +36,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 {
     /** The File. */
     private File file;
 
@@ -95,7 +98,6 @@ public abstract class CommonByteReader<I
      * Close the MappedByteReader.
      * @throws IOException if the close operation fails.
      */
-    @Override
     public void close() throws IOException {
         if (fc != null)
             fc.close();

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java?rev=1651610&r1=1651609&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -16,13 +16,16 @@
  */
 package org.apache.sis.internal.shapefile.jdbc;
 
+import java.io.*;
 import java.sql.*;
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-import java.util.logging.Logger;
-import org.apache.sis.util.ArgumentChecks;
-import org.apache.sis.internal.system.Modules;
+import java.util.*;
+import java.util.logging.*;
+
+import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
+import org.apache.sis.internal.system.*;
+
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
 
 
 /**
@@ -41,11 +44,19 @@ public class DBFDriver extends AbstractJ
     }
 
     /**
+     * @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 Class<?> getInterface() {
+    final protected Class<?> getInterface() {
         return Driver.class;
     }
 
@@ -55,17 +66,17 @@ public class DBFDriver extends AbstractJ
      * @param  url  The path to a {@code .dbf} file.
      * @param  info Ignored in current implementation.
      * @return A connection to the given DBF file.
-     * @throws SQLException if this method can not create a connection to the given file.
+     * @throws InvalidDbaseFileFormatException if the database file format is invalid.
+     * @throws DbaseFileNotFoundException if the database file doesn't exist.
+     * @throws InvalidDbaseFileFormatException if the database file has a wrong format.
      */
     @Override
-    public Connection connect(final String url, @SuppressWarnings("unused") Properties info) throws SQLException {
-        ArgumentChecks.ensureNonNull("url", url);
-        try {
-            return new DBFConnection(new File(url));
-        } catch (IOException e) {
-            throw new SQLNonTransientConnectionException(Resources.format(
-                    Resources.Keys.InvalidDBFFormatDescriptor_2, url, e.getLocalizedMessage()));
-        }
+    @SuppressWarnings("resource") // the function opens a connection.
+    public Connection connect(final String url, @SuppressWarnings("unused") Properties info) throws InvalidDbaseFileFormatException, DbaseFileNotFoundException {
+        Objects.requireNonNull(url, "the DBase3 url cannot be null");
+        File file = new File(url);
+
+        return new DBFConnection(file, new MappedByteReader(file));
     }
 
     /**
@@ -76,16 +87,24 @@ public class DBFDriver extends AbstractJ
         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(String url, Properties info) {
+    public DriverPropertyInfo[] getPropertyInfo(@SuppressWarnings("unused") String url, @SuppressWarnings("unused") Properties info) {
         return new DriverPropertyInfo[0];
     }
 
@@ -120,8 +139,7 @@ public class DBFDriver extends AbstractJ
     /**
      * The logger used by this driver.
      */
-    // No @Override on JDK6
     public Logger getParentLogger() {
-        return LOGGER;
+        return super.getLogger();
     }
 }

Copied: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java (from r1651598, sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java?p2=sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java&p1=sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java&r1=1651598&r2=1651610&rev=1651610&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -35,9 +35,9 @@ import org.opengis.feature.Feature;
  * @since   0.5
  * @module
  */
-public class MappedByteReader extends AbstractDbase3ByteReader implements AutoCloseable {
+public class MappedByteReader extends AbstractDbase3ByteReader {
     /** List of field descriptors. */
-    private List<DBase3FieldDescriptor> fieldsDescriptors = new ArrayList<>();
+    private List<DBase3FieldDescriptor> fieldsDescriptors = new ArrayList<DBase3FieldDescriptor>();
 
     /**
      * Construct a mapped byte reader on a file.
@@ -94,7 +94,7 @@ public class MappedByteReader extends Ab
         byte isDeleted = getByteBuffer().get(); // denotes whether deleted or current
         // read first part of record
 
-        HashMap<String, Object> fieldsValues = new HashMap<>();
+        HashMap<String, Object> fieldsValues = new HashMap<String,Object>();
 
         for (DBase3FieldDescriptor fd : fieldsDescriptors) {
             byte[] data = new byte[fd.getLength()];

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/AbstractConnection.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -68,7 +68,6 @@ abstract class AbstractConnection extend
     /**
      * Unsupported by default.
      */
-    @Override
     public String getSchema() throws SQLException {
         throw unsupportedOperation("getSchema");
     }
@@ -76,7 +75,6 @@ abstract class AbstractConnection extend
     /**
      * Unsupported by default.
      */
-    @Override
     public void setSchema(String schema) throws SQLException {
         throw unsupportedOperation("setSchema");
     }
@@ -395,7 +393,6 @@ abstract class AbstractConnection extend
     /**
      * Defaults to 0, which means there is no limit.
      */
-    @Override
     public int getNetworkTimeout() {
         return 0; // Means there is no limt.
     }
@@ -403,7 +400,6 @@ abstract class AbstractConnection extend
     /**
      * Unsupported by default.
      */
-    @Override
     public void setNetworkTimeout(Executor executor, int milliseconds) {
         logUnsupportedOperation("setNetworkTimeout");
     }
@@ -411,7 +407,6 @@ abstract class AbstractConnection extend
     /**
      * Unsupported by default.
      */
-    @Override
     public void abort(Executor executor) throws SQLException {
         throw unsupportedOperation("abort");
     }

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -28,6 +28,9 @@ import org.apache.sis.internal.shapefile
 import org.apache.sis.internal.shapefile.jdbc.resultset.*;
 import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
 
 /**
  * Connection to a DBF database.
@@ -41,7 +44,7 @@ public class DBFConnection extends Abstr
     final File databaseFile;
 
     /** Opened statement. */
-    private HashSet<DBFStatement> openedStatements = new HashSet<>();
+    private HashSet<DBFStatement> openedStatements = new HashSet<DBFStatement>();
 
     /** ByteReader. */
     private Dbase3ByteReader byteReader;

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/AbstractDatabaseMetaData.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -119,7 +119,7 @@ public abstract class AbstractDatabaseMe
     /**
      * @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 {
+    public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
         throw unsupportedOperation("getPseudoColumns", catalog, schemaPattern, tableNamePattern, columnNamePattern);
     }
 

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFDatabaseMetaData.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -19,13 +19,16 @@ package org.apache.sis.internal.shapefil
 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;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
 /**
  * Database Metadata.
  * @author Marc LE BIHAN
@@ -73,8 +76,11 @@ 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()) {
+        DBFStatement stmt = (DBFStatement)connection.createStatement();
+        try {
             return new DBFBuiltInMemoryResultSetForColumnsListing(stmt, connection.getFieldsDescriptors());
+        } finally {
+            stmt.close();
         }
     }
 
@@ -1286,7 +1292,7 @@ public class DBFDatabaseMetaData extends
     /**
      * @see java.sql.DatabaseMetaData#generatedKeyAlwaysReturned()
      */
-    @Override public boolean generatedKeyAlwaysReturned() {
+    public boolean generatedKeyAlwaysReturned() {
         logStep("generatedKeyAlwaysReturned");
         return false;
     }

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/metadata/DBFResultSetMataData.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -20,7 +20,6 @@ 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;
@@ -29,6 +28,10 @@ import org.apache.sis.internal.shapefile
 import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
 import org.apache.sis.internal.shapefile.jdbc.resultset.*;
 
+// Branch-dependent imports
+import org.apache.sis.internal.jdk7.Objects;
+
+
 /**
  * ResultSet Metadata.
  * @author Marc LE BIHAN
@@ -92,13 +95,16 @@ public class DBFResultSetMataData extend
     @Override public boolean isAutoIncrement(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("isAutoIncrement", column);
 
-        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+        try {
             return rsDatabase.getString("TYPE_NAME").equals("AUTO_INCREMENT");
         }
         catch(SQLNoSuchFieldException e) {
             // We encounter an internal API error in this case.
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
             throw new RuntimeException(message, e);
+        } finally {
+            rsDatabase.close();
         }
     }
 
@@ -126,12 +132,15 @@ public class DBFResultSetMataData extend
     @Override public boolean isCurrency(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("isCurrency", column);
 
-        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+        try {
             return rsDatabase.getString("TYPE_NAME").equals("CURRENCY");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
             throw new RuntimeException(message, e);
+        } finally {
+            rsDatabase.close();
         }
     }
 
@@ -159,43 +168,47 @@ public class DBFResultSetMataData extend
     @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;
-
+        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+        try {
+            final String v = rsDatabase.getString("TYPE_NAME");
+            if (v.equals("AUTO_INCREMENT") ||
+                v.equals("CHAR") ||
+                v.equals("INTEGER"))
+            {
+                return rsDatabase.getInt("COLUMN_SIZE");
+            }
+            if (v.equals("DATE")) {
+                return 8;
+            }
+            if (v.equals("DOUBLE") ||
+                v.equals("FLOAT") ||
+                v.equals("DECIMAL"))
+            {
                 // 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.
-
+                return rsDatabase.getInt("COLUMN_SIZE") + 1;
+            }
+            if (v.equals("BOOLEAN")) {
+                return 5; // Translation for true, false, null.
+            }
+            if (v.equals("CURRENCY") ||
+                v.equals("DATETIME") ||
+                v.equals("TIMESTAMP") ||
+                v.equals("MEMO") ||
+                v.equals("PICTURE") ||
+                v.equals("VARIFIELD") ||
+                v.equals("VARIANT") ||
+                v.equals("UNKNOWN"))
+            {
                 // 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");
+                return rsDatabase.getInt("COLUMN_SIZE");
             }
+            return rsDatabase.getInt("COLUMN_SIZE");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
             throw new RuntimeException(message, e);
+        } finally {
+            rsDatabase.close();
         }
     }
 
@@ -207,12 +220,15 @@ public class DBFResultSetMataData extend
     @Override public String getColumnLabel(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getColumnLabel", column);
 
-        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+        try {
             return rsDatabase.getString("COLUMN_NAME");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "COLUMN_NAME", e.getMessage());
             throw new RuntimeException(message, e);
+        } finally {
+            rsDatabase.close();
         }
     }
 
@@ -224,12 +240,15 @@ public class DBFResultSetMataData extend
     @Override public String getColumnName(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getColumnName", column);
 
-        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+        try {
             return rsDatabase.getString("COLUMN_NAME");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "COLUMN_NAME", e.getMessage());
             throw new RuntimeException(message, e);
+        } finally {
+            rsDatabase.close();
         }
     }
 
@@ -249,12 +268,15 @@ public class DBFResultSetMataData extend
     @Override public int getPrecision(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getPrecision", column);
 
-        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+        try {
             return rsDatabase.getInt("COLUMN_SIZE");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "COLUMN_SIZE", e.getMessage());
             throw new RuntimeException(message, e);
+        } finally {
+            rsDatabase.close();
         }
     }
 
@@ -266,12 +288,15 @@ public class DBFResultSetMataData extend
     @Override public int getScale(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getScale", column);
 
-        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+        try {
             return rsDatabase.getInt("DECIMAL_DIGITS");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "DECIMAL_DIGITS", e.getMessage());
             throw new RuntimeException(message, e);
+        } finally {
+            rsDatabase.close();
         }
     }
 
@@ -304,12 +329,15 @@ public class DBFResultSetMataData extend
     @Override public int getColumnType(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getColumnType", column);
 
-        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+        try {
             return rsDatabase.getInt("DATA_TYPE");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "DATA_TYPE", e.getMessage());
             throw new RuntimeException(message, e);
+        } finally {
+            rsDatabase.close();
         }
     }
 
@@ -321,12 +349,15 @@ public class DBFResultSetMataData extend
     @Override public String getColumnTypeName(int column) throws SQLIllegalColumnIndexException, SQLConnectionClosedException {
         logStep("getColumnTypeName", column);
 
-        try(DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column)) {
+        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+        try {
             return rsDatabase.getString("TYPE_NAME");
         }
         catch(SQLNoSuchFieldException e) {
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
             throw new RuntimeException(message, e);
+        } finally {
+            rsDatabase.close();
         }
     }
 
@@ -363,64 +394,65 @@ public class DBFResultSetMataData extend
     @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();
+        DBFBuiltInMemoryResultSetForColumnsListing rsDatabase = desc(column);
+        try {
+            final String v = rsDatabase.getString("TYPE_NAME");
+            if (v.equals("AUTO_INCREMENT"))
+                return Integer.class.getName();
 
-                case "CHAR":
-                    return String.class.getName();
+            if (v.equals("CHAR"))
+                return String.class.getName();
 
-                case "INTEGER":
-                   return Integer.class.getName();
+            if (v.equals("INTEGER"))
+               return Integer.class.getName();
 
-                case "DATE":
-                    return java.sql.Date.class.getName();
+            if (v.equals("DATE"))
+                return java.sql.Date.class.getName();
 
-                case "DOUBLE":
-                    return Double.class.getName();
+            if (v.equals("DOUBLE"))
+                return Double.class.getName();
 
-                case "FLOAT":
-                    return Float.class.getName();
+            if (v.equals("FLOAT"))
+                return Float.class.getName();
 
-                case "DECIMAL":
-                    return Double.class.getName();
+            if (v.equals("DECIMAL"))
+                return Double.class.getName();
 
-                case "BOOLEAN":
-                    return Boolean.class.getName();
+            if (v.equals("BOOLEAN"))
+                return Boolean.class.getName();
 
-                case "CURRENCY":
-                    return Double.class.getName();
+            if (v.equals("CURRENCY"))
+                return Double.class.getName();
 
-                case "DATETIME":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime");
+            if (v.equals("DATETIME"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime");
 
-                case "TIMESTAMP":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp");
+            if (v.equals("TIMESTAMP"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp");
 
-                case "MEMO":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo");
+            if (v.equals("MEMO"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo");
 
-                case "PICTURE":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture");
+            if (v.equals("PICTURE"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture");
 
-                case "VARIFIELD":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField");
+            if (v.equals("VARIFIELD"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField");
 
-                case "VARIANT":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant");
+            if (v.equals("VARIANT"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant");
 
-                case "UNKNOWN":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
+            if (v.equals("UNKNOWN"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
 
-                default:
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
-            }
+            throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + rsDatabase.getString("TYPE_NAME"));
         }
         catch(SQLNoSuchFieldException e) {
             // We encounter an internal API error in this case.
             String message = format(Level.SEVERE, "assert.expected_databasemetadata_not_found", "TYPE_NAME", e.getMessage());
             throw new RuntimeException(message, e);
+        } finally {
+            rsDatabase.close();
         }
     }
 

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java?rev=1651610&r1=1651609&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/package-info.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -16,8 +16,8 @@
  */
 
 /**
- * Allows access to {@link org.apache.sis.storage.shapefile} storage through JDBC driver.
- *
+ * 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

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

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForColumnsListing.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -60,102 +60,98 @@ public class DBFBuiltInMemoryResultSetFo
     @Override public String getString(String columnLabel) throws SQLNoSuchFieldException {
         logStep("getString", columnLabel);
 
-        switch(columnLabel) {
-            // String => table name
-            case "TABLE_NAME": {
-                String tableName = getTableName();
-                wasNull = (tableName == null);
-                return tableName;
-            }
-
-            // String => column name
-            case "COLUMN_NAME": {
-                String columnName = current.getName();
-                wasNull = (columnName == null);
-                return columnName;
-            }
+        // String => table name
+        if (columnLabel.equals("TABLE_NAME")) {
+            String tableName = getTableName();
+            wasNull = (tableName == null);
+            return tableName;
+        }
 
-            // 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);
-                return typeName;
-            }
+        // String => column name
+        if (columnLabel.equals("COLUMN_NAME")) {
+            String columnName = current.getName();
+            wasNull = (columnName == null);
+            return columnName;
+        }
 
-            /**
-             * 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": {
-                wasNull = true;
-                return null;
-            }
+        // String => Data source dependent type name, for a UDT the type name is fully qualified
+        if (columnLabel.equals("TYPE_NAME")) {
+            String typeName = current.getType() != null ? toColumnTypeName() : null;
+            wasNull = (typeName == null);
+            return typeName;
+        }
 
-            // String => table schema (may be null)
-            case "TABLE_SCHEM": {
-                wasNull = true;
-                return null;
-            }
+        /**
+         * 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)
+        if (columnLabel.equals("TABLE_CAT")) {
+            wasNull = true;
+            return null;
+        }
 
-            // String => comment describing column (may be null)
-            case "REMARKS":
-                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;
-                return null;
-            }
+        // String => table schema (may be null)
+        if (columnLabel.equals("TABLE_SCHEM")) {
+            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;
-                return null;
-            }
+        // String => comment describing column (may be null)
+        if (columnLabel.equals("REMARKS")) {
+            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)
+        if (columnLabel.equals("COLUMN_DEF")) {
+            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;
-                return null;
-            }
+        // String => catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF)
+        if (columnLabel.equals("SCOPE_CATALOG")) {
+            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;
-                return null;
-            }
+        // String => schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF)
+        if (columnLabel.equals("SCOPE_SCHEMA")) {
+            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": {
-                wasNull = false;
-                return "NO";
-            }
+        // String => table name that this the scope of a reference attribute (null if the DATA_TYPE isn't REF)
+        if (columnLabel.equals("SCOPE_TABLE")) {
+            wasNull = true;
+            return null;
+        }
 
-            /**
-             * 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": {
-                wasNull = false;
-                return "NO";
-            }
+        /**
+         * 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
+         */
+        if (columnLabel.equals("IS_AUTOINCREMENT")) {
+            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.
-            }
+        /**
+         * 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
+         */
+        if (columnLabel.equals("IS_GENERATEDCOLUMN")) {
+            wasNull = false;
+            return "NO";
         }
+
+        // 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.
     }
 
     /**
@@ -165,92 +161,89 @@ public class DBFBuiltInMemoryResultSetFo
     @Override public int getInt(String columnLabel) throws SQLNoSuchFieldException {
         logStep("getInt", columnLabel);
 
-        switch(columnLabel) {
-            // int => SQL type from java.sql.Types
-            case "DATA_TYPE": {
-                wasNull = false;
-                return toSQLDataType();
-            }
-
-            // int => column size.
-            case "COLUMN_SIZE": {
-                wasNull = false;
-                return toPrecision();
-            }
+        // int => SQL type from java.sql.Types
+        if (columnLabel.equals("DATA_TYPE")) {
+            wasNull = false;
+            return toSQLDataType();
+        }
 
-            // 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;
-                return scale == -1 ? 0 : scale;
-            }
+        // int => column size.
+        if (columnLabel.equals("COLUMN_SIZE")) {
+            wasNull = false;
+            return toPrecision();
+        }
 
-            // int => Radix (typically either 10 or 2)
-            case "NUM_PREC_RADIX": {
-                return 10;
-            }
+        // int => the number of fractional digits. Null is returned for data types where DECIMAL_DIGITS is not applicable.
+        if (columnLabel.equals("DECIMAL_DIGITS")) {
+            int scale = toScale();
+            wasNull = toScale() == -1;
+            return scale == -1 ? 0 : scale;
+        }
 
-            /**
-             * int => is NULL allowed.
-             * columnNoNulls - might not allow NULL values
-             * columnNullable - definitely allows NULL values
-             * columnNullableUnknown - nullability unknown
-             */
-            case "NULLABLE": {
-                wasNull = false;
-                return DatabaseMetaData.columnNullableUnknown;
-            }
+        // int => Radix (typically either 10 or 2)
+        if (columnLabel.equals("NUM_PREC_RADIX")) {
+            return 10;
+        }
 
-            // int => unused
-            case "SQL_DATA_TYPE": {
-                wasNull = false;
-                return toSQLDataType();
-            }
+        /**
+         * int => is NULL allowed.
+         * columnNoNulls - might not allow NULL values
+         * columnNullable - definitely allows NULL values
+         * columnNullableUnknown - nullability unknown
+         */
+        if (columnLabel.equals("NULLABLE")) {
+            wasNull = false;
+            return DatabaseMetaData.columnNullableUnknown;
+        }
 
-            // int => for char types the maximum number of bytes in the column
-            case "CHAR_OCTET_LENGTH": {
-                if (toSQLDataType() == Types.CHAR) {
-                    return toPrecision();
-                }
+        // int => unused
+        if (columnLabel.equals("SQL_DATA_TYPE")) {
+            wasNull = false;
+            return toSQLDataType();
+        }
 
-                return 0;
+        // int => for char types the maximum number of bytes in the column
+        if (columnLabel.equals("CHAR_OCTET_LENGTH")) {
+            if (toSQLDataType() == Types.CHAR) {
+                return toPrecision();
             }
 
-            // int => index of column in table (starting at 1)
-            case "ORDINAL_POSITION": {
-                return columnIndex;
-            }
+            return 0;
+        }
 
-            /**
-             * 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": {
-                wasNull = true;
-                return 0;
-            }
+        // int => index of column in table (starting at 1)
+        if (columnLabel.equals("ORDINAL_POSITION")) {
+            return columnIndex;
+        }
 
-            // is not used.
-            case "BUFFER_LENGTH": {
-                wasNull = false;
-                return 0;
-            }
+        /**
+         * 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)
+        if (columnLabel.equals("SOURCE_DATA_TYPE")) {
+            wasNull = true;
+            return 0;
+        }
 
-            // int => unused
-            case "SQL_DATETIME_SUB": {
-                wasNull = false;
-                return 0;
-            }
+        // is not used.
+        if (columnLabel.equals("BUFFER_LENGTH")) {
+            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);
+        // int => unused
+        if (columnLabel.equals("SQL_DATETIME_SUB")) {
+            wasNull = false;
+            return 0;
         }
+
+        // FIXME : this function is not perfect. It a column label is given that refers to a field described in getString(..) this function
+        // will tell that the field doesn't exist. It's not true : the field is not numeric. But as getString(..) defaults to getInt(...),
+        // getInt(..) cannot default to getString(..), else the function will run in a cycle.
+        String message = format(Level.WARNING, "excp.no_desc_field", columnLabel, getTableName());
+        throw new SQLNoSuchFieldException(message, "asking columns desc", getFile(), columnLabel);
     }
 
     /**

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesListing.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -42,33 +42,31 @@ public class DBFBuiltInMemoryResultSetFo
     @Override public String getString(String columnLabel) {
         logStep("getString", columnLabel);
 
-        switch(columnLabel) {
-            case "TABLE_NAME":                // String => table name.
-            {
-                String tableName = getTableName();
-                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;
-                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)
-                wasNull = true;
-                return null;
+        if (columnLabel.equals("TABLE_NAME"))                // String => table name.
+        {
+            String tableName = getTableName();
+            wasNull = (tableName == null);
+            return tableName;
+        }
 
-            default:
-                wasNull = true;
-                return null;
+        if (columnLabel.equals("TABLE_TYPE")) {              // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
+            wasNull = false;
+            return "TABLE";
+        }
+        if (columnLabel.equals("TYPE_NAME") ||                 // String => type name (may be null)
+            columnLabel.equals("TABLE_CAT") ||                 // String => table catalog (may be null)
+            columnLabel.equals("TABLE_SCHEM") ||               // String => table schema (may be null)
+            columnLabel.equals("REMARKS") ||                   // String => explanatory comment on the table
+            columnLabel.equals("TYPE_CAT") ||                  // String => the types catalog (may be null)
+            columnLabel.equals("TYPE_SCHEM") ||                // String => the types schema (may be null)
+            columnLabel.equals("SELF_REFERENCING_COL_NAME") || // String => name of the designated "identifier" column of a typed table (may be null)
+            columnLabel.equals("REF_GENERATION"))            // String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null)
+        {
+            wasNull = true;
+            return null;
         }
+        wasNull = true;
+        return null;
     }
 
     /**

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFBuiltInMemoryResultSetForTablesTypesListing.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -42,19 +42,16 @@ public class DBFBuiltInMemoryResultSetFo
     @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 ?
-                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;
-                return "TABLE";               // and DBase 3 only knows tables.
-
-            default:
-                wasNull = true;
-                return null;
+        if (columnLabel.equals("OBJECTID")) {         // FIXME Documentation of ObjectId for geTabletTypes() has not been found. What are the rules about this field ?
+            wasNull = false;
+            return "1";
+        }
+        if (columnLabel.equals("TABLE_TYPE")) {       // String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
+            wasNull = false;
+            return "TABLE";               // and DBase 3 only knows tables.
         }
+        wasNull = true;
+        return null;
     }
 
     /**

Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java?rev=1651610&r1=1651598&r2=1651610&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] Wed Jan 14 09:53:53 2015
@@ -76,7 +76,8 @@ public class DBFRecordBasedResultSet ext
         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)) {
+        DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql);
+        try {
             MathContext mc = new MathContext(field.getInt("DECIMAL_DIGITS"), RoundingMode.HALF_EVEN);
             Double doubleValue = getDouble(columnLabel);
 
@@ -89,6 +90,8 @@ public class DBFRecordBasedResultSet ext
                 wasNull = true;
                 return null;
             }
+        } finally {
+            field.close();
         }
     }
 
@@ -335,7 +338,8 @@ public class DBFRecordBasedResultSet ext
      */
     @Override
     public Object getObject(int column) throws SQLConnectionClosedException, SQLIllegalColumnIndexException, SQLFeatureNotSupportedException, SQLNoSuchFieldException, SQLNotNumericException, SQLNotDateException {
-        try(DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(column, sql)) {
+        DBFBuiltInMemoryResultSetForColumnsListing field = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(column, sql);
+        try {
             String fieldType;
 
             try {
@@ -346,63 +350,62 @@ public class DBFRecordBasedResultSet ext
                 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);
+            if (fieldType.equals("AUTO_INCREMENT") ||
+                fieldType.equals("INTEGER"))
+                return getInt(column);
+
+            if (fieldType.equals("CHAR"))
+                return getString(column);
+
+            if (fieldType.equals("DATE"))
+                return getDate(column);
+
+            if (fieldType.equals("DECIMAL")) {
+                // Choose Integer or Long type, if no decimal and that the field is not to big.
+                if (field.getInt("DECIMAL_DIGITS") == 0 && field.getInt("COLUMN_SIZE") <= 18) {
+                    if (field.getInt("COLUMN_SIZE") <= 9)
+                        return getInt(column);
+                    else
+                        return getLong(column);
                 }
 
-                case "DOUBLE":
-                case "CURRENCY":
-                    return getDouble(column);
+                return getDouble(column);
+            }
 
-                case "FLOAT":
-                    return getFloat(column);
+            if (fieldType.equals("DOUBLE") ||
+                fieldType.equals("CURRENCY"))
+                return getDouble(column);
 
-                case "BOOLEAN":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Boolean");
+            if (fieldType.equals("FLOAT"))
+                return getFloat(column);
 
-                case "DATETIME":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime");
+            if (fieldType.equals("BOOLEAN"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Boolean");
 
-                case "TIMESTAMP":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp");
+            if (fieldType.equals("DATETIME"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on DateTime");
 
-                case "MEMO":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo");
+            if (fieldType.equals("TIMESTAMP"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on TimeStamp");
 
-                case "PICTURE":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture");
+            if (fieldType.equals("MEMO"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Memo");
 
-                case "VARIFIELD":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField");
+            if (fieldType.equals("PICTURE"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Picture");
 
-                case "VARIANT":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant");
+            if (fieldType.equals("VARIFIELD"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on VariField");
 
-                case "UNKNOWN":
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + fieldType);
+            if (fieldType.equals("VARIANT"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on Variant");
 
-                default:
-                    throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + fieldType);
-            }
+            if (fieldType.equals("UNKNOWN"))
+                throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + fieldType);
+
+            throw unsupportedOperation("ResultSetMetaData.getColumnClassName(..) on " + fieldType);
+        } finally {
+            field.close();
         }
     }
 
@@ -584,7 +587,8 @@ public class DBFRecordBasedResultSet ext
     private <T extends Number> T getNumeric(String columnLabel, Function<String, T> parse) throws SQLConnectionClosedException, SQLNoSuchFieldException, SQLNotNumericException {
         assertNotClosed();
 
-        try(DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql)) {
+        DBFBuiltInMemoryResultSetForColumnsListing rs = (DBFBuiltInMemoryResultSetForColumnsListing)getFieldDesc(columnLabel, sql);
+        try {
             String textValue = (String)record.get(columnLabel);
 
             if (textValue == null) {
@@ -600,6 +604,8 @@ public class DBFRecordBasedResultSet ext
                 String message = format(Level.WARNING, "excp.field_is_not_numeric", columnLabel, rs.getString("TYPE_NAME"), sql, textValue);
                 throw new SQLNotNumericException(message, sql, getFile(), columnLabel, textValue);
             }
+        } finally {
+            rs.close();
         }
     }
 

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



Mime
View raw message