m.put(a, new ArgValues(a));
}
- protected void addArgValue(Arg a, ArgValue av)
- {
- if (getMap() == null)
- m = new HashMap<Arg, ArgValues>();
-
- 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);
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;
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
*/
public String getBasename()
{
- return getDirOrBasename(false);
+ return getDirBasenameOrExtension(false, false);
+ }
+
+ /*
+ * 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);
}
/*
*/
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);
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);
}