sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1727561 [3/5] - in /sis/branches/JDK6: ./ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/sql/ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/s...
Date Fri, 29 Jan 2016 12:23:11 GMT
Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -20,7 +20,9 @@ import java.util.Map;
 import java.util.Set;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.Collections;
+import java.util.Arrays;
 import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
 import javax.measure.unit.Unit;
@@ -46,6 +48,7 @@ import org.opengis.referencing.datum.Eng
 import org.apache.sis.internal.referencing.GeodeticObjectBuilder;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.measure.Units;
 import org.apache.sis.referencing.CommonCRS;
@@ -54,6 +57,7 @@ import org.apache.sis.referencing.cs.Coo
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.iso.DefaultNameSpace;
 import org.apache.sis.util.iso.SimpleInternationalString;
@@ -201,6 +205,14 @@ public class CommonAuthorityFactory exte
     private static final String AUTO2 = "AUTO2";
 
     /**
+     * The namespaces of codes defined by OGC.
+     *
+     * @see #getCodeSpaces()
+     */
+    private static final Set<String> CODESPACES = Collections.unmodifiableSet(
+            new LinkedHashSet<String>(Arrays.asList(Constants.OGC, Constants.CRS, "AUTO", AUTO2)));
+
+    /**
      * The bit for saying that a namespace is the legacy {@code "AUTO"} namespace.
      */
     private static final int LEGACY_MASK = 0x80000000;
@@ -227,7 +239,7 @@ public class CommonAuthorityFactory exte
     /**
      * The parameter separator for codes in the {@code "AUTO(2)"} namespace.
      */
-    private static final char SEPARATOR = ',';
+    static final char SEPARATOR = ',';
 
     /**
      * The codes known to this factory, associated with their CRS type. This is set to an empty map
@@ -255,23 +267,35 @@ public class CommonAuthorityFactory exte
     }
 
     /**
-     * Returns the organization responsible for definition of the CRS codes recognized by this factory.
-     * The authority for this factory is the <cite>Open Geospatial Consortium</cite>.
+     * Returns the specification that defines the codes recognized by this factory. The definitive source for this
+     * factory is OGC <a href="http://www.opengeospatial.org/standards/wms">Web Map Service</a> (WMS) specification,
+     * also available as the ISO 19128 <cite>Geographic Information — Web map server interface</cite> standard.
+     *
+     * <p>While the authority is WMS, the {@linkplain org.apache.sis.xml.IdentifierSpace#getName() namespace}
+     * of that authority is set to {@code "OGC"}. Apache SIS does that for consistency with the namespace used
+     * in URNs (for example {@code "urn:ogc:def:crs:OGC:1.3:CRS84"}).</p>
      *
-     * @return The OGC authority.
+     * @return The <cite>"Web Map Service"</cite> authority.
      *
-     * @see Citations#OGC
+     * @see #getCodeSpaces()
+     * @see Citations#WMS
      */
     @Override
     public Citation getAuthority() {
-        return Citations.OGC;
+        return Citations.WMS;
     }
 
     /**
-     * Returns {@code true} if the given portion of the code is equal, ignoring case, to the given namespace.
+     * Rewrites the given code in a canonical format.
+     * If the code can not be reformatted, then this method returns {@code null}.
      */
