org.apache.commons.cli
Class OptionGroup

java.lang.Object
  extended by org.apache.commons.cli.OptionGroup
All Implemented Interfaces:
java.io.Serializable

public class OptionGroup
extends java.lang.Object
implements java.io.Serializable

A group of mutually exclusive options.

Version:
$Revision: 680644 $, $Date: 2008-07-29 01:13:48 -0700 (Tue, 29 Jul 2008) $
Author:
John Keyes ( john at integralsource.com )
See Also:
Serialized Form

Field Summary
private  java.util.Map optionMap
          hold the options
private  boolean required
          specified whether this group is required
private  java.lang.String selected
          the name of the selected option
private static long serialVersionUID
           
 
Constructor Summary
OptionGroup()
           
 
Method Summary
 OptionGroup addOption(Option option)
          Add the specified Option to this group.
 java.util.Collection getNames()
           
 java.util.Collection getOptions()
           
 java.lang.String getSelected()
           
 boolean isRequired()
          Returns whether this option group is required.
 void setRequired(boolean required)
           
 void setSelected(Option option)
          Set the selected option of this group to name.
 java.lang.String toString()
          Returns the stringified version of this OptionGroup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

optionMap

private java.util.Map 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

Constructor Detail

OptionGroup

public OptionGroup()
Method Detail

addOption

public OptionGroup addOption(Option option)
Add the specified Option to this group.

Parameters:
option - the option to add to this group
Returns:
this option group with the option 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 option)
                 throws AlreadySelectedException
Set the selected option of this group to name.

Parameters:
option - 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.

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