JAL-629 Added --structureimage code and formatting args/subvals. Added tests for...
[jalview.git] / src / jalview / bin / argparser / ArgValuesMap.java
index 085099a..ab6fcc1 100644 (file)
@@ -120,6 +120,33 @@ public class ArgValuesMap
     return m.keySet();
   }
 
+  public ArgValue getArgValueOfArgWithSubValKey(Arg a, String svKey)
+  {
+    return getArgValueOfArgWithSubValKey(a, svKey, false);
+  }
+
+  public ArgValue getArgValueOfArgWithSubValKey(Arg a, String svKey,
+          boolean last)
+  {
+    ArgValues avs = this.getArgValues(a);
+    if (avs == null)
+    {
+      return null;
+    }
+    List<ArgValue> compareAvs = avs.getArgValueList();
+    for (int i = 0; i < compareAvs.size(); i++)
+    {
+      int index = last ? compareAvs.size() - 1 - i : i;
+      ArgValue av = compareAvs.get(index);
+      SubVals sv = av.getSubVals();
+      if (sv.has(svKey) && !sv.get(svKey).equals("false"))
+      {
+        return av;
+      }
+    }
+    return null;
+  }
+
   public ArgValue getClosestPreviousArgValueOfArg(ArgValue thisAv, Arg a)
   {
     ArgValue closestAv = null;
@@ -161,6 +188,7 @@ public class ArgValuesMap
     return closestAv;
   }
 
+  // TODO this is incomplete and currently unused (fortunately)
   public ArgValue[] getArgValuesReferringTo(String key, String value, Arg a)
   {
     // this looks for the *next* arg that *might* be referring back to