Clover icon

Coverage Report

  1. Project Clover database Thu Nov 28 2024 11:45:30 GMT
  2. Package jalview.bin.argparser

File ArgValue.java

 

Coverage histogram

../../../img/srcFileCovDistChart7.png
31% of files have more coverage

Code metrics

8
42
17
1
175
115
22
0.52
2.47
17
1.29

Classes

Class Line # Actions
ArgValue 29 42 22
0.626865762.7%
 

Contributing tests

This file is covered by 92 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ 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
10    * of the License, or (at your option) any later version.
11    *
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.
16    *
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.
20    */
21    package jalview.bin.argparser;
22   
23    import jalview.bin.argparser.Arg.Opt;
24    import jalview.bin.argparser.Arg.Type;
25   
26    /**
27    * A helper class to keep an index of argument position with argument values
28    */
 
29    public class ArgValue implements Comparable<ArgValue>
30    {
31    private Arg arg;
32   
33    private int argIndex;
34   
35    private String value;
36   
37    private String givenLinkedId = null;
38   
39    private String assignedLinkedId = null;
40   
41    private boolean setByWildcardLinkedId = false;
42   
43    /*
44    * Type type is only really used by --help-type
45    */
46    private Type type = null;
47   
48    /*
49    * This id is set by a subVal id= to identify the product of this ArgValue
50    * later. Set but not currently used.
51    */
52    private String id;
53   
54    private SubVals subVals;
55   
 
56  246 toggle protected ArgValue(Arg a, SubVals sv, Type type, String content,
57    int argIndex, boolean setByWildcardLinkedId, String givenLinkedId,
58    String assignedLinkedId)
59    {
60  246 this.arg = a;
61  246 this.value = content;
62  246 this.argIndex = argIndex;
63  246 this.subVals = sv == null ? new SubVals("") : sv;
64  246 this.setType(type);
65  246 this.setByWildcardLinkedId = setByWildcardLinkedId;
66  246 this.givenLinkedId = givenLinkedId;
67  246 this.assignedLinkedId = assignedLinkedId;
68    }
69   
 
70  360 toggle protected ArgValue(Arg a, Type type, String value, int argIndex,
71    boolean setByWildcardLinkedId, String givenLinkedId,
72    String assignedLinkedId)
73    {
74  360 this.arg = a;
75  360 this.argIndex = argIndex;
76  360 this.subVals = new SubVals(value);
77  360 this.value = getSubVals().getContent();
78  360 this.setType(type);
79  360 this.setByWildcardLinkedId = setByWildcardLinkedId;
80  360 this.givenLinkedId = givenLinkedId;
81  360 this.assignedLinkedId = assignedLinkedId;
82    }
83   
 
84  606 toggle protected void setType(Type t)
85    {
86  606 if (this.getArg().hasOption(Opt.HASTYPE))
87  0 this.type = t;
88    }
89   
 
90  0 toggle public Type getType()
91    {
92  0 return type;
93    }
94   
 
95  931 toggle public Arg getArg()
96    {
97  931 return arg;
98    }
99   
 
100  1302 toggle public String getValue()
101    {
102  1302 return value;
103    }
104   
 
105  2454 toggle public int getArgIndex()
106    {
107  2454 return argIndex;
108    }
109   
 
110  0 toggle protected void setId(String i)
111    {
112  0 id = i;
113    }
114   
 
115  0 toggle public String getId()
116    {
117  0 return id;
118    }
119   
 
120  1053 toggle public SubVals getSubVals()
121    {
122  1053 return subVals;
123    }
124   
 
125  21 toggle public String getSubVal(String key)
126    {
127  21 if (subVals == null || !subVals.has(key))
128  20 return null;
129  1 return subVals.get(key);
130    }
131   
 
132  0 toggle protected void putSubVal(String key, String val)
133    {
134  0 this.subVals.put(key, val);
135    }
136   
 
137  21 toggle @Override
138    public final int compareTo(ArgValue o)
139    {
140  21 return this.getArgIndex() - o.getArgIndex();
141    }
142   
 
143  0 toggle @Override
144    public String toString()
145    {
146  0 StringBuilder sb = new StringBuilder();
147  0 sb.append(this.getArg().argString());
148  0 sb.append("=");
149  0 if (!this.getSubVals().getSubValMap().isEmpty())
150    {
151  0 sb.append(this.getSubVals().toString());
152    }
153  0 sb.append("'");
154  0 sb.append(this.getValue());
155  0 sb.append("'");
156   
157  0 return sb.toString();
158    }
159   
 
160  81 toggle public String getGivenLinkedId()
161    {
162  81 return this.givenLinkedId;
163    }
164   
 
165  0 toggle public String getAssignedLinkedId()
166    {
167  0 return this.assignedLinkedId;
168    }
169   
 
170  89 toggle public boolean setByWildcardLinkedId()
171    {
172    // looking for deliberately user set wildcard
173  89 return this.setByWildcardLinkedId && this.getGivenLinkedId() != null;
174    }
175    }