-    private static boolean regionMatches(final String namespace, final String code, final int start, final int end) {
-        return (namespace.length() == end - start) && code.regionMatches(true, start, namespace, 0, namespace.length());
+    static String reformat(final String code) {
+        try {
+            return format(Integer.parseInt(code.substring(skipNamespace(code) & ~LEGACY_MASK)));
+        } catch (Exception e) {  // (NoSuchAuthorityCodeException | NumberFormatException) on the JDK7 branch.
+            Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY), CommonAuthorityFactory.class, "reformat", e);
+            return null;
+        }
     }
 
     /**
@@ -311,7 +335,7 @@ public class CommonAuthorityFactory exte
                 }
                 if (!isRecognized) {
                     throw new NoSuchAuthorityCodeException(Errors.format(Errors.Keys.UnknownAuthority_1,
-                            CharSequences.trimWhitespaces(code.substring(0, s))), Constants.OGC, code);
+                            CharSequences.trimWhitespaces(code, 0, s)), Constants.OGC, code);
                 }
             }
         }
@@ -343,8 +367,7 @@ public class CommonAuthorityFactory exte
     @Override
     public Set<String> getAuthorityCodes(final Class<? extends IdentifiedObject> type) throws FactoryException {
         ArgumentChecks.ensureNonNull("type", type);
-        final boolean all = type.isAssignableFrom(SingleCRS.class);
-        if (!all && !SingleCRS.class.isAssignableFrom(type)) {
+        if (!type.isAssignableFrom(SingleCRS.class) && !SingleCRS.class.isAssignableFrom(type)) {
             return Collections.emptySet();
         }
         synchronized (codes) {
@@ -359,20 +382,49 @@ public class CommonAuthorityFactory exte
                 }
             }
         }
-        return all ? Collections.unmodifiableSet(codes.keySet()) : new FilteredCodes(codes, type).keySet();
+        return new FilteredCodes(codes, type).keySet();
+    }
+
+    /**
+     * Formats the given code with a {@code "CRS:"} or {@code "AUTO2:"} prefix.
+     */
+    private static String format(final int code) {
+        return ((code >= FIRST_PROJECTION_CODE) ? AUTO2 : Constants.CRS) + DefaultNameSpace.DEFAULT_SEPARATOR + code;
     }
 
     /**
      * Adds an element in the {@link #codes} map, witch check against duplicated values.
      */
     private void add(final int code, final Class<? extends SingleCRS> type) throws FactoryException {
-        final String namespace = (code >= FIRST_PROJECTION_CODE) ? AUTO2 : Constants.CRS;
-        if (codes.put(namespace + DefaultNameSpace.DEFAULT_SEPARATOR + code, type) != null) {
+        assert (code >= FIRST_PROJECTION_CODE) == (ProjectedCRS.class.isAssignableFrom(type)) : code;
+        if (codes.put(format(code), type) != null) {
             throw new FactoryException();    // Should never happen, but we are paranoiac.
         }
     }
 
     /**
+     * Returns the namespaces defined by the OGC specifications implemented by this factory.
+     * At the difference of other factories, the namespaces of {@code CommonAuthorityFactory}
+     * are quite different than the {@linkplain #getAuthority() authority} title or identifier:
+     *
+     * <ul>
+     *   <li><b>Authority:</b> {@code "WMS"} (for <cite>"Web Map Services"</cite>)</li>
+     *   <li><b>Namespaces:</b> {@code "CRS"}, {@code "AUTO"}, {@code "AUTO2"}.
+     *       The {@code "OGC"} namespace is also accepted for compatibility reason,
+     *       but its scope is wider than the above-cited namespaces.</li>
+     * </ul>
+     *
+     * @return A set containing at least the {@code "CRS"}, {@code "AUTO"} and {@code "AUTO2"} strings.
+     *
+     * @see #getAuthority()
+     * @see Citations#WMS
+     */
+    @Override
+    public Set<String> getCodeSpaces() {
+        return CODESPACES;
+    }
+
+    /**
      * Returns a description of the object corresponding to a code.
      * The description can be used for example in a combo box in a graphical user interface.
      *

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -221,13 +221,15 @@ public abstract class ConcurrentAuthorit
     /**
      * {@code true} if the call to {@link #closeExpired()} is scheduled for future execution in the background
      * cleaner thread. A value of {@code true} implies that this factory contains at least one active data access.
-     * However the reciprocal is not true: this field may be set to {@code false} while a worker factory is currently
-     * in use because this field is set to {@code true} only when a worker factory is {@linkplain #release() released}.
+     * However the reciprocal is not true: this field may be set to {@code false} while a DAO is currently in use
+     * because this field is set to {@code true} only when a worker factory is {@linkplain #release released}.
      *
      * <p>Note that we can not use {@code !availableDAOs.isEmpty()} as a replacement of {@code isCleanScheduled}
      * because the queue is empty if all Data Access Objects are currently in use.</p>
      *
      * <p>Every access to this field must be performed in a block synchronized on {@link #availableDAOs}.</p>
+     *
+     * @see #isCleanScheduled()
      */
     private boolean isCleanScheduled;
 
@@ -313,6 +315,8 @@ public abstract class ConcurrentAuthorit
     /**
      * Returns the number of Data Access Objects available for reuse. This count does not include the
      * Data Access Objects that are currently in use. This method is used only for testing purpose.
+     *
+     * @see #isCleanScheduled()
      */
     @Debug
     final int countAvailableDataAccess() {
@@ -481,6 +485,23 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
+     * {@code true} if the call to {@link #closeExpired()} is scheduled for future execution in the background
+     * cleaner thread. A value of {@code true} implies that this factory contains at least one active data access.
+     * However the reciprocal is not true: this field may be set to {@code false} while a DAO is currently in use
+     * because this field is set to {@code true} only when a worker factory is {@linkplain #release released}.
+     *
+     * <p>This method is used only for testing purpose.</p>
+     *
+     * @see #countAvailableDataAccess()
+     */
+    @Debug
+    final boolean isCleanScheduled() {
+        synchronized (availableDAOs) {
+            return isCleanScheduled;
+        }
+    }
+
+    /**
      * Confirms that the given factories can be closed. If any factory is still in use,
      * it will be removed from that {@cod factories} list and re-injected in the {@link #availableDAOs} queue.
      */
@@ -659,7 +680,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns the organization or party responsible for definition and maintenance of the underlying database.
+     * Returns the database or specification that defines the codes recognized by this factory.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Returns the cached value if it exists.</li>
@@ -771,9 +792,8 @@ public abstract class ConcurrentAuthorit
      *
      * <p>The default implementation performs the following steps:</p>
      * <ol>
-     *   <li>Removes the authority scope if presents. For example if the {@linkplain #getAuthority() authority}
-     *       is EPSG and the given code starts with the {@code "EPSG:"} prefix, then that prefix is removed.
-     *       Otherwise, the scope is unchanged.</li>
+     *   <li>Removes the namespace if presents. For example if the {@linkplain #getCodeSpaces() codespace}
+     *       is EPSG and the given code starts with the {@code "EPSG:"} prefix, then that prefix is removed.</li>
      *   <li>Removes leading and trailing spaces.</li>
      * </ol>
      *
@@ -786,7 +806,7 @@ public abstract class ConcurrentAuthorit
      * @throws FactoryException if an error occurred while normalizing the given code.
      */
     protected String normalizeCode(String code) throws FactoryException {
-        return trimAuthority(code, null);
+        return trimNamespace(code);
     }
 
     /**
@@ -836,7 +856,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a geographic coordinate reference system from a code.
+     * Returns a 2- or 3-dimensional coordinate reference system based on an ellipsoidal approximation of the geoid.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -859,7 +879,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a geocentric coordinate reference system from a code.
+     * Returns a 3-dimensional coordinate reference system with the origin at the approximate centre of mass of the earth.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -882,7 +902,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a projected coordinate reference system from a code.
+     * Returns a 2-dimensional coordinate reference system used to approximate the shape of the earth on a planar surface.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -905,7 +925,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a vertical coordinate reference system from a code.
+     * Returns a 1-dimensional coordinate reference system used for recording heights or depths.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -928,7 +948,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a temporal coordinate reference system from a code.
+     * Returns a 1-dimensional coordinate reference system used for the recording of time.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -951,7 +971,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a 3D or 4D coordinate reference system from a code.
+     * Returns a CRS describing the position of points through two or more independent coordinate reference systems.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -974,7 +994,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a derived coordinate reference system from a code.
+     * Returns a CRS that is defined by its coordinate conversion from another CRS (not by a datum).
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -997,7 +1017,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an engineering coordinate reference system from a code.
+     * Returns a 1-, 2- or 3-dimensional contextually local coordinate reference system.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1020,7 +1040,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an image coordinate reference system from a code.
+     * Returns a 2-dimensional engineering coordinate reference system applied to locations in images.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1043,7 +1063,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an arbitrary datum from a code.
+     * Returns an arbitrary datum from a code. The returned object will typically be an
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1066,7 +1086,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a geodetic datum from a code.
+     * Returns a datum defining the location and orientation of an ellipsoid that approximates the shape of the earth.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1089,7 +1109,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a vertical datum from a code.
+     * Returns a datum identifying a particular reference level surface used as a zero-height surface.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1112,7 +1132,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a temporal datum from a code.
+     * Returns a datum defining the origin of a temporal coordinate reference system.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1135,7 +1155,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an engineering datum from a code.
+     * Returns a datum defining the origin of an engineering coordinate reference system.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1158,7 +1178,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an image datum from a code.
+     * Returns a datum defining the origin of an image coordinate reference system.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1181,7 +1201,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an ellipsoid from a code.
+     * Returns a geometric figure that can be used to describe the approximate shape of the earth.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1204,7 +1224,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a prime meridian from a code.
+     * Returns a prime meridian defining the origin from which longitude values are determined.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1227,7 +1247,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an extent (usually a domain of validity) from a code.
+     * Returns information about spatial, vertical, and temporal extent (usually a domain of validity) from a code.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1272,7 +1292,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an ellipsoidal coordinate system from a code.
+     * Returns a 2- or 3-dimensional coordinate system for geodetic latitude and longitude, sometime with ellipsoidal height.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1295,7 +1315,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a vertical coordinate system from a code.
+     * Returns a 1-dimensional coordinate system for heights or depths of points.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1318,7 +1338,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a temporal coordinate system from a code.
+     * Returns a 1-dimensional coordinate system for heights or depths of points.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1341,7 +1361,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a Cartesian coordinate system from a code.
+     * Returns a 2- or 3-dimensional Cartesian coordinate system made of straight orthogonal axes.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1364,7 +1384,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a spherical coordinate system from a code.
+     * Returns a 3-dimensional coordinate system with one distance measured from the origin and two angular coordinates.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1387,7 +1407,8 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a cylindrical coordinate system from a code.
+     * Returns a 3-dimensional coordinate system made of a polar coordinate system
+     * extended by a straight perpendicular axis.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1410,7 +1431,8 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a polar coordinate system from a code.
+     * Returns a 2-dimensional coordinate system for coordinates represented by a distance from the origin
+     * and an angle from a fixed direction.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1433,7 +1455,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a coordinate system axis from a code.
+     * Returns a coordinate system axis with name, direction, unit and range of values.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1478,7 +1500,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns a parameter descriptor from a code.
+     * Returns a definition of a single parameter used by an operation method.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1501,7 +1523,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an operation method from a code.
+     * Returns a description of the algorithm and parameters used to perform a coordinate operation.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1524,7 +1546,7 @@ public abstract class ConcurrentAuthorit
     }
 
     /**
-     * Returns an operation from a code.
+     * Returns an operation for transforming coordinates in the source CRS to coordinates in the target CRS.
      * The default implementation performs the following steps:
      * <ul>
      *   <li>Return the cached instance for the given code if such instance already exists.</li>
@@ -1792,19 +1814,6 @@ public abstract class ConcurrentAuthorit
             }
         }
 
-        /**
-         * Returns the authority of the factory examined by this finder.
-         */
-        @Override
-        public synchronized Citation getAuthority() throws FactoryException {
-            try {
-                acquire();
-                return finder.getAuthority();
-            } finally {
-                release();
-            }
-        }
-
         /**
          * Returns a set of authority codes that <strong>may</strong> identify the same
          * object than the specified one. This method delegates to the data access object.

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -88,10 +88,17 @@ final class FilteredCodes extends Abstra
     }
 
     /**
-     * Ignored, except that it must be non-null.
+     * Returns a non-null value if the given code is included in the set.
      */
     @Override
     public Boolean get(final Object key) {
-        return Boolean.TRUE;
+        Class<?> t = codes.get(key);
+        if (t == null && key instanceof String) {
+            t = codes.get(CommonAuthorityFactory.reformat((String) key));
+            if (t == null) {
+                return null;
+            }
+        }
+        return type.isAssignableFrom(t) ? Boolean.TRUE : null;
     }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -71,12 +71,12 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Returns the organization or party responsible for definition and maintenance of the database.
+     * Returns the database or specification that defines the codes recognized by this factory.
      * This method may return {@code null} if it can not obtain this information, for example because
      * the connection to a database is not available.
      *
-     * <div class="note"><b>Example</b>
-     * A factory that create coordinate reference system objects from EPSG codes could return
+     * <div class="note"><b>Example:</b>
+     * a factory that create coordinate reference system objects from EPSG codes could return
      * a citation like below:
      *
      * {@preformat text
@@ -102,6 +102,43 @@ public abstract class GeodeticAuthorityF
     public abstract Citation getAuthority();
 
     /**
+     * Returns all namespaces recognized by this factory. Those namespaces can appear before codes in
+     * calls to {@code createFoo(String)} methods, for example {@code "EPSG"} in {@code "EPSG::4326"}.
+     * Namespaces are case-insensitive.
+     *
+     * <p>The namespaces are closely related to the {@linkplain #getAuthority() authority}. Often the namespace is
+     * the authority {@linkplain org.apache.sis.metadata.iso.citation.DefaultCitation#getIdentifiers() identifier},
+     * but not always.</p>
+     *
+     * <div class="note"><b>Examples:</b>
+     * <ul class="verbose">
+     *   <li>The {@link org.apache.sis.referencing.factory.sql.EPSGFactory} authority identifier is {@code "EPSG"}
+     *       and its {@code getCodeSpaces()} method returns a set containing {@code "EPSG"}. So in this example,
+     *       authority and namespace match. That namespace value means that {@code EPSGFactory.createFoo(String)}
+     *       methods accept both {@code "EPSG::4326"} (case-insensitive) and {@code "4326"} codes as argument.</li>
+     *
+     *   <li>The {@link org.apache.sis.referencing.factory.sql.EPSGDataAccess} authority identifier is {@code "EPSG"}
+     *       but its {@code getCodeSpaces()} method returns an empty set. This means that despite the EPSG authority,
+     *       {@code EPSGDataAccess.createFoo(String)} methods accept only codes like {@code "4326"} without
+     *       {@code "EPSG:"} prefix (the reason is that {@code EPSGDataAccess} is not expected to be used directly).</li>
+     *
+     *   <li>The {@link CommonAuthorityFactory} authority identifiers are ISO 19128 and OGC 06-042 (the WMS specification)
+     *       but its {@code getCodeSpaces()} method returns a set containing {@code "CRS"}, {@code "AUTO"} and {@code "AUTO2"}.
+     *       While ISO 19128 is defined as the first authority, the namespace is actually defined by OGC.</li>
+     * </ul></div>
+     *
+     * The default implementation infers the namespace from the {@linkplain #getAuthority() authority}.
+     * Subclasses can override this method, but the set should always contain the same elements during
+     * all factory lifetime.
+     *
+     * @return The namespaces recognized by this factory, or an empty set if none.
+     */
+    public Set<String> getCodeSpaces() {
+        final String authority = Citations.getCodeSpace(getAuthority());
+        return (authority != null) ? Collections.singleton(authority) : Collections.<String>emptySet();
+    }
+
+    /**
      * Returns a description of the object corresponding to a code.
      * The description can be used for example in a combo box in a graphical user interface.
      *
@@ -750,7 +787,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates 2- or 3-dimensional coordinate system for geodetic latitude and longitude,
+     * Creates a 2- or 3-dimensional coordinate system for geodetic latitude and longitude,
      * sometime with ellipsoidal height.
      *
      * <div class="note"><b>Example:</b>
@@ -1031,7 +1068,7 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Creates description of the algorithm and parameters used to perform a coordinate operation.
+     * Creates a description of the algorithm and parameters used to perform a coordinate operation.
      * An {@code OperationMethod} is a kind of metadata: it does not perform any coordinate operation
      * (e.g. map projection) by itself, but tells us what is needed in order to perform such operation.
      *
@@ -1112,46 +1149,55 @@ public abstract class GeodeticAuthorityF
     }
 
     /**
-     * Returns a finder which can be used for looking up unidentified objects.
+     * Creates a finder which can be used for looking up unidentified objects.
      * The finder tries to fetch a fully {@linkplain AbstractIdentifiedObject identified object}
      * from an incomplete one, for example from an object without "{@code ID[…]}" or
      * "{@code AUTHORITY[…]}" element in <cite>Well Known Text</cite>.
      *
      * @return A finder to use for looking up unidentified objects.
      * @throws FactoryException if the finder can not be created.
+     *
+     * @see org.apache.sis.referencing.IdentifiedObjects#newFinder(String)
      */
     public IdentifiedObjectFinder newIdentifiedObjectFinder() throws FactoryException {
         return new IdentifiedObjectFinder(this);
     }
 
     /**
-     * Trims the authority scope, if present. For example if this factory is an EPSG authority factory
+     * Returns {@code true} if the given portion of the code is equal, ignoring case, to the given namespace.
+     */
+    static boolean regionMatches(final String namespace, final String code, final int start, final int end) {
+        return (namespace.length() == end - start) && code.regionMatches(true, start, namespace, 0, namespace.length());
+    }
+
+    /**
+     * Trims the namespace, if present. For example if this factory is an EPSG authority factory
      * and the specified code start with the {@code "EPSG:"} prefix, then the prefix is removed.
      * Otherwise, the string is returned unchanged (except for leading and trailing spaces).
      *
      * @param  code The code to trim.
-     * @param  authority The authority factory, or {@code null} for {@link #getAuthority()}.
-     * @return The code with the authority part removed if that part matched the expected authority.
+     * @return The code with the namespace part removed if that part matched one of the values given by
+     *         {@link #getCodeSpaces()}.
      */
-    final String trimAuthority(final String code, Citation authority) {
+    final String trimNamespace(final String code) {
         int s = code.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR);
         if (s >= 0) {
-            if (authority == null) {
-                authority = getAuthority();     // Costly operation for EPSGDataAccess.
-            }
-            if (Citations.identifierMatches(authority, null, code.substring(0, s))) {    // Comparison ignores spaces.
-                final int n = code.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR, s + 1);
-                if (n >= 0) {
-                    /*
-                     * The separator sometime appears twice, as in "EPSG::4326" or "EPSG:8.8:4326".
-                     * The part between the two separators is the verion number, which we ignore in
-                     * this simple version.
-                     */
-                    s = n;
+            final int end   = CharSequences.skipTrailingWhitespaces(code, 0, s);
+            final int start = CharSequences.skipLeadingWhitespaces (code, 0, end);
+            for (final String codespace : getCodeSpaces()) {
+                if (regionMatches(codespace, code, start, end)) {
+                    final int n = code.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR, s + 1);
+                    if (n >= 0) {
+                        /*
+                         * The separator sometime appears twice, as in "EPSG::4326" or "EPSG:8.8:4326".
+                         * The part between the two separators is the verion number, which we ignore in
+                         * this simple version.
+                         */
+                        s = n;
+                    }
+                    final int length = code.length();
+                    return CharSequences.trimWhitespaces(code, s+1, length).toString();
                 }
-                final int length = code.length();
-                s = CharSequences.skipLeadingWhitespaces(code, s+1, length);
-                return code.substring(s, CharSequences.skipTrailingWhitespaces(code, s, length));
             }
         }
         return CharSequences.trimWhitespaces(code);
@@ -1191,7 +1237,7 @@ public abstract class GeodeticAuthorityF
         final Identifier id = object.getName();
         final Citation authority = (id != null) ? id.getAuthority() : getAuthority();
         throw new NoSuchAuthorityCodeException(Errors.format(Errors.Keys.UnexpectedTypeForReference_3, code, type, actual),
-                Citations.getIdentifier(authority, false), trimAuthority(code, authority), code);
+                Citations.getIdentifier(authority, false), trimNamespace(code), code);
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/IdentifiedObjectFinder.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -23,15 +23,14 @@ import java.util.LinkedHashSet;
 import org.opengis.util.GenericName;
 import org.opengis.util.FactoryException;
 import org.opengis.metadata.Identifier;
-import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.AuthorityFactory;
 import org.opengis.referencing.NoSuchAuthorityCodeException;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.internal.util.Citations;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.util.collection.BackingStoreException;
+import org.apache.sis.util.iso.DefaultNameSpace;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
@@ -154,6 +153,13 @@ public class IdentifiedObjectFinder {
     private boolean ignoreAxes;
 
     /**
+     * {@code true} if the search should ignore names, aliases and identifiers. This is set to {@code true}
+     * only when this finder is wrapped by a {@link MultiAuthoritiesFactory} finder, which performs it own
+     * search based on identifiers.
+     */
+    boolean ignoreIdentifiers;
+
+    /**
      * Creates a finder using the specified factory.
      *
      * <div class="note"><b>Design note:</b>
@@ -186,17 +192,6 @@ public class IdentifiedObjectFinder {
     }
 
     /**
-     * Returns the authority of the factory used by this finder.
-     * The default implementation delegates to {@link GeodeticAuthorityFactory#getAuthority()}.
-     *
-     * @return The authority of the factory used for the searches, or {@code null} if unknown.
-     * @throws FactoryException If an error occurred while fetching the authority.
-     */
-    public Citation getAuthority() throws FactoryException {
-        return factory.getAuthority();
-    }
-
-    /**
      * Returns the domain of the search (for example whether to include deprecated objects in the search).
      * If {@code DECLARATION}, only a fast lookup based on embedded identifiers and names will be performed.
      * Otherwise an exhaustive full scan against all registered objects will be performed (may be slow).
@@ -305,23 +300,25 @@ public class IdentifiedObjectFinder {
             final AuthorityFactoryProxy<?> previous = proxy;
             proxy = AuthorityFactoryProxy.getInstance(object.getClass());
             try {
-                /*
-                 * First check if one of the identifiers can be used to find directly an identified object.
-                 * Verify that the object that we found is actually equal to given one; we do not blindly
-                 * trust the identifiers in the user object.
-                 */
-                IdentifiedObject candidate = createFromIdentifiers(object);
-                if (candidate != null) {
-                    return Collections.singleton(candidate);    // Not worth to cache.
-                }
-                /*
-                 * We are unable to find the object from its identifiers. Try a quick name lookup.
-                 * Some implementations like the one backed by the EPSG database are capable to find
-                 * an object from its name.
-                 */
-                candidate = createFromNames(object);
-                if (candidate != null) {
-                    return Collections.singleton(candidate);    // Not worth to cache.
+                if (!ignoreIdentifiers) {
+                    /*
+                     * First check if one of the identifiers can be used to find directly an identified object.
+                     * Verify that the object that we found is actually equal to given one; we do not blindly
+                     * trust the identifiers in the user object.
+                     */
+                    IdentifiedObject candidate = createFromIdentifiers(object);
+                    if (candidate != null) {
+                        return Collections.singleton(candidate);    // Not worth to cache.
+                    }
+                    /*
+                     * We are unable to find the object from its identifiers. Try a quick name lookup.
+                     * Some implementations like the one backed by the EPSG database are capable to find
+                     * an object from its name.
+                     */
+                    candidate = createFromNames(object);
+                    if (candidate != null) {
+                        return Collections.singleton(candidate);    // Not worth to cache.
+                    }
                 }
                 /*
                  * Here we exhausted the quick paths.
@@ -385,10 +382,15 @@ public class IdentifiedObjectFinder {
      * @see #createFromNames(IdentifiedObject)
      */
     private IdentifiedObject createFromIdentifiers(final IdentifiedObject object) throws FactoryException {
-        final Citation authority = getAuthority();
         for (final Identifier id : object.getIdentifiers()) {
-            if (Citations.identifierMatches(authority, id.getAuthority())) {
-                final String code = IdentifiedObjects.toString(id);
+            final String code = IdentifiedObjects.toString(id);
+            /*
+             * We will process only codes with a namespace (e.g. "AUTHORITY:CODE") for avoiding ambiguity.
+             * We do not try to check by ourselves if the identifier is in the namespace of the factory,
+             * because calling factory.getAuthorityCodes() or factory.getCodeSpaces() may be costly for
+             * some implementations.
+             */
+            if (code.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR) >= 0) {
                 final IdentifiedObject candidate;
                 try {
                     candidate = create(code);
@@ -458,11 +460,11 @@ public class IdentifiedObjectFinder {
     /**
      * Creates an object equals (optionally ignoring metadata), to the specified object.
      * This method scans the {@linkplain #getCodeCandidates(IdentifiedObject) authority codes},
-     * create the objects and returns the first one which is equal to the specified object in
+     * creates the objects and returns the first one which is equal to the specified object in
      * the sense of {@link Utilities#deepEquals(Object, Object, ComparisonMode)}.
      *
-     * <p>This method may be used in order to get a fully {@linkplain AbstractIdentifiedObject identified
-     * object} from an object without {@linkplain AbstractIdentifiedObject#getIdentifiers() identifiers}.</p>
+     * <p>This method may be used in order to get a fully {@linkplain AbstractIdentifiedObject identified object}
+     * from an object without {@linkplain AbstractIdentifiedObject#getIdentifiers() identifiers}.</p>
      *
      * <p>Scanning the whole set of authority codes may be slow. Users should try
      * <code>{@linkplain #createFromIdentifiers createFromIdentifiers}(object)</code> and/or
@@ -476,7 +478,7 @@ public class IdentifiedObjectFinder {
      * @see #createFromIdentifiers(IdentifiedObject)
      * @see #createFromNames(IdentifiedObject)
      */
-    private Set<IdentifiedObject> createFromCodes(final IdentifiedObject object) throws FactoryException {
+    Set<IdentifiedObject> createFromCodes(final IdentifiedObject object) throws FactoryException {
         final Set<IdentifiedObject> result = new LinkedHashSet<IdentifiedObject>();     // We need to preserve order.
         for (final String code : getCodeCandidates(object)) {
             final IdentifiedObject candidate;
@@ -536,6 +538,6 @@ public class IdentifiedObjectFinder {
      * Invoked when an exception occurred during the creation of a candidate from a code.
      */
     private static void exceptionOccurred(final FactoryException exception) {
-        Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY), IdentifiedObjectFinder.class, "fine", exception);
+        Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY), IdentifiedObjectFinder.class, "find", exception);
     }
 }

Copied: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java (from r1727537, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java?p2=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java&r1=1727537&r2=1727561&rev=1727561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -229,8 +229,8 @@ public class MultiAuthoritiesFactory ext
             else nullMask |= (1 << i);
         }
         providers = ArraysExt.resize(p, length);
-        factories = new ConcurrentHashMap<>();
-        warnings  = new HashMap<>();
+        factories = new ConcurrentHashMap<AuthorityFactoryIdentifier, AuthorityFactory>();
+        warnings  = new HashMap<AuthorityFactoryIdentifier, Boolean>();
         isIterationCompleted = new AtomicInteger(nullMask);
     }
 
@@ -310,13 +310,13 @@ public class MultiAuthoritiesFactory ext
                     private final Iterator<AuthorityFactory> factories = getAllFactories();
 
                     /** An iterator over the codes of the current factory. */
-                    private Iterator<String> codes = Collections.emptyIterator();
+                    private Iterator<String> codes = Collections.<String>emptySet().iterator();
 
                     /** The prefix to prepend before codes, or {@code null} if none. */
                     private String prefix;
 
                     /** For filtering duplicated codes when there is many versions of the same authority. */
-                    private final Set<String> done = new HashSet<>();
+                    private final Set<String> done = new HashSet<String>();
 
                     /** Tests if there is more codes to return. */
                     @Override public boolean hasNext() {
@@ -350,7 +350,7 @@ public class MultiAuthoritiesFactory ext
             /**
              * The cache of values returned by {@link #getAuthorityCodes(AuthorityFactory)}.
              */
-            private final Map<AuthorityFactory, Set<String>> cache = new IdentityHashMap<>();
+            private final Map<AuthorityFactory, Set<String>> cache = new IdentityHashMap<AuthorityFactory, Set<String>>();
 
             /**
              * Returns the authority codes for the given factory.
@@ -394,7 +394,7 @@ public class MultiAuthoritiesFactory ext
             public int size() {
                 if (size < 0) {
                     int n = 0;
-                    final Set<String> done = new HashSet<>();
+                    final Set<String> done = new HashSet<String>();
                     for (final Iterator<AuthorityFactory> it = getAllFactories(); it.hasNext();) {
                         final AuthorityFactory factory = it.next();
                         if (done.add(getCodeSpace(factory))) {
@@ -475,7 +475,7 @@ public class MultiAuthoritiesFactory ext
     public Set<String> getCodeSpaces() {
         Set<String> union = codeSpaces;
         if (union == null) {
-            union = new LinkedHashSet<>();
+            union = new LinkedHashSet<String>();
             for (final Iterator<AuthorityFactory> it = getAllFactories(); it.hasNext();) {
                 union.addAll(getCodeSpaces(it.next()));
             }
@@ -533,7 +533,7 @@ public class MultiAuthoritiesFactory ext
      * condition is meet, threads can safely use their iterators concurrently.</p>
      */
     final Iterator<AuthorityFactory> getAllFactories() {
-        return new LazySynchronizedIterator<>(providers);
+        return new LazySynchronizedIterator<AuthorityFactory>(providers);
     }
 
     /**
@@ -1555,8 +1555,8 @@ public class MultiAuthoritiesFactory ext
         @Override
         final Set<IdentifiedObject> createFromCodes(final IdentifiedObject object) throws FactoryException {
             if (finders == null) try {
-                final ArrayList<IdentifiedObjectFinder> list = new ArrayList<>();
-                final Map<AuthorityFactory,Boolean> unique = new IdentityHashMap<>();
+                final ArrayList<IdentifiedObjectFinder> list = new ArrayList<IdentifiedObjectFinder>();
+                final Map<AuthorityFactory,Boolean> unique = new IdentityHashMap<AuthorityFactory,Boolean>();
                 final Iterator<AuthorityFactory> it = ((MultiAuthoritiesFactory) factory).getAllFactories();
                 while (it.hasNext()) {
                     final AuthorityFactory candidate = it.next();
@@ -1573,7 +1573,7 @@ public class MultiAuthoritiesFactory ext
             } catch (BackingStoreException e) {
                 throw e.unwrapOrRethrow(FactoryException.class);
             }
-            final Set<IdentifiedObject> found = new LinkedHashSet<>();
+            final Set<IdentifiedObject> found = new LinkedHashSet<IdentifiedObject>();
             for (final IdentifiedObjectFinder finder : finders) {
                 found.addAll(finder.find(object));
             }

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=1727561&r1=1727560&r2=1727561&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] Fri Jan 29 12:23:09 2016
@@ -342,9 +342,23 @@ public class EPSGDataAccess extends Geod
     }
 
     /**
-     * Returns the authority for this EPSG database. The returned citation contains the database version
+     * Returns the authority for this EPSG dataset. The returned citation contains the database version
      * in the {@linkplain Citation#getEdition() edition} attribute, together with date of last update in
      * the {@linkplain Citation#getEditionDate() edition date}.
+     * Example (the exact content will vary with Apache SIS versions, JDBC driver and EPSG dataset versions):
+     *
+     * {@preformat text
+     *   Citation
+     *   ├─ Title ……………………………………………………… EPSG Geodetic Parameter Dataset
+     *   ├─ Identifier ………………………………………… EPSG
+     *   ├─ Online resource (1 of 2)
+     *   │  ├─ Linkage ………………………………………… http://epsg-registry.org/
+     *   │  └─ Function ……………………………………… Browse
+     *   └─ Online resource (2 of 2)
+     *      ├─ Linkage ………………………………………… jdbc:derby:/my/path/to/SIS_DATA/Databases/SpatialMetadata
+     *      ├─ Description ……………………………… EPSG dataset version 8.8 on “Apache Derby Embedded JDBC Driver” version 10.12.
+     *      └─ Function ……………………………………… Connection
+     * }
      */
     @Override
     public synchronized Citation getAuthority() {
@@ -385,6 +399,9 @@ public class EPSGDataAccess extends Geod
              *    Linkage:      jdbc:derby:/my/path/to/SIS_DATA/Databases/SpatialMetadata
              *    Function:     Connection
              *    Description:  EPSG dataset version 8.8 on “Apache Derby Embedded JDBC Driver” version 10.12.
+             *
+             * TODO: A future version should use Citations.EPSG as a template.
+             *       See the "EPSG" case in ServiceForUtility.createCitation(String).
              */
             final DatabaseMetaData metadata  = connection.getMetaData();
 addURIs:    for (int i=0; ; i++) {
@@ -527,6 +544,17 @@ addURIs:    for (int i=0; ; i++) {
     }
 
     /**
+     * Returns an empty set since this data access class expects no namespace.
+     * Code shall be given to {@code createFoo(String)} methods directly, without {@code "EPSG:"} prefix.
+     *
+     * @return Empty set.
+     */
+    @Override
+    public Set<String> getCodeSpaces() {
+        return Collections.emptySet();
+    }
+
+    /**
      * Gets a description of the object corresponding to a code.
      * This method returns the object name in a lightweight manner, without creating the full {@link IdentifiedObject}.
      *

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=1727561&r1=1727560&r2=1727561&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] Fri Jan 29 12:23:09 2016
@@ -16,10 +16,13 @@
  */
 package org.apache.sis.referencing.factory.sql;
 
+import java.util.Collections;
 import java.util.Locale;
+import java.util.Set;
 import java.sql.Connection;
 import java.sql.SQLException;
 import javax.sql.DataSource;
+import java.util.concurrent.TimeUnit;
 import org.opengis.util.NameFactory;
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.crs.CRSFactory;
@@ -33,6 +36,7 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.apache.sis.internal.metadata.sql.Initializer;
 import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.referencing.factory.ConcurrentAuthorityFactory;
 import org.apache.sis.referencing.factory.UnavailableFactoryException;
 import org.apache.sis.util.ArgumentChecks;
@@ -59,6 +63,13 @@ public class EPSGFactory extends Concurr
         CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, Localized
 {
     /**
+     * The namespace of EPSG codes.
+     *
+     * @see #getCodeSpaces()
+     */
+    private static final Set<String> CODESPACES = Collections.singleton(Constants.EPSG);
+
+    /**
      * The factory to use for creating {@link Connection}s to the EPSG database.
      */
     protected final DataSource dataSource;
@@ -168,6 +179,7 @@ public class EPSGFactory extends Concurr
         this.mtFactory    = factory(MathTransformFactory.class, mtFactory);
         this.translator   = translator;
         this.locale       = Locale.getDefault();
+        super.setTimeout(10, TimeUnit.SECONDS);
     }
 
     /**
@@ -181,6 +193,16 @@ public class EPSGFactory extends Concurr
     }
 
     /**
+     * Returns the namespace of EPSG codes.
+     *
+     * @return The {@code "EPSG"} string in a singleton map.
+     */
+    @Override
+    public Set<String> getCodeSpaces() {
+        return CODESPACES;
+    }
+
+    /**
      * Returns the locale used by this factory for producing error messages.
      * This locale does not change the way data are read from the EPSG database.
      *

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -266,7 +266,7 @@ public class DefaultMathTransformFactory
          *
          * Wrapping the ServiceLoader in a LazySet avoid this issue.
          */
-        this(new LazySet<OperationMethod>(ServiceLoader.load(OperationMethod.class).iterator()));
+        this(new LazySet<OperationMethod>(ServiceLoader.load(OperationMethod.class)));
     }
 
     /**
@@ -1299,8 +1299,7 @@ public class DefaultMathTransformFactory
             methodsByName.clear();
             Iterable<? extends OperationMethod> m = methods;
             if (m instanceof LazySet<?>) { // Workaround for JDK bug. See DefaultMathTransformFactory() constructor.
-                ((LazySet<?>) m).reload();
-                m = ((LazySet<? extends OperationMethod>) m).source;
+                m = ((LazySet<? extends OperationMethod>) m).reload();
             }
             if (m instanceof ServiceLoader<?>) {
                 ((ServiceLoader<?>) m).reload();

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyFormula.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyFormula.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyFormula.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/MolodenskyFormula.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -255,7 +255,7 @@ abstract class MolodenskyFormula extends
      *   <li><cite>"X-axis translation"</cite> (Molodensky only)</li>
      *   <li><cite>"Y-axis translation"</cite> (Molodensky only)</li>
      *   <li><cite>"Z-axis translation"</cite> (Molodensky only)</li>
-     *   <li><cite>"Geocentric translations file"</cite> (Geocentric interpolations only)</li>
+     *   <li><cite>"Geocentric translation file"</cite> (Geocentric interpolations only)</li>
      *   <li><cite>"Semi-major axis length difference"</cite> (Always for Molodensky, internal WKT only for geocentric interpolations)</li>
      *   <li><cite>"Flattening difference"</cite> (Always for Molodensky, internal WKT only for geocentric interpolations)</li>
      * </ul>

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/OperationMethodSet.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -19,12 +19,12 @@ package org.apache.sis.referencing.opera
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Set;
-import java.util.AbstractSet;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 import java.util.ServiceLoader;
 import org.opengis.referencing.operation.SingleOperation;
 import org.opengis.referencing.operation.OperationMethod;
+import org.apache.sis.internal.util.SetOfUnknownSize;
 import org.apache.sis.referencing.operation.DefaultOperationMethod;
 
 
@@ -43,10 +43,10 @@ import org.apache.sis.referencing.operat
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.6
+ * @version 0.7
  * @module
  */
-final class OperationMethodSet extends AbstractSet<OperationMethod> {
+final class OperationMethodSet extends SetOfUnknownSize<OperationMethod> {
     /**
      * The operation type we are looking for.
      */
@@ -163,6 +163,14 @@ final class OperationMethodSet extends A
     }
 
     /**
+     * Returns {@code true} if the {@link #size()} method is cheap.
+     */
+    @Override
+    protected synchronized boolean isSizeKnown() {
+        return methodIterator == null;
+    }
+
+    /**
      * Returns {@code true} if {@link #next(int)} can return an operation method at the given index.
      */
     final synchronized boolean hasNext(final int index) {

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/TransformSeparator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/TransformSeparator.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/TransformSeparator.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/TransformSeparator.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -272,16 +272,16 @@ public class TransformSeparator {
      * Returns the input dimensions to keep or kept in the separated transform.
      * This method performs the first applicable action in the following list:
      *
-     * <ol>
-     *   <li><p>Source dimensions have been explicitly set by at least one call to {@link #addSourceDimensions(int...)}
+     * <ol class="verbose">
+     *   <li>Source dimensions have been explicitly set by at least one call to {@link #addSourceDimensions(int...)}
      *       or {@link #addSourceDimensionRange(int, int)} since construction or since last call to {@link #clear()}.
-     *       In such case, this method returns all specified source dimensions.</p></li>
+     *       In such case, this method returns all specified source dimensions.</li>
      *
-     *   <li><p>No source dimensions were set but {@link #separate()} has been invoked.
+     *   <li>No source dimensions were set but {@link #separate()} has been invoked.
      *       In such case, this method returns the sequence of source dimensions that {@code separate()} chooses to retain.
-     *       It is often, but not necessarily, all source dimensions of the transform given at construction time.</p></li>
+     *       It is often, but not necessarily, all source dimensions of the transform given at construction time.</li>
      *
-     *   <li><p>Otherwise an exception is thrown.</p></li>
+     *   <li>Otherwise an exception is thrown.</li>
      * </ol>
      *
      * @return The input dimension as a sequence of strictly increasing values.
@@ -333,16 +333,16 @@ public class TransformSeparator {
      * Returns the output dimensions to keep or kept in the separated transform.
      * This method performs the first applicable action in the following list:
      *
-     * <ol>
-     *   <li><p>Target dimensions have been explicitly set by at least one call to {@link #addTargetDimensions(int...)}
+     * <ol class="verbose">
+     *   <li>Target dimensions have been explicitly set by at least one call to {@link #addTargetDimensions(int...)}
      *       or {@link #addTargetDimensionRange(int, int)} since construction or since last call to {@link #clear()}.
-     *       In such case, this method returns all specified target dimensions.</p></li>
+     *       In such case, this method returns all specified target dimensions.</li>
      *
-     *   <li><p>No target dimensions were set but {@link #separate()} has been invoked.
+     *   <li>No target dimensions were set but {@link #separate()} has been invoked.
      *       In such case, the target dimensions are inferred automatically from the {@linkplain #getSourceDimensions()
-     *       source dimensions} and the transform.</p></li>
+     *       source dimensions} and the transform.</li>
      *
-     *   <li><p>Otherwise an exception is thrown.</p></li>
+     *   <li>Otherwise an exception is thrown.</li>
      * </ol>
      *
      * @return The output dimension as a sequence of strictly increasing values.
@@ -362,14 +362,14 @@ public class TransformSeparator {
      * source dimensions} and return only the {@linkplain #addTargetDimensions(int...) specified target dimensions}.
      * If the source or target dimensions were not specified, then they will be inferred as below:
      *
-     * <ul>
-     *   <li><p>If source dimensions were unspecified, then the returned transform will keep at least all source
+     * <ul class="verbose">
+     *   <li>If source dimensions were unspecified, then the returned transform will keep at least all source
      *       dimensions needed for computing the specified target dimensions. In many cases the returned transform
      *       unconditionally keep all source dimensions, but not necessarily. If all source dimensions need to be
-     *       kept, it is better to {@linkplain #addSourceDimensionRange(int, int) specify that explicitely}.</p></li>
+     *       kept, it is better to {@linkplain #addSourceDimensionRange(int, int) specify that explicitely}.</li>
      *
-     *   <li><p>If target dimensions were unspecified, then the returned transform will expect only the specified
-     *       source dimensions as inputs, and the target dimensions will be inferred automatically.</p></li>
+     *   <li>If target dimensions were unspecified, then the returned transform will expect only the specified
+     *       source dimensions as inputs, and the target dimensions will be inferred automatically.</li>
      * </ul>
      *
      * The source and target dimensions actually used can be queried by calls to {@link #getSourceDimensions()}
@@ -446,7 +446,7 @@ public class TransformSeparator {
      *
      * <p>Subclasses can override this method if they need to handle some {@code MathTransform} implementations
      * in a special way. However all implementations of this method shall obey to the following contract:</p>
-     * <ul>
+     * <ul class="verbose">
      *   <li>{@link #sourceDimensions} and {@link #targetDimensions} should not be assumed accurate
      *       since they may be temporarily outdated or modified during recursive calls to this method.</li>
      *   <li>{@link #sourceDimensions} should not be modified by this method.</li>

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -73,7 +73,8 @@ import org.opengis.util.Factory;
     org.apache.sis.referencing.crs.DefaultCompoundCRSTest.class,
     org.apache.sis.referencing.crs.DefaultEngineeringCRSTest.class,
     org.apache.sis.referencing.crs.DefaultImageCRSTest.class,
-    org.apache.sis.referencing.cs.DirectionAlongMeridianTest.class
+    org.apache.sis.referencing.cs.DirectionAlongMeridianTest.class,
+    org.apache.sis.referencing.factory.GeodeticObjectFactoryTest.class
 })
 public final strictfp class GeodeticObjectParserTest extends TestCase {
     /**

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CRSTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -22,6 +22,10 @@ import org.opengis.referencing.crs.Singl
 import org.opengis.util.FactoryException;
 import org.apache.sis.referencing.crs.DefaultCompoundCRS;
 import org.apache.sis.referencing.crs.HardCodedCRS;
+import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.Utilities;
+
+// Test imports
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -35,18 +39,23 @@ import static org.apache.sis.test.Assert
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.7
  * @module
  */
 @DependsOn({
-    CommonCRSTest.class
+    CommonCRSTest.class,
+    AuthorityFactoriesTest.class
 })
 public final strictfp class CRSTest extends TestCase {
     /**
      * Asserts that the result of {@link CRS#forCode(String)} is the given CRS.
      */
     private static void verifyForCode(final SingleCRS expected, final String code) throws FactoryException {
-        assertSame(code, expected, CRS.forCode(code));
+        final CoordinateReferenceSystem actual = CRS.forCode(code);
+        assertTrue(code, Utilities.deepEquals(expected, actual, ComparisonMode.DEBUG));
+        if (!EPSGFactoryFallback.FORCE_HARDCODED) {
+            assertSame(code, expected, actual);
+        }
     }
 
     /**
@@ -60,6 +69,7 @@ public final strictfp class CRSTest exte
     public void testForEpsgCode() throws FactoryException {
         verifyForCode(CommonCRS.WGS84 .geographic(),   "EPSG:4326");
         verifyForCode(CommonCRS.WGS84 .geographic(),   "urn:ogc:def:crs:EPSG::4326");
+        verifyForCode(CommonCRS.WGS84 .geographic(),   "urn:x-ogc:def:crs:EPSG::4326");
         verifyForCode(CommonCRS.WGS84 .geographic(),   "http://www.opengis.net/gml/srs/epsg.xml#4326");
         verifyForCode(CommonCRS.WGS72 .geographic(),   "EPSG:4322");
         verifyForCode(CommonCRS.SPHERE.geographic(),   "EPSG:4047");
@@ -74,7 +84,13 @@ public final strictfp class CRSTest exte
         verifyForCode(CommonCRS.WGS72 .geographic3D(), "EPSG:4985");
         verifyForCode(CommonCRS.ETRS89.geographic3D(), "EPSG:4937");
         verifyForCode(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(), "EPSG:5714");
-        verifyForCode(CommonCRS.Vertical.DEPTH.crs(), "EPSG:5715");
+        /*
+         * Following test is skipped when using the EPSG factory because EPSG uses
+         * the "Gravity-related depth" axis name while ISO 19111 mandates "Depth".
+         */
+        if (EPSGFactoryFallback.PENDING_NEXT_EPSG) {
+            verifyForCode(CommonCRS.Vertical.DEPTH.crs(), "EPSG:5715");
+        }
     }
 
     /**
@@ -90,6 +106,8 @@ public final strictfp class CRSTest exte
         verifyForCode(CommonCRS.WGS84.normalizedGeographic(), "CRS:84");
         verifyForCode(CommonCRS.NAD83.normalizedGeographic(), "CRS:83");
         verifyForCode(CommonCRS.NAD27.normalizedGeographic(), "CRS:27");
+        verifyForCode(CommonCRS.WGS84.normalizedGeographic(), "http://www.opengis.net/gml/srs/crs.xml#84");
+        verifyForCode(CommonCRS.NAD83.normalizedGeographic(), "http://www.opengis.net/gml/srs/crs.xml#83");
     }
 
     /**
@@ -234,4 +252,16 @@ public final strictfp class CRSTest exte
         assertEquals(0,          CRS.getGreenwichLongitude(HardCodedCRS.WGS84), STRICT);
         assertEquals(2.33722917, CRS.getGreenwichLongitude(HardCodedCRS.NTF),   1E-12);
     }
+
+    /**
+     * Tests {@link IdentifiedObjects#lookupEPSG(IdentifiedObject)} and
+     * {@link IdentifiedObjects#lookupURN(IdentifiedObject, Citation)}.
+     *
+     * @throws FactoryException if an error occurred during the lookup.
+     */
+    @Test
+    public void testIdentifiedObjectLookup() throws FactoryException {
+        IdentifiedObjectsTest.testLookupEPSG();
+        IdentifiedObjectsTest.testLookupWMS();
+    }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/CommonCRSTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -18,8 +18,6 @@ package org.apache.sis.referencing;
 
 import java.util.Date;
 import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.util.FactoryException;
-import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.crs.TemporalCRS;
 import org.opengis.referencing.crs.VerticalCRS;
 import org.opengis.referencing.crs.GeographicCRS;
@@ -165,10 +163,13 @@ public final strictfp class CommonCRSTes
                  */
                 Validators.validate(crs);
             }
-            assertSame  (name, datum,          e.datum()); // Datum before CRS creation.
-            assertSame  (name, crs.getDatum(), e.datum()); // Datum after CRS creation.
+            assertSame  (name, datum,          e.datum());                      // Datum before CRS creation.
+            assertSame  (name, crs.getDatum(), e.datum());                      // Datum after CRS creation.
             assertEquals(name, datumName, datum.getName().getCode());
             assertEquals(name, datumType, datum.getVerticalDatumType());
+            if (!EPSGFactoryFallback.PENDING_NEXT_EPSG && e == CommonCRS.Vertical.DEPTH) {
+                continue;   // Pending the renaming of "Gravity-related depth" as "Depth" in EPSG database.
+            }
             assertEquals(name, axisName,  crs.getCoordinateSystem().getAxis(0).getName().getCode());
         }
     }
@@ -222,43 +223,4 @@ public final strictfp class CommonCRSTes
         assertSame("Expected a cached instance.", crs, CommonCRS.WGS72.UTM(-45, -122));
         assertNotSame("Expected a new instance.", crs, CommonCRS.WGS72.UTM(+45, -122));
     }
-
-    /**
-     * Tests {@link CommonCRS#forCode(String, String, FactoryException)}.
-     *
-     * @throws FactoryException If a CRS can not be constructed.
-     *
-     * @see CRSTest#testForEpsgCode()
-     * @see CRSTest#testForCrsCode()
-     *
-     * @since 0.5
-     */
-    @Test
-    public void testForCode() throws FactoryException {
-        verifyForCode(CommonCRS.WGS84 .geographic(),            Constants.EPSG, "4326");
-        verifyForCode(CommonCRS.WGS72 .geographic(),            Constants.EPSG, "4322");
-        verifyForCode(CommonCRS.SPHERE.geographic(),            Constants.EPSG, "4047");
-        verifyForCode(CommonCRS.NAD83 .geographic(),            Constants.EPSG, "4269");
-        verifyForCode(CommonCRS.NAD27 .geographic(),            Constants.EPSG, "4267");
-        verifyForCode(CommonCRS.ETRS89.geographic(),            Constants.EPSG, "4258");
-        verifyForCode(CommonCRS.ED50  .geographic(),            Constants.EPSG, "4230");
-        verifyForCode(CommonCRS.WGS84 .geocentric(),            Constants.EPSG, "4978");
-        verifyForCode(CommonCRS.WGS72 .geocentric(),            Constants.EPSG, "4984");
-        verifyForCode(CommonCRS.ETRS89.geocentric(),            Constants.EPSG, "4936");
-        verifyForCode(CommonCRS.WGS84 .geographic3D(),          Constants.EPSG, "4979");
-        verifyForCode(CommonCRS.WGS72 .geographic3D(),          Constants.EPSG, "4985");
-        verifyForCode(CommonCRS.ETRS89.geographic3D(),          Constants.EPSG, "4937");
-        verifyForCode(CommonCRS.Vertical.MEAN_SEA_LEVEL.crs(),  Constants.EPSG, "5714");
-        verifyForCode(CommonCRS.Vertical.DEPTH.crs(),           Constants.EPSG, "5715");
-        verifyForCode(CommonCRS.WGS84.normalizedGeographic(),   Constants.CRS,  "84");
-        verifyForCode(CommonCRS.NAD83.normalizedGeographic(),   Constants.CRS,  "83");
-        verifyForCode(CommonCRS.NAD27.normalizedGeographic(),   Constants.CRS,  "27");
-    }
-
-    /**
-     * Asserts that the result of {@link CommonCRS#forCode(String, String, FactoryException)} is the given CRS.
-     */
-    private static void verifyForCode(final SingleCRS expected, final String authority, final String code) throws FactoryException {
-        assertSame(code, expected, CommonCRS.forCode(authority, code, null));
-    }
 }

Copied: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java (from r1727537, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java?p2=sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java&p1=sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java&r1=1727537&r2=1727561&rev=1727561&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/EPSGFactoryFallbackTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -122,7 +122,7 @@ public final strictfp class EPSGFactoryF
         final CRSAuthorityFactory EPSG = (CRSAuthorityFactory) AuthorityFactories.EPSG();
         try {
             setEPSGFactory(EPSGFactoryFallback.INSTANCE);
-            final ArrayList<String> codes = new ArrayList<>(EPSGFactoryFallback.INSTANCE.getAuthorityCodes(CoordinateReferenceSystem.class));
+            final ArrayList<String> codes = new ArrayList<String>(EPSGFactoryFallback.INSTANCE.getAuthorityCodes(CoordinateReferenceSystem.class));
             Collections.shuffle(codes, TestUtilities.createRandomNumberGenerator());
             for (final String code : codes) {
                 if (!EPSGFactoryFallback.PENDING_NEXT_EPSG && code.equals("5715")) {

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/IdentifiedObjectsTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -18,8 +18,11 @@ package org.apache.sis.referencing;
 
 import org.opengis.util.GenericName;
 import org.opengis.util.NameFactory;
+import org.opengis.util.FactoryException;
+import org.opengis.metadata.citation.Citation;
 import org.opengis.referencing.IdentifiedObject;
 import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.referencing.crs.HardCodedCRS;
 import org.apache.sis.test.mock.IdentifiedObjectMock;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -30,10 +33,13 @@ import static org.apache.sis.referencing
 
 /**
  * Tests the {@link IdentifiedObjects} static methods.
+ * This test class intentionally declares {@code testLookup()} method without {@link Test} annotation
+ * because those tests should not be executed only after the EPSG tests. Those tests will be executed
+ * by {@link CRSTest} instead.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.7
  * @module
  */
 public final strictfp class IdentifiedObjectsTest extends TestCase {
@@ -73,4 +79,40 @@ public final strictfp class IdentifiedOb
         assertTrue (isHeuristicMatchForName(object, "Réunion"));
         assertTrue (isHeuristicMatchForName(object, "Reunion"));
     }
+
+    /**
+     * Tests {@link IdentifiedObjects#lookupEPSG(IdentifiedObject)} and
+     * {@link IdentifiedObjects#lookupURN(IdentifiedObject, Citation)}
+     * with a CRS which is expected to be found in the EPSG dataset.
+     *
+     * <p>This method is intentionally not annotated with {@link Test}.
+     * See class javadoc for explanation.</p>
+     *
+     * @throws FactoryException if an error occurred during the lookup.
+     *
+     * @see CRSTest#testIdentifiedObjectLookup()
+     */
+    public static void testLookupEPSG() throws FactoryException {
+        assertEquals("EPSG:4326", Integer.valueOf(4326), IdentifiedObjects.lookupEPSG(HardCodedCRS.WGS84_φλ));
+        String urn = IdentifiedObjects.lookupURN(HardCodedCRS.WGS84_φλ, null);
+        assertTrue(urn, urn.matches("urn\\:ogc\\:def\\:crs\\:EPSG\\:.*\\:4326"));
+    }
+
+    /**
+     * Tests {@link IdentifiedObjects#lookupEPSG(IdentifiedObject)} and
+     * {@link IdentifiedObjects#lookupURN(IdentifiedObject, Citation)}.
+     * with a CRS which is expected to be found in the WMS definitions.
+     *
+     * <p>This method is intentionally not annotated with {@link Test}.
+     * See class javadoc for explanation.</p>
+     *
+     * @throws FactoryException if an error occurred during the lookup.
+     *
+     * @see CRSTest#testIdentifiedObjectLookup()
+     */
+    public static void testLookupWMS() throws FactoryException {
+        assertNull("CRS:84", IdentifiedObjects.lookupEPSG(HardCodedCRS.WGS84));
+        String urn = IdentifiedObjects.lookupURN(HardCodedCRS.WGS84, null);
+        assertTrue(urn, urn.matches("urn\\:ogc\\:def\\:crs\\:OGC\\:.*\\:CRS84"));
+    }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/StandardDefinitionsTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -32,7 +32,7 @@ import org.apache.sis.metadata.iso.citat
 import org.apache.sis.internal.util.Constants;
 
 // Test dependencies
-import org.apache.sis.test.mock.GeodeticDatumMock;
+import org.apache.sis.referencing.datum.GeodeticDatumMock;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -194,7 +194,7 @@ public final strictfp class StandardDefi
         crs = StandardDefinitions.createVerticalCRS(CommonCRS.Vertical.NAVD88.crs, datum);
         assertEquals("name", "NAVD88 height", crs.getName().getCode());
         assertEquals("identifier", "5703", IdentifiedObjects.getIdentifier(crs, Citations.EPSG).getCode());
-        assertEquals("identifier",   "88", IdentifiedObjects.getIdentifier(crs, Citations.OGC ).getCode());
+        assertEquals("identifier",   "88", IdentifiedObjects.getIdentifier(crs, Citations.WMS ).getCode());
         assertEquals("direction", AxisDirection.UP, crs.getCoordinateSystem().getAxis(0).getDirection());
 
         datum = StandardDefinitions.createVerticalDatum(CommonCRS.Vertical.MEAN_SEA_LEVEL.datum);

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/BursaWolfParametersTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -30,7 +30,6 @@ import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.apache.sis.test.Assert.*;
-import static org.apache.sis.test.mock.GeodeticDatumMock.WGS84;
 
 
 /**
@@ -52,7 +51,7 @@ public final strictfp class BursaWolfPar
      * Area of validity is the World.
      */
     static BursaWolfParameters createWGS72_to_WGS84() {
-        final BursaWolfParameters bursaWolf = new BursaWolfParameters(WGS84, Extents.WORLD);
+        final BursaWolfParameters bursaWolf = new BursaWolfParameters(GeodeticDatumMock.WGS84, Extents.WORLD);
         bursaWolf.tZ = 4.5;
         bursaWolf.rZ = 0.554;
         bursaWolf.dS = 0.219;
@@ -67,7 +66,7 @@ public final strictfp class BursaWolfPar
      * Area of validity is the North Sea: 5.05°W to 11.13°E in longitude and 51.04°N to 62.0°N in latitude.
      */
     static BursaWolfParameters createED87_to_WGS84() {
-        final BursaWolfParameters bursaWolf = new BursaWolfParameters(WGS84, new DefaultExtent("Europe - North Sea",
+        final BursaWolfParameters bursaWolf = new BursaWolfParameters(GeodeticDatumMock.WGS84, new DefaultExtent("Europe - North Sea",
                 new DefaultGeographicBoundingBox(-5.05, 11.13, 51.04, 62.0), null, null));
         bursaWolf.tX =  -82.981;
         bursaWolf.tY =  -99.719;
@@ -88,7 +87,7 @@ public final strictfp class BursaWolfPar
      * This transformation uses only translation parameters.
      */
     static BursaWolfParameters createNTF_to_WGS84() {
-        final BursaWolfParameters bursaWolf = new BursaWolfParameters(WGS84, Extents.WORLD);
+        final BursaWolfParameters bursaWolf = new BursaWolfParameters(GeodeticDatumMock.WGS84, Extents.WORLD);
         bursaWolf.tX = -168;
         bursaWolf.tY =  -60;
         bursaWolf.tZ =  320;

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java?rev=1727561&r1=1727560&r2=1727561&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java [UTF-8] Fri Jan 29 12:23:09 2016
@@ -22,7 +22,6 @@ import javax.measure.unit.NonSI;
 import org.apache.sis.measure.Latitude;
 import org.apache.sis.measure.Longitude;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.test.mock.GeodeticDatumMock;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.XMLTestCase;
 import org.apache.sis.test.DependsOn;




Mime
View raw message