if (nameAttribute == null)
throw new InvalidModuleException("Invalid parameter: missing required 'name' attribute");
else
paramName = nameAttribute.getValue();
Flag flag = new Flag(paramName);
//child elements:
List children = element.getChildren();
for (int i=0; i<children.size(); i++) {
Element child = (Element)children.get(i);
String name = child.getName().toLowerCase();
if (name.equals("title"))
flag.setTitle(child.getText());
else if (name.equals("help"))
flag.setHelp(child.getText());
else if (name.equals("true-value"))
flag.setTrueValue(child.getText());
else if (name.equals("false-value"))
flag.setFalseValue(child.getText());
else if (name.equals("default")) {
boolean value = child.getText().toLowerCase().equals("true");
flag.setDefault(new Boolean(value));
}
else if (name.equals("scriptlet"))
flag.setScriptlet(child.getText());
}
if (flag.getTrueValue() == null)
throw new InvalidModuleException("Flag parameter must have 'true-value' specified to be useful");
return flag;
}