sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1727156 - in /sis/branches/JDK7: ./ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ core/sis-referencing/src/main/java/org/apache/sis/referencing/ core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ core/sis...
Date Wed, 27 Jan 2016 19:01:00 GMT
Author: desruisseaux
Date: Wed Jan 27 19:01:00 2016
New Revision: 1727156

URL: http://svn.apache.org/viewvc?rev=1727156&view=rev
Log:
Merge tests from the JDK8 branch.

Added:
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java
      - copied unchanged from r1727153, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactoryTest.java
Modified:
    sis/branches/JDK7/   (props changed)
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
    sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/DefinitionURITest.java

Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 27 19:01:00 2016
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
 /sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1726916
+/sis/branches/JDK8:1584960-1727153
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -81,6 +81,7 @@ import org.apache.sis.internal.util.Cita
  * @module
  *
  * @see ImmutableIdentifier
+ * @see org.apache.sis.referencing.IdentifiedObjects#toURN(Class, Identifier)
  */
 @XmlType(name = "MD_Identifier_Type", propOrder = {
     "authority",

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -126,6 +126,7 @@ import java.util.Objects;
  * @module
  *
  * @see DefaultIdentifier
+ * @see org.apache.sis.referencing.IdentifiedObjects#toURN(Class, Identifier)
  */
 @XmlType(name = "RS_Identifier_Type", propOrder = {
     "authority",

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -131,15 +131,15 @@ public final class CRS extends Static {
      *   <li>{@code "http://www.opengis.net/gml/srs/epsg.xml#4326"}</li>
      * </ul>
      *
-     * The {@link IdentifiedObjects#lookupURN(IdentifiedObject, Citation)} method can be seen
-     * as a converse of this method.
+     * Note that the {@link IdentifiedObjects#lookupURN(IdentifiedObject, Citation)}
+     * method can be seen as a converse of this method.
      *
      * @param  code The authority code.
      * @return The Coordinate Reference System for the given authority code.
      * @throws NoSuchAuthorityCodeException If there is no known CRS associated to the given code.
      * @throws FactoryException if the CRS creation failed for an other reason.
      *
-     * @see #getAuthorityFactory()
+     * @see #getAuthorityFactory(String)
      * @see org.apache.sis.referencing.factory.GeodeticAuthorityFactory
      *
      * @category factory
@@ -552,31 +552,39 @@ check:  while (lower != 0 || upper != di
 
     /**
      * Returns the system-wide authority factory used by {@link #forCode(String)} and other SIS methods.
-     * By default, this method returns an instance of {@link org.apache.sis.referencing.factory.MultiAuthoritiesFactory}
-     * capable to process at least some EPSG and WMS codes. The set of EPSG codes that are guaranteed to be supported
-     * is listed in the {@link #forCode(String)} method javadoc.
-     * Other authorities may also be supported if their factories are declared in the following file:
+     * If the given authority is non-null, then this method returns a factory specifically for that authority.
+     * Otherwise, this method returns the {@link org.apache.sis.referencing.factory.MultiAuthoritiesFactory}
+     * instance that manages all other factories.
+     *
+     * <p>The {@code authority} argument can be {@code "EPSG"}, {@code "OGC"} or any other authority found
+     * on the classpath. In the {@code "EPSG"} case, whether the full set of EPSG codes is supported or not
+     * depends on whether a {@linkplain org.apache.sis.referencing.factory.sql connection to the database}
+     * can be established. If no connection can be established, then this method returns a small embedded
+     * EPSG factory containing at least the CRS defined in the {@link #forCode(String)} method javadoc.</p>
+     *
+     * <p>User-defined authorities can be added to the SIS environment by creating a {@code CRSAuthorityFactory}
+     * implementation with a public no-argument constructor, and declaring the fully-qualified name of that class
+     * in a file at the following location:</p>
      *
      * {@preformat text
      *     META-INF/services/org.opengis.referencing.crs.CRSAuthorityFactory
      * }
      *
-     * <div class="section">Factories of other kinds</div>
-     * By default the returned factory can also be used as
-     * {@link org.opengis.referencing.cs.CSAuthorityFactory},
-     * {@link org.opengis.referencing.datum.DatumAuthorityFactory} or
-     * {@link org.opengis.referencing.operation.CoordinateOperationAuthorityFactory}.
-     * However callers are encouraged to verify the type before to cast
-     * since a future SIS version may allow users to set a custom factory.
-     *
-     * @return The system-wide authority factory used by SIS.
+     * @param  authority The authority of the desired factory (typically {@code "EPSG"} or {@code "OGC"}),
+     *         or {@code null} for the {@link org.apache.sis.referencing.factory.MultiAuthoritiesFactory}
+     *         instance that manage all factories.
+     * @return The system-wide authority factory used by SIS for the given authority.
+     * @throws FactoryException if no factory can be returned for the given authority.
      *
      * @see #forCode(String)
      * @see org.apache.sis.referencing.factory.MultiAuthoritiesFactory
      *
      * @since 0.7
      */
-    public static CRSAuthorityFactory getAuthorityFactory() {
-        return AuthorityFactories.ALL;
+    public static CRSAuthorityFactory getAuthorityFactory(final String authority) throws FactoryException {
+        if (authority == null) {
+            return AuthorityFactories.ALL;
+        }
+        return AuthorityFactories.ALL.getAuthorityFactory(CRSAuthorityFactory.class, authority, null);
     }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -35,11 +35,13 @@ import org.apache.sis.util.CharSequences
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.iso.DefaultNameSpace;
+import org.apache.sis.internal.util.Constants;
 import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.internal.metadata.NameMeaning;
 import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.referencing.factory.IdentifiedObjectFinder;
+import org.apache.sis.referencing.factory.GeodeticAuthorityFactory;
 
 import static org.apache.sis.internal.util.Citations.iterator;
 import static org.apache.sis.internal.util.Citations.identifierMatches;
@@ -381,8 +383,8 @@ public final class IdentifiedObjects ext
      * If the given object declares explicitly an identifier, then this method will instantiate an object from the
      * authority factory using that identifier and compare it with the given object. If the comparison fails, then
      * this method returns {@code null}. Consequently this method may return {@code null} even if the given object
-     * declares explicitly its identifier. If the declared identifier is wanted unconditionally, use the following
-     * pattern instead:
+     * declares explicitly its identifier. If the declared identifier is wanted unconditionally,
+     * one can use the following pattern instead:
      *
      * {@preformat java
      *     String urn = toURN(object.getClass(), getIdentifier(object, authority));
@@ -397,7 +399,7 @@ public final class IdentifiedObjects ext
      * @return The identifier, or {@code null} if none was found without ambiguity or if the given object was null.
      * @throws FactoryException if an error occurred during the search.
      *
-     * @see #newFinder()
+     * @see #newFinder(String)
      * @see #toURN(Class, Identifier)
      *
      * @since 0.7
@@ -405,7 +407,7 @@ public final class IdentifiedObjects ext
     public static String lookupURN(final IdentifiedObject object, final Citation authority) throws FactoryException {
         String urn = null;
         if (object != null) {
-            for (final IdentifiedObject candidate : newFinder().find(object)) {
+            for (final IdentifiedObject candidate : newFinder(null).find(object)) {
                 final String c = toURN(candidate.getClass(), getIdentifier(candidate, authority));
                 if (c != null) {
                     if (urn != null && !urn.equals(c)) {
@@ -428,8 +430,8 @@ public final class IdentifiedObjects ext
      * If the given object declares explicitly an identifier, then this method will instantiate an object from the
      * EPSG factory using that identifier and compare it with the given object. If the comparison fails, then this
      * method returns {@code null}. Consequently this method may return {@code null} even if the given object
-     * declares explicitly its identifier. If the declared identifier is wanted unconditionally, use the following
-     * pattern instead:
+     * declares explicitly its identifier. If the declared identifier is wanted unconditionally,
+     * one can use the following pattern instead:
      *
      * {@preformat java
      *     String code = toString(getIdentifier(object, Citations.EPSG));
@@ -442,14 +444,14 @@ public final class IdentifiedObjects ext
      * @return The EPSG code, or {@code null} if none was found without ambiguity or if the given object was null.
      * @throws FactoryException if an error occurred during the search.
      *
-     * @see #newFinder()
+     * @see #newFinder(String)
      *
      * @since 0.7
      */
     public static Integer lookupEPSG(final IdentifiedObject object) throws FactoryException {
         Integer code = null;
         if (object != null) {
-            for (final IdentifiedObject candidate : newFinder().find(object)) {
+            for (final IdentifiedObject candidate : newFinder(Constants.EPSG).find(object)) {
                 final Identifier id = getIdentifier(candidate, Citations.EPSG);
                 if (id != null) try {
                     Integer previous = code;
@@ -471,39 +473,45 @@ public final class IdentifiedObjects ext
      *
      * <div class="note"><b>Example 1: be lenient regarding axis order</b><br>
      * By default, {@code lookup(…)} methods require that objects in the dataset have their axes in the
-     * same order than the given object. For relaxing this condition, one can use the following Java code:
+     * same order than the given object. For relaxing this condition, one can use the following Java code.
+     * This example assumes that at most one object from the dataset will match the given object.
+     * If more than one object may match, then the call to {@code findSingleton(…)} should be replaced
+     * by {@code find(…)}.
      *
      * {@preformat java
-     *     IdentifiedObjectFinder finder = IdentifiedObjects.newFinder();
+     *     IdentifiedObjectFinder finder = IdentifiedObjects.newFinder(null);
      *     finder.setIgnoringAxes(true);
      *     IdentifiedObject found = finder.findSingleton(object);
-     * }
-     *
-     * This example assumes that at most one object from the dataset will match the given object.
-     * If more than one object may match, then the call to {@code findSingleton(…)} should be replaced
-     * by {@code find(…)}.</div>
+     * }</div>
      *
      * <div class="note"><b>Example 2: extend the search to deprecated definitions</b><br>
      * By default, {@code lookup(…)} methods exclude deprecated objects from the search.
      * To search also among deprecated objects, one can use the following Java code:
+     * This example does not use the {@code findSingleton(…)} convenience method on the assumption
+     * that the search may find both deprecated and non-deprecated objects.
      *
      * {@preformat java
-     *     IdentifiedObjectFinder finder = IdentifiedObjects.newFinder();
+     *     IdentifiedObjectFinder finder = IdentifiedObjects.newFinder(null);
      *     finder.setSearchDomain(IdentifiedObjectFinder.Domain.ALL_DATASET);
      *     Set<IdentifiedObject> found = finder.find(object);
-     * }
-     *
-     * This example does not use the {@code findSingleton(…)} convenience method on the assumption
-     * that the search may find both deprecated and non-deprecated objects.</div>
+     * }</div>
      *
+     * @param  authority The authority of the objects to search (typically {@code "EPSG"} or {@code "OGC"}),
+     *         or {@code null} for searching among the objects created by all authorities.
      * @return A finder to use for looking up unidentified objects.
      * @throws FactoryException if the finder can not be created.
      *
      * @see org.apache.sis.referencing.factory.GeodeticAuthorityFactory#newIdentifiedObjectFinder()
      * @see IdentifiedObjectFinder#find(IdentifiedObject)
      */
-    public static IdentifiedObjectFinder newFinder() throws FactoryException {
-        return AuthorityFactories.ALL.newIdentifiedObjectFinder();
+    public static IdentifiedObjectFinder newFinder(final String authority) throws FactoryException {
+        final GeodeticAuthorityFactory factory;
+        if (authority == null) {
+            factory = AuthorityFactories.ALL;
+        } else {
+            factory = AuthorityFactories.ALL.getAuthorityFactory(GeodeticAuthorityFactory.class, authority, null);
+        }
+        return factory.newIdentifiedObjectFinder();
     }
 
     /**
@@ -552,40 +560,52 @@ public final class IdentifiedObjects ext
 
     /**
      * Returns the URN of the given identifier, or {@code null} if no valid URN can be formed.
-     * The given type should be assignable to one of the given types:
+     * This method builds a URN from the {@linkplain NamedIdentifier#getCodeSpace() codespace},
+     * {@linkplain NamedIdentifier#getVersion() version} and {@linkplain NamedIdentifier#getCode() code}
+     * of the given identifier, completed by the given {@link Class} argument.
+     *
+     * <p>First, this method starts the URN with {@code "urn:"} followed by a namespace determined
+     * from the identifier {@linkplain NamedIdentifier#getCodeSpace() codespace} (which is usually
+     * an abbreviation of the identifier {@linkplain NamedIdentifier#getAuthority() authority}).
+     * The recognized namespaces are listed in the following table
+     * (note that the list of authorities than can be used in the {@code "urn:ogc:def"} namespace
+     * is specified by the <a href="http://www.opengeospatial.org/ogcna">OGC Naming Authority</a>).
+     * If this method can not determine a namespace for the given identifier, it returns {@code null}.</p>
      *
      * <table class="sis">
-     *   <caption>Recognized object types in URN</caption>
-     *   <tr><th>Interface</th>                                                     <th>Type in URN</th>         <th>Meaning</th></tr>
-     *   <tr><td>{@link org.opengis.referencing.cs.CoordinateSystemAxis}</td>       <td>axis</td>                <td>Coordinate system axe definition</td></tr>
-     *   <tr><td>{@link org.opengis.referencing.operation.CoordinateOperation}</td> <td>coordinateOperation</td> <td>Coordinate operation definition</td></tr>
-     *   <tr><td>{@link org.opengis.referencing.crs.CoordinateReferenceSystem}</td> <td>crs</td>                 <td>Coordinate reference system definition</td></tr>
-     *   <tr><td>{@link org.opengis.referencing.cs.CoordinateSystem}</td>           <td>cs</td>                  <td>Coordinate system definition</td></tr>
-     *   <tr><td>{@link org.opengis.referencing.datum.Datum}</td>                   <td>datum</td>               <td>Datum definition</td></tr>
-     *   <tr><td>{@link org.opengis.referencing.datum.Ellipsoid}</td>               <td>ellipsoid</td>           <td>Ellipsoid definition</td></tr>
-     *   <tr><td>{@link org.opengis.referencing.datum.PrimeMeridian}</td>           <td>meridian</td>            <td>Prime meridian definition</td></tr>
-     *   <tr><td>{@link org.opengis.referencing.operation.OperationMethod}</td>     <td>method</td>              <td>Operation method definition</td></tr>
-     *   <tr><td>{@link org.opengis.parameter.ParameterDescriptor}</td>             <td>parameter</td>           <td>Operation parameter definition</td></tr>
-     *   <tr><td>{@link org.opengis.referencing.ReferenceSystem}</td>               <td>referenceSystem</td>     <td>Value reference system definition</td></tr>
-     *   <tr><td>{@link javax.measure.unit.Unit}</td>                               <td>uom</td>                 <td>Unit of measure definition</td></tr>
+     *   <caption>Valid values for the authority component in URN</caption>
+     *   <tr><th>Namespace</th>           <th>Authority in URN</th> <th>Description</th></tr>
+     *   <tr><td>{@code urn:ogc:def}</td> <td>{@code EPSG}</td>     <td>EPSG dataset</td></tr>
+     *   <tr><td>{@code urn:ogc:def}</td> <td>{@code OGC}</td>      <td>Open Geospatial Consortium</td></tr>
+     *   <tr><td>{@code urn:ogc:def}</td> <td>{@code OGC-WFS}</td>  <td>OGC Web Feature Service</td></tr>
+     *   <tr><td>{@code urn:ogc:def}</td> <td>{@code SI}</td>       <td>Système International d'Unités</td></tr>
+     *   <tr><td>{@code urn:ogc:def}</td> <td>{@code UCUM}</td>     <td>Unified Code for Units of Measure</td></tr>
+     *   <tr><td>{@code urn:ogc:def}</td> <td>{@code UNSD}</td>     <td>United Nations Statistics Division</td></tr>
+     *   <tr><td>{@code urn:ogc:def}</td> <td>{@code USNO}</td>     <td>United States Naval Observatory</td></tr>
      * </table>
      *
-     * In addition, the identifier codespace shall be one of the following authorities:
+     * The namespace is followed by the authority, then by a type determined from the given {@link Class} argument.
+     * That class is usually determined simply by {@code IdentifiedObject.getClass()}.
+     * The given class shall be assignable to one of the following types, otherwise this method returns {@code null}:
      *
      * <table class="sis">
-     *   <caption>Recognized authorities in URN</caption>
-     *   <tr><th>Namespace</th> <th>Authority</th>         <th>Description</th></tr>
-     *   <tr><td>OGC</td>       <td>{@code "EPSG"}</td>    <td>EPSG dataset</td></tr>
-     *   <tr><td>OGC</td>       <td>{@code "OGC"}</td>     <td>Open Geospatial Consortium</td></tr>
-     *   <tr><td>OGC</td>       <td>{@code "OGC-WFS"}</td> <td>OGC Web Feature Service</td></tr>
-     *   <tr><td>OGC</td>       <td>{@code "SI"}</td>      <td>Système International d'Unités</td></tr>
-     *   <tr><td>OGC</td>       <td>{@code "UCUM"}</td>    <td>Unified Code for Units of Measure</td></tr>
-     *   <tr><td>OGC</td>       <td>{@code "UNSD"}</td>    <td>United Nations Statistics Division</td></tr>
-     *   <tr><td>OGC</td>       <td>{@code "USNO"}</td>    <td>United States Naval Observatory</td></tr>
+     *   <caption>Valid values for the type component in URN</caption>
+     *   <tr><th>Interface</th>                                                     <th>Type in URN</th>                 <th>Description</th></tr>
+     *   <tr><td>{@link org.opengis.referencing.cs.CoordinateSystemAxis}</td>       <td>{@code axis}</td>                <td>Coordinate system axe definition</td></tr>
+     *   <tr><td>{@link org.opengis.referencing.operation.CoordinateOperation}</td> <td>{@code coordinateOperation}</td> <td>Coordinate operation definition</td></tr>
+     *   <tr><td>{@link org.opengis.referencing.crs.CoordinateReferenceSystem}</td> <td>{@code crs}</td>                 <td>Coordinate reference system definition</td></tr>
+     *   <tr><td>{@link org.opengis.referencing.cs.CoordinateSystem}</td>           <td>{@code cs}</td>                  <td>Coordinate system definition</td></tr>
+     *   <tr><td>{@link org.opengis.referencing.datum.Datum}</td>                   <td>{@code datum}</td>               <td>Datum definition</td></tr>
+     *   <tr><td>{@link org.opengis.referencing.datum.Ellipsoid}</td>               <td>{@code ellipsoid}</td>           <td>Ellipsoid definition</td></tr>
+     *   <tr><td>{@link org.opengis.referencing.datum.PrimeMeridian}</td>           <td>{@code meridian}</td>            <td>Prime meridian definition</td></tr>
+     *   <tr><td>{@link org.opengis.referencing.operation.OperationMethod}</td>     <td>{@code method}</td>              <td>Operation method definition</td></tr>
+     *   <tr><td>{@link org.opengis.parameter.ParameterDescriptor}</td>             <td>{@code parameter}</td>           <td>Operation parameter definition</td></tr>
+     *   <tr><td>{@link org.opengis.referencing.ReferenceSystem}</td>               <td>{@code referenceSystem}</td>     <td>Value reference system definition</td></tr>
+     *   <tr><td>{@link javax.measure.unit.Unit}</td>                               <td>{@code uom}</td>                 <td>Unit of measure definition</td></tr>
      * </table>
      *
-     * The reason why the authorities are restricted to the above white list is because this method formats a URN
-     * in the OGC namespace. Consequently the URN should use only components recognized by the OGC Naming Authority.
+     * The type is followed by the {@linkplain NamedIdentifier#getVersion() codespace version} if available,
+     * and finally by the {@linkplain NamedIdentifier#getCode() code} value.
      *
      * <p>The above tables may be expanded in any future SIS version.</p>
      *

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/CommonAuthorityFactory.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -48,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;
@@ -56,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;
@@ -284,6 +286,19 @@ public class CommonAuthorityFactory exte
     }
 
     /**
+     * Rewrites the given code in a canonical format.
+     * If the code can not be reformatted, then this method returns {@code null}.
+     */
+    static String reformat(final String code) {
+        try {
+            return format(Integer.parseInt(code.substring(skipNamespace(code) & ~LEGACY_MASK)));
+        } catch (NoSuchAuthorityCodeException | NumberFormatException e) {
+            Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY), CommonAuthorityFactory.class, "reformat", e);
+            return null;
+        }
+    }
+
+    /**
      * Returns the index where the code begins, ignoring spaces and the {@code "OGC"}, {@code "CRS"}, {@code "AUTO"},
      * {@code "AUTO1"} or {@code "AUTO2"} namespaces if present. If a namespace is found and is a legacy one, then
      * this {@link #LEGACY_MASK} bit will be set.
@@ -352,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) {
@@ -368,15 +382,22 @@ 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.
         }
     }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -218,13 +218,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;
 
@@ -310,6 +312,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() {
@@ -474,6 +478,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.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/FilteredCodes.java [UTF-8] Wed Jan 27 19:01:00 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/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticAuthorityFactory.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -1156,6 +1156,8 @@ public abstract class GeodeticAuthorityF
      *
      * @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);

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/MultiAuthoritiesFactory.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -124,6 +124,8 @@ import org.apache.sis.internal.jdk8.JDK8
  * @since   0.7
  * @version 0.7
  * @module
+ *
+ * @see org.apache.sis.referencing.CRS#getAuthorityFactory(String)
  */
 public class MultiAuthoritiesFactory extends GeodeticAuthorityFactory implements CRSAuthorityFactory,
         CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory
@@ -663,12 +665,12 @@ public class MultiAuthoritiesFactory ext
                 }
             } else if (type >= AuthorityFactoryIdentifier.GEODETIC) {
                 /*
-                 * Special cases: if the requested factory is ANY, take the first factory that we can found
+                 * Special cases: if the requested factory is ANY, take the first factory that we can find
                  * regardless of its type. We will try CRS, CS, DATUM and OPERATION factories in that order.
                  * The GEODETIC type is like ANY except for the additional restriction that the factory shall
                  * be an instance of the SIS-specific GeodeticAuthorityFactory class.
                  */
-                assert providers.length < Math.min(type, Byte.MAX_VALUE) : type;
+                assert providers.length <= Math.min(type, Byte.MAX_VALUE) : type;
                 for (byte i=0; i < providers.length; i++) {
                     factory = getAuthorityFactory(request.newType(i));
                     switch (type) {
@@ -760,7 +762,7 @@ public class MultiAuthoritiesFactory ext
             int end = CharSequences.skipTrailingWhitespaces(code, 0, afterAuthority);
             int start = CharSequences.skipLeadingWhitespaces(code, 0, end);
             if (start >= end) {
-                throw new NoSuchAuthorityFactoryException(Errors.format(Errors.Keys.MissingAuthority_1, code), null);
+                throw new NoSuchAuthorityCodeException(Errors.format(Errors.Keys.MissingAuthority_1, code), null, code);
             }
             authority = code.substring(start, end);
             /*

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AuthorityFactoriesTest.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -16,13 +16,25 @@
  */
 package org.apache.sis.referencing;
 
+import java.util.Collection;
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.NoSuchAuthorityCodeException;
+import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.crs.CRSAuthorityFactory;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.crs.GeographicCRS;
-import org.opengis.util.FactoryException;
+import org.apache.sis.util.ComparisonMode;
+import org.apache.sis.util.logging.Logging;
 import org.apache.sis.internal.system.Loggers;
+import org.apache.sis.internal.util.Constants;
+import org.apache.sis.referencing.crs.HardCodedCRS;
+import org.apache.sis.referencing.factory.IdentifiedObjectFinder;
+import org.apache.sis.referencing.factory.NoSuchAuthorityFactoryException;
+
+// Test imports
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.LoggingWatcher;
 import org.apache.sis.test.TestCase;
-import org.apache.sis.util.logging.Logging;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -116,4 +128,113 @@ public final strictfp class AuthorityFac
         assertEquals(0, listener.maximumLogCount);
         assertSame(crs, factory.createGeographicCRS("urn:ogc:def:crs:EPSG::4326"));
     }
+
+    /**
+     * Tests the {@code createCoordinateReferenceSystem(…)} method with various code.
+     *
+     * @throws FactoryException if a CRS creation failed.
+     */
+    @Test
+    @DependsOnMethod("testCRS84")
+    public void testCreateCRS() throws FactoryException {
+        final CRSAuthorityFactory factory = AuthorityFactories.ALL;
+        final CRSAuthorityFactory wms = AuthorityFactories.ALL.getAuthorityFactory(CRSAuthorityFactory.class, Constants.OGC, null);
+        CoordinateReferenceSystem actual, expected;
+
+        actual   = factory.createCoordinateReferenceSystem("CRS:84");
+        expected = wms.createCoordinateReferenceSystem("84");
+        assertSame(expected, actual);
+        assertSame(expected, factory.createObject("CRS:84"));
+
+        actual   = factory .createCoordinateReferenceSystem("AUTO:42001,0,0");
+        expected = wms.createCoordinateReferenceSystem("42001,0,0");
+        assertSame(expected, actual);
+        assertSame(expected, factory.createObject("AUTO:42001,0,0"));
+
+        actual   = factory.createCoordinateReferenceSystem("CRS:27");
+        expected = wms.createCoordinateReferenceSystem("27");
+        assertSame(expected, actual);
+        assertSame(expected, factory.createObject("CRS:27"));
+
+        try {
+            factory.createCoordinateReferenceSystem("84");
+            fail("Should not work without authority.");
+        } catch (NoSuchAuthorityCodeException exception) {
+            // This is the expected exception.
+            assertEquals("84", exception.getAuthorityCode());
+        }
+
+        try {
+            factory.createCoordinateReferenceSystem("FOO:84");
+            fail("Should not work with unknown authority.");
+        } catch (NoSuchAuthorityFactoryException exception) {
+            // This is the expected exception.
+            assertEquals("FOO", exception.getAuthority());
+        }
+    }
+
+    /**
+     * Tests creation of CRS from codes in the {@code "http://www.opengis.net/gml/srs/"} name space.
+     *
+     * @throws FactoryException if a CRS creation failed.
+     */
+    @Test
+    public void testHttp() throws FactoryException {
+        final CRSAuthorityFactory factory = AuthorityFactories.ALL;
+        final CRSAuthorityFactory wms = AuthorityFactories.ALL.getAuthorityFactory(CRSAuthorityFactory.class, Constants.OGC, null);
+        CoordinateReferenceSystem actual, expected;
+
+        actual   = factory.createCoordinateReferenceSystem("http://www.opengis.net/gml/srs/CRS#84");
+        expected = wms.createCoordinateReferenceSystem("84");
+        assertSame(expected, actual);
+
+        actual = factory.createCoordinateReferenceSystem("HTTP://WWW.OPENGIS.NET/GML/SRS/crs#84");
+        assertSame(expected, actual);
+
+        actual = factory.createCoordinateReferenceSystem("http://www.opengis.net/gml/srs/CRS.xml#84");
+        assertSame(expected, actual);
+
+        try {
+            factory.createCoordinateReferenceSystem("http://www.dummy.net/gml/srs/CRS#84");
+            fail("Should not accept http://www.dummy.net");
+        } catch (NoSuchAuthorityCodeException e) {
+            assertNotNull(e.getMessage());
+        }
+
+        try {
+            factory.createCoordinateReferenceSystem("http://www.opengis.net/gml/dummy/CRS#84");
+            fail("Should not accept “dummy” as an authority");
+        } catch (NoSuchAuthorityCodeException e) {
+            assertNotNull(e.getMessage());
+        }
+    }
+
+    /**
+     * Tests the {@code getAuthorityCodes(…)} method.
+     *
+     * @throws FactoryException if an error occurred while fetching the codes.
+     */
+    @Test
+    public void testGetAuthorityCodes() throws FactoryException {
+        final CRSAuthorityFactory factory = AuthorityFactories.ALL;
+        final Collection<String> codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
+        assertFalse(codes.isEmpty());
+        assertTrue(codes.contains("CRS:84"));
+        assertTrue(codes.contains("AUTO:42001") || codes.contains("AUTO2:42001"));
+    }
+
+    /**
+     * Tests the {@code IdentifiedObjectFinder.find(…)} method.
+     *
+     * @throws FactoryException if the operation failed creation failed.
+     */
+    @Test
+    public void testFind() throws FactoryException {
+        final CRSAuthorityFactory factory = AuthorityFactories.ALL;
+        final IdentifiedObjectFinder finder = AuthorityFactories.ALL.newIdentifiedObjectFinder();
+        final IdentifiedObject find = finder.findSingleton(HardCodedCRS.WGS84);
+        assertNotNull("With scan allowed, should find the CRS.", find);
+        assertTrue(HardCodedCRS.WGS84.equals(find, ComparisonMode.DEBUG));
+        assertSame(factory.createCoordinateReferenceSystem("CRS:84"), find);
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/AuthorityFactoryMock.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -52,8 +52,8 @@ import static org.junit.Assert.*;
  * @version 0.7
  * @module
  */
-public final strictfp class AuthorityFactoryMock extends GeodeticAuthorityFactory
-        implements CRSAuthorityFactory, CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory
+public final strictfp class AuthorityFactoryMock extends GeodeticAuthorityFactory implements CRSAuthorityFactory,
+        CSAuthorityFactory, DatumAuthorityFactory, CoordinateOperationAuthorityFactory, AutoCloseable
 {
     /**
      * The authority.
@@ -61,6 +61,12 @@ public final strictfp class AuthorityFac
     private final Citation authority;
 
     /**
+     * {@code true} if this factory has been closed by
+     * an explicit call to the {@link #close()} method.
+     */
+    private boolean closed;
+
+    /**
      * Creates a new factory for the given authority.
      *
      * @param authority The title of the authority to declare.
@@ -100,6 +106,7 @@ public final strictfp class AuthorityFac
      */
     @Override
     public Set<String> getAuthorityCodes(Class<? extends IdentifiedObject> type) {
+        assertFalse("This factory has been closed.", isClosed());
         final Set<String> codes = new LinkedHashSet<>();
         if (type.isAssignableFrom(GeocentricCRS.class)) add(codes, 4979);
         if (type.isAssignableFrom(GeographicCRS.class)) add(codes, 84, 4326);
@@ -117,6 +124,7 @@ public final strictfp class AuthorityFac
      */
     @Override
     public IdentifiedObject createObject(final String code) throws NoSuchAuthorityCodeException {
+        assertFalse("This factory has been closed.", isClosed());
         final int n;
         try {
             n = Integer.parseInt(trimNamespace(code));
@@ -151,6 +159,7 @@ public final strictfp class AuthorityFac
      */
     @Override
     public Unit<?> createUnit(final String code) throws NoSuchAuthorityCodeException {
+        assertFalse("This factory has been closed.", isClosed());
         final int n;
         try {
             n = Integer.parseInt(trimNamespace(code));
@@ -172,6 +181,7 @@ public final strictfp class AuthorityFac
      */
     @Override
     public Extent createExtent(final String code) throws NoSuchAuthorityCodeException {
+        assertFalse("This factory has been closed.", isClosed());
         final int n;
         try {
             n = Integer.parseInt(trimNamespace(code));
@@ -183,4 +193,20 @@ public final strictfp class AuthorityFac
             default: throw new NoSuchAuthorityCodeException(code, authority.getTitle().toString(), code);
         }
     }
+
+    /**
+     * Returns {@code true} if this factory has been closed
+     * by an explicit call to the {@link #close()} method.
+     */
+    final synchronized boolean isClosed() {
+        return closed;
+    }
+
+    /**
+     * Flags this factory as closed.
+     */
+    @Override
+    public synchronized void close() {
+        closed = true;
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -17,6 +17,7 @@
 package org.apache.sis.referencing.factory;
 
 import java.util.Arrays;
+import java.util.Set;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.NoninvertibleTransformException;
 import javax.measure.unit.SI;
@@ -91,6 +92,16 @@ public final strictfp class CommonAuthor
                 factory.getAuthorityCodes(VerticalCRS.class));
         assertSetEquals(Arrays.asList("CRS:1"),
                 factory.getAuthorityCodes(EngineeringCRS.class));
+
+        final Set<String> codes = factory.getAuthorityCodes(GeographicCRS.class);
+        assertFalse("CRS:1",      codes.contains("CRS:1"));
+        assertTrue ("CRS:27",     codes.contains("CRS:27"));
+        assertTrue ("CRS:83",     codes.contains("CRS:83"));
+        assertTrue ("CRS:84",     codes.contains("CRS:84"));
+        assertFalse("CRS:88",     codes.contains("CRS:88"));
+        assertTrue ("0084",       codes.contains("0084"));
+        assertFalse("0088",       codes.contains("0088"));
+        assertTrue ("OGC:CRS084", codes.contains("OGC:CRS084"));
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/EPSGFactoryTest.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -325,10 +325,7 @@ public final strictfp class EPSGFactoryT
         assertEpsgNameAndIdentifierEqual("Transverse Mercator", 9807, variant.getConversionFromBase().getMethod());
         assertEpsgNameAndIdentifierEqual("UTM zone 10N", 16010, variant.getConversionFromBase());
         verifyTransverseMercatorParmeters(crs.getConversionFromBase().getParameterValues(), -123);
-        assertEquals("Operation method", crs.getConversionFromBase().getMethod(),
-                                     variant.getConversionFromBase().getMethod());
-        assertEquals("Coordinate system", crs.getCoordinateSystem(),
-                                      variant.getCoordinateSystem());
+
         assertSame("Operation method", crs.getConversionFromBase().getMethod(),
                                    variant.getConversionFromBase().getMethod());
         assertSame("Coordinate system", crs.getCoordinateSystem(),

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -197,6 +197,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.CommonCRSTest.class,
     org.apache.sis.referencing.factory.CommonAuthorityFactoryTest.class,
     org.apache.sis.referencing.factory.AuthorityFactoryProxyTest.class,
+    org.apache.sis.referencing.factory.ConcurrentAuthorityFactoryTest.class,
     org.apache.sis.referencing.factory.IdentifiedObjectFinderTest.class,
     org.apache.sis.referencing.factory.MultiAuthoritiesFactoryTest.class,
     org.apache.sis.referencing.factory.sql.EPSGFactoryTest.class,

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -460,6 +460,7 @@ public final class DefinitionURI {
      * @param url       The URL to parse.
      * @param result    If non-null, store the type, authority and code in that object.
      */
+    @SuppressWarnings("fallthrough")
     private static String codeForGML(final String type, String authority, final String url, int lower,
             final DefinitionURI result)
     {
@@ -484,17 +485,24 @@ public final class DefinitionURI {
                 }
                 lower += authority.length();
                 int upper = url.length();
-                if (lower < upper && url.charAt(lower) == '.') {
-                    // Ignore the extension (typically ".xml", but we accept anything).
-                    if ((lower = url.indexOf('#', lower+1)) >= 0) {
-                        final String code = trimWhitespaces(url, lower+1, upper).toString();
-                        if (result != null) {
-                            result.isGML     = true;
-                            result.type      = entry.getKey();
-                            result.authority = authority;
-                            result.code      = code;
+                if (lower < upper) {
+                    switch (url.charAt(lower)) {
+                        case '.': {
+                            // Ignore the extension (typically ".xml", but we accept anything).
+                            lower = url.indexOf('#', lower + 1);
+                            if (lower < 0) continue;
+                            // Fall through
+                        }
+                        case '#': {
+                            final String code = trimWhitespaces(url, lower+1, upper).toString();
+                            if (result != null) {
+                                result.isGML     = true;
+                                result.type      = entry.getKey();
+                                result.authority = authority;
+                                result.code      = code;
+                            }
+                            return code;
                         }
-                        return code;
                     }
                 }
             }

Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/DefinitionURITest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/DefinitionURITest.java?rev=1727156&r1=1727155&r2=1727156&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/DefinitionURITest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/DefinitionURITest.java [UTF-8] Wed Jan 27 19:01:00 2016
@@ -134,6 +134,13 @@ public final strictfp class DefinitionUR
         assertEquals ("code",      "4326", parsed.code);
         assertNull   ("parameters",        parsed.parameters);
         assertEquals ("toString()", "http://www.opengis.net/gml/srs/epsg.xml#4326", parsed.toString());
+
+        final DefinitionURI withoutExtension = DefinitionURI.parse("http://www.opengis.net/gml/srs/epsg#4326");
+        assertNotNull("Should parse even if the .xml extension is missig.", withoutExtension);
+        assertEquals(parsed.toString(), withoutExtension.toString());
+
+        assertNull("Should not parse if no '#' character.",
+                DefinitionURI.parse("http://www.opengis.net/gml/srs/epsg?4326"));
     }
 
     /**



Mime
View raw message