JAL-1432 updated copyright notices
[jalview.git] / src / jalview / ws / jws2 / dm / JabaOption.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3  * Copyright (C) 2014 The Jalview Authors
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  * The Jalview Authors are detailed in the 'AUTHORS' file.
18  */
19 package jalview.ws.jws2.dm;
20
21 import jalview.ws.jws2.ParameterUtils;
22 import jalview.ws.params.OptionI;
23
24 import java.net.URL;
25 import java.util.List;
26
27 import compbio.metadata.Option;
28
29 public class JabaOption implements jalview.ws.params.OptionI
30 {
31   public JabaOption(Option rg)
32   {
33     opt = rg;
34   }
35
36   Option opt;
37
38   @Override
39   public String getValue()
40   {
41     return opt.getDefaultValue();
42   }
43
44   @Override
45   public String getName()
46   {
47     return opt.getName();
48   }
49
50   @Override
51   public URL getFurtherDetails()
52   {
53     return opt.getFurtherDetails();
54   }
55
56   @Override
57   public boolean isRequired()
58   {
59     return opt.isRequired();
60   }
61
62   @Override
63   public String getDescription()
64   {
65     return opt.getDescription();
66   }
67
68   @Override
69   public List<String> getPossibleValues()
70   {
71     // TODO: assert typesafety
72     return opt.getPossibleValues();
73   }
74
75   @Override
76   public void setValue(String selectedItem)
77   {
78     try
79     {
80       opt.setDefaultValue(selectedItem);
81     } catch (Exception e)
82     {
83       e.printStackTrace();
84       throw new Error(
85               "Implementation error: cannot set Jaba Option to a value outside its allowed value range!");
86     }
87   }
88
89   @Override
90   public OptionI copy()
91   {
92     return new JabaOption(ParameterUtils.copyOption(opt));
93   }
94
95   /**
96    * get the underlying Jaba option or parameter object. Note - use copy first
97    * if you want to modify the value of the option.
98    * 
99    * @return
100    */
101   public Option getOption()
102   {
103     return opt;
104   }
105
106 }