String paramsStr = arg.value.substring(ARG_TASK.length());
String params[] = paramsStr.split(",");
String className = params[0];
try {
Class theClass = plugInLoader.getPlugInClass(className);
SmartCardTask task = (SmartCardTask) theClass.newInstance();
if (params.length > 2) {
throw new InvalidCommandLineException("Two parameters are accepted at most. "
+ "Following parameters were found:\n" + params.toString());
}
if (2 == params.length) {
int nArgs;
if (params[1].equals("...")) {
task.setnArgs(SmartCardTask.ALL_ARGS);
cl.addArgDefs(task.getArgDefs());
} else {
try {
nArgs = Integer.decode(params[1]);
} catch (NumberFormatException ex) {
throw new InvalidCommandLineException("Could not convert second parameter to an integer.", ex);
}
if (nArgs < 0) {
throw new InvalidCommandLineException("Only positive values is valid as second parameter.");
}
if (nArgs > 0) {
task.setnArgs(nArgs);
cl.addEphemeralArgDefs(task.getArgDefs(), nArgs);
}
}
} else {
task.setnArgs(0);
cl.addArgDefs(task.getArgDefs());
}
tasks.add(task);
if(false==taskClassNames.contains(className)){
taskClassNames.add(className);
System.out.println("Task added:");
System.out.println(task.getAboutMsg());
}
} catch (InstantiationException ex) {
throw new InvalidCommandLineException(ex);
} catch (IllegalAccessException ex) {
throw new InvalidCommandLineException(ex);