public final class GfxdOptionBuilder extends Object
Details on the Builder pattern can be found at http://c2.com/cgi-bin/wiki?BuilderPattern.
| Constructor and Description |
|---|
GfxdOptionBuilder() |
| Modifier and Type | Method and Description |
|---|---|
GfxdOption |
create()
Create an Option using the current settings
|
GfxdOption |
create(char opt)
Create an Option using the current settings and with the specified Option
char. |
GfxdOption |
create(String opt)
Create an Option using the current settings and with the specified Option
char. |
GfxdOptionBuilder |
hasArg()
The next Option created will require an argument value.
|
GfxdOptionBuilder |
hasArg(boolean hasArg)
The next Option created will require an argument value if
hasArg is true. |
GfxdOptionBuilder |
hasArgs()
The next Option created can have unlimited argument values.
|
GfxdOptionBuilder |
hasArgs(int num)
The next Option created can have
num argument values. |
GfxdOptionBuilder |
hasOptionalArg()
The next Option can have an optional argument.
|
GfxdOptionBuilder |
hasOptionalArgs()
The next Option can have an unlimited number of optional arguments.
|
GfxdOptionBuilder |
hasOptionalArgs(int numArgs)
The next Option can have the specified number of optional arguments.
|
GfxdOptionBuilder |
isRequired()
The next Option created will be required.
|
GfxdOptionBuilder |
isRequired(boolean newRequired)
The next Option created will be required if
required is true. |
GfxdOptionBuilder |
withArgName(String name)
The next Option created will have the specified argument value name.
|
GfxdOptionBuilder |
withDescription(String newDescription)
The next Option created will have the specified description
|
GfxdOptionBuilder |
withLongOpt(String newLongopt)
The next Option created will have the following long option value.
|
GfxdOptionBuilder |
withType(Object newType)
The next Option created will have a value that will be an instance of
type. |
GfxdOptionBuilder |
withValueSeparator()
The next Option created uses '
=' as a means to separate
argument values. |
GfxdOptionBuilder |
withValueSeparator(char sep)
The next Option created uses
sep as a means to separate
argument values. |
public GfxdOptionBuilder withLongOpt(String newLongopt)
newLongopt - the long option valuepublic GfxdOptionBuilder hasArg()
public GfxdOptionBuilder hasArg(boolean hasArg)
hasArg is true.hasArg - if true then the Option has an argument valuepublic GfxdOptionBuilder withArgName(String name)
name - the name for the argument valuepublic GfxdOptionBuilder isRequired()
public GfxdOptionBuilder withValueSeparator(char sep)
sep as a means to separate
argument values.
Example:
Option opt = this.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 GfxdOptionBuilder withValueSeparator()
=' as a means to separate
argument values.
Example:
Option opt = this.withValueSeparator().create('D');
CommandLine line = parser.parse(args);
String propertyName = opt.getValue(0);
String propertyValue = opt.getValue(1);
public GfxdOptionBuilder isRequired(boolean newRequired)
required is true.newRequired - if true then the Option is requiredpublic GfxdOptionBuilder hasArgs()
public GfxdOptionBuilder hasArgs(int num)
num argument values.num - the number of args that the option can havepublic GfxdOptionBuilder hasOptionalArg()
public GfxdOptionBuilder hasOptionalArgs()
public GfxdOptionBuilder hasOptionalArgs(int numArgs)
numArgs - - the maximum number of optional arguments the next Option created
can have.public GfxdOptionBuilder withType(Object newType)
type.newType - the type of the Options argument valuepublic GfxdOptionBuilder withDescription(String newDescription)
newDescription - a description of the Option's purposepublic GfxdOption create(char opt) throws IllegalArgumentException
char.opt - the character representation of the OptionIllegalArgumentException - if opt is not a valid character. See Option.public GfxdOption create() throws IllegalArgumentException
IllegalArgumentException - if longOpt has not been set.public GfxdOption 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 © 2010-2015 Pivotal Software, Inc. All rights reserved.