JAL-629 Added linkedId to ArgValuesMap for reference. Updated Arg descriptions. Made...
[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 implements Comparable<ArgValue>
7 {
8   private Arg arg;
9
10   private int argIndex;
11
12   private String value;
13
14   // This id is set by a subVal id= to identify the product of this ArgValue
15   // later. Set but not currently used.
16   private String id;
17
18   private SubVals subVals;
19
20   protected ArgValue(Arg a, SubVals sv, String content, int argIndex)
21   {
22     this.arg = a;
23     this.value = content;
24     this.argIndex = argIndex;
25     this.subVals = sv == null ? new SubVals("") : sv;
26   }
27
28   protected ArgValue(Arg a, String value, int argIndex)
29   {
30     this.arg = a;
31     this.argIndex = argIndex;
32     this.subVals = new SubVals(value);
33     this.value = getSubVals().getContent();
34   }
35
36   public Arg getArg()
37   {
38     return arg;
39   }
40
41   public String getValue()
42   {
43     return value;
44   }
45
46   public int getArgIndex()
47   {
48     return argIndex;
49   }
50
51   protected void setId(String i)
52   {
53     id = i;
54   }
55
56   public String getId()
57   {
58     return id;
59   }
60
61   public SubVals getSubVals()
62   {
63     return subVals;
64   }
65
66   public String getSubVal(String key)
67   {
68     if (subVals == null || !subVals.has(key))
69       return null;
70     return subVals.get(key);
71   }
72
73   protected void putSubVal(String key, String val)
74   {
75     this.subVals.put(key, val);
76   }
77
78   @Override
79   public int compareTo(ArgValue o)
80   {
81     return this.getArgIndex() - o.getArgIndex();
82   }
83 }