From: Ben Soares Date: Fri, 24 Feb 2023 14:43:38 +0000 (+0000) Subject: JAL-629 helper function for getting sensible structure (or other arg value) X-Git-Tag: Release_2_11_4_0~475 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=44ac7ea37b8cb3d4562a5575ddadba296d649a7a;p=jalview.git JAL-629 helper function for getting sensible structure (or other arg value) --- diff --git a/src/jalview/bin/ArgParser.java b/src/jalview/bin/ArgParser.java index 2290182..3dc7921 100644 --- a/src/jalview/bin/ArgParser.java +++ b/src/jalview/bin/ArgParser.java @@ -121,8 +121,6 @@ public class ArgParser private boolean defaultBoolValue = false; - private int argIndex = -1; - public String toLongString() { StringBuilder sb = new StringBuilder(); @@ -205,16 +203,6 @@ public class ArgParser { return defaultBoolValue; } - - private void setArgIndex(int i) - { - this.argIndex = i; - } - - protected int getArgIndex() - { - return this.argIndex; - } } public static class ArgValues @@ -869,6 +857,25 @@ public class ArgParser ArgValues av = getArgValues(a); return av == null ? false : av.getBoolean(); } + + protected ArgValue getClosestPreviousArgValueOfArg(ArgValue thisAv, + Arg a) + { + ArgValue closestAv = null; + int thisArgIndex = thisAv.getArgIndex(); + ArgValues compareAvs = this.getArgValues(a); + int closestPreviousIndex = -1; + for (ArgValue av : compareAvs.getArgValueList()) + { + int argIndex = av.getArgIndex(); + if (argIndex < thisArgIndex && argIndex > closestPreviousIndex) + { + closestPreviousIndex = argIndex; + closestAv = av; + } + } + return closestAv; + } } private static final Collection bootstrapArgs = new ArrayList(