}
if (!isCaseSensitive) {
arg = arg.toLowerCase();
}
if (!isValidOptionName(arg)) {
throw new ParseException("Wrong character in command line option value for enumerated option: '" + arg + "'"
+"\nallowed are alphanumeric characters + '$' and '_' sign only",
new IllegalArgumentException());
}
// we cannot use Arrays.binarySearch() because strings cannot be
// sorted according to the required natural order!
if (Arrays.asList(validOptionValuesArray).contains(arg)) {
return arg;
}
else {
throw new ParseException("Option has wrong value '" + arg + "'"
+ "; valid values are: "+Arrays.asList(validOptionValuesArray), new IllegalArgumentException());
}
}