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
34 * current value in string format, or "null" if undefined
39 * default value in string format, or "null" if undefined
45 List<String> possibleVals;
48 * optional display names corresponding to possibleVals
50 List<String> displayVals;
61 public Option(Option opt)
65 defvalue = opt.defvalue;
66 description = opt.description;
67 if (opt.possibleVals != null)
69 possibleVals = new ArrayList<>(opt.possibleVals);
71 required = opt.required;
72 // URLs are singletons - so we copy by reference. nasty but true.
73 fdetails = opt.fdetails;
81 * Constructor including display names for possible values
91 public Option(String name2, String description2, boolean isrequired,
92 String defValue, String val, List<String> possibleVals,
93 List<String> displayNames, URL fdetails)
96 description = description2;
98 this.required = isrequired;
99 this.defvalue = defValue;
100 if (possibleVals != null)
102 this.possibleVals = new ArrayList<>(possibleVals);
104 if (displayNames != null)
106 this.displayVals = new ArrayList<>(displayNames);
108 this.fdetails = fdetails;
115 * @param description2
119 * @param possibleVals
122 public Option(String name2, String description2, boolean isrequired,
123 String defValue, String val, List<String> possibleVals,
126 this(name2, description2, isrequired, defValue, val, possibleVals, null,
131 public OptionI copy()
133 Option opt = new Option(this);
138 * toString method to help identify options in the debugger only
141 public String toString()
143 return this.getClass().getName() + ":" + name;
147 public String getName()
153 public String getValue()
155 return value == null ? defvalue : value;
159 public void setValue(String selectedItem)
161 value = selectedItem;
165 public URL getFurtherDetails()
171 public boolean isRequired()
177 public String getDescription()
183 public List<String> getPossibleValues()
189 public List<String> getDisplayNames()