shortdesc = (Element)shortdescs.item(0);
shortdesctext = shortdesc.getTextContent();
}
if (optiontype.equals("string") || optiontype.equals("bool") || optiontype.equals("integer") || optiontype.equals("unary")) {
Option op = og.getOption(optionname);
if (op != null) {
throw new OptionException("The option name '"+optionname+"' for option group '"+og.getName()+"' already exists. It is only allowed to override the class and enum option type to add legal value. ");
}
} else if (optiontype.equals("class") || optiontype.equals("enum") || optiontype.equals("stringenum")) {
Option op = og.getOption(optionname);
if (op != null) {
if (op instanceof EnumOption && !optiontype.equals("enum")) {
throw new OptionException("The option name '"+optionname+"' for option group '"+og.getName()+"' already exists. The existing option is of enum type, but the new option is of '"+optiontype+"' type. ");
}
if (op instanceof ClassOption && !optiontype.equals("class")) {
throw new OptionException("The option name '"+optionname+"' for option group '"+og.getName()+"' already exists. The existing option is of class type, but the new option is of '"+optiontype+"' type. ");
}
if (op instanceof StringEnumOption && !optiontype.equals("stringenum")) {
throw new OptionException("The option name '"+optionname+"' for option group '"+og.getName()+"' already exists. The existing option is of urlenum type, but the new option is of '"+optiontype+"' type. ");
}
}
}
if (optiontype.equals("string")) {
og.addOption(new StringOption(og, optionname, shortdesctext, flag, usage, defaultValue));
} else if (optiontype.equals("bool")) {
og.addOption(new BoolOption(og, optionname, shortdesctext, flag, usage, defaultValue));
} else if (optiontype.equals("integer")) {
og.addOption(new IntegerOption(og, optionname, shortdesctext, flag, usage, defaultValue));
} else if (optiontype.equals("unary")) {
og.addOption(new UnaryOption(og, optionname, shortdesctext, flag, usage));
} else if (optiontype.equals("enum")) {
Option op = og.getOption(optionname);
EnumOption eop = null;
if (op == null) {
eop = new EnumOption(og, optionname, shortdesctext, flag, usage);
} else {
if (op instanceof EnumOption) {
eop = (EnumOption)op;
}
}
NodeList legalvalues = option.getElementsByTagName("legalvalue");
Element legalvalue;
for (int j = 0; j < legalvalues.getLength(); j++) {
legalvalue = (Element)legalvalues.item(j);
String legalvaluename = legalvalue.getAttribute("name");
String legalvaluetext = legalvalue.getTextContent();
eop.addLegalValue(legalvaluename, legalvaluetext);
}
if (op == null) {
eop.setDefaultValue(defaultValue);
og.addOption(eop);
}
} else if (optiontype.equals("class") ) {
Option op = og.getOption(optionname);
ClassOption cop = null;
if (op == null) {
cop = new ClassOption(og, optionname, shortdesctext, flag, usage);
} else {
if (op instanceof ClassOption) {
cop = (ClassOption)op;
}
}
NodeList legalvalues = option.getElementsByTagName("legalvalue");
Element legalvalue;
for (int j = 0; j < legalvalues.getLength(); j++) {
legalvalue = (Element)legalvalues.item(j);
String legalvaluename = legalvalue.getAttribute("name").toLowerCase();
String classname = legalvalue.getAttribute("class");
String legalvaluetext = legalvalue.getTextContent();
cop.addLegalValue(legalvaluename, legalvaluetext, classname);
}
if (op == null) {
cop.setDefaultValue(defaultValue);
og.addOption(cop);
}
} else if (optiontype.equals("stringenum") ) {
Option op = og.getOption(optionname);
StringEnumOption ueop = null;
if (op == null) {
ueop = new StringEnumOption(og, optionname, shortdesctext, flag, usage);
} else {
if (op instanceof StringEnumOption) {