JAL-629 parse SubVals once with ArgValue. Ensure SubVals exists. Change to setprops...
[jalview.git] / src / jalview / bin / argparser / ArgValue.java
1 package jalview.bin.argparser;
2
3 /**
4  * A helper class to keep an index of argument position with argument values
5  */
6 public class ArgValue
7 {
8   private int argIndex;
9
10   private String value;
11
12   private String id;
13
14   private SubVals subVals;
15
16   protected ArgValue(SubVals sv, String content, int argIndex)
17   {
18     this.value = content;
19     this.argIndex = argIndex;
20     this.subVals = sv == null ? new SubVals("") : sv;
21   }
22
23   protected ArgValue(String value, int argIndex)
24   {
25     this.argIndex = argIndex;
26     this.subVals = new SubVals(value);
27     this.value = getSubVals().getContent();
28   }
29
30   public String getValue()
31   {
32     return value;
33   }
34
35   public int getArgIndex()
36   {
37     return argIndex;
38   }
39
40   protected void setId(String i)
41   {
42     id = i;
43   }
44
45   public String getId()
46   {
47     return id;
48   }
49
50   public SubVals getSubVals()
51   {
52     return subVals;
53   }
54
55   public String getSubVal(String key)
56   {
57     if (subVals == null || !subVals.has(key))
58       return null;
59     return subVals.get(key);
60   }
61
62   protected void putSubVal(String key, String val)
63   {
64     this.subVals.put(key, val);
65   }
66 }