NamedNodeMap attributes = n.getAttributes();
String sn = getAttr(attributes, "short");
String def = getAttr(attributes, "default");
String obs = getAttr(attributes, "obsolete");
String alias = getAttr(attributes, "alias");
ParamModelData opt = new ParamModelData(
getAttr(attributes, "name"),
typeOf(getAttr(attributes, "type")),
Boolean.parseBoolean(getAttr(attributes, "optional")),
def,
ok(sn) ? sn : null,
ok(obs) ? Boolean.parseBoolean(obs) : false,
alias);
if (getAttr(attributes, "type").equals("PASSWORD")) {
opt.param._password = true;
opt.description = getAttr(attributes, "description");
}
cm.add(opt);
if (opt.getType() == File.class)
sawFile = true;
}
// should be only one operand item
opts = doc.getElementsByTagName("operand");
for (int i = 0; i < opts.getLength(); i++) {
Node n = opts.item(i);
NamedNodeMap attributes = n.getAttributes();
Class<?> type = typeOf(getAttr(attributes, "type"));
if (type == File.class) {
sawFile = true;
}
int min = Integer.parseInt(getAttr(attributes, "min"));
String max = getAttr(attributes, "max");
boolean multiple = false;
if (max.equals("unlimited")) {
multiple = true;
// XXX - should convert to array of whatever
if (type == File.class) {
type = File[].class;
} else {
type = List.class;
}
}
ParamModelData pm = new ParamModelData(
getAttr(attributes, "name"), type, min == 0, null);
pm.param._primary = true;
pm.param._multiple = multiple;
cm.add(pm);
}
/*
* If one of the options or operands is a FILE,
* make sure there's also a --upload option available.
* XXX - should only add it if it's not present
* XXX - should just define upload parameter on remote command
*/
if (sawFile) {
cm.add(new ParamModelData("upload", Boolean.class,
true, null));
addedUploadOption = true;
cm.setAddedUploadOption(true);
}
} catch (ParserConfigurationException pex) {