jsonOptions.put(optns);
}
for (int i = 0; i < jsonOptions.length(); i++) {
JSONObject jsOpt = jsonOptions.getJSONObject(i);
String type = jsOpt.getString("@type");
ParamModelData opt = new ParamModelData(
jsOpt.getString("@name"),
typeOf(type),
jsOpt.optBoolean("@optional", false),
jsOpt.optString("@default"),
jsOpt.optString("@short"),
jsOpt.optBoolean("@obsolete", false),
jsOpt.optString("@alias"));
opt.param._acceptableValues = jsOpt.optString("@acceptable-values");
if ("PASSWORD".equals(type)) {
opt.param._password = true;
opt.prompt = jsOpt.optString("@prompt");
opt.promptAgain = jsOpt.optString("@prompt-again");
} else if ("FILE".equals(type)) {
sawFile = true;
}
if (jsOpt.optBoolean("@primary", false)) {
opt.param._primary = true;
}
if (jsOpt.optBoolean("@multiple", false)) {
if (opt.type == File.class) {
opt.type = File[].class;
} else {
opt.type = List.class;
}
opt.param._multiple = true;
}
cm.add(opt);
}
}
if (sawFile) {
cm.add(new ParamModelData("upload", Boolean.class,
true, null));
addedUploadOption = true;
cm.setAddedUploadOption(true);
}
if (notify) {
cm.add(new ParamModelData("notify",Boolean.class,false, "false"));
}
this.usage = cm.getUsage();
return cm;
} catch (JSONException ex) {
logger.log(Level.FINER, "Can not parse command metadata", ex);