sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jso...@apache.org
Subject svn commit: r1803139 - /sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java
Date Thu, 27 Jul 2017 08:36:14 GMT
Author: jsorel
Date: Thu Jul 27 08:36:13 2017
New Revision: 1803139

URL: http://svn.apache.org/viewvc?rev=1803139&view=rev
Log:
Fix NameToIdentifier.isHeuristicMatchForIdentifier, search result for names wihout separators
were always false.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java?rev=1803139&r1=1803138&r2=1803139&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/NameToIdentifier.java
[UTF-8] Thu Jul 27 08:36:13 2017
@@ -217,9 +217,17 @@ public final class NameToIdentifier impl
      */
     public static boolean isHeuristicMatchForIdentifier(final Iterable<? extends Identifier>
identifiers, final String toSearch) {
         if (toSearch != null && identifiers != null) {
-            for (int s = toSearch.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR); s >= 0;
-                     s = toSearch.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR, s))
-            {
+            int s = toSearch.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR);
+            if (s < 0) {
+                // no codespace in searched name
+                for (final Identifier id : identifiers) {
+                    if (toSearch.equalsIgnoreCase(id.getCode())) {
+                        return true;
+                    }
+                }
+                return false;
+            }
+            do {
                 final String codespace = toSearch.substring(0, s).trim();
                 final String code = toSearch.substring(++s).trim();
                 for (final Identifier id : identifiers) {
@@ -227,7 +235,8 @@ public final class NameToIdentifier impl
                         return true;
                     }
                 }
-            }
+                s = toSearch.indexOf(DefaultNameSpace.DEFAULT_SEPARATOR, s);
+            } while (s >= 0);
         }
         return false;
     }



Mime
View raw message