commandlineprocessing.OptionSet Class Reference

Collaboration diagram for commandlineprocessing.OptionSet:

Collaboration graph
[legend]

List of all members.

Public Member Functions

java.util.ArrayList< OptionData > getOptionData ()
OptionData getOption (String key)
boolean isSet (String key)
String getSetName ()
int getMinData ()
int getMaxData ()
java.util.ArrayList< String > getData ()
java.util.ArrayList< String > getUnmatched ()
OptionSet addOption (String key)
OptionSet addOption (String key, Options.Multiplicity multiplicity)
OptionSet addOption (String key, Options.Separator separator)
OptionSet addOption (String key, Options.Separator separator, Options.Multiplicity multiplicity)
OptionSet addOption (String key, boolean details, Options.Separator separator)
OptionSet addOption (String key, boolean details, Options.Separator separator, Options.Multiplicity multiplicity)

Package Functions

 OptionSet (Options.Prefix prefix, Options.Multiplicity defaultMultiplicity, String setName, int minData, int maxData)
OptionSet addOption (String key, boolean details, Options.Separator separator, boolean value, Options.Multiplicity multiplicity)

Private Attributes

java.util.ArrayList< OptionData > options = new java.util.ArrayList<OptionData>()
java.util.HashMap< String,
OptionData > 
keys = new java.util.HashMap<String, OptionData>()
java.util.ArrayList< String > unmatched = new java.util.ArrayList<String>()
java.util.ArrayList< String > data = new java.util.ArrayList<String>()
String setName = null
int minData = 0
int maxData = 0
Options.Prefix prefix = null
Options.Multiplicity defaultMultiplicity = null

Static Private Attributes

static final String CLASS = "OptionSet"


Detailed Description

This class holds the information for a set of options. A set can hold any number of OptionData instances which are checked together to determine success or failure.

