|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.cli.OptionBuilder
public class OptionBuilder
OptionBuilder allows the user to create Options using descriptive methods.
Details on the Builder pattern can be found at http://c2.com/cgi-bin/wiki?BuilderPattern.
Field Summary | |
---|---|
private static java.lang.String |
argName
argument name |
private static java.lang.String |
description
option description |
private static OptionBuilder |
instance
option builder instance |
private static java.lang.String |
longopt
long option |
private static int |
numberOfArgs
the number of arguments |
private static boolean |
optionalArg
option can have an optional argument value |
private static boolean |
required
is required? |
private static java.lang.Object |
type
option type |
private static char |
valuesep
value separator for argument value |
Constructor Summary | |
---|---|
private |
OptionBuilder()
|
Method Summary | |
---|---|
static Option |
create()
Create an Option using the current settings |
static Option |
create(char opt)
Create an Option using the current settings and with the specified Option char . |
static Option |
create(java.lang.String opt)
Create an Option using the current settings and with the specified Option char . |
static OptionBuilder |
hasArg()
The next Option created will require an argument value. |
static OptionBuilder |
hasArg(boolean hasArg)
The next Option created will require an argument value if hasArg is true. |
static OptionBuilder |
hasArgs()
The next Option created can have unlimited argument values. |
static OptionBuilder |
hasArgs(int num)
The next Option created can have num
argument values. |
static OptionBuilder |
hasOptionalArg()
The next Option can have an optional argument. |
static OptionBuilder |
hasOptionalArgs()
The next Option can have an unlimited number of optional arguments. |
static OptionBuilder |
hasOptionalArgs(int numArgs)
The next Option can have the specified number of optional arguments. |
static OptionBuilder |
isRequired()
The next Option created will be required. |
static OptionBuilder |
isRequired(boolean required)
The next Option created will be required if required
is true. |
private static void |
reset()
Resets the member variables to their default values. |
static OptionBuilder |
withArgName(java.lang.String name)
The next Option created will have the specified argument value name. |
static OptionBuilder |
withDescription(java.lang.String description)
The next Option created will have the specified description |
static OptionBuilder |
withLongOpt(java.lang.String longopt)
The next Option created will have the following long option value. |
static OptionBuilder |
withType(java.lang.Object type)
The next Option created will have a value that will be an instance of type . |
static OptionBuilder |
withValueSeparator()
The next Option created uses ' = ' as a means to
separate argument values. |
static OptionBuilder |
withValueSeparator(char sep)
The next Option created uses sep as a means to
separate argument values. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static java.lang.String longopt
private static java.lang.String description
private static java.lang.String argName
private static boolean required
private static int numberOfArgs
private static java.lang.Object type
private static boolean optionalArg
private static char valuesep
private static OptionBuilder instance
Constructor Detail |
---|
private OptionBuilder()
Method Detail |
---|
private static void reset()
Resets the member variables to their default values.
public static OptionBuilder withLongOpt(java.lang.String longopt)
The next Option created will have the following long option value.
longopt
- the long option value
public static OptionBuilder hasArg()
The next Option created will require an argument value.
public static OptionBuilder hasArg(boolean hasArg)
The next Option created will require an argument value if
hasArg
is true.
hasArg
- if true then the Option has an argument value
public static OptionBuilder withArgName(java.lang.String name)
The next Option created will have the specified argument value name.
name
- the name for the argument value
public static OptionBuilder isRequired()
The next Option created will be required.
public static OptionBuilder withValueSeparator(char sep)
The next Option created uses sep
as a means to
separate argument values.
Option opt = OptionBuilder.withValueSeparator( ':' ) .create( 'D' ); CommandLine line = parser.parse( args ); String propertyName = opt.getValue( 0 ); String propertyValue = opt.getValue( 1 );
public static OptionBuilder withValueSeparator()
The next Option created uses '=
' as a means to
separate argument values.
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 required)
The next Option created will be required if required
is true.
required
- if true then the Option is required
public static OptionBuilder hasArgs()
The next Option created can have unlimited argument values.
public static OptionBuilder hasArgs(int num)
The next Option created can have num
argument values.
num
- the number of args that the option can have
public static OptionBuilder hasOptionalArg()
The next Option can have an optional argument.
public static OptionBuilder hasOptionalArgs()
The next Option can have an unlimited number of optional arguments.
public static OptionBuilder hasOptionalArgs(int numArgs)
The next Option can have the specified number of optional arguments.
numArgs
- - the maximum number of optional arguments
the next Option created can have.
public static OptionBuilder withType(java.lang.Object type)
The next Option created will have a value that will be an instance
of type
.
type
- the type of the Options argument value
public static OptionBuilder withDescription(java.lang.String description)
The next Option created will have the specified description
description
- a description of the Option's purpose
public static Option create(char opt) throws java.lang.IllegalArgumentException
Create an Option using the current settings and with
the specified Option char
.
opt
- the character representation of the Option
java.lang.IllegalArgumentException
- if opt
is not
a valid character. See Option.public static Option create() throws java.lang.IllegalArgumentException
Create an Option using the current settings
java.lang.IllegalArgumentException
- if longOpt
has
not been set.public static Option create(java.lang.String opt) throws java.lang.IllegalArgumentException
Create an Option using the current settings and with
the specified Option char
.
opt
- the java.lang.String
representation
of the Option
java.lang.IllegalArgumentException
- if opt
is not
a valid character. See Option.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |