2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.bin.argparser;
23 import jalview.bin.argparser.Arg.Opt;
24 import jalview.bin.argparser.Arg.Type;
27 * A helper class to keep an index of argument position with argument values
29 public class ArgValue implements Comparable<ArgValue>
37 private String givenLinkedId = null;
39 private String assignedLinkedId = null;
41 private boolean setByWildcardLinkedId = false;
44 * Type type is only really used by --help-type
46 private Type type = null;
49 * This id is set by a subVal id= to identify the product of this ArgValue
50 * later. Set but not currently used.
54 private SubVals subVals;
56 protected ArgValue(Arg a, SubVals sv, Type type, String content,
57 int argIndex, boolean setByWildcardLinkedId, String givenLinkedId,
58 String assignedLinkedId)
62 this.argIndex = argIndex;
63 this.subVals = sv == null ? new SubVals("") : sv;
65 this.setByWildcardLinkedId = setByWildcardLinkedId;
66 this.givenLinkedId = givenLinkedId;
67 this.assignedLinkedId = assignedLinkedId;
70 protected ArgValue(Arg a, Type type, String value, int argIndex,
71 boolean setByWildcardLinkedId, String givenLinkedId,
72 String assignedLinkedId)
75 this.argIndex = argIndex;
76 this.subVals = new SubVals(value);
77 this.value = getSubVals().getContent();
79 this.setByWildcardLinkedId = setByWildcardLinkedId;
80 this.givenLinkedId = givenLinkedId;
81 this.assignedLinkedId = assignedLinkedId;
84 protected void setType(Type t)
86 if (this.getArg().hasOption(Opt.HASTYPE))
100 public String getValue()
105 public int getArgIndex()
110 protected void setId(String i)
115 public String getId()
120 public SubVals getSubVals()
125 public String getSubVal(String key)
127 if (subVals == null || !subVals.has(key))
129 return subVals.get(key);
132 protected void putSubVal(String key, String val)
134 this.subVals.put(key, val);
138 public final int compareTo(ArgValue o)
140 return this.getArgIndex() - o.getArgIndex();
144 public String toString()
146 StringBuilder sb = new StringBuilder();
147 sb.append(this.getArg().argString());
149 if (!this.getSubVals().getSubValMap().isEmpty())
151 sb.append(this.getSubVals().toString());
154 sb.append(this.getValue());
157 return sb.toString();
160 public String getGivenLinkedId()
162 return this.givenLinkedId;
165 public String getAssignedLinkedId()
167 return this.assignedLinkedId;
170 public boolean setByWildcardLinkedId()
172 // looking for deliberately user set wildcard
173 return this.setByWildcardLinkedId && this.getGivenLinkedId() != null;