Option.builder(String)
instead@Deprecated public final class OptionBuilder extends Object
Details on the Builder pattern can be found at http://c2.com/cgi-bin/wiki?BuilderPattern.
This class is NOT thread safe. See CLI-209
Modifier and Type | Method and Description |
---|---|
static Option |
create()
Deprecated.
Create an Option using the current settings
|
static Option |
create(char opt)
Deprecated.
Create an Option using the current settings and with
the specified Option
char . |
static Option |
create(String opt)
Deprecated.
Create an Option using the current settings and with
the specified Option
char . |
static OptionBuilder |
hasArg()
Deprecated.
The next Option created will require an argument value.
|
static OptionBuilder |
hasArg(boolean hasArg)
Deprecated.
The next Option created will require an argument value if
hasArg is true. |
static OptionBuilder |
hasArgs()
Deprecated.
The next Option created can have unlimited argument values.
|
static OptionBuilder |
hasArgs(int num)
Deprecated.
The next Option created can have
num argument values. |
static OptionBuilder |
hasOptionalArg()
Deprecated.
The next Option can have an optional argument.
|
static OptionBuilder |
hasOptionalArgs()
Deprecated.
The next Option can have an unlimited number of optional arguments.
|
static OptionBuilder |
hasOptionalArgs(int numArgs)
Deprecated.
The next Option can have the specified number of optional arguments.
|
static OptionBuilder |
isRequired()
Deprecated.
The next Option created will be required.
|
static OptionBuilder |
isRequired(boolean newRequired)
Deprecated.
The next Option created will be required if
required
is true. |
static OptionBuilder |
withArgName(String name)
Deprecated.
The next Option created will have the specified argument value name.
|
static OptionBuilder |
withDescription(String newDescription)
Deprecated.
The next Option created will have the specified description
|
static OptionBuilder |
withLongOpt(String newLongopt)
Deprecated.
The next Option created will have the following long option value.
|
static OptionBuilder |
withType(Class<?> newType)
Deprecated.
The next Option created will have a value that will be an instance
of
type . |
static OptionBuilder |
withType(Object newType)
Deprecated.
since 1.3, use
withType(Class) instead |
static OptionBuilder |
withValueSeparator()
Deprecated.
The next Option created uses '
= ' as a means to
separate argument values. |
static OptionBuilder |
withValueSeparator(char sep)
Deprecated.
The next Option created uses
sep as a means to
separate argument values. |
public static OptionBuilder withLongOpt(String newLongopt)
newLongopt
- the long option valuepublic static OptionBuilder hasArg()
public static OptionBuilder hasArg(boolean hasArg)
hasArg
is true.hasArg
- if true then the Option has an argument valuepublic static OptionBuilder withArgName(String name)
name
- the name for the argument valuepublic static OptionBuilder isRequired()
public static OptionBuilder withValueSeparator(char sep)
sep
as a means to
separate argument values.
Example:
Option opt = OptionBuilder.withValueSeparator('=') .create('D'); String args = "-Dkey=value"; CommandLine line = parser.parse(args); String propertyName = opt.getValue(0); // will be "key" String propertyValue = opt.getValue(1); // will be "value"
sep
- The value separator to be used for the argument values.public static OptionBuilder 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 static OptionBuilder isRequired(boolean newRequired)
required
is true.newRequired
- if true then the Option is requiredpublic static OptionBuilder hasArgs()
public static OptionBuilder hasArgs(int num)
num
argument values.num
- the number of args that the option can havepublic static OptionBuilder hasOptionalArg()
public static OptionBuilder hasOptionalArgs()
public static OptionBuilder hasOptionalArgs(int numArgs)
numArgs
- - the maximum number of optional arguments
the next Option created can have.@Deprecated public static OptionBuilder withType(Object newType)
withType(Class)
insteadtype
.
Note: this method is kept for binary compatibility and the
input type is supposed to be a Class
object.
newType
- the type of the Options argument valuepublic static OptionBuilder withType(Class<?> newType)
type
.newType
- the type of the Options argument valuepublic static OptionBuilder withDescription(String newDescription)
newDescription
- a description of the Option's purposepublic static Option create(char opt) throws IllegalArgumentException
char
.opt
- the character representation of the OptionIllegalArgumentException
- if opt
is not
a valid character. See Option.public static Option create() throws IllegalArgumentException
IllegalArgumentException
- if longOpt
has not been set.public static 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 © 2002–2015 The Apache Software Foundation. All rights reserved.