+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.bin;
+import jalview.util.Platform;
+
import java.net.URLDecoder;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
/**
* Notes: this argParser does not distinguish between parameter switches,
*/
public class ArgsParser
{
- Vector<String> vargs = null;
+
+ // BH 2019 - new
+
+ public static final String NOCALCULATION = "nocalculation";
+
+ public static final String NOMENUBAR = "nomenubar";
+
+ public static final String NOSTATUS = "nostatus";
+
+ public static final String SHOWOVERVIEW = "showoverview";
+
+ //
+ public static final String ANNOTATIONS = "annotations";
+
+ public static final String COLOUR = "colour";
+
+ public static final String FEATURES = "features";
+
+ public static final String GROOVY = "groovy";
+
+ public static final String GROUPS = "groups";
+
+ public static final String HEADLESS = "headless";
+
+ public static final String JABAWS = "jabaws";
+
+ public static final String NOANNOTATION = "no-annotation";
+
+ public static final String NOANNOTATION2 = "noannotation"; // BH 2019.05.07
+
+ public static final String NODISPLAY = "nodisplay";
+
+ public static final String NOGUI = "nogui";
+
+ public static final String NONEWS = "nonews";
+
+ public static final String NOQUESTIONNAIRE = "noquestionnaire";
+
+ public static final String NOSORTBYTREE = "nosortbytree";
+
+ public static final String NOUSAGESTATS = "nousagestats";
+
+ public static final String OPEN = "open";
+
+ public static final String OPEN2 = "open2"; // BH added -- for applet
+ // compatibility; not fully
+ // implemented
+
+ public static final String PROPS = "props";
+
+ public static final String QUESTIONNAIRE = "questionnaire";
+
+ public static final String SETPROP = "setprop";
+
+ public static final String SORTBYTREE = "sortbytree";
+
+ public static final String TREE = "tree";
+
+ public static final String VDOC = "vdoc";
+
+ public static final String VSESS = "vsess";
+
+ private List<String> vargs = null;
+
+ private boolean isApplet;
+
+ private AppletParams appletParams;
+
+ public boolean isApplet()
+ {
+ return isApplet;
+ }
public ArgsParser(String[] args)
{
- vargs = new Vector<String>();
- for (int i = 0; i < args.length; i++)
+ vargs = new ArrayList<>();
+ isApplet = (args.length > 0 && args[0].startsWith("<applet"));
+ if (isApplet)
+ {
+ appletParams = AppletParams.getAppletParams(args, vargs);
+ }
+ else
{
- String arg = args[i].trim();
- if (arg.charAt(0) == '-')
+ if (Platform.isJS())
+
+ {
+ isApplet = true;
+ appletParams = AppletParams
+ .getAppletParams(Platform.getAppletInfoAsMap(), vargs);
+ }
+ for (int i = 0; i < args.length; i++)
{
- arg = arg.substring(1);
+ String arg = args[i].trim();
+ if (arg.charAt(0) == '-')
+ {
+ arg = arg.substring(1);
+ }
+ vargs.add(arg);
}
- vargs.addElement(arg);
}
}
String dc = null, ret = null;
if (index != -1)
{
- ret = vargs.elementAt(index + 1).toString();
- vargs.removeElementAt(index);
- vargs.removeElementAt(index);
+ ret = vargs.get(index + 1).toString();
+ vargs.remove(index);
+ vargs.remove(index);
if (utf8decode && ret != null)
{
try
{
if (vargs.contains(arg))
{
- vargs.removeElement(arg);
+ vargs.remove(arg);
return true;
}
else
return vargs.size();
}
-}
\ No newline at end of file
+ public Object getAppletValue(String key, String def, boolean asString)
+ {
+ Object value;
+ return (appletParams == null ? null
+ : (value = appletParams.get(key.toLowerCase())) == null
+ ? def : asString ? "" + value
+ : value);
+ }
+
+}