2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.ws.params.simple;
23 import jalview.ws.params.OptionI;
26 import java.util.ArrayList;
27 import java.util.List;
29 public class Option implements OptionI
36 * current value in string format, or "null" if undefined
41 * default value in string format, or "null" if undefined
47 List<String> possibleVals;
50 * optional display names corresponding to possibleVals
52 List<String> displayVals;
63 public Option(Option opt)
68 defvalue = opt.defvalue;
69 description = opt.description;
70 if (opt.possibleVals != null)
72 possibleVals = new ArrayList<>(opt.possibleVals);
74 required = opt.required;
75 // URLs are singletons - so we copy by reference. nasty but true.
76 fdetails = opt.fdetails;
83 public Option(String name, String description, String label, boolean isrequired,
84 String defValue, String val, List<String> possibleVals, URL fdetails)
86 this(name, description, isrequired, defValue, val, possibleVals, fdetails);
91 * Constructor including display names for possible values
101 public Option(String name2, String description2, boolean isrequired,
102 String defValue, String val, List<String> possibleVals,
103 List<String> displayNames, URL fdetails)
106 description = description2;
108 this.required = isrequired;
109 this.defvalue = defValue;
110 if (possibleVals != null)
112 this.possibleVals = new ArrayList<>(possibleVals);
114 if (displayNames != null)
116 this.displayVals = new ArrayList<>(displayNames);
118 this.fdetails = fdetails;
125 * @param description2
129 * @param possibleVals
132 public Option(String name2, String description2, boolean isrequired,
133 String defValue, String val, List<String> possibleVals,
136 this(name2, description2, isrequired, defValue, val, possibleVals, null,
141 public OptionI copy()
143 Option opt = new Option(this);
148 * toString method to help identify options in the debugger only
151 public String toString()
153 return this.getClass().getName() + ":" + name;
157 public String getName()
163 public String getLabel()
165 return label != null ? label : name;
169 public String getValue()
171 return value == null ? defvalue : value;
175 public void setValue(String selectedItem)
177 value = selectedItem;
181 public URL getFurtherDetails()
187 public boolean isRequired()
193 public String getDescription()
199 public List<String> getPossibleValues()
205 public List<String> getDisplayNames()