public final class DefaultOptionBuilder extends Object
Constructor and Description |
---|
DefaultOptionBuilder()
private constructor to prevent instances being created
|
Modifier and Type | Method and Description |
---|---|
org.apache.commons.cli.Option |
create()
Create an Option using the current settings
|
org.apache.commons.cli.Option |
create(char opt)
Create an Option using the current settings and with
the specified Option
char . |
org.apache.commons.cli.Option |
create(String opt)
Create an Option using the current settings and with
the specified Option
char . |
DefaultOptionBuilder |
hasArg()
The next Option created will require an argument value.
|
DefaultOptionBuilder |
hasArg(boolean hasArg)
The next Option created will require an argument value if
hasArg is true. |
DefaultOptionBuilder |
hasArgs()
The next Option created can have unlimited argument values.
|
DefaultOptionBuilder |
hasArgs(int num)
The next Option created can have
num argument values. |
DefaultOptionBuilder |
hasOptionalArg()
The next Option can have an optional argument.
|
DefaultOptionBuilder |
hasOptionalArgs()
The next Option can have an unlimited number of optional arguments.
|
DefaultOptionBuilder |
hasOptionalArgs(int numArgs)
The next Option can have the specified number of optional arguments.
|
DefaultOptionBuilder |
isRequired()
The next Option created will be required.
|
DefaultOptionBuilder |
isRequired(boolean newRequired)
The next Option created will be required if
required
is true. |
DefaultOptionBuilder |
withArgName(String name)
The next Option created will have the specified argument value name.
|
DefaultOptionBuilder |
withDescription(String newDescription)
The next Option created will have the specified description
|
DefaultOptionBuilder |
withLongOpt(String newLongopt)
The next Option created will have the following long option value.
|
DefaultOptionBuilder |
withType(Class newType)
The next Option created will have a value that will be an instance
of
type . |
DefaultOptionBuilder |
withValueSeparator()
The next Option created uses '
= ' as a means to
separate argument values. |
DefaultOptionBuilder |
withValueSeparator(char sep)
The next Option created uses
sep as a means to
separate argument values. |
public DefaultOptionBuilder()
public DefaultOptionBuilder withLongOpt(String newLongopt)
newLongopt
- the long option valuepublic DefaultOptionBuilder hasArg()
public DefaultOptionBuilder hasArg(boolean hasArg)
hasArg
is true.hasArg
- if true then the Option has an argument valuepublic DefaultOptionBuilder withArgName(String name)
name
- the name for the argument valuepublic DefaultOptionBuilder isRequired()
public DefaultOptionBuilder withValueSeparator(char sep)
sep
as a means to
separate argument values.
Example:
Option opt = OptionBuilder.withValueSeparator(':') .create('D'); CommandLine line = parser.parse(args); String propertyName = opt.getValue(0); String propertyValue = opt.getValue(1);
sep
- The value separator to be used for the argument values.public DefaultOptionBuilder withValueSeparator()
=
' as a means to
separate argument values.
Example:
Option opt = OptionBuilder.withValueSeparator() .create('D'); CommandLine line = parser.parse(args); String propertyName = opt.getValue(0); String propertyValue = opt.getValue(1);
public DefaultOptionBuilder isRequired(boolean newRequired)
required
is true.newRequired
- if true then the Option is requiredpublic DefaultOptionBuilder hasArgs()
public DefaultOptionBuilder hasArgs(int num)
num
argument values.num
- the number of args that the option can havepublic DefaultOptionBuilder hasOptionalArg()
public DefaultOptionBuilder hasOptionalArgs()
public DefaultOptionBuilder hasOptionalArgs(int numArgs)
numArgs
- - the maximum number of optional arguments
the next Option created can have.public DefaultOptionBuilder withType(Class newType)
type
.newType
- the type of the Options argument valuepublic DefaultOptionBuilder withDescription(String newDescription)
newDescription
- a description of the Option's purposepublic org.apache.commons.cli.Option create(char opt) throws IllegalArgumentException
char
.opt
- the character representation of the OptionIllegalArgumentException
- if opt
is not
a valid character. See Option.public org.apache.commons.cli.Option create() throws IllegalArgumentException
IllegalArgumentException
- if longOpt
has not been set.public org.apache.commons.cli.Option create(String opt) throws IllegalArgumentException
char
.opt
- the java.lang.String
representation
of the OptionIllegalArgumentException
- if opt
is not
a valid character. See Option.Copyright © 2018. All rights reserved.