X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2Fargparser%2FArgValuesMap.java;h=085099a680724221e1cb791142265c3ad33e41d1;hb=1828f012a09cc00f8748fd9ee5b53af0779a8945;hp=176dc7c5101e1daecf295dbf040a270999a7f540;hpb=0788111a588187a04dd0d254d70b055274cf2c9d;p=jalview.git diff --git a/src/jalview/bin/argparser/ArgValuesMap.java b/src/jalview/bin/argparser/ArgValuesMap.java index 176dc7c..085099a 100644 --- a/src/jalview/bin/argparser/ArgValuesMap.java +++ b/src/jalview/bin/argparser/ArgValuesMap.java @@ -18,16 +18,25 @@ public class ArgValuesMap { protected Map m; - protected ArgValuesMap() + private String linkedId; + + protected ArgValuesMap(String linkedId) { + this.linkedId = linkedId; this.newMap(); } - protected ArgValuesMap(Map map) + protected ArgValuesMap(String linkedId, Map map) { + this.linkedId = linkedId; this.m = map; } + public String getLinkedId() + { + return linkedId; + } + private Map getMap() { return m; @@ -46,17 +55,6 @@ public class ArgValuesMap m.put(a, new ArgValues(a)); } - protected void addArgValue(Arg a, ArgValue av) - { - if (getMap() == null) - m = new HashMap(); - - if (!m.containsKey(a)) - m.put(a, new ArgValues(a)); - ArgValues avs = m.get(a); - avs.addArgValue(av); - } - public ArgValues getArgValues(Arg a) { return m == null ? null : m.get(a); @@ -147,6 +145,8 @@ public class ArgValuesMap // specify an id in the subValues so wouldn't need to be guessed). ArgValue closestAv = null; int thisArgIndex = thisAv.getArgIndex(); + if (!containsArg(a)) + return null; ArgValues compareAvs = this.getArgValues(a); int closestNextIndex = Integer.MAX_VALUE; for (ArgValue av : compareAvs.getArgValueList()) @@ -193,37 +193,64 @@ public class ArgValuesMap } /* - * This method returns the basename of the first --open or --opennew value. + * This method returns the basename of the first --append or --open value. * Used primarily for substitutions in output filenames. */ public String getBasename() { - return getDirOrBasename(false); + return getDirBasenameOrExtension(false, false); } /* - * This method returns the dirname of the first --open or --opennew value. + * This method returns the basename of the first --append or --open value. + * Used primarily for substitutions in output filenames. + */ + public String getExtension() + { + return getDirBasenameOrExtension(false, true); + } + + /* + * This method returns the dirname of the first --append or --open value. * Used primarily for substitutions in output filenames. */ public String getDirname() { - return getDirOrBasename(true); + return getDirBasenameOrExtension(true, false); } - public String getDirOrBasename(boolean dirname) + public String getDirBasenameOrExtension(boolean dirname, + boolean extension) { String filename = null; + String appendVal = getValue(Arg.APPEND); String openVal = getValue(Arg.OPEN); - String opennewVal = getValue(Arg.OPENNEW); - if (openVal != null) + if (appendVal != null) + filename = appendVal; + if (filename == null && openVal != null) filename = openVal; - if (filename == null && opennewVal != null) - filename = opennewVal; if (filename == null) return null; File file = new File(filename); - return dirname ? FileUtils.getDirname(file) + if (dirname) + { + return FileUtils.getDirname(file); + } + return extension ? FileUtils.getExtension(file) : FileUtils.getBasename(file); } + + /* + * Checks if there is an Arg with Opt + */ + public boolean hasArgWithOption(Opt o) + { + for (Arg a : getArgKeys()) + { + if (a.hasOption(o)) + return true; + } + return false; + } }