org.apache.commons.cli

Class OptionGroup

public class OptionGroup extends Object

A group of mutually exclusive options.

Version: $Revision: 542144 $

Author: John Keyes ( john at integralsource.com )

Field Summary
HashMapoptionMap
hold the options
booleanrequired
specified whether this group is required
Stringselected
the name of the selected option
Method Summary
OptionGroupaddOption(Option opt)
add opt to this group
CollectiongetNames()
CollectiongetOptions()
StringgetSelected()
booleanisRequired()
Returns whether this option group is required.
voidsetRequired(boolean required)
voidsetSelected(Option opt)
set the selected option of this group to name.
StringtoString()

Returns the stringified version of this OptionGroup.

Field Detail

optionMap

private HashMap optionMap
hold the options

required

private boolean required
specified whether this group is required

selected

private String selected
the name of the selected option

Method Detail

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 Collection getNames()

Returns: the names of the options in this group as a Collection

getOptions

public Collection getOptions()

Returns: the options in this group as a Collection

getSelected

public String getSelected()

Returns: the selected option name

isRequired

public boolean isRequired()
Returns whether this option group is required.

Returns: whether this option group is required

setRequired

public void setRequired(boolean required)

Parameters: required specifies if this group is required

setSelected

public void setSelected(Option opt)
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.

toString

public String toString()

Returns the stringified version of this OptionGroup.

Returns: the stringified representation of this group