return true;
}
public CommandDefinition getCommandDefinition() {
CommandDefinition commandDefinition = new CommandDefinition();
String[] extraLines = new String[alternatives.length];
for (int i = 0; i < extraLines.length; i++) {
extraLines[i] = (i + 1) + " " + alternatives[i];
}
CommandInfo ci1 = new CommandInfo("selection", "Selected value", "More than one alternative was found.\nPlease choose option by entering digit corresponding with selection",
null,
extraLines, true, false, false, false) {
@Override
public String validate(String input) {
int selection = -1;
try {
selection = Integer.parseInt(input);
}
catch (NumberFormatException e) {
return "Invalid Selection. Please select a number corresponding with one of the alternative choices";
}
if (selection <= 0 || selection > alternatives.length) {
return "Invalid Selection. Selected number does not correspond with one of the values."
+ "\nPlease select a number between 1 and " + alternatives.length;
}
return null;
}
};
commandDefinition.add(ci1);
return commandDefinition;
}