From 24ae41ac6530eb119671b2d6cc9db8110d2433e6 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 12 Oct 2007 11:03:00 +0000 Subject: [PATCH] added separator parameter with default of '|' to control the list separator to use, and better debug output. --- src/jalview/bin/JalviewLite.java | 87 ++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 17 deletions(-) diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index c61c516..5b103c5 100755 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -210,6 +210,22 @@ public class JalviewLite { debug = dbg.toLowerCase().equals("true"); } + /** + * get the separator parameter if present + */ + String sep = getParameter("separator"); + if (sep!=null) + { + if (sep.length()>0) + { separator = sep; + if (debug) + { + System.err.println("Separator set to '"+separator+"'"); + } + } else { + throw new Error("Invalid separator parameter - must be non-zero length"); + } + } int r = 255; int g = 255; int b = 255; @@ -727,17 +743,26 @@ public class JalviewLite return file; } } - - public String[] tabbedListToArray(String list) + /** + * separator used for separatorList + */ + protected String separator = "|"; // this is a safe(ish) separator - tabs don't work for firefox + /** + * parse the string into a list + * @param list + * @return elements separated by separator + */ + public String[] separatorListToArray(String list) { + int seplen = separator.length(); if (list==null || list.equals("")) return null; java.util.Vector jv = new Vector(); int cp=0,pos; - while ((pos=list.indexOf("\t",cp))>cp) + while ((pos=list.indexOf(separator,cp))>cp) { jv.addElement(list.substring(cp,pos)); - cp = pos+1; + cp = pos+seplen; } if (cp0) { String[] v = new String[jv.size()]; - jv.copyInto(v); + for (int i=0; i