commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Neidhart <>
Subject Re: [CLI] - withValueSeparator() usage
Date Tue, 05 Feb 2013 09:17:15 GMT
On Sun, Feb 3, 2013 at 9:56 PM, Thomas Neidhart

> On 02/03/2013 06:29 PM, Greg Thomas wrote:
> > I've had a look; I the only place that could do with clarification is
> > the javadoc for getOptionValues @
> >
> > /
> >
> > Currently, both say:
> >
> > "Retrieves the array of values, if any, of an option."
> >
> > I'd suggest something like;
> >
> > Where a valueSeparator is used to separate two argument values, these
> > will return both values in an array of length 2.
> > @see OptionBuilder#withValueSeparator()
> I think the examples provided in OptionBuilder#withValueSeparator() and
> OptionBulder#withValueSeparator(char) should be improved to clearly
> indicate that this separator is only used to distinguish between key and
> value, and not to split values itself.

I did look further into this issue, and

The value separator is only used in the Option#processValue method and is
indeed used to split the argument into multiple values.
Now, the splitting is only performed if in the OptionBuilder, the hasArgs()
is specified with the number of expected argument values.
With the default setting of hasArg(), like in the example above, no
splitting will be performed.

The example above also worked, because the option and arguments are
separated by whitespace and thus provided as separate tokens to the parser.
In this case, the argument is always the next token, regardless of the
separator. If you would specify hasArgs(3), you would indeed get the values
split into an array of 3 strings.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message