public static final class DefaultParser.Builder extends Object
DefaultParser
instances
using descriptive methods.
Example usage:
DefaultParser parser = Option.builder() .setAllowPartialMatching(false) .setStripLeadingAndTrailingQuotes(false) .build();
Modifier and Type | Method and Description |
---|---|
DefaultParser |
build()
Builds an DefaultParser with the values declared by this
DefaultParser.Builder . |
DefaultParser.Builder |
setAllowPartialMatching(boolean allowPartialMatching)
Sets if partial matching of long options is supported.
|
DefaultParser.Builder |
setStripLeadingAndTrailingQuotes(Boolean stripLeadingAndTrailingQuotes)
Sets if balanced leading and trailing double quotes should be stripped from option arguments.
|
public DefaultParser build()
DefaultParser.Builder
.DefaultParser
public DefaultParser.Builder setAllowPartialMatching(boolean allowPartialMatching)
{ @code final Options options = new Options(); options.addOption(new Option("d", "debug", false, "Turn on debug.")); options.addOption(new Option("e", "extract", false, "Turn on extract.")); options.addOption(new Option("o", "option", true, "Turn on option with argument.")); }If "partial matching" is turned on,
-de
only matches the "debug"
option. However, with
"partial matching" disabled, -de
would enable both debug
as well as extract
allowPartialMatching
- whether to allow partial matching of long optionspublic DefaultParser.Builder setStripLeadingAndTrailingQuotes(Boolean stripLeadingAndTrailingQuotes)
-o '"x"'
getValue() will return x
, instead of "x"
If "stripping of balanced leading and trailing double quotes from option arguments" is null,
then quotes will be stripped from option values separated by space from the option, but
kept in other cases, which is the historic behaviour.stripLeadingAndTrailingQuotes
- whether balanced leading and trailing double quotes should be stripped from option arguments.Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.