Package org.apache.commons.cli
Class OptionBuilder
java.lang.Object
org.apache.commons.cli.OptionBuilder
Deprecated.
OptionBuilder allows the user to create Options using descriptive methods.
Details on the Builder pattern can be found at https://c2.com/cgi-bin/wiki?BuilderPattern.
This class is NOT thread safe. See CLI-209
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optioncreate()Deprecated.Creates an Option using the current settingsstatic Optioncreate(char opt) Deprecated.Creates an Option using the current settings and with the specified Optionchar.static OptionDeprecated.Creates an Option using the current settings and with the specified Optionchar.static OptionBuilderhasArg()Deprecated.The next Option created will require an argument value.static OptionBuilderhasArg(boolean hasArg) Deprecated.The next Option created will require an argument value ifhasArgis true.static OptionBuilderhasArgs()Deprecated.The next Option created can have unlimited argument values.static OptionBuilderhasArgs(int num) Deprecated.The next Option created can havenumargument values.static OptionBuilderDeprecated.The next Option can have an optional argument.static OptionBuilderDeprecated.The next Option can have an unlimited number of optional arguments.static OptionBuilderhasOptionalArgs(int numArgs) Deprecated.The next Option can have the specified number of optional arguments.static OptionBuilderDeprecated.The next Option created will be required.static OptionBuilderisRequired(boolean newRequired) Deprecated.The next Option created will be required ifrequiredis true.static OptionBuilderwithArgName(String name) Deprecated.The next Option created will have the specified argument value name.static OptionBuilderwithDescription(String newDescription) Deprecated.The next Option created will have the specified descriptionstatic OptionBuilderwithLongOpt(String newLongopt) Deprecated.The next Option created will have the following long option value.static OptionBuilderDeprecated.The next Option created will have a value that will be an instance oftype.static OptionBuilderDeprecated.since 1.3, usewithType(Class)insteadstatic OptionBuilderDeprecated.The next Option created uses '=' as a means to separate argument values.static OptionBuilderwithValueSeparator(char sep) Deprecated.The next Option created usessepas a means to separate argument values.
-
Method Details
-
create
Deprecated.Creates an Option using the current settings- Returns:
- the Option instance
- Throws:
IllegalArgumentException- iflongOpthas not been set.
-
create
Deprecated.Creates an Option using the current settings and with the specified Optionchar.- Parameters:
opt- the character representation of the Option- Returns:
- the Option instance
- Throws:
IllegalArgumentException- ifoptis not a valid character. See Option.
-
create
Deprecated.Creates an Option using the current settings and with the specified Optionchar.- Parameters:
opt- theStringrepresentation of the Option- Returns:
- the Option instance
- Throws:
IllegalArgumentException- ifoptis not a valid character. See Option.
-
hasArg
Deprecated.The next Option created will require an argument value.- Returns:
- the OptionBuilder instance
-
hasArg
Deprecated.The next Option created will require an argument value ifhasArgis true.- Parameters:
hasArg- if true then the Option has an argument value- Returns:
- the OptionBuilder instance
-
hasArgs
Deprecated.The next Option created can have unlimited argument values.- Returns:
- the OptionBuilder instance
-
hasArgs
Deprecated.The next Option created can havenumargument values.- Parameters:
num- the number of args that the option can have- Returns:
- the OptionBuilder instance
-
hasOptionalArg
Deprecated.The next Option can have an optional argument.- Returns:
- the OptionBuilder instance
-
hasOptionalArgs
Deprecated.The next Option can have an unlimited number of optional arguments.- Returns:
- the OptionBuilder instance
-
hasOptionalArgs
Deprecated.The next Option can have the specified number of optional arguments.- Parameters:
numArgs- the maximum number of optional arguments the next Option created can have.- Returns:
- the OptionBuilder instance
-
isRequired
Deprecated.The next Option created will be required.- Returns:
- the OptionBuilder instance
-
isRequired
Deprecated.The next Option created will be required ifrequiredis true.- Parameters:
newRequired- if true then the Option is required- Returns:
- the OptionBuilder instance
-
withArgName
Deprecated.The next Option created will have the specified argument value name.- Parameters:
name- the name for the argument value- Returns:
- the OptionBuilder instance
-
withDescription
Deprecated.The next Option created will have the specified description- Parameters:
newDescription- a description of the Option's purpose- Returns:
- the OptionBuilder instance
-
withLongOpt
Deprecated.The next Option created will have the following long option value.- Parameters:
newLongopt- the long option value- Returns:
- the OptionBuilder instance
-
withType
Deprecated.The next Option created will have a value that will be an instance oftype.- Parameters:
newType- the type of the Options argument value- Returns:
- the OptionBuilder instance
- Since:
- 1.3
-
withType
Deprecated.since 1.3, usewithType(Class)insteadThe next Option created will have a value that will be an instance oftype.Note: this method is kept for binary compatibility and the input type is supposed to be a
Classobject.- Parameters:
newType- the type of the Options argument value- Returns:
- the OptionBuilder instance
-
withValueSeparator
Deprecated.The next Option created uses '=' as a means to separate argument values. Example:Option opt = withValueSeparator().create('D'); CommandLine line = parser.parse(args); String propertyName = opt.getValue(0); String propertyValue = opt.getValue(1);- Returns:
- the OptionBuilder instance
-
withValueSeparator
Deprecated.The next Option created usessepas 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"- Parameters:
sep- The value separator to be used for the argument values.- Returns:
- the OptionBuilder instance
-
Option.builder(String)instead