|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.cli.Options
public class Options
Main entry-point into the library.
Options represents a collection of Option
objects, which
describe the possible options for a command-line.
It may flexibly parse long and short options, with or without values. Additionally, it may parse only a portion of a commandline, allowing for flexible multi-stage parsing.
CommandLine
,
Serialized FormConstructor Summary | |
---|---|
Options()
|
Method Summary | |
---|---|
Options |
addOption(Option opt)
Adds an option instance |
Options |
addOption(String opt,
boolean hasArg,
String description)
Add an option that only contains a short-name. |
Options |
addOption(String opt,
String longOpt,
boolean hasArg,
String description)
Add an option that contains a short-name and a long-name. |
Options |
addOptionGroup(OptionGroup group)
Add the specified option group. |
Option |
getOption(String opt)
Retrieve the Option matching the long or short name specified. |
OptionGroup |
getOptionGroup(Option opt)
Returns the OptionGroup the opt belongs to. |
Collection |
getOptions()
Retrieve a read-only list of options in this set |
List |
getRequiredOptions()
Returns the required options. |
boolean |
hasOption(String opt)
Returns whether the named Option is a member of this Options . |
String |
toString()
Dump state, suitable for debugging. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Options()
Method Detail |
---|
public Options addOptionGroup(OptionGroup group)
group
- the OptionGroup that is to be added
public Options addOption(String opt, boolean hasArg, String description)
opt
- Short single-character name of the option.hasArg
- flag signally if an argument is required after this optiondescription
- Self-documenting description
public Options addOption(String opt, String longOpt, boolean hasArg, String description)
opt
- Short single-character name of the option.longOpt
- Long multi-character name of the option.hasArg
- flag signally if an argument is required after this optiondescription
- Self-documenting description
public Options addOption(Option opt)
opt
- the option that is to be added
public Collection getOptions()
Option
objects in this descriptorpublic List getRequiredOptions()
public Option getOption(String opt)
Option
matching the long or short name specified.
The leading hyphens in the name are ignored (up to 2).
opt
- short or long name of the Option
public boolean hasOption(String opt)
Option
is a member of this Options
.
opt
- short or long name of the Option
Option
is a member
of this Options
public OptionGroup getOptionGroup(Option opt)
opt
belongs to.
opt
- the option whose OptionGroup is being queried.
opt
is part
of an OptionGroup, otherwise return nullpublic String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |