private NumberRange parseRange(String text) throws CommandSyntaxException {
int delimPos = text.indexOf(rangeDelim);
int start;
int end;
if (text.equals(rangeDelim)) {
throw new CommandSyntaxException("Invalid number range");
}
if (delimPos == -1) {
// this is ok, as we allow a single integer to represent the range n-n
start = end = parseInt(text);
} else if (delimPos == 0) {
start = min;
end = parseInt(text.substring(rangeDelim.length(), text.length()));
} else if (delimPos == (text.length() - rangeDelim.length())) {
start = parseInt(text.substring(0, delimPos));
end = max;
} else {
start = parseInt(text.substring(0, delimPos));
end = parseInt(text.substring(delimPos + rangeDelim.length(), text.length()));
}
try {
return new NumberRange(start, end, min - 1, max + 1);
} catch (IllegalArgumentException ex) {
throw new CommandSyntaxException("Invalid number range");
}
}