{
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;
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 (cp<list.length())
{
}
if (jv.size()>0)
{ String[] v = new String[jv.size()];
- jv.copyInto(v);
+ for (int i=0; i<v.length; i++)
+ {
+ v[i] = (String) jv.elementAt(i);
+ }
jv.removeAllElements();
if (debug)
{
- System.err.println("Array from Tabbed List:\n"+v.length+"\n"+v.toString());
+ System.err.println("Array from '"+separator+"' separated List:\n"+v.length);
+ for (int i=0; i<v.length;i++)
+ {
+ System.err.println("item "+i+" '"+v[i]+"'");
+ }
}
return v;
}
if (debug)
{
- System.err.println("Empty Array from Tabbed List");
+ System.err.println("Empty Array from '"+separator+"' separated List");
}
return null;
}
-
- public String ArraytotabbedList(String[] list)
+ /**
+ * concatenate the list with separator
+ * @param list
+ * @return concatenated string
+ */
+ public String arrayToSeparatorList(String[] list)
{
StringBuffer v = new StringBuffer();
if (list!=null)
{
v.append(list[i]);
}
- v.append("\t");
+ v.append(separator);
}
if (list[list.length-1]!=null)
{ v.append(list[list.length-1]);
}
if (debug)
{
- System.err.println("Tabbed List:\n"+v.toString());
+ System.err.println("Returning '"+separator+"' separated List:\n");
+ System.err.println(v);
}
return v.toString();
}
if (debug)
{
- System.err.println("Empty Tabbed List\n");
+ System.err.println("Returning empty '"+separator+"' separated List\n");
}
return "";
}
*/
public String getFeatureGroups()
{
- String lst = ArraytotabbedList(currentAlignFrame.getFeatureGroups());
+ String lst = arrayToSeparatorList(currentAlignFrame.getFeatureGroups());
return lst;
}
/**
*/
public String getFeatureGroupsOn(AlignFrame alf)
{
- String lst = ArraytotabbedList(alf.getFeatureGroups());
+ String lst = arrayToSeparatorList(alf.getFeatureGroups());
return lst;
}
/**
*/
public String getFeatureGroupsOfState(boolean visible)
{
- return ArraytotabbedList(currentAlignFrame.getFeatureGroupsOfState(visible));
+ return arrayToSeparatorList(currentAlignFrame.getFeatureGroupsOfState(visible));
}
/**
* @param alf align frame to get groups of state visible
*/
public String getFeatureGroupsOfStateOn(AlignFrame alf, boolean visible)
{
- return ArraytotabbedList(alf.getFeatureGroupsOfState(visible));
+ return arrayToSeparatorList(alf.getFeatureGroupsOfState(visible));
} /**
* @param groups tab separated list of group names
* @param state true or false
public void setFeatureGroupStateOn(AlignFrame alf, String groups, boolean state)
{
boolean st = state;//!(state==null || state.equals("") || state.toLowerCase().equals("false"));
- alf.setFeatureGroupState(tabbedListToArray(groups), st);
+ alf.setFeatureGroupState(separatorListToArray(groups), st);
}
public void setFeatureGroupState(String groups, boolean state)
{
setFeatureGroupStateOn(currentAlignFrame, groups, state);
}
+ /**
+ * List separator string
+ * @return the separator
+ */
+ public String getSeparator()
+ {
+ return separator;
+ }
+ /**
+ * List separator string
+ * @param separator the separator to set
+ */
+ public void setSeparator(String separator)
+ {
+ this.separator = separator;
+ }
}