Details
Description
It seems like no required Options can be created via the
PatternOptionBuilder. That is for the following reason:
Usually "required" is being specified by including an "!"
into the pattern. E.g. like this "hc!<" which should make
the option "c" mandatory. But you always get an
IllegalArgumentException because the "!" is used to create
an Option. Here is the main loop...
if (!isValueCode(ch))
{
if (opt != ' ')
opt = ch;
}
else if (ch == '!')
else
{ type = getValueClass(ch); }If you look at the code you can see the that "!"
case is only being reached in the else clause.
Which in turn means if isValueCode('!') is true.
If you look at "isValueCode"
public static boolean isValueCode(char ch)
{
if ((ch != '@') && (ch != ':') && (ch != '%') && (ch != '+')
&& (ch != '#') && (ch != '<') && (ch != '>') && (ch != '*')
&& (ch != '/'))
return true;
}
you can see that "isValueCode('!')" will always return
false and the else clause can never be reached.
Adding the "!" to the "isValueCode" method should
do the trick.
public static boolean isValueCode(char ch)
{
if ((ch != '@') && (ch != ':') && (ch != '%') && (ch != '+')
&& (ch != '#') && (ch != '<') && (ch != '>') && (ch != '*')
&& (ch != '/') && (ch != '!'))
{ return false; }
return true;
}
Could someone please fix this?
Thanks, Torsten