* @param classname the fully qualified name of the class
* @throws OptionException
*/
public void addLegalValue(String value, String desc, String classname) throws MaltChainedException {
if (value == null || value.equals("")) {
throw new OptionException("The legal value is missing for the '"+getName()+"' option. ");
} else if (legalValues.contains(value.toLowerCase())) {
throw new OptionException("The legal value for the '"+getName()+"' option already exists. ");
} else {
legalValues.add(value.toLowerCase());
if (desc == null || desc.equals("")) {
legalValueDesc.put(value.toLowerCase(), "Description is missing. ");
} else {
legalValueDesc.put(value.toLowerCase(), desc);
}
if (classname == null || classname.equals("")) {
throw new OptionException("The class name used by the '"+getName()+"' option is missing. ");
} else {
try {
Class<?> clazz = null;
if (PluginLoader.instance() != null) {
clazz = PluginLoader.instance().getClass(classname);
}
if (clazz == null) {
clazz = Class.forName(classname);
}
legalValueClass.put(value, clazz);
classLegalValues.put(clazz, value);
} catch (ClassNotFoundException e) {
throw new OptionException("The class "+classname+" for the '"+getName()+"' option could not be found. ", e);
}
}
}
}