sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1724528 [5/15] - in /sis/branches/JDK6: ./ application/sis-console/src/main/artifact/bin/ application/sis-console/src/main/artifact/log/ application/sis-console/src/main/java/org/apache/sis/console/ core/sis-build-helper/src/main/java/org/...
Date Wed, 13 Jan 2016 23:25:42 GMT
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java?rev=1724528&r1=1724479&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/CoordinateOperationSet.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -49,7 +49,7 @@ final class CoordinateOperationSet exten
      */
     CoordinateOperationSet(final AuthorityFactory factory) {
         super(factory, CoordinateOperation.class);
-        projections = new HashMap<>();
+        projections = new HashMap<String,Integer>();
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1724528&r1=1724479&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -110,7 +110,9 @@ import org.apache.sis.measure.Measuremen
 import org.apache.sis.measure.Units;
 
 // Branch-dependent imports
+import org.apache.sis.internal.jdk7.JDK7;
 import org.apache.sis.internal.jdk8.JDK8;
+import org.apache.sis.internal.jdk7.AutoCloseable;
 
 
 /**
@@ -153,8 +155,9 @@ import org.apache.sis.internal.jdk8.JDK8
  *
  * @see <a href="http://sis.apache.org/book/tables/CoordinateReferenceSystems.html">List of authority codes</a>
  */
+@AutoCloseable
 public class EPSGDataAccess extends GeodeticAuthorityFactory implements CRSAuthorityFactory,
-        CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, Localized, AutoCloseable
+        CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, Localized
 {
     /**
      * The namespace of EPSG names and codes. This namespace is needed by all {@code createFoo(String)} methods.
@@ -189,7 +192,7 @@ public class EPSGDataAccess extends Geod
      * A pool of prepared statements. Keys are {@link String} objects related to their originating method
      * (for example "Ellipsoid" for {@link #createEllipsoid(String)}).
      */
-    private final Map<String,PreparedStatement> statements = new HashMap<>();
+    private final Map<String,PreparedStatement> statements = new HashMap<String,PreparedStatement>();
 
     /**
      * The set of authority codes for different types. This map is used by the {@link #getAuthorityCodes(Class)}
@@ -207,7 +210,7 @@ public class EPSGDataAccess extends Geod
      * and returns {@code false} if some are found (thus blocking the call to {@link #close()}
      * by the {@link org.apache.sis.referencing.factory.ConcurrentAuthorityFactory} timer).</p>
      */
-    private final Map<Class<?>, CloseableReference<AuthorityCodes>> authorityCodes = new HashMap<>();
+    private final Map<Class<?>, CloseableReference<AuthorityCodes>> authorityCodes = new HashMap<Class<?>, CloseableReference<AuthorityCodes>>();
 
     /**
      * Cache for axis names. This service is not provided by {@code ConcurrentAuthorityFactory}
@@ -215,7 +218,7 @@ public class EPSGDataAccess extends Geod
      *
      * @see #getAxisName(int)
      */
-    private final Map<Integer,AxisName> axisNames = new HashMap<>();
+    private final Map<Integer,AxisName> axisNames = new HashMap<Integer,AxisName>();
 
     /**
      * Cache for the number of dimensions of coordinate systems. This service is not provided by
@@ -223,7 +226,7 @@ public class EPSGDataAccess extends Geod
      *
      * @see #getDimensionForCS(int)
      */
-    private final Map<Integer,Integer> csDimensions = new HashMap<>();
+    private final Map<Integer,Integer> csDimensions = new HashMap<Integer,Integer>();
 
     /**
      * Cache for whether conversions are projections. This service is not provided by {@code ConcurrentAuthorityFactory}
@@ -231,7 +234,7 @@ public class EPSGDataAccess extends Geod
      *
      * @see #isProjection(int)
      */
-    private final Map<Integer,Boolean> isProjection = new HashMap<>();
+    private final Map<Integer,Boolean> isProjection = new HashMap<Integer,Boolean>();
 
     /**
      * Cache of naming systems other than EPSG. There is usually few of them (at most 15).
@@ -239,13 +242,13 @@ public class EPSGDataAccess extends Geod
      *
      * @see #createProperties(String, String, String, String, boolean)
      */
-    private final Map<String,NameSpace> namingSystems = new HashMap<>();
+    private final Map<String,NameSpace> namingSystems = new HashMap<String,NameSpace>();
 
     /**
      * The properties to be given the objects to construct.
      * Reused every time {@code createProperties(…)} is invoked.
      */
-    private final Map<String,Object> properties = new HashMap<>();
+    private final Map<String,Object> properties = new HashMap<String,Object>();
 
     /**
      * A safety guard for preventing never-ending loops in recursive calls to some {@code createFoo(String)} methods.
@@ -259,7 +262,7 @@ public class EPSGDataAccess extends Geod
      *
      * Keys are EPSG codes and values are the type of object being constructed (but those values are not yet used).
      */
-    private final Map<Integer,Class<?>> safetyGuard = new HashMap<>();
+    private final Map<Integer,Class<?>> safetyGuard = new HashMap<Integer,Class<?>>();
 
     /**
      * {@code true} for disabling the logging of warnings when this factory creates deprecated objects.
@@ -359,9 +362,9 @@ public class EPSGDataAccess extends Geod
             final String query = translator.apply("SELECT VERSION_NUMBER, VERSION_DATE FROM [Version History]" +
                                                   " ORDER BY VERSION_DATE DESC, VERSION_HISTORY_CODE DESC");
             String version = null;
-            try (Statement statement = connection.createStatement();
-                 ResultSet result = statement.executeQuery(query))
-            {
+            final Statement statement = connection.createStatement();
+            final ResultSet result = statement.executeQuery(query);
+            try {
                 while (result.next()) {
                     version = getOptionalString(result, 1);
                     final Date date = result.getDate(2);                            // Local timezone.
@@ -371,6 +374,9 @@ public class EPSGDataAccess extends Geod
                         break;
                     }
                 }
+            } finally {
+                result.close();
+                statement.close();
             }
             /*
              * Add some hard-coded links to EPSG resources, and finally add the JDBC driver name and version number.
@@ -511,7 +517,7 @@ addURIs:    for (int i=0; ; i++) {
                     result = codes;
                 } else {
                     if (result instanceof AuthorityCodes) {
-                        result = new LinkedHashMap<>(result);
+                        result = new LinkedHashMap<String,String>(result);
                     }
                     result.putAll(codes);
                 }
@@ -623,12 +629,15 @@ addURIs:    for (int i=0; ; i++) {
                 }
                 statement.setString(1, SQLUtilities.toLikePattern(code));
                 Integer resolved = null;
-                try (ResultSet result = statement.executeQuery()) {
+                final ResultSet result = statement.executeQuery();
+                try {
                     while (result.next()) {
                         if (SQLUtilities.filterFalsePositive(code, result.getString(2))) {
                             resolved = ensureSingleton(getOptionalInteger(result, 1), resolved, code);
                         }
                     }
+                } finally {
+                    result.close();
                 }
                 if (resolved != null) {
                     primaryKeys[i] = resolved;
@@ -928,10 +937,10 @@ addURIs:    for (int i=0; ; i++) {
     {
         String reason = null;
         Object replacedBy = null;
-        try (ResultSet result = executeQuery("Deprecation",
+        final ResultSet result = executeQuery("Deprecation",
                 "SELECT OBJECT_TABLE_NAME, DEPRECATION_REASON, REPLACED_BY" +
-                " FROM [Deprecation] WHERE OBJECT_CODE = ?", code))
-        {
+                " FROM [Deprecation] WHERE OBJECT_CODE = ?", code);
+        try {
             while (result.next()) {
                 if (tableMatches(table, result.getString(1))) {
                     reason     = getOptionalString (result, 2);
@@ -939,6 +948,8 @@ addURIs:    for (int i=0; ; i++) {
                     break;
                 }
             }
+        } finally {
+            result.close();
         }
         if (replacedBy == null) {
             replacedBy = '(' + Vocabulary.getResources(locale).getString(Vocabulary.Keys.None).toLowerCase(locale) + ')';
@@ -1013,14 +1024,14 @@ addURIs:    for (int i=0; ; i++) {
          * Search for aliases. Note that searching for the object code is not sufficient. We also need to check if the
          * record is really from the table we are looking for since different tables may have objects with the same ID.
          */
-        final List<GenericName> aliases = new ArrayList<>();
-        try (ResultSet result = executeQuery("Alias",
+        final List<GenericName> aliases = new ArrayList<GenericName>();
+        final ResultSet result = executeQuery("Alias",
                 "SELECT OBJECT_TABLE_NAME, NAMING_SYSTEM_NAME, ALIAS" +
                 " FROM [Alias] INNER JOIN [Naming System]" +
                   " ON [Alias].NAMING_SYSTEM_CODE =" +
                 " [Naming System].NAMING_SYSTEM_CODE" +
-                " WHERE OBJECT_CODE = ?", code))
-        {
+                " WHERE OBJECT_CODE = ?", code);
+        try {
             while (result.next()) {
                 if (tableMatches(table, result.getString(1))) {
                     final String naming = getOptionalString(result, 2);
@@ -1037,6 +1048,8 @@ addURIs:    for (int i=0; ; i++) {
                     aliases.add(parent.nameFactory.createLocalName(ns, alias));
                 }
             }
+        } finally {
+            result.close();
         }
         if (!aliases.isEmpty()) {
             properties.put(IdentifiedObject.ALIAS_KEY, aliases.toArray(new GenericName[aliases.size()]));
@@ -1112,7 +1125,8 @@ addURIs:    for (int i=0; ; i++) {
                 }
                 query.append(" FROM ").append(table.table)
                      .append(" WHERE ").append(column).append(isPrimaryKey ? " = ?" : " LIKE ?");
-                try (PreparedStatement stmt = connection.prepareStatement(translator.apply(query.toString()))) {
+                final PreparedStatement stmt = connection.prepareStatement(translator.apply(query.toString()));
+                try {
                     /*
                      * Check if at least one record is found for the code or the name.
                      * Ensure that there is not two values for the same code or name.
@@ -1123,12 +1137,15 @@ addURIs:    for (int i=0; ; i++) {
                         stmt.setString(1, SQLUtilities.toLikePattern(code));
                     }
                     Integer present = null;
-                    try (ResultSet result = stmt.executeQuery()) {
+                    final ResultSet result = stmt.executeQuery();
+                    try {
                         while (result.next()) {
                             if (isPrimaryKey || SQLUtilities.filterFalsePositive(code, result.getString(2))) {
                                 present = ensureSingleton(getOptionalInteger(result, 1), present, code);
                             }
                         }
+                    } finally {
+                        result.close();
                     }
                     if (present != null) {
                         if (found >= 0) {
@@ -1136,6 +1153,8 @@ addURIs:    for (int i=0; ; i++) {
                         }
                         found = i;
                     }
+                } finally {
+                    stmt.close();
                 }
             }
         } catch (SQLException exception) {
@@ -1192,7 +1211,9 @@ addURIs:    for (int i=0; ; i++) {
     {
         ArgumentChecks.ensureNonNull("code", code);
         CoordinateReferenceSystem returnValue = null;
-        try (ResultSet result = executeQuery("Coordinate Reference System", "COORD_REF_SYS_CODE", "COORD_REF_SYS_NAME",
+        ResultSet result = null;
+        try {
+            result = executeQuery("Coordinate Reference System", "COORD_REF_SYS_CODE", "COORD_REF_SYS_NAME",
                 "SELECT COORD_REF_SYS_CODE,"          +     // [ 1]
                       " COORD_REF_SYS_NAME,"          +     // [ 2]
                       " AREA_OF_USE_CODE,"            +     // [ 3]
@@ -1207,8 +1228,8 @@ addURIs:    for (int i=0; ; i++) {
                       " CMPD_HORIZCRS_CODE,"          +     // [12] For CompoundCRS only
                       " CMPD_VERTCRS_CODE"            +     // [13] For CompoundCRS only
                 " FROM [Coordinate Reference System]" +
-                " WHERE COORD_REF_SYS_CODE = ?", code))
-        {
+                " WHERE COORD_REF_SYS_CODE = ?", code);
+
             while (result.next()) {
                 final Integer epsg       = getInteger  (code, result, 1);
                 final String  name       = getString   (code, result, 2);
@@ -1223,15 +1244,16 @@ addURIs:    for (int i=0; ; i++) {
                  */
                 final CRSFactory crsFactory = parent.crsFactory;
                 final CoordinateReferenceSystem crs;
-                switch (type.toLowerCase(Locale.US)) {
+                {   // On the JDK7 branch, this is a switch on strings.
                     /* ----------------------------------------------------------------------
                      *   GEOGRAPHIC CRS
                      *
                      *   NOTE: 'createProperties' MUST be invoked after any call to an other
                      *         'createFoo' method. Consequently, do not factor out.
                      * ---------------------------------------------------------------------- */
-                    case "geographic 2d":
-                    case "geographic 3d": {
+                    if (type.equalsIgnoreCase("geographic 2d") ||
+                        type.equalsIgnoreCase("geographic 3d"))
+                    {
                         final EllipsoidalCS cs = parent.createEllipsoidalCS(getString(code, result, 8));
                         final String datumCode = getOptionalString(result, 9);
                         final GeodeticDatum datum;
@@ -1249,7 +1271,6 @@ addURIs:    for (int i=0; ; i++) {
                         }
                         crs = crsFactory.createGeographicCRS(createProperties("Coordinate Reference System",
                                 name, epsg, area, scope, remarks, deprecated), datum, cs);
-                        break;
                     }
                     /* ----------------------------------------------------------------------
                      *   PROJECTED CRS
@@ -1257,7 +1278,7 @@ addURIs:    for (int i=0; ; i++) {
                      *   NOTE: This method invokes itself indirectly, through createGeographicCRS.
                      *         Consequently we can not use 'result' anymore after this block.
                      * ---------------------------------------------------------------------- */
-                    case "projected": {
+                    else if (type.equalsIgnoreCase("projected")) {
                         final String csCode  = getString(code, result,  8);
                         final String geoCode = getString(code, result, 10);
                         final String opCode  = getString(code, result, 11);
@@ -1276,17 +1297,15 @@ addURIs:    for (int i=0; ; i++) {
                         } finally {
                             endOfRecursivity(ProjectedCRS.class, epsg);
                         }
-                        break;
                     }
                     /* ----------------------------------------------------------------------
                      *   VERTICAL CRS
                      * ---------------------------------------------------------------------- */
-                    case "vertical": {
+                    else if (type.equalsIgnoreCase("vertical")) {
                         final VerticalCS    cs    = parent.createVerticalCS   (getString(code, result, 8));
                         final VerticalDatum datum = parent.createVerticalDatum(getString(code, result, 9));
                         crs = crsFactory.createVerticalCRS(createProperties("Coordinate Reference System",
                                 name, epsg, area, scope, remarks, deprecated), datum, cs);
-                        break;
                     }
                     /* ----------------------------------------------------------------------
                      *   TEMPORAL CRS
@@ -1294,13 +1313,11 @@ addURIs:    for (int i=0; ; i++) {
                      *   NOTE : The original EPSG database does not define any temporal CRS.
                      *          This block is a SIS-specific extension.
                      * ---------------------------------------------------------------------- */
-                    case "time":
-                    case "temporal": {
+                    else if (type.equalsIgnoreCase("time") || type.equalsIgnoreCase("temporal")) {
                         final TimeCS        cs    = parent.createTimeCS       (getString(code, result, 8));
                         final TemporalDatum datum = parent.createTemporalDatum(getString(code, result, 9));
                         crs = crsFactory.createTemporalCRS(createProperties("Coordinate Reference System",
                                 name, epsg, area, scope, remarks, deprecated), datum, cs);
-                        break;
                     }
                     /* ----------------------------------------------------------------------
                      *   COMPOUND CRS
@@ -1308,7 +1325,7 @@ addURIs:    for (int i=0; ; i++) {
                      *   NOTE: This method invokes itself recursively.
                      *         Consequently, we can not use 'result' anymore.
                      * ---------------------------------------------------------------------- */
-                    case "compound": {
+                    else if (type.equalsIgnoreCase("compound")) {
                         final String code1 = getString(code, result, 12);
                         final String code2 = getString(code, result, 13);
                         result.close();
@@ -1323,12 +1340,11 @@ addURIs:    for (int i=0; ; i++) {
                         // Note: Do not invoke 'createProperties' sooner.
                         crs  = crsFactory.createCompoundCRS(createProperties("Coordinate Reference System",
                                 name, epsg, area, scope, remarks, deprecated), crs1, crs2);
-                        break;
                     }
                     /* ----------------------------------------------------------------------
                      *   GEOCENTRIC CRS
                      * ---------------------------------------------------------------------- */
-                    case "geocentric": {
+                    else if (type.equalsIgnoreCase("geocentric")) {
                         final CoordinateSystem cs = parent.createCoordinateSystem(getString(code, result, 8));
                         final GeodeticDatum datum = parent.createGeodeticDatum   (getString(code, result, 9));
                         final Map<String,Object> properties = createProperties("Coordinate Reference System",
@@ -1341,22 +1357,20 @@ addURIs:    for (int i=0; ; i++) {
                             throw new FactoryDataException(error().getString(
                                     Errors.Keys.IllegalCoordinateSystem_1, cs.getName()));
                         }
-                        break;
                     }
                     /* ----------------------------------------------------------------------
                      *   ENGINEERING CRS
                      * ---------------------------------------------------------------------- */
-                    case "engineering": {
+                    else if (type.equalsIgnoreCase("engineering")) {
                         final CoordinateSystem cs    = parent.createCoordinateSystem(getString(code, result, 8));
                         final EngineeringDatum datum = parent.createEngineeringDatum(getString(code, result, 9));
                         crs = crsFactory.createEngineeringCRS(createProperties("Coordinate Reference System",
                                 name, epsg, area, scope, remarks, deprecated), datum, cs);
-                        break;
                     }
                     /* ----------------------------------------------------------------------
                      *   UNKNOWN CRS
                      * ---------------------------------------------------------------------- */
-                    default: {
+                    else {
                         throw new FactoryDataException(error().getString(Errors.Keys.UnknownType_1, type));
                     }
                 }
@@ -1367,6 +1381,12 @@ addURIs:    for (int i=0; ; i++) {
             }
         } catch (SQLException exception) {
             throw databaseFailure(CoordinateReferenceSystem.class, code, exception);
+        } finally {
+            if (result != null) try {
+                result.close();
+            } catch (SQLException e) {
+                // Suppressed exception on the JDK7 branch.
+            }
         }
         if (returnValue == null) {
              throw noSuchAuthorityCode(CoordinateReferenceSystem.class, code);
@@ -1402,7 +1422,9 @@ addURIs:    for (int i=0; ; i++) {
     public synchronized Datum createDatum(final String code) throws NoSuchAuthorityCodeException, FactoryException {
         ArgumentChecks.ensureNonNull("code", code);
         Datum returnValue = null;
-        try (ResultSet result = executeQuery("Datum", "DATUM_CODE", "DATUM_NAME",
+        ResultSet result = null;
+        try {
+            result = executeQuery("Datum", "DATUM_CODE", "DATUM_NAME",
                 "SELECT DATUM_CODE," +
                       " DATUM_NAME," +
                       " DATUM_TYPE," +
@@ -1415,8 +1437,8 @@ addURIs:    for (int i=0; ; i++) {
                       " ELLIPSOID_CODE," +          // Only for geodetic type
                       " PRIME_MERIDIAN_CODE" +      // Only for geodetic type
                 " FROM [Datum]" +
-                " WHERE DATUM_CODE = ?", code))
-        {
+                " WHERE DATUM_CODE = ?", code);
+
             while (result.next()) {
                 final Integer epsg       = getInteger  (code, result, 1);
                 final String  name       = getString   (code, result, 2);
@@ -1442,14 +1464,14 @@ addURIs:    for (int i=0; ; i++) {
                 }
                 final DatumFactory datumFactory = parent.datumFactory;
                 final Datum datum;
-                switch (type.toLowerCase(Locale.US)) {
+                {   // On the JDK7 branch, this is a switch on strings.
                     /*
                      * The "geodetic" case invokes createProperties(…) indirectly through calls to
                      * createEllipsoid(String) and createPrimeMeridian(String), so we must protect
                      * the properties map from changes.
                      */
-                    case "geodetic": {
-                        properties = new HashMap<>(properties);         // Protect from changes
+                    if (type.equalsIgnoreCase("geodetic")) {
+                        properties = new HashMap<String,Object>(properties);         // Protect from changes
                         final Ellipsoid ellipsoid    = parent.createEllipsoid    (getString(code, result, 10));
                         final PrimeMeridian meridian = parent.createPrimeMeridian(getString(code, result, 11));
                         final BursaWolfParameters[] param = createBursaWolfParameters(epsg);
@@ -1457,20 +1479,18 @@ addURIs:    for (int i=0; ; i++) {
                             properties.put(DefaultGeodeticDatum.BURSA_WOLF_KEY, param);
                         }
                         datum = datumFactory.createGeodeticDatum(properties, ellipsoid, meridian);
-                        break;
                     }
                     /*
                      * Vertical datum type is hard-coded to geoidal for now. See @todo in method javadoc.
                      */
-                    case "vertical": {
+                    else if (type.equalsIgnoreCase("vertical")) {
                         datum = datumFactory.createVerticalDatum(properties, VerticalDatumType.GEOIDAL);
-                        break;
                     }
                     /*
                      * Origin date is stored in ORIGIN_DESCRIPTION field. A column of SQL type
                      * "date" type would have been better, but we do not modify the EPSG model.
                      */
-                    case "temporal": {
+                    else if (type.equalsIgnoreCase("temporal")) {
                         final Date originDate;
                         if (anchor == null || anchor.isEmpty()) {
                             throw new FactoryDataException(error().getString(Errors.Keys.DatumOriginShallBeDate));
@@ -1485,16 +1505,14 @@ addURIs:    for (int i=0; ; i++) {
                             throw new FactoryDataException(error().getString(Errors.Keys.DatumOriginShallBeDate), e);
                         }
                         datum = datumFactory.createTemporalDatum(properties, originDate);
-                        break;
                     }
                     /*
                      * Straightforward case.
                      */
-                    case "engineering": {
+                    else if (type.equalsIgnoreCase("engineering")) {
                         datum = datumFactory.createEngineeringDatum(properties);
-                        break;
                     }
-                    default: {
+                    else {
                         throw new FactoryDataException(error().getString(Errors.Keys.UnknownType_1, type));
                     }
                 }
@@ -1505,6 +1523,12 @@ addURIs:    for (int i=0; ; i++) {
             }
         } catch (SQLException exception) {
             throw databaseFailure(Datum.class, code, exception);
+        } finally {
+            if (result != null) try {
+                result.close();
+            } catch (SQLException e) {
+                // Suppressed exception on the JDK7 branch.
+            }
         }
         if (returnValue == null) {
             throw noSuchAuthorityCode(Datum.class, code);
@@ -1532,8 +1556,8 @@ addURIs:    for (int i=0; ; i++) {
         if (code == BursaWolfInfo.TARGET_DATUM) {
             return null;
         }
-        final List<BursaWolfInfo> bwInfos = new ArrayList<>();
-        try (ResultSet result = executeQuery("BursaWolfParametersSet",
+        final List<BursaWolfInfo> bwInfos = new ArrayList<BursaWolfInfo>();
+        ResultSet result = executeQuery("BursaWolfParametersSet",
                 "SELECT COORD_OP_CODE," +
                       " COORD_OP_METHOD_CODE," +
                       " TARGET_CRS_CODE" +
@@ -1544,8 +1568,8 @@ addURIs:    for (int i=0; ; i++) {
                  " AND COORD_OP_METHOD_CODE <= " + BursaWolfInfo.MAX_METHOD_CODE +
                  " AND SOURCE_CRS_CODE IN " +
                "(SELECT COORD_REF_SYS_CODE FROM [Coordinate Reference System] WHERE DATUM_CODE = ?)" +
-            " ORDER BY TARGET_CRS_CODE, COORD_OP_ACCURACY, COORD_OP_CODE DESC", code))
-        {
+            " ORDER BY TARGET_CRS_CODE, COORD_OP_ACCURACY, COORD_OP_CODE DESC", code);
+        try {
             while (result.next()) {
                 final BursaWolfInfo info = new BursaWolfInfo(
                         getInteger(code, result, 1),                // Operation
@@ -1555,6 +1579,8 @@ addURIs:    for (int i=0; ; i++) {
                     bwInfos.add(info);
                 }
             }
+        } finally {
+            result.close();
         }
         int size = bwInfos.size();
         if (size == 0) {
@@ -1569,7 +1595,7 @@ addURIs:    for (int i=0; ; i++) {
             final BursaWolfInfo[] codes = bwInfos.toArray(new BursaWolfInfo[size]);
             sort("Coordinate_Operation", codes);
             bwInfos.clear();
-            final Set<Integer> added = new HashSet<>();
+            final Set<Integer> added = new HashSet<Integer>();
             for (BursaWolfInfo candidate : codes) {
                 if (added.add(candidate.target)) {
                     bwInfos.add(candidate);
@@ -1592,20 +1618,22 @@ addURIs:    for (int i=0; ; i++) {
                 endOfRecursivity(BursaWolfParameters.class, code);
             }
             final BursaWolfParameters bwp = new BursaWolfParameters(datum, null);
-            try (ResultSet result = executeQuery("BursaWolfParameters",
+            result = executeQuery("BursaWolfParameters",
                 "SELECT PARAMETER_CODE," +
                       " PARAMETER_VALUE," +
                       " UOM_CODE" +
                 " FROM [Coordinate_Operation Parameter Value]" +
                 " WHERE COORD_OP_CODE = ?" +
-                  " AND COORD_OP_METHOD_CODE = ?", info.operation, info.method))
-            {
+                  " AND COORD_OP_METHOD_CODE = ?", info.operation, info.method);
+            try {
                 while (result.next()) {
                     BursaWolfInfo.setBursaWolfParameter(bwp,
                             getInteger(info.operation, result, 1),
                             getDouble (info.operation, result, 2),
                             parent.createUnit(getString(info.operation, result, 3)), locale);
                 }
+            } finally {
+                result.close();
             }
             if (info.isFrameRotation()) {
                 // Coordinate frame rotation (9607): same as 9606,
@@ -1646,7 +1674,9 @@ addURIs:    for (int i=0; ; i++) {
     {
         ArgumentChecks.ensureNonNull("code", code);
         Ellipsoid returnValue = null;
-        try (ResultSet result = executeQuery("Ellipsoid", "ELLIPSOID_CODE", "ELLIPSOID_NAME",
+        ResultSet result = null;
+        try {
+            result = executeQuery("Ellipsoid", "ELLIPSOID_CODE", "ELLIPSOID_NAME",
                 "SELECT ELLIPSOID_CODE," +
                       " ELLIPSOID_NAME," +
                       " SEMI_MAJOR_AXIS," +
@@ -1656,8 +1686,8 @@ addURIs:    for (int i=0; ; i++) {
                       " REMARKS," +
                       " DEPRECATED" +
                 " FROM [Ellipsoid]" +
-                " WHERE ELLIPSOID_CODE = ?", code))
-        {
+                " WHERE ELLIPSOID_CODE = ?", code);
+
             while (result.next()) {
                 /*
                  * One of 'semiMinorAxis' and 'inverseFlattening' values can be NULL in the database.
@@ -1699,6 +1729,12 @@ addURIs:    for (int i=0; ; i++) {
             }
         } catch (SQLException exception) {
             throw databaseFailure(Ellipsoid.class, code, exception);
+        } finally {
+            if (result != null) try {
+                result.close();
+            } catch (SQLException e) {
+                // Suppressed exception on the JDK7 branch.
+            }
         }
         if (returnValue == null) {
              throw noSuchAuthorityCode(Ellipsoid.class, code);
@@ -1735,7 +1771,9 @@ addURIs:    for (int i=0; ; i++) {
     {
         ArgumentChecks.ensureNonNull("code", code);
         PrimeMeridian returnValue = null;
-        try (ResultSet result = executeQuery("Prime Meridian", "PRIME_MERIDIAN_CODE", "PRIME_MERIDIAN_NAME",
+        ResultSet result = null;
+        try {
+            result = executeQuery("Prime Meridian", "PRIME_MERIDIAN_CODE", "PRIME_MERIDIAN_NAME",
                 "SELECT PRIME_MERIDIAN_CODE," +
                       " PRIME_MERIDIAN_NAME," +
                       " GREENWICH_LONGITUDE," +
@@ -1743,8 +1781,8 @@ addURIs:    for (int i=0; ; i++) {
                       " REMARKS," +
                       " DEPRECATED" +
                 " FROM [Prime Meridian]" +
-                " WHERE PRIME_MERIDIAN_CODE = ?", code))
-        {
+                " WHERE PRIME_MERIDIAN_CODE = ?", code);
+
             while (result.next()) {
                 final Integer epsg       = getInteger  (code, result, 1);
                 final String  name       = getString   (code, result, 2);
@@ -1759,6 +1797,12 @@ addURIs:    for (int i=0; ; i++) {
             }
         } catch (SQLException exception) {
             throw databaseFailure(PrimeMeridian.class, code, exception);
+        } finally {
+            if (result != null) try {
+                result.close();
+            } catch (SQLException e) {
+                // Suppressed exception on the JDK7 branch.
+            }
         }
         if (returnValue == null) {
             throw noSuchAuthorityCode(PrimeMeridian.class, code);
@@ -1793,15 +1837,17 @@ addURIs:    for (int i=0; ; i++) {
     {
         ArgumentChecks.ensureNonNull("code", code);
         Extent returnValue = null;
-        try (ResultSet result = executeQuery("Area", "AREA_CODE", "AREA_NAME",
+        ResultSet result = null;
+        try {
+            result = executeQuery("Area", "AREA_CODE", "AREA_NAME",
                 "SELECT AREA_OF_USE," +
                       " AREA_SOUTH_BOUND_LAT," +
                       " AREA_NORTH_BOUND_LAT," +
                       " AREA_WEST_BOUND_LON," +
                       " AREA_EAST_BOUND_LON" +
                 " FROM [Area]" +
-                " WHERE AREA_CODE = ?", code))
-        {
+                " WHERE AREA_CODE = ?", code);
+
             while (result.next()) {
                 final String description = getOptionalString(result, 1);
                 double ymin = getOptionalDouble(result, 2);
@@ -1832,6 +1878,12 @@ addURIs:    for (int i=0; ; i++) {
             }
         } catch (SQLException exception) {
             throw databaseFailure(Extent.class, code, exception);
+        } finally {
+            if (result != null) try {
+                result.close();
+            } catch (SQLException e) {
+                // Suppressed exception on the JDK7 branch.
+            }
         }
         if (returnValue == null) {
             throw noSuchAuthorityCode(Extent.class, code);
@@ -1872,7 +1924,9 @@ addURIs:    for (int i=0; ; i++) {
     {
         ArgumentChecks.ensureNonNull("code", code);
         CoordinateSystem returnValue = null;
-        try (ResultSet result = executeQuery("Coordinate System", "COORD_SYS_CODE", "COORD_SYS_NAME",
+        ResultSet result = null;
+        try {
+            result = executeQuery("Coordinate System", "COORD_SYS_CODE", "COORD_SYS_NAME",
                 "SELECT COORD_SYS_CODE," +
                       " COORD_SYS_NAME," +
                       " COORD_SYS_TYPE," +
@@ -1880,8 +1934,8 @@ addURIs:    for (int i=0; ; i++) {
                       " REMARKS," +
                       " DEPRECATED" +
                 " FROM [Coordinate System]" +
-                " WHERE COORD_SYS_CODE = ?", code))
-        {
+                " WHERE COORD_SYS_CODE = ?", code);
+
             while (result.next()) {
                 final Integer epsg       = getInteger  (code, result, 1);
                 final String  name       = getString   (code, result, 2);
@@ -1893,67 +1947,56 @@ addURIs:    for (int i=0; ; i++) {
                 final Map<String,Object> properties = createProperties("Coordinate System", name, epsg, remarks, deprecated);   // Must be after axes.
                 final CSFactory csFactory = parent.csFactory;
                 CoordinateSystem cs = null;
-                switch (type.toLowerCase(Locale.US)) {
-                    case "ellipsoidal": {
+                {   // On the JDK7 branch, this is a switch on strings.
+                    if (type.equalsIgnoreCase("ellipsoidal")) {
                         switch (dimension) {
                             case 2: cs = csFactory.createEllipsoidalCS(properties, axes[0], axes[1]); break;
                             case 3: cs = csFactory.createEllipsoidalCS(properties, axes[0], axes[1], axes[2]); break;
                         }
-                        break;
                     }
-                    case "cartesian": {
+                    else if (type.equalsIgnoreCase("cartesian")) {
                         switch (dimension) {
                             case 2: cs = csFactory.createCartesianCS(properties, axes[0], axes[1]); break;
                             case 3: cs = csFactory.createCartesianCS(properties, axes[0], axes[1], axes[2]); break;
                         }
-                        break;
                     }
-                    case "spherical": {
+                    else if (type.equalsIgnoreCase("spherical")) {
                         switch (dimension) {
                             case 3: cs = csFactory.createSphericalCS(properties, axes[0], axes[1], axes[2]); break;
                         }
-                        break;
                     }
-                    case "vertical":
-                    case "gravity-related": {
+                    else if (type.equalsIgnoreCase("vertical") || type.equalsIgnoreCase("gravity-related")) {
                         switch (dimension) {
                             case 1: cs = csFactory.createVerticalCS(properties, axes[0]); break;
                         }
-                        break;
                     }
-                    case "time":            // Was used in older ISO-19111 versions.
-                    case "temporal": {
+                    else if (type.equalsIgnoreCase("time") || type.equalsIgnoreCase("temporal")) {
                         switch (dimension) {
                             case 1: cs = csFactory.createTimeCS(properties, axes[0]); break;
                         }
-                        break;
                     }
-                    case "linear": {
+                    else if (type.equalsIgnoreCase("linear")) {
                         switch (dimension) {
                             case 1: cs = csFactory.createLinearCS(properties, axes[0]); break;
                         }
-                        break;
                     }
-                    case "polar": {
+                    else if (type.equalsIgnoreCase("polar")) {
                         switch (dimension) {
                             case 2: cs = csFactory.createPolarCS(properties, axes[0], axes[1]); break;
                         }
-                        break;
                     }
-                    case "cylindrical": {
+                    else if (type.equalsIgnoreCase("cylindrical")) {
                         switch (dimension) {
                             case 3: cs = csFactory.createCylindricalCS(properties, axes[0], axes[1], axes[2]); break;
                         }
-                        break;
                     }
-                    case "affine": {
+                    else if (type.equalsIgnoreCase("affine")) {
                         switch (dimension) {
                             case 2: cs = csFactory.createAffineCS(properties, axes[0], axes[1]); break;
                             case 3: cs = csFactory.createAffineCS(properties, axes[0], axes[1], axes[2]); break;
                         }
-                        break;
                     }
-                    default: {
+                    else {
                         throw new FactoryDataException(error().getString(Errors.Keys.UnknownType_1, type));
                     }
                 }
@@ -1964,6 +2007,12 @@ addURIs:    for (int i=0; ; i++) {
             }
         } catch (SQLException exception) {
             throw databaseFailure(CoordinateSystem.class, code, exception);
+        } finally {
+            if (result != null) try {
+                result.close();
+            } catch (SQLException e) {
+                // Suppressed exception on the JDK7 branch.
+            }
         }
         if (returnValue == null) {
             throw noSuchAuthorityCode(CoordinateSystem.class, code);
@@ -1982,13 +2031,15 @@ addURIs:    for (int i=0; ; i++) {
     private Integer getDimensionForCS(final Integer cs) throws SQLException {
         Integer dimension = csDimensions.get(cs);
         if (dimension == null) {
-            try (ResultSet result = executeQuery("Dimension",
+            final ResultSet result = executeQuery("Dimension",
                     " SELECT COUNT(COORD_AXIS_CODE)" +
                      " FROM [Coordinate Axis]" +
-                     " WHERE COORD_SYS_CODE = ?", cs))
-            {
+                     " WHERE COORD_SYS_CODE = ?", cs);
+            try {
                 dimension = result.next() ? result.getInt(1) : 0;
                 csDimensions.put(cs, dimension);
+            } finally {
+                result.close();
             }
         }
         return (dimension != 0) ? dimension : null;
@@ -2011,12 +2062,12 @@ addURIs:    for (int i=0; ; i++) {
     {
         int i = 0;
         final CoordinateSystemAxis[] axes = new CoordinateSystemAxis[dimension];
-        try (ResultSet result = executeQuery("AxisOrder",
+        final ResultSet result = executeQuery("AxisOrder",
                 "SELECT COORD_AXIS_CODE" +
                 " FROM [Coordinate Axis]" +
                 " WHERE COORD_SYS_CODE = ?" +
-                " ORDER BY [ORDER]", cs))
-        {
+                " ORDER BY [ORDER]", cs);
+        try {
             while (result.next()) {
                 final String axis = getString(cs, result, 1);
                 if (i < axes.length) {
@@ -2028,6 +2079,8 @@ addURIs:    for (int i=0; ; i++) {
                 }
                 ++i;
             }
+        } finally {
+            result.close();
         }
         if (i != axes.length) {
             throw new FactoryDataException(error().getString(Errors.Keys.MismatchedDimension_2, axes.length, i));
@@ -2063,15 +2116,17 @@ addURIs:    for (int i=0; ; i++) {
     {
         ArgumentChecks.ensureNonNull("code", code);
         CoordinateSystemAxis returnValue = null;
-        try (ResultSet result = executeQuery("Coordinate Axis", "COORD_AXIS_CODE", null,
+        ResultSet result = null;
+        try {
+            result = executeQuery("Coordinate Axis", "COORD_AXIS_CODE", null,
                 "SELECT COORD_AXIS_CODE," +
                       " COORD_AXIS_NAME_CODE," +
                       " COORD_AXIS_ORIENTATION," +
                       " COORD_AXIS_ABBREVIATION," +
                       " UOM_CODE" +
                 " FROM [Coordinate Axis]" +
-               " WHERE COORD_AXIS_CODE = ?", code))
-        {
+               " WHERE COORD_AXIS_CODE = ?", code);
+
             while (result.next()) {
                 final Integer epsg         = getInteger(code, result, 1);
                 final Integer nameCode     = getInteger(code, result, 2);
@@ -2092,6 +2147,12 @@ addURIs:    for (int i=0; ; i++) {
             }
         } catch (SQLException exception) {
             throw databaseFailure(CoordinateSystemAxis.class, code, exception);
+        } finally {
+            if (result != null) try {
+                result.close();
+            } catch (SQLException e) {
+                // Suppressed exception on the JDK7 branch.
+            }
         }
         if (returnValue == null) {
             throw noSuchAuthorityCode(CoordinateSystemAxis.class, code);
@@ -2103,15 +2164,15 @@ addURIs:    for (int i=0; ; i++) {
      * Returns the name and description for the specified {@link CoordinateSystemAxis} code.
      * Many axes share the same name and description, so it is worth to cache them.
      */
-    private AxisName getAxisName(final Integer code) throws FactoryException {
+    private AxisName getAxisName(final Integer code) throws FactoryException, SQLException {
         assert Thread.holdsLock(this);
         AxisName returnValue = axisNames.get(code);
         if (returnValue == null) {
-            try (ResultSet result = executeQuery("Coordinate Axis Name",
+            final ResultSet result = executeQuery("Coordinate Axis Name",
                     "SELECT COORD_AXIS_NAME, DESCRIPTION, REMARKS" +
                     " FROM [Coordinate Axis Name]" +
-                    " WHERE COORD_AXIS_NAME_CODE = ?", code))
-            {
+                    " WHERE COORD_AXIS_NAME_CODE = ?", code);
+            try {
                 while (result.next()) {
                     final String name  = getString(code,   result, 1);
                     String description = getOptionalString(result, 2);
@@ -2119,13 +2180,13 @@ addURIs:    for (int i=0; ; i++) {
                     if (description == null) {
                         description = remarks;
                     } else if (remarks != null) {
-                        description += System.lineSeparator() + remarks;
+                        description += JDK7.lineSeparator() + remarks;
                     }
                     final AxisName axis = new AxisName(name, description);
                     returnValue = ensureSingleton(axis, returnValue, code);
                 }
-            } catch (SQLException exception) {
-                throw databaseFailure(AxisName.class, code, exception);
+            } finally {
+                result.close();
             }
             if (returnValue == null) {
                 throw noSuchAuthorityCode(AxisName.class, String.valueOf(code));
@@ -2163,15 +2224,17 @@ addURIs:    for (int i=0; ; i++) {
     public synchronized Unit<?> createUnit(final String code) throws NoSuchAuthorityCodeException, FactoryException {
         ArgumentChecks.ensureNonNull("code", code);
         Unit<?> returnValue = null;
-        try (ResultSet result = executeQuery("Unit of Measure", "UOM_CODE", "UNIT_OF_MEAS_NAME",
+        ResultSet result = null;
+        try {
+            result = executeQuery("Unit of Measure", "UOM_CODE", "UNIT_OF_MEAS_NAME",
                 "SELECT UOM_CODE," +
                       " FACTOR_B," +
                       " FACTOR_C," +
                       " TARGET_UOM_CODE," +
                       " UNIT_OF_MEAS_NAME" +
                 " FROM [Unit of Measure]" +
-                " WHERE UOM_CODE = ?", code))
-        {
+                " WHERE UOM_CODE = ?", code);
+
             while (result.next()) {
                 final int source = getInteger(code,  result, 1);
                 final double   b = getOptionalDouble(result, 2);
@@ -2203,6 +2266,12 @@ addURIs:    for (int i=0; ; i++) {
             }
         } catch (SQLException exception) {
             throw databaseFailure(Unit.class, code, exception);
+        } finally {
+            if (result != null) try {
+                result.close();
+            } catch (SQLException e) {
+                // Suppressed exception on the JDK7 branch.
+            }
         }
         if (returnValue == null) {
             throw noSuchAuthorityCode(Unit.class, code);
@@ -2238,14 +2307,16 @@ addURIs:    for (int i=0; ; i++) {
     {
         ArgumentChecks.ensureNonNull("code", code);
         ParameterDescriptor<?> returnValue = null;
-        try (ResultSet result = executeQuery("Coordinate_Operation Parameter", "PARAMETER_CODE", "PARAMETER_NAME",
+        ResultSet result = null;
+        try {
+            result = executeQuery("Coordinate_Operation Parameter", "PARAMETER_CODE", "PARAMETER_NAME",
                 "SELECT PARAMETER_CODE," +
                       " PARAMETER_NAME," +
                       " DESCRIPTION," +
                       " DEPRECATED" +
                 " FROM [Coordinate_Operation Parameter]" +
-                " WHERE PARAMETER_CODE = ?", code))
-        {
+                " WHERE PARAMETER_CODE = ?", code);
+
             while (result.next()) {
                 final Integer epsg       = getInteger  (code, result, 1);
                 final String  name       = getString   (code, result, 2);
@@ -2258,14 +2329,14 @@ addURIs:    for (int i=0; ; i++) {
                  * If the parameter appears to have at least one non-null value in the "Parameter File Name" column,
                  * then the type is assumed to be URI as a string. Otherwise, the type is a floating point number.
                  */
-                try (ResultSet resultUnits = executeQuery("ParameterUnit",
+                final ResultSet resultUnits = executeQuery("ParameterUnit",
                         "SELECT MIN(UOM_CODE) AS UOM," +
                               " MIN(PARAM_VALUE_FILE_REF) AS PARAM_FILE" +
                             " FROM [Coordinate_Operation Parameter Value]" +
                         " WHERE (PARAMETER_CODE = ?)" +
                         " GROUP BY UOM_CODE" +
-                        " ORDER BY COUNT(UOM_CODE) DESC", epsg))
-                {
+                        " ORDER BY COUNT(UOM_CODE) DESC", epsg);
+                try {
                     if (resultUnits.next()) {
                         String element = getOptionalString(resultUnits, 2);
                         type = (element != null) ? String.class : Double.class;
@@ -2278,17 +2349,26 @@ addURIs:    for (int i=0; ; i++) {
                     } else {
                         type = Double.class;
                     }
+                } finally {
+                    resultUnits.close();
                 }
                 /*
                  * Now creates the parameter descriptor.
                  */
-                final ParameterDescriptor<?> descriptor = new DefaultParameterDescriptor<>(
+                @SuppressWarnings({"unchecked", "rawtypes"})
+                final ParameterDescriptor<?> descriptor = new DefaultParameterDescriptor(
                         createProperties("Coordinate_Operation Parameter", name, epsg, remarks, deprecated),
                         1, 1, type, valueDomain, null, null);
                 returnValue = ensureSingleton(descriptor, returnValue, code);
             }
         } catch (SQLException exception) {
             throw databaseFailure(OperationMethod.class, code, exception);
+        } finally {
+            if (result != null) try {
+                result.close();
+            } catch (SQLException e) {
+                // Suppressed exception on the JDK7 branch.
+            }
         }
         if (returnValue == null) {
              throw noSuchAuthorityCode(OperationMethod.class, code);
@@ -2304,16 +2384,18 @@ addURIs:    for (int i=0; ; i++) {
      * @throws SQLException if a SQL statement failed.
      */
     private ParameterDescriptor<?>[] createParameterDescriptors(final Integer method) throws FactoryException, SQLException {
-        final List<ParameterDescriptor<?>> descriptors = new ArrayList<>();
-        try (ResultSet result = executeQuery("Coordinate_Operation Parameter Usage",
+        final List<ParameterDescriptor<?>> descriptors = new ArrayList<ParameterDescriptor<?>>();
+        final ResultSet result = executeQuery("Coordinate_Operation Parameter Usage",
                 "SELECT PARAMETER_CODE" +
                 " FROM [Coordinate_Operation Parameter Usage]" +
                 " WHERE COORD_OP_METHOD_CODE = ?" +
-                " ORDER BY SORT_ORDER", method))
-        {
+                " ORDER BY SORT_ORDER", method);
+        try {
             while (result.next()) {
                 descriptors.add(parent.createParameterDescriptor(getString(method, result, 1)));
             }
+        } finally {
+            result.close();
         }
         return descriptors.toArray(new ParameterDescriptor<?>[descriptors.size()]);
     }
@@ -2329,7 +2411,7 @@ addURIs:    for (int i=0; ; i++) {
     private void fillParameterValues(final Integer method, final Integer operation, final ParameterValueGroup parameters)
             throws FactoryException, SQLException
     {
-        try (ResultSet result = executeQuery("Coordinate_Operation Parameter Value",
+        final ResultSet result = executeQuery("Coordinate_Operation Parameter Value",
                 "SELECT CP.PARAMETER_NAME," +
                       " CV.PARAMETER_VALUE," +
                       " CV.PARAM_VALUE_FILE_REF," +
@@ -2342,8 +2424,8 @@ addURIs:    for (int i=0; ; i++) {
                  " AND (CV.COORD_OP_METHOD_CODE = CU.COORD_OP_METHOD_CODE)" +
                 " WHERE CV.COORD_OP_METHOD_CODE = ?" +
                   " AND CV.COORD_OP_CODE = ?" +
-             " ORDER BY CU.SORT_ORDER", method, operation))
-        {
+             " ORDER BY CU.SORT_ORDER", method, operation);
+        try {
             while (result.next()) {
                 final String name  = getString(operation, result, 1);
                 final double value = getOptionalDouble(result, 2);
@@ -2392,6 +2474,8 @@ addURIs:    for (int i=0; ; i++) {
                     throw new FactoryDataException(error().getString(Errors.Keys.CanNotSetParameterValue_1, name), exception);
                 }
             }
+        } finally {
+            result.close();
         }
     }
 
@@ -2422,14 +2506,16 @@ addURIs:    for (int i=0; ; i++) {
     {
         ArgumentChecks.ensureNonNull("code", code);
         OperationMethod returnValue = null;
-        try (ResultSet result = executeQuery("Coordinate_Operation Method", "COORD_OP_METHOD_CODE", "COORD_OP_METHOD_NAME",
+        ResultSet result = null;
+        try {
+            result = executeQuery("Coordinate_Operation Method", "COORD_OP_METHOD_CODE", "COORD_OP_METHOD_NAME",
                 "SELECT COORD_OP_METHOD_CODE," +
                       " COORD_OP_METHOD_NAME," +
                       " REMARKS," +
                       " DEPRECATED" +
                  " FROM [Coordinate_Operation Method]" +
-                " WHERE COORD_OP_METHOD_CODE = ?", code))
-        {
+                " WHERE COORD_OP_METHOD_CODE = ?", code);
+
             while (result.next()) {
                 final Integer epsg       = getInteger  (code, result, 1);
                 final String  name       = getString   (code, result, 2);
@@ -2445,6 +2531,12 @@ addURIs:    for (int i=0; ; i++) {
             }
         } catch (SQLException exception) {
             throw databaseFailure(OperationMethod.class, code, exception);
+        } finally {
+            if (result != null) try {
+                result.close();
+            } catch (SQLException e) {
+                // Suppressed exception on the JDK7 branch.
+            }
         }
         if (returnValue == null) {
              throw noSuchAuthorityCode(OperationMethod.class, code);
@@ -2480,7 +2572,7 @@ addURIs:    for (int i=0; ; i++) {
         ArgumentChecks.ensureNonNull("code", code);
         CoordinateOperation returnValue = null;
         try {
-            try (ResultSet result = executeQuery("Coordinate_Operation", "COORD_OP_CODE", "COORD_OP_NAME",
+            final ResultSet result = executeQuery("Coordinate_Operation", "COORD_OP_CODE", "COORD_OP_NAME",
                     "SELECT COORD_OP_CODE," +
                           " COORD_OP_NAME," +
                           " COORD_OP_TYPE," +
@@ -2494,8 +2586,9 @@ addURIs:    for (int i=0; ; i++) {
                           " REMARKS," +
                           " DEPRECATED" +
                     " FROM [Coordinate_Operation]" +
-                    " WHERE COORD_OP_CODE = ?", code))
-            {
+                    " WHERE COORD_OP_CODE = ?", code);
+
+            try {
                 while (result.next()) {
                     final Integer epsg = getInteger(code, result, 1);
                     final String  name = getString (code, result, 2);
@@ -2596,17 +2689,19 @@ addURIs:    for (int i=0; ; i++) {
                          * we are going to invoke this method recursively in the following lines.
                          */
                         result.close();
-                        opProperties = new HashMap<>(opProperties);     // Because this class uses a shared map.
-                        final List<String> codes = new ArrayList<>();
-                        try (ResultSet cr = executeQuery("Coordinate_Operation Path",
+                        opProperties = new HashMap<String,Object>(opProperties);     // Because this class uses a shared map.
+                        final List<String> codes = new ArrayList<String>();
+                        final ResultSet cr = executeQuery("Coordinate_Operation Path",
                                 "SELECT SINGLE_OPERATION_CODE" +
                                  " FROM [Coordinate_Operation Path]" +
                                 " WHERE (CONCAT_OPERATION_CODE = ?)" +
-                                " ORDER BY OP_PATH_STEP", epsg))
-                        {
+                                " ORDER BY OP_PATH_STEP", epsg);
+                        try {
                             while (cr.next()) {
                                 codes.add(getString(code, cr, 1));
                             }
+                        } finally {
+                            cr.close();
                         }
                         final CoordinateOperation[] operations = new CoordinateOperation[codes.size()];
                         ensureNoCycle(CoordinateOperation.class, epsg);
@@ -2677,6 +2772,8 @@ addURIs:    for (int i=0; ; i++) {
                         return returnValue;
                     }
                 }
+            } finally {
+                result.close();
             }
         } catch (SQLException exception) {
             throw databaseFailure(CoordinateOperation.class, code, exception);
@@ -2737,10 +2834,13 @@ addURIs:    for (int i=0; ; i++) {
                             " AND COORD_REF_SYS_CODE = ?";
                 }
                 final Integer targetKey = searchTransformations ? null : pair[1];
-                try (ResultSet result = executeQuery(key, sql, pair)) {
+                final ResultSet result = executeQuery(key, sql, pair);
+                try {
                     while (result.next()) {
                         set.addAuthorityCode(getString(label, result, 1), targetKey);
                     }
+                } finally {
+                    result.close();
                 }
             } while ((searchTransformations = !searchTransformations) == true);
             /*
@@ -2852,7 +2952,7 @@ addURIs:    for (int i=0; ; i++) {
                 } finally {
                     setIgnoringAxes(previous);
                 }
-                codes = new LinkedHashSet<>(Containers.hashMapCapacity(find.size()));
+                codes = new LinkedHashSet<Number>(Containers.hashMapCapacity(find.size()));
                 for (final IdentifiedObject dep : find) {
                     Identifier id = IdentifiedObjects.getIdentifier(dep, Citations.EPSG);
                     if (id != null) try {           // Should never be null, but let be safe.
@@ -2897,9 +2997,10 @@ addURIs:    for (int i=0; ; i++) {
              * - A floating point number, in which case the search will be performed
              *   with a tolerance threshold of 1 cm for a planet of the size of Earth.
              */
-            final Set<String> result = new LinkedHashSet<>();       // We need to preserve order in this set.
+            final Set<String> result = new LinkedHashSet<String>();       // We need to preserve order in this set.
             try {
-                try (PreparedStatement s = connection.prepareStatement(translator.apply(buffer.toString()))) {
+                final PreparedStatement s = connection.prepareStatement(translator.apply(buffer.toString()));
+                try {
                     for (final Number code : codes) {
                         if (isFloat) {
                             final double value = code.doubleValue();
@@ -2910,12 +3011,17 @@ addURIs:    for (int i=0; ; i++) {
                         } else {
                             s.setInt(1, code.intValue());
                         }
-                        try (ResultSet r = s.executeQuery()) {
+                        final ResultSet r = s.executeQuery();
+                        try {
                             while (r.next()) {
                                 result.add(r.getString(1));
                             }
+                        } finally {
+                            r.close();
                         }
                     }
+                } finally {
+                    s.close();
                 }
                 result.remove(null);    // Should not have null element, but let be safe.
                 /*
@@ -2946,13 +3052,15 @@ addURIs:    for (int i=0; ; i++) {
     final boolean isProjection(final Integer code) throws SQLException {
         Boolean projection = isProjection.get(code);
         if (projection == null) {
-            try (ResultSet result = executeQuery("isProjection",
+            final ResultSet result = executeQuery("isProjection",
                     "SELECT COORD_REF_SYS_CODE" +
                     " FROM [Coordinate Reference System]" +
                     " WHERE PROJECTION_CONV_CODE = ?" +
-                      " AND COORD_REF_SYS_KIND LIKE 'projected%'", code))
-            {
+                      " AND COORD_REF_SYS_KIND LIKE 'projected%'", code);
+            try {
                 projection = result.next();
+            } finally {
+                result.close();
             }
             isProjection.put(code, projection);
         }
@@ -3003,7 +3111,8 @@ addURIs:    for (int i=0; ; i++) {
                 " INNER JOIN [Coordinate_Operation] AS CO ON TGT.PROJECTION_CONV_CODE = CO.COORD_OP_CODE" +
                       " WHERE CO.DEPRECATED = 0 AND COORD_OP_METHOD_CODE = ?";
             }
-            try (ResultSet result = executeQuery(key, sql, method)) {
+            final ResultSet result = executeQuery(key, sql, method);
+            try {
                 while (result.next()) {
                     for (int i=0; i<dimensions.length; i++) {
                         if (!differents[i]) {   // Not worth to test heterogenous dimensions.
@@ -3023,6 +3132,8 @@ addURIs:    for (int i=0; ; i++) {
                         }
                     }
                 }
+            } finally {
+                result.close();
             }
         } while ((projections = !projections) == true);
         return dimensions;
@@ -3046,12 +3157,12 @@ addURIs:    for (int i=0; ; i++) {
             boolean changed = false;
             for (int i=0; i<codes.length; i++) {
                 final String code = codes[i].toString();
-                try (ResultSet result = executeQuery("Supersession", null, null,
+                final ResultSet result = executeQuery("Supersession", null, null,
                         "SELECT OBJECT_TABLE_NAME, SUPERSEDED_BY" +
                         " FROM [Supersession]" +
                         " WHERE OBJECT_CODE = ?" +
-                        " ORDER BY SUPERSESSION_YEAR DESC", code))
-                {
+                        " ORDER BY SUPERSESSION_YEAR DESC", code);
+                try {
                     while (result.next()) {
                         if (tableMatches(table, result.getString(1))) {
                             final String replacement = result.getString(2);
@@ -3070,6 +3181,8 @@ addURIs:    for (int i=0; ; i++) {
                             }
                         }
                     }
+                } finally {
+                    result.close();
                 }
             }
             if (!changed) {
@@ -3152,7 +3265,6 @@ addURIs:    for (int i=0; ; i++) {
      *
      * @see #connection
      */
-    @Override
     public synchronized void close() throws FactoryException {
         SQLException exception = null;
         final Iterator<PreparedStatement> ip = statements.values().iterator();
@@ -3163,7 +3275,7 @@ addURIs:    for (int i=0; ; i++) {
                 if (exception == null) {
                     exception = e;
                 } else {
-                    exception.addSuppressed(e);
+                    // exception.addSuppressed(e) on the JDK7 branch.
                 }
             }
             ip.remove();
@@ -3176,7 +3288,7 @@ addURIs:    for (int i=0; ; i++) {
                 if (exception == null) {
                     exception = e;
                 } else {
-                    exception.addSuppressed(e);
+                    // exception.addSuppressed(e) on the JDK7 branch.
                 }
             }
             it.remove();
@@ -3187,7 +3299,7 @@ addURIs:    for (int i=0; ; i++) {
             if (exception == null) {
                 exception = e;
             } else {
-                e.addSuppressed(exception);     // Keep the connection thrown be Connection as the main one to report.
+                // e.addSuppressed(exception) on the JDK7 branch.
             }
         }
         if (exception != null) {

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java?rev=1724528&r1=1724479&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -167,7 +167,7 @@ public class EPSGFactory extends Concurr
         this.copFactory   = factory(CoordinateOperationFactory.class, copFactory);
         this.mtFactory    = factory(MathTransformFactory.class, mtFactory);
         this.translator   = translator;
-        this.locale       = Locale.getDefault(Locale.Category.DISPLAY);
+        this.locale       = Locale.getDefault();
     }
 
     /**
@@ -235,7 +235,7 @@ public class EPSGFactory extends Concurr
             if (connection != null) try {
                 connection.close();
             } catch (SQLException e2) {
-                e.addSuppressed(e2);
+                // e.addSuppressed(e2) on the JDK7 branch.
             }
             throw new UnavailableFactoryException(e.getLocalizedMessage(), e);
         }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java?rev=1724528&r1=1724479&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/SQLTranslator.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -185,15 +185,18 @@ public class SQLTranslator {
              * This column has been renamed "coord_axis_order" in DLL scripts.
              * We need to check which name our current database uses.
              */
-            try (ResultSet result = md.getColumns(null, schema, "Coordinate Axis", "ORDER")) {
+            final ResultSet result = md.getColumns(null, schema, "Coordinate Axis", "ORDER");
+            try {
                 if (result.next()) {
                     accessToAnsi = Collections.emptyMap();
                 } else {
                     accessToAnsi = Collections.singletonMap("ORDER", "coord_axis_order");
                 }
+            } finally {
+                result.close();
             }
         } else {
-            accessToAnsi = new HashMap<>(4);
+            accessToAnsi = new HashMap<String,String>(4);
             accessToAnsi.put("ORDER",                "coord_axis_order");     // A column, not a table.
             accessToAnsi.put("Coordinate_Operation", "coordoperation");
             accessToAnsi.put("Parameter",            "param");
@@ -210,7 +213,8 @@ public class SQLTranslator {
             if (toUpperCase && i != MIXED_CASE) {
                 table = table.toUpperCase(Locale.US);
             }
-            try (ResultSet result = md.getTables(null, null, table, null)) {
+            final ResultSet result = md.getTables(null, null, table, null);
+            try {
                 if (result.next()) {
                     quoteTableNames = (i == MIXED_CASE);
                     /*
@@ -223,6 +227,8 @@ public class SQLTranslator {
                     } while (!Constants.EPSG.equalsIgnoreCase(schema) && result.next());
                     return schema;
                 }
+            } finally {
+                result.close();
             }
         }
         throw new SQLDataException(Errors.format(Errors.Keys.TableNotFound_1, SENTINEL[MIXED_CASE]));

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -44,8 +44,11 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.collection.Containers;
 import org.apache.sis.util.UnsupportedImplementationException;
+import org.apache.sis.util.logging.Logging;
 import org.apache.sis.parameter.Parameterized;
+import org.apache.sis.referencing.cs.CoordinateSystems;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
+import org.apache.sis.referencing.operation.transform.MathTransforms;
 import org.apache.sis.referencing.operation.transform.PassThroughTransform;
 import org.apache.sis.internal.referencing.PositionalAccuracyConstant;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
@@ -54,6 +57,7 @@ import org.apache.sis.internal.metadata.
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.internal.system.Semaphores;
+import org.apache.sis.internal.system.Loggers;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 
@@ -718,7 +722,7 @@ check:      for (int isTarget=0; ; isTar
      * @return {@code true} if both objects are equal for the given comparison mode.
      */
     @Override
-    public boolean equals(final Object object, final ComparisonMode mode) {
+    public boolean equals(final Object object, ComparisonMode mode) {
         if (super.equals(object, mode)) {
             if (mode == ComparisonMode.STRICT) {
                 final AbstractCoordinateOperation that = (AbstractCoordinateOperation) object;
@@ -730,34 +734,76 @@ check:      for (int isTarget=0; ; isTar
                     Objects.equals(coordinateOperationAccuracy, that.coordinateOperationAccuracy))
                 {
                     // Check against never-ending recursivity with DerivedCRS.
-                    if (Semaphores.queryAndSet(Semaphores.COMPARING)) {
+                    if (Semaphores.queryAndSet(Semaphores.CONVERSION_AND_CRS)) {
                         return true;
                     } else try {
                         return Objects.equals(targetCRS, that.targetCRS);
                     } finally {
-                        Semaphores.clear(Semaphores.COMPARING);
+                        Semaphores.clear(Semaphores.CONVERSION_AND_CRS);
                     }
                 }
             } else {
+                /*
+                 * This block is for all ComparisonModes other than STRICT. At this point we know that the metadata
+                 * properties (class, name, identifiers, etc.) match the criterion of the given comparison mode.
+                 * Before to continue perform the following checks:
+                 *
+                 *   - Scope, domain and accuracy properties only if NOT in "ignore metadata" mode.
+                 *   - Interpolation CRS in all cases (regardless if ignoring metadata or not).
+                 */
                 final CoordinateOperation that = (CoordinateOperation) object;
-                if (mode == ComparisonMode.BY_CONTRACT) {
-                    if (!deepEquals(getScope(),                       that.getScope(), mode) ||
-                        !deepEquals(getDomainOfValidity(),            that.getDomainOfValidity(), mode) ||
-                        !deepEquals(getCoordinateOperationAccuracy(), that.getCoordinateOperationAccuracy(), mode))
-                    {
-                        return false;
-                    }
-                }
-                if (deepEquals(getMathTransform(),    that.getMathTransform(),   mode) &&
-                    deepEquals(getSourceCRS(),        that.getSourceCRS(),       mode) &&
-                    deepEquals(getInterpolationCRS(), getInterpolationCRS(that), mode))
+                if ((mode.isIgnoringMetadata() ||
+                    (deepEquals(getScope(),                       that.getScope(), mode) &&
+                     deepEquals(getDomainOfValidity(),            that.getDomainOfValidity(), mode) &&
+                     deepEquals(getCoordinateOperationAccuracy(), that.getCoordinateOperationAccuracy(), mode))) &&
+                     deepEquals(getInterpolationCRS(),            getInterpolationCRS(that), mode))
                 {
-                    if (Semaphores.queryAndSet(Semaphores.COMPARING)) {
-                        return true;
+                    /*
+                     * At this point all metdata match or can be ignored. First, compare the targetCRS.
+                     * We need to perform this comparison only if this 'equals(…)' method is not invoked
+                     * from AbstractDerivedCRS, otherwise we would fall in an infinite recursive loop
+                     * (because targetCRS is the DerivedCRS, which in turn wants to compare this operation).
+                     *
+                     * We also opportunistically use this "anti-recursivity" check for another purpose.
+                     * The Semaphores.COMPARING flag should be set only when AbstractDerivedCRS is comparing
+                     * its "from base" conversion. The flag should never be set in any other circumstance,
+                     * since this is an internal Apache SIS mechanism. If we know that we are comparing the
+                     * AbstractDerivedCRS.fromBase conversion, then (in the way Apache SIS is implemented)
+                     * this.sourceCRS == AbstractDerivedCRS.baseCRS. Consequently we can relax the check
+                     * sourceCRS axis order if the mode is ComparisonMode.IGNORE_METADATA.
+                     */
+                    if (Semaphores.queryAndSet(Semaphores.CONVERSION_AND_CRS)) {
+                        if (mode.isIgnoringMetadata()) {
+                            mode = ComparisonMode.ALLOW_VARIANT;
+                        }
                     } else try {
-                        return deepEquals(getTargetCRS(), that.getTargetCRS(), mode);
+                        if (!deepEquals(getTargetCRS(), that.getTargetCRS(), mode)) {
+                            return false;
+                        }
                     } finally {
-                        Semaphores.clear(Semaphores.COMPARING);
+                        Semaphores.clear(Semaphores.CONVERSION_AND_CRS);
+                    }
+                    /*
+                     * Now compare the sourceCRS, potentially with a relaxed ComparisonMode (see above comment).
+                     * If the comparison mode allows the two CRS to have different axis order and units, then we
+                     * need to take in account those difference before to compare the MathTransform. We proceed
+                     * by modifying 'tr2' as if it was a MathTransform with crs1 as the source instead of crs2.
+                     */
+                    final CoordinateReferenceSystem crs1 = this.getSourceCRS();
+                    final CoordinateReferenceSystem crs2 = that.getSourceCRS();
+                    if (deepEquals(crs1, crs2, mode)) {
+                        MathTransform tr1 = this.getMathTransform();
+                        MathTransform tr2 = that.getMathTransform();
+                        if (mode == ComparisonMode.ALLOW_VARIANT) try {
+                            final MathTransform swap = MathTransforms.linear(
+                                    CoordinateSystems.swapAndScaleAxes(crs1.getCoordinateSystem(),
+                                                                       crs2.getCoordinateSystem()));
+                            tr2 = MathTransforms.concatenate(swap, tr2);
+                        } catch (Exception e) {    // (ConversionException | RuntimeException) on the JDK7 branch.
+                            Logging.recoverableException(Logging.getLogger(Loggers.COORDINATE_OPERATION),
+                                    AbstractCoordinateOperation.class, "equals", e);
+                        }
+                        return deepEquals(tr1, tr2, mode);
                     }
                 }
             }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -93,7 +93,7 @@ class AbstractSingleOperation extends Ab
      * The operation method.
      *
      * <p><b>Consider this field as final!</b>
-     * This field is modified only at unmarshalling time by {@link #setMethod(OperationMethod)}</p>
+     * This field is modified only at unmarshalling time by {@link #setMethod(OperationMethod)}.</p>
      *
      * @see #getMethod()
      */
@@ -104,7 +104,7 @@ class AbstractSingleOperation extends Ab
      *
      * <p><b>Consider this field as final!</b>
      * This field is non-final only for the convenience of constructors and for initialization
-     * at XML unmarshalling time by {@link #setParameters(GeneralParameterValue[])}</p>
+     * at XML unmarshalling time by {@link #setParameters(GeneralParameterValue[])}.</p>
      */
     ParameterValueGroup parameters;
 
@@ -128,8 +128,7 @@ class AbstractSingleOperation extends Ab
          * However there is a few cases, for example the Molodenski transform, where we can not infer the
          * parameters easily because the operation is implemented by a concatenation of math transforms.
          */
-        parameters = Containers.property(properties, ReferencingServices.PARAMETERS_KEY, ParameterValueGroup.class);
-        // No clone since this is a SIS internal property and SIS does not modify those values after construction.
+        parameters = Parameters.unmodifiable(Containers.property(properties, ReferencingServices.PARAMETERS_KEY, ParameterValueGroup.class));
     }
 
     /**
@@ -164,7 +163,7 @@ class AbstractSingleOperation extends Ab
     protected AbstractSingleOperation(final SingleOperation operation) {
         super(operation);
         method = operation.getMethod();
-        parameters = getParameterValues(operation);
+        parameters = Parameters.unmodifiable(operation.getParameterValues());
     }
 
     /**
@@ -314,9 +313,8 @@ class AbstractSingleOperation extends Ab
      * Returns the parameter values. The default implementation performs the following choice:
      *
      * <ul>
-     *   <li>If parameter values were specified explicitely at construction time, then a
-     *       {@linkplain org.apache.sis.parameter.DefaultParameterValueGroup#clone() clone}
-     *       of those parameters is returned.</li>
+     *   <li>If parameter values were specified explicitely at construction time, then they are returned as an
+     *       {@linkplain Parameters#unmodifiable(ParameterValueGroup) unmodifiable parameter group}.</li>
      *   <li>Otherwise if this method can infer the parameter values from the
      *       {@linkplain #getMathTransform() math transform}, then those parameters are returned.</li>
      *   <li>Otherwise throw {@link org.apache.sis.util.UnsupportedImplementationException}.</li>
@@ -330,18 +328,7 @@ class AbstractSingleOperation extends Ab
      */
     @Override
     public ParameterValueGroup getParameterValues() {
-        return (parameters != null) ? parameters.clone() : super.getParameterValues();
-    }
-
-    /**
-     * Gets the parameter values of the given operation without computing and without cloning them (if possible).
-     * If the parameters are automatically inferred from the math transform, do not compute them and instead return
-     * {@code null} (in conformance with {@link #parameters} contract).
-     */
-    private static ParameterValueGroup getParameterValues(final SingleOperation operation) {
-        return (operation instanceof AbstractSingleOperation)
-               ? ((AbstractSingleOperation) operation).parameters   // Null if inferred from MathTransform
-               : operation.getParameterValues();
+        return (parameters != null) ? parameters : super.getParameterValues();
     }
 
     /**
@@ -508,6 +495,7 @@ class AbstractSingleOperation extends Ab
              */
             parameters = new DefaultParameterValueGroup(method.getParameters());
             CC_OperationMethod.store(values, parameters.values(), replacements);
+            parameters = Parameters.unmodifiable(parameters);
         } else {
             ReferencingUtilities.propertyAlreadySet(AbstractSingleOperation.class, "setParameters", "parameterValue");
         }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java?rev=1724528&r1=1724527&r2=1724528&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java [UTF-8] Wed Jan 13 23:25:38 2016
@@ -74,13 +74,15 @@ final class DefaultConicProjection exten
      * @param sourceCRS  The source CRS.
      * @param targetCRS  The target CRS.
      * @param factory    The factory to use for creating a transform from the parameters or for performing axis changes.
+     * @param actual     An array of length 1 where to store the actual operation method used by the math transform factory.
      */
     DefaultConicProjection(final Conversion definition,
                            final CoordinateReferenceSystem sourceCRS,
                            final CoordinateReferenceSystem targetCRS,
-                           final MathTransformFactory factory) throws FactoryException
+                           final MathTransformFactory factory,
+                           final OperationMethod[] actual) throws FactoryException
     {
-        super(definition, sourceCRS, targetCRS, factory);
+        super(definition, sourceCRS, targetCRS, factory, actual);
     }
 
     /**



Mime
View raw message