From 2064b1ccb9520d4135775c522fdd41971ad55042 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 2 Feb 2015 16:43:10 +0000 Subject: [PATCH] JAL-715 tweaks for SRBS description string parsing --- src/jalview/ws/rest/RestServiceDescription.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/jalview/ws/rest/RestServiceDescription.java b/src/jalview/ws/rest/RestServiceDescription.java index 6f304a9..e60875d 100644 --- a/src/jalview/ws/rest/RestServiceDescription.java +++ b/src/jalview/ws/rest/RestServiceDescription.java @@ -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 jv = new ArrayList(); 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()) { -- 1.7.10.2