update author list in license for (JAL-826)
[jalview.git] / src / jalview / ws / jws2 / dm / JabaOption.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3  * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
4  * 
5  * This file is part of Jalview.
6  * 
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 of the License, or (at your option) any later version.
10  * 
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.ws.jws2.dm;
19
20 import jalview.ws.jws2.ParameterUtils;
21 import jalview.ws.params.OptionI;
22
23 import java.net.URL;
24 import java.util.List;
25
26 import compbio.metadata.Option;
27
28 public class JabaOption implements jalview.ws.params.OptionI
29 {
30   public JabaOption(Option rg)
31   {
32     opt = rg;
33   }
34
35   Option opt;
36
37   @Override
38   public String getValue()
39   {
40     return opt.getDefaultValue();
41   }
42
43   @Override
44   public String getName()
45   {
46     return opt.getName();
47   }
48
49   @Override
50   public URL getFurtherDetails()
51   {
52     return opt.getFurtherDetails();
53   }
54
55   @Override
56   public boolean isRequired()
57   {
58     return opt.isRequired();
59   }
60
61   @Override
62   public String getDescription()
63   {
64     return opt.getDescription();
65   }
66
67   @Override
68   public List<String> getPossibleValues()
69   {
70     // TODO: assert typesafety
71     return opt.getPossibleValues();
72   }
73
74   @Override
75   public void setValue(String selectedItem)
76   {
77     try
78     {
79       opt.setDefaultValue(selectedItem);
80     } catch (Exception e)
81     {
82       e.printStackTrace();
83       throw new Error(
84               "Implementation error: cannot set Jaba Option to a value outside its allowed value range!");
85     }
86   }
87
88   @Override
89   public OptionI copy()
90   {
91     return new JabaOption(ParameterUtils.copyOption(opt));
92   }
93
94   /**
95    * get the underlying Jaba option or parameter object. Note - use copy first
96    * if you want to modify the value of the option.
97    * 
98    * @return
99    */
100   public Option getOption()
101   {
102     return opt;
103   }
104
105 }