public void addDef(OptDef pDef) { mArgDefs.add(pDef); if (mShortNameToLongNameMap.containsKey(pDef.shortname)) { throw new RuntimeException("Duplicate short name: " + pDef.shortname); } mValidOptionNames.add(pDef.longname); if (pDef.shortname != null) { mValidOptionNames.add(pDef.shortname); mShortNameToLongNameMap.put(pDef.shortname, pDef.longname); } else { mOptionsWithoutShortName.add(pDef.longname); } if (pDef.hasvalue) { mNamesOfOptionsRequiringValue.add(pDef.longname); } if (pDef.defaultvalue != null) { // a little sanity check, if you permit... if (!(pDef.hasvalue)) { throw new RuntimeException( "Illegal situation: parameter " + pDef.longname + " has no value, " + "but still has default value " + pDef.defaultvalue); } mDefaultValues.put(pDef.longname, pDef.defaultvalue); } if (pDef.possiblevalues != null) { // for an "enum" type parameter mPossibleValues.putMultiple(pDef.longname, pDef.possiblevalues); } }
/** * Hmm, bit ugly to do this afterwards, but currently we must handle "dependent" default values * this way, by hand. */ public void putDefaultValue(String pKey, String pVal) { mDefaultValues.put(pKey, pVal); }