X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fparams%2Fsimple%2FOption.java;h=653359f3d11ec226855361f795f9620800ba9afe;hb=2b618ede76f5a9d2f1be7db9aad8bb3a2b10e23b;hp=ce5d6697b3601a941f5214f14e41407f9e21d026;hpb=ac4a041c0706baca6fd04570bf37e8264457ea86;p=jalview.git diff --git a/src/jalview/ws/params/simple/Option.java b/src/jalview/ws/params/simple/Option.java index ce5d669..653359f 100644 --- a/src/jalview/ws/params/simple/Option.java +++ b/src/jalview/ws/params/simple/Option.java @@ -24,125 +24,20 @@ import jalview.ws.params.OptionI; import java.net.URL; import java.util.ArrayList; +import java.util.Collection; import java.util.List; public class Option implements OptionI { - String name; - /* - * current value in string format, or "null" if undefined - */ - String value; + String name, value, defvalue, description; - /* - * default value in string format, or "null" if undefined - */ - String defvalue; - - String description; - - List possibleVals; - - /* - * optional display names corresponding to possibleVals - */ - List displayVals; + ArrayList possibleVals = new ArrayList(); boolean required; URL fdetails; - /** - * Copy constructor - * - * @param opt - */ - public Option(Option opt) - { - name = opt.name; - value = opt.value; - defvalue = opt.defvalue; - description = opt.description; - if (opt.possibleVals != null) - { - possibleVals = new ArrayList<>(opt.possibleVals); - } - required = opt.required; - // URLs are singletons - so we copy by reference. nasty but true. - fdetails = opt.fdetails; - } - - public Option() - { - } - - /** - * Constructor including display names for possible values - * - * @param name2 - * @param description2 - * @param isrequired - * @param defValue - * @param val - * @param possibleVals - * @param fdetails - */ - public Option(String name2, String description2, boolean isrequired, - String defValue, String val, List possibleVals, - List displayNames, URL fdetails) - { - name = name2; - description = description2; - this.value = val; - this.required = isrequired; - this.defvalue = defValue; - if (possibleVals != null) - { - this.possibleVals = new ArrayList<>(possibleVals); - } - if (displayNames != null) - { - this.displayVals = new ArrayList<>(displayNames); - } - this.fdetails = fdetails; - } - - /** - * Constructor - * - * @param name2 - * @param description2 - * @param isrequired - * @param defValue - * @param val - * @param possibleVals - * @param fdetails - */ - public Option(String name2, String description2, boolean isrequired, - String defValue, String val, List possibleVals, - URL fdetails) - { - this(name2, description2, isrequired, defValue, val, possibleVals, null, - fdetails); - } - - @Override - public OptionI copy() - { - Option opt = new Option(this); - return opt; - } - - /** - * toString method to help identify options in the debugger only - */ - @Override - public String toString() - { - return this.getClass().getName() + ":" + name; - } - @Override public String getName() { @@ -185,9 +80,49 @@ public class Option implements OptionI return possibleVals; } + public Option(Option opt) + { + name = new String(opt.name); + if (opt.value != null) + value = new String(opt.value); + if (opt.defvalue != null) + defvalue = new String(opt.defvalue); + if (opt.description != null) + description = new String(opt.description); + if (opt.possibleVals != null) + { + possibleVals = (ArrayList) opt.possibleVals.clone(); + } + required = opt.required; + // URLs are singletons - so we copy by reference. nasty but true. + fdetails = opt.fdetails; + } + + public Option() + { + } + + public Option(String name2, String description2, boolean isrequired, + String defValue, String value, Collection possibleVals, + URL fdetails) + { + name = name2; + description = description2; + this.value = value; + this.required = isrequired; + this.defvalue = defValue; + if (possibleVals != null) + { + this.possibleVals = new ArrayList(); + this.possibleVals.addAll(possibleVals); + } + this.fdetails = fdetails; + } + @Override - public List getDisplayNames() + public OptionI copy() { - return displayVals; + Option opt = new Option(this); + return opt; } }