The approach to use this class looks like this:

  1. The user uses any of the Options.addSet() (e. g. Options#addSet(String)) to create any number of sets required (or just relies on the default set, if only one set is required)
  2. The user adds all required option definitions to each set
  3. Using any of the Options.check() methods, each set can be checked whether the options that were specified on the command line satisfy its requirements
  4. If the check was successful for a given set, several data items are available from this class:
    • All options defined for the set (through with e. g. values, details, and multiplicity are available)
    • All data items found (these are the items on the command line which do not start with the prefix, i. e. non-option arguments)
    • All unmatched arguments on the command line (these are the items on the command line which start with the prefix, but do not match to one of the options). Programs can elect to ignore these, or react with an error

Definition at line 27 of file OptionSet.java.


Constructor & Destructor Documentation

commandlineprocessing.OptionSet.OptionSet ( Options.Prefix  prefix,
Options.Multiplicity  defaultMultiplicity,
String  setName,
int  minData,
int  maxData 
) [package]

Constructor

Definition at line 45 of file OptionSet.java.


Member Function Documentation

java.util.ArrayList<OptionData> commandlineprocessing.OptionSet.getOptionData (  ) 

Get a list of all the options defined for this set

Returns:
A list of OptionData instances defined for this set

Definition at line 62 of file OptionSet.java.

OptionData commandlineprocessing.OptionSet.getOption ( String  key  ) 

Get the data for a specific option, identified by its key name (which is unique)

Parameters:
key The key for the option
Returns:
The OptionData instance
Exceptions:
IllegalArgumentException If the key is null or unknown in this set

Definition at line 76 of file OptionSet.java.

boolean commandlineprocessing.OptionSet.isSet ( String  key  ) 

Check whether a specific option is set, i. e. whether it was specified at least once on the command line.

Parameters:
key The key for the option
Returns:
true or false, depending on the outcome of the check
Exceptions:
IllegalArgumentException If the key is null or unknown in this set

Definition at line 92 of file OptionSet.java.

String commandlineprocessing.OptionSet.getSetName (  ) 

Getter method for setName property

Returns:
The value for the setName property

Definition at line 104 of file OptionSet.java.

int commandlineprocessing.OptionSet.getMinData (  ) 

Getter method for minData property

Returns:
The value for the minData property

Definition at line 114 of file OptionSet.java.

int commandlineprocessing.OptionSet.getMaxData (  ) 

Getter method for maxData property

Returns:
The value for the maxData property

Definition at line 124 of file OptionSet.java.

java.util.ArrayList<String> commandlineprocessing.OptionSet.getData (  ) 

Return the data items found (these are the items on the command line which do not start with the prefix, i. e. non-option arguments)

Returns:
A list of strings with all data items found

Definition at line 134 of file OptionSet.java.

java.util.ArrayList<String> commandlineprocessing.OptionSet.getUnmatched (  ) 

Return all unmatched items found (these are the items on the command line which start with the prefix, but do not match to one of the options)

Returns:
A list of strings with all unmatched items found

Definition at line 145 of file OptionSet.java.

OptionSet commandlineprocessing.OptionSet.addOption ( String  key  ) 

Add a non-value option with the given key, and the default prefix and multiplicity

Parameters:
key The key for the option
Returns:
The set instance itself (to support invocation chaining for addOption() methods)
Exceptions:
IllegalArgumentException If the key is null or a key with this name has already been defined

Definition at line 159 of file OptionSet.java.

Referenced by commandlineprocessing.OptionSet.addOption(), and commandline.NormalMeshAlgorithm.CommandLineConfiguration.configure_commandline().

OptionSet commandlineprocessing.OptionSet.addOption ( String  key,
Options.Multiplicity  multiplicity 
)

Add a non-value option with the given key and multiplicity, and the default prefix

Parameters:
key The key for the option
multiplicity The multiplicity for the option
Returns:
The set instance itself (to support invocation chaining for addOption() methods)
Exceptions:
IllegalArgumentException If the key is null or a key with this name has already been defined or if multiplicity is null

Definition at line 175 of file OptionSet.java.

OptionSet commandlineprocessing.OptionSet.addOption ( String  key,
Options.Separator  separator 
)

Add a value option with the given key and separator, no details, and the default prefix and multiplicity

Parameters:
key The key for the option
separator The separator for the option
Returns:
The set instance itself (to support invocation chaining for addOption() methods)
Exceptions:
IllegalArgumentException If the key is null or a key with this name has already been defined or if separator is null

Definition at line 191 of file OptionSet.java.

OptionSet commandlineprocessing.OptionSet.addOption ( String  key,
Options.Separator  separator,
Options.Multiplicity  multiplicity 
)

Add a value option with the given key, separator, and multiplicity, no details, and the default prefix

Parameters:
key The key for the option
separator The separator for the option
multiplicity The multiplicity for the option
Returns:
The set instance itself (to support invocation chaining for addOption() methods)
Exceptions:
IllegalArgumentException If the key is null or a key with this name has already been defined or if separator or multiplicity are null

Definition at line 208 of file OptionSet.java.

OptionSet commandlineprocessing.OptionSet.addOption ( String  key,
boolean  details,
Options.Separator  separator 
)

Add a value option with the given key and separator, possibly details, and the default prefix and multiplicity

Parameters:
key The key for the option
details A boolean indicating whether details are expected for the option
separator The separator for the option
Returns:
The set instance itself (to support invocation chaining for addOption() methods)
Exceptions:
IllegalArgumentException If the key is null or a key with this name has already been defined or if separator is null

Definition at line 226 of file OptionSet.java.

OptionSet commandlineprocessing.OptionSet.addOption ( String  key,
boolean  details,
Options.Separator  separator,
Options.Multiplicity  multiplicity 
)

Add a value option with the given key, separator, and multiplicity, possibly details, and the default prefix

Parameters:
key The key for the option
details A boolean indicating whether details are expected for the option
separator The separator for the option
multiplicity The multiplicity for the option
Returns:
The set instance itself (to support invocation chaining for addOption() methods)
Exceptions:
IllegalArgumentException If the key is null or a key with this name has already been defined or if separator or multiplicity are null

Definition at line 244 of file OptionSet.java.

OptionSet commandlineprocessing.OptionSet.addOption ( String  key,
boolean  details,
Options.Separator  separator,
boolean  value,
Options.Multiplicity  multiplicity 
) [package]

The master method to add an option. Since there are combinations which are not acceptable (like a NONE separator and a true value), this method is not public. Internally, we only supply acceptable combinations.

Definition at line 254 of file OptionSet.java.


Member Data Documentation

final String commandlineprocessing.OptionSet.CLASS = "OptionSet" [static, private]

java.util.ArrayList<OptionData> commandlineprocessing.OptionSet.options = new java.util.ArrayList<OptionData>() [private]

java.util.HashMap<String, OptionData> commandlineprocessing.OptionSet.keys = new java.util.HashMap<String, OptionData>() [private]

java.util.ArrayList<String> commandlineprocessing.OptionSet.unmatched = new java.util.ArrayList<String>() [private]

Definition at line 33 of file OptionSet.java.

Referenced by commandlineprocessing.OptionSet.getUnmatched().

java.util.ArrayList<String> commandlineprocessing.OptionSet.data = new java.util.ArrayList<String>() [private]

Definition at line 34 of file OptionSet.java.

Referenced by commandlineprocessing.OptionSet.getData().

String commandlineprocessing.OptionSet.setName = null [private]

Definition at line 35 of file OptionSet.java.

Referenced by commandlineprocessing.OptionSet.getSetName().

Definition at line 36 of file OptionSet.java.

Referenced by commandlineprocessing.OptionSet.getMinData().

Definition at line 37 of file OptionSet.java.

Referenced by commandlineprocessing.OptionSet.getMaxData().


The documentation for this class was generated from the following file:

Generated on Tue Jul 8 15:04:08 2008 for NODIC by  doxygen 1.5.5