org.apache.commons.cli
Class OptionGroup
java.lang.Object
|
+--org.apache.commons.cli.OptionGroup
- public class OptionGroup
- extends java.lang.Object
A group of mutually exclusive options.
- Version:
- $Revision: 1.2 $
- Author:
- John Keyes ( john at integralsource.com )
Field Summary |
private java.util.HashMap |
optionMap
hold the options |
private boolean |
required
specified whether this group is required |
private java.lang.String |
selected
the name of the selected option |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
optionMap
private java.util.HashMap optionMap
- hold the options
selected
private java.lang.String selected
- the name of the selected option
required
private boolean required
- specified whether this group is required
OptionGroup
public OptionGroup()
addOption
public OptionGroup addOption(Option opt)
- add
opt
to this group
- Parameters:
opt
- the option to add to this group- Returns:
- this option group with opt added
getNames
public java.util.Collection getNames()
- Returns:
- the names of the options in this group as a
Collection
getOptions
public java.util.Collection getOptions()
- Returns:
- the options in this group as a
Collection
setSelected
public void setSelected(Option opt)
throws AlreadySelectedException
- set the selected option of this group to
name
.
- Parameters:
opt
- the option that is selected- Throws:
- AlreadySelectedException - if an option from this group has
already been selected.
getSelected
public java.lang.String getSelected()
- Returns:
- the selected option name
setRequired
public void setRequired(boolean required)
- Parameters:
required
- specifies if this group is required
isRequired
public boolean isRequired()
- Returns whether this option group is required.
toString
public java.lang.String toString()
Returns the stringified version of this OptionGroup.
- Overrides:
- toString in class java.lang.Object
- Returns:
- the stringified representation of this group