import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
import java.util.StringTokenizer;
+import org.jmol.util.ArrayUtil;
import compbio.metadata.Argument;
import compbio.metadata.Option;
import compbio.metadata.Parameter;
public static List<ArgumentI> getJwsArgsfromJaba(List jabargs)
{
+ return getJwsArgsfromJaba(jabargs, true);
+ }
+
+ public static List<ArgumentI> getJwsArgsfromJaba(List jabargs,
+ boolean sortByOpt)
+ {
List<ArgumentI> rgs = new ArrayList<ArgumentI>();
+ List<String> rgnames = new ArrayList<String>();
for (Object rg : jabargs)
{
- ArgumentI narg = (rg instanceof Parameter) ? new JabaParameter(
- (Parameter) rg) : (rg instanceof Option) ? new JabaOption(
- (Option) rg) : null;
+ ArgumentI narg = null;
+ String nargstring = null;
+ if (rg instanceof Parameter)
+ {
+ narg = new JabaParameter((Parameter) rg);
+ nargstring = narg.getName(); // just sort by name for this
+ }
+ else if (rg instanceof Option)
+ {
+ narg = new JabaOption((Option) rg);
+ nargstring = (String) ((Option) rg).getOptionNames().get(0);
+ }
if (narg == null)
{
throw new Error(
else
{
rgs.add(narg);
+ rgnames.add(nargstring);
}
}
- return rgs;
+ if (!sortByOpt)
+ {
+ return rgs;
+ }
+ ArgumentI[] rgssort = rgs.toArray(new ArgumentI[rgs.size()]);
+ String[] rgssorton = rgnames.toArray(new String[rgs.size()]);
+ jalview.util.QuickSort.sort(rgssorton, rgssort);
+ return Arrays.asList(rgssort);
}
public static List getJabafromJwsArgs(List<ArgumentI> jwsargs)