package jalview.ws.params.simple; 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, value, defvalue,description; ArrayList possibleVals=new ArrayList(); boolean required; URL fdetails; @Override public String getName() { return name; } @Override public String getValue() { return value==null ? defvalue : value; } @Override public void setValue(String selectedItem) { value = selectedItem; } @Override public URL getFurtherDetails() { return fdetails; } @Override public boolean isRequired() { return required; } @Override public String getDescription() { return description; } @Override public List getPossibleValues() { 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 OptionI copy() { Option opt = new Option(this); return opt; } }