JAL-715 tweaks for SRBS description string parsing
authorJim Procter <jprocter@dundee.ac.uk>
Mon, 2 Feb 2015 16:43:10 +0000 (16:43 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Mon, 2 Feb 2015 16:43:10 +0000 (16:43 +0000)
src/jalview/ws/rest/RestServiceDescription.java

index 6f304a9..e60875d 100644 (file)
@@ -87,7 +87,8 @@ public class RestServiceDescription
     boolean diff = (gapCharacter != other.gapCharacter);
     diff |= vseparable != other.vseparable;
     diff |= hseparable != other.hseparable;
-    diff |= !(urlSuffix.equals(other.urlSuffix));
+    diff |= !(urlSuffix == null && other.urlSuffix == null || (urlSuffix != null
+            && other.urlSuffix != null && urlSuffix.equals(other.urlSuffix)));
     // TODO - robust diff that includes constants and reordering of URL
     // diff |= !(postUrl.equals(other.postUrl));
     // diff |= !inputParams.equals(other.inputParams);
@@ -356,7 +357,7 @@ public class RestServiceDescription
     return invalidMessage == null;
   }
 
-  private static boolean debug = false;
+  private static boolean debug = true;
 
   /**
    * parse the string into a list
@@ -369,7 +370,9 @@ public class RestServiceDescription
   {
     int seplen = separator.length();
     if (list == null || list.equals("") || list.equals(separator))
+    {
       return null;
+    }
     java.util.ArrayList<String> jv = new ArrayList<String>();
     int cp = 0, pos, escape;
     boolean wasescaped = false, wasquoted = false;
@@ -384,7 +387,6 @@ public class RestServiceDescription
         jv.set(jv.size() - 1,
                 lstitem = lstitem + separator
                         + list.substring(cp, pos + escape));
-
       }
       else
       {
@@ -392,15 +394,9 @@ public class RestServiceDescription
       }
       cp = pos + seplen;
       wasescaped = escape == -1;
-      if (!wasescaped)
-      {
-        // last separator may be in an unmatched quote
-        if (java.util.regex.Pattern.matches("('[^']*')*[^']*'", lstitem))
-        {
-          wasquoted = true;
-        }
-      }
-
+      // last separator may be in an unmatched quote
+      wasquoted = (java.util.regex.Pattern.matches(".*='[^']*(?!')",
+              lstitem));
     }
     if (cp < list.length())
     {