|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xerial.util.cui.OptionGroup<OptionID>
public class OptionGroup<OptionID extends Comparable>
OptionGroup creates a bundle of options By setting some OptionGroup as exclusive, you can prevent multiple exclusive OptionGroups will be activated at the same time.
enum Opt { "cui", "gui" }
OptionGroup<Opt> cuiGroup = new OptionGroup<Opt>("cui", true);
cuiGroup.addOption(Opt.cui, "c", "cui", "CUI mode");
OptionGroup<Opt> guiGroup = new OptionGroup<Opt>("gui", true);
guiGroup.addOption(Opt.gui, "g", "gui", "GUI mode");
OptionParser<Opt> parser = new OptionParser<Opt>();
parser.addOptionGroup(cuiGroup);
parser.addOptionGroup(guiGroup);
parser.parse(new String[] {"--cui", "--gui" }); // throws OptionParserException
| Constructor Summary | |
|---|---|
OptionGroup(String groupName)
|
|
OptionGroup(String groupName,
boolean isExclusive)
Creates an option group |
|
| Method Summary | |
|---|---|
void |
activate()
|
protected void |
activateParentGroup()
|
void |
addOption(OptionID optionID,
String shortOptionName,
String longOptionName,
String description)
Adds an option to this option group |
void |
addOption(OptionID optionID,
String shortOptionName,
String longOptionName,
String description,
boolean presetValue)
Adds an option to this option group |
void |
addOption(OptionID optionID,
String shortOptionName,
String longOptionName,
String description,
boolean presetValue,
OptionHandler<OptionID> handler)
Adds an option to this option group |
void |
addOption(OptionID optionID,
String shortOptionName,
String longOptionName,
String description,
OptionHandler<OptionID> handler)
Adds an option to this option group |
void |
addOptionGroup(OptionGroup<OptionID> optionGroup)
|
void |
addOptionHandler(OptionID optionID,
OptionHandler<OptionID> handler)
|
void |
addOptionWithArgment(OptionID optionID,
String shortOptionName,
String longOptionName,
String argumentName,
String description)
Adds an option to this option group |
void |
addOptionWithArgment(OptionID optionID,
String shortOptionName,
String longOptionName,
String argumentName,
String description,
OptionHandler<OptionID> handler)
Adds an option to this option group |
void |
addOptionWithArgment(OptionID optionID,
String shortOptionName,
String longOptionName,
String argumentName,
String description,
String defaultValue)
Adds an option to this option group |
protected void |
collectOptionDescriptions(org.xerial.util.cui.OptionDescriptionContainer container)
|
protected void |
collectOptionID(List<OptionID> optionIDList)
|
protected Option<OptionID> |
findByLongOptionName(String longOption)
|
protected Option<OptionID> |
findByShortOptionName(String shortOption)
|
protected Option<OptionID> |
findOption(OptionID optionID)
|
String |
getGroupName()
|
OptionHandler<OptionID> |
getOptionHandler(OptionID optionID)
Finds the option handler of the specified optionID. |
protected OptionGroup<OptionID> |
getParent()
|
void |
handle(String[] args,
int argIndex)
|
boolean |
isActive()
|
protected void |
setParent(OptionGroup<OptionID> parentGroup)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public OptionGroup(String groupName)
public OptionGroup(String groupName,
boolean isExclusive)
groupName - the group nameisExclusive - true when you forbid the activation of other option groups, which belong to the same level with this option group| Method Detail |
|---|
public void addOption(OptionID optionID,
String shortOptionName,
String longOptionName,
String description)
optionID - the option IDshortOptionName - the short option name. If you specified "h" as the argument, "-h" can be used as a command line optionlongOptionName - the long option name. If you specified "help" as the argument, "--help" can be used as a command line optiondescription - the description of this option
public void addOption(OptionID optionID,
String shortOptionName,
String longOptionName,
String description,
boolean presetValue)
optionID - the option IDshortOptionName - the short option name. If you specified "h" as the argument, "-h" can be used as a command line optionlongOptionName - the long option name. If you specified "help" as the argument, "--help" can be used as a command line optiondescription - the description of this optionpresetValue - true: this option is on in default, false: off
public void addOption(OptionID optionID,
String shortOptionName,
String longOptionName,
String description,
OptionHandler<OptionID> handler)
optionID - the option IDshortOptionName - the short option name. If you specified "h" as the argument, "-h" can be used as a command line optionlongOptionName - the long option name. If you specified "help" as the argument, "--help" can be used as a command line optiondescription - the description of this optionhandler - OptionHandler invoked when this option is set
public void addOption(OptionID optionID,
String shortOptionName,
String longOptionName,
String description,
boolean presetValue,
OptionHandler<OptionID> handler)
optionID - the option IDshortOptionName - the short option name. If you specified "h" as the argument, "-h" can be used as a command line optionlongOptionName - the long option name. If you specified "help" as the argument, "--help" can be used as a command line optiondescription - the description of this optionpresetValue - true: this option is on in default, false: offhandler - OptionHandler invoked when this option is set
public void addOptionWithArgment(OptionID optionID,
String shortOptionName,
String longOptionName,
String argumentName,
String description)
optionID - the option IDshortOptionName - the short option name. If you specified "h" as the argument, "-h" can be used as a command line optionlongOptionName - the long option name. If you specified "help" as the argument, "--help" can be used as a command line optionargumentName - argument name of this option. This argument is used only for displaying the help message.description - the description of this optionhandler - OptionHandler invoked when this option is set
public void addOptionWithArgment(OptionID optionID,
String shortOptionName,
String longOptionName,
String argumentName,
String description,
OptionHandler<OptionID> handler)
optionID - the option IDshortOptionName - the short option name. If you specified "l" as the argument, "-l" can be used as a command line optionlongOptionName - the long option name. If you specified "loglevel" as the argument, "--loglevel" can be used as a command line optionargumentName - argument name of this option. This argument is used only for displaying the help message.description - the description of this optionhandler - OptionHandler invoked when this option is set
public void addOptionWithArgment(OptionID optionID,
String shortOptionName,
String longOptionName,
String argumentName,
String description,
String defaultValue)
optionID - the option IDshortOptionName - the short option name. If you specified "h" as the argument, "-h" can be used as a command line optionlongOptionName - the long option name. If you specified "help" as the argument, "--help" can be used as a command line optionargumentName - argument name of this option. This argument is used only for displaying the help message.description - the description of this optiondefaultValue - the default value of this optionpublic void addOptionGroup(OptionGroup<OptionID> optionGroup)
public void addOptionHandler(OptionID optionID,
OptionHandler<OptionID> handler)
protected void collectOptionDescriptions(org.xerial.util.cui.OptionDescriptionContainer container)
protected Option<OptionID> findByLongOptionName(String longOption)
protected Option<OptionID> findByShortOptionName(String shortOption)
protected Option<OptionID> findOption(OptionID optionID)
protected void collectOptionID(List<OptionID> optionIDList)
public OptionHandler<OptionID> getOptionHandler(OptionID optionID)
optionID - the option ID
public boolean isActive()
public void activate()
public String getGroupName()
public void handle(String[] args,
int argIndex)
protected void setParent(OptionGroup<OptionID> parentGroup)
protected OptionGroup<OptionID> getParent()
protected void activateParentGroup()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
