sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1708453 [2/2] - in /sis/trunk: ./ core/sis-build-helper/src/main/java/org/apache/sis/util/resources/ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ core/sis-re...
Date Tue, 13 Oct 2015 15:53:45 GMT
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java?rev=1708453&r1=1708452&r2=1708453&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
[UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/DefinitionURI.java
[UTF-8] Tue Oct 13 15:53:44 2015
@@ -18,7 +18,6 @@ package org.apache.sis.internal.util;
 
 import java.util.Map;
 import java.util.Collections;
-import org.opengis.referencing.ReferenceIdentifier;
 
 import static org.apache.sis.util.CharSequences.*;
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -97,9 +96,10 @@ import static org.apache.sis.internal.ut
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.7
  * @module
  *
+ * @see org.apache.sis.internal.metadata.NameMeaning
  * @see <a href="http://portal.opengeospatial.org/files/?artifact_id=24045">Definition
identifier URNs in OGC namespace</a>
  * @see <a href="http://www.opengeospatial.org/ogcna">OGC Naming Authority</a>
  */
@@ -132,17 +132,25 @@ public final class DefinitionURI {
 
     /**
      * The type part of a URI, or {@code null} if none (empty).
+     * Note that the set of valid types in OGC namespace is restricted.
+     * See class javadoc for more information.
      *
      * <div class="note"><b>Example:</b>
      * In the {@code "urn:ogc:def:crs:EPSG:8.2:4326"} URN, this is {@code "crs"}.</div>
+     *
+     * @see org.apache.sis.internal.metadata.NameMeaning#toObjectType(Class)
      */
     public String type;
 
     /**
      * The authority part of a URI, or {@code null} if none (empty).
+     * Note that the set of valid authorities in OGC namespace is restricted.
+     * See class javadoc for more information.
      *
      * <div class="note"><b>Example:</b>
      * In the {@code "urn:ogc:def:crs:EPSG:8.2:4326"} URN, this is {@code "EPSG"}.</div>
+     *
+     * @see org.apache.sis.internal.metadata.NameMeaning#authority(String)
      */
     public String authority;
 
@@ -451,19 +459,21 @@ public final class DefinitionURI {
      * version and code are appended omitting any characters that are not valid for a Unicode
identifier.
      * If some information are missing in the given identifier, then this method returns
{@code null}.
      *
-     * @param  type The object type, as one of the type documented in class javadoc, or {@code
null}.
-     * @param  identifier The identifier to format.
-     * @return An identifier using the URN syntax, or {@code null} if an information is missing.
+     * @param  type      The object type as one of the types documented in class javadoc,
or {@code null}.
+     * @param  authority The authority as one of the values documented in class javadoc,
or {@code null}.
+     * @param  version   The code version, or {@code null}. This is the only optional information.
+     * @param  code      The code, or {@code null}.
+     * @return An identifier using the URN syntax, or {@code null} if a mandatory information
is missing.
      */
-    public static String format(final String type, final ReferenceIdentifier identifier)
{
+    public static String format(final String type, final String authority, final String version,
final String code) {
         final StringBuilder buffer = new StringBuilder(PREFIX);
         for (int p=0; p<4; p++) {
             final String component;
             switch (p) {
-                case 0:  component = type;                      break;
-                case 1:  component = identifier.getCodeSpace(); break;
-                case 2:  component = identifier.getVersion();   break;
-                case 3:  component = identifier.getCode();      break;
+                case 0:  component = type;      break;
+                case 1:  component = authority; break;
+                case 2:  component = version;   break;
+                case 3:  component = code;      break;
                 default: throw new AssertionError(p);
             }
             if (!appendUnicodeIdentifier(buffer.append(SEPARATOR), '\u0000', component, ".-",
false)) {

Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/DefinitionURITest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/DefinitionURITest.java?rev=1708453&r1=1708452&r2=1708453&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/DefinitionURITest.java
[UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/DefinitionURITest.java
[UTF-8] Tue Oct 13 15:53:44 2015
@@ -17,8 +17,6 @@
 package org.apache.sis.internal.util;
 
 import org.opengis.referencing.ReferenceIdentifier;
-import org.apache.sis.internal.simple.SimpleIdentifier;
-import org.apache.sis.internal.simple.SimpleCitation;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -151,7 +149,7 @@ public final strictfp class DefinitionUR
      */
     @Test
     public void testToURN() {
-        final ReferenceIdentifier identifier = new SimpleIdentifier(new SimpleCitation("EPSG"),
"4326", false);
-        assertEquals("urn:ogc:def:crs:EPSG::4326", DefinitionURI.format("crs", identifier));
+        assertEquals("urn:ogc:def:crs:EPSG::4326", DefinitionURI.format("crs", "EPSG", null,
"4326"));
+        assertNull  ("Authority is not optional.", DefinitionURI.format("crs", null,   null,
"4326"));
     }
 }



Mime
View raw message