commandlineprocessing.Options Class Reference

List of all members.

Public Types

enum  Separator
enum  Prefix
enum  Multiplicity

Public Member Functions

 Options (String args[], Prefix prefix, Multiplicity defaultMultiplicity, int defMinData, int defMaxData)
 Options (String args[], Prefix prefix, Multiplicity defaultMultiplicity, int data)
 Options (String args[], Prefix prefix, Multiplicity defaultMultiplicity)
 Options (String args[], Multiplicity defaultMultiplicity, int defMinData, int defMaxData)
 Options (String args[], Multiplicity defaultMultiplicity, int data)
 Options (String args[], Multiplicity defaultMultiplicity)
 Options (String args[])
 Options (String args[], int data)
 Options (String args[], int defMinData, int defMaxData)
 Options (String args[], Prefix prefix)
 Options (String args[], Prefix prefix, int data)
 Options (String args[], Prefix prefix, int defMinData, int defMaxData)
OptionSet getMatchingSet ()
OptionSet getMatchingSet (boolean ignoreUnmatched, boolean requireDataLast)
OptionSet addSet (String setName, int minData, int maxData)
OptionSet addSet (String setName, int data)
OptionSet addSet (String setName)
OptionSet getSet (String setName)
OptionSet getSet ()
String getCheckErrors ()
boolean check ()
boolean check (boolean ignoreUnmatched, boolean requireDataLast)
boolean check (String setName)
boolean check (String setName, boolean ignoreUnmatched, boolean requireDataLast)
void addOptionAllSets (String key)
void addOptionAllSets (String key, Multiplicity multiplicity)
void addOptionAllSets (String key, Separator separator)
void addOptionAllSets (String key, Separator separator, Multiplicity multiplicity)
void addOptionAllSets (String key, boolean details, Separator separator)
void addOptionAllSets (String key, boolean details, Separator separator, Multiplicity multiplicity)
String toString ()

Static Public Attributes

static final String DEFAULT_SET = "DEFAULT_OPTION_SET"

Private Attributes

java.util.HashMap< String,
OptionSet > 
optionSets = new java.util.HashMap<String, OptionSet>()
Prefix prefix = null
Multiplicity defaultMultiplicity = null
String[] arguments = null
int defaultMinData = 0
int defaultMaxData = 0
StringBuffer checkErrors = null

Static Private Attributes

static final String CLASS = "Options"


Detailed Description

The central class for option processing. Sets are identified by their name, but there is also an anonymous default set, which is very convenient if an application requieres only one set.

Definition at line 8 of file Options.java.


Member Enumeration Documentation

An enum encapsulating the possible separators between value options and their actual values.

Enumerator:
COLON  Separate option and value by ":"
EQUALS  Separate option and value by "="
BLANK  Separate option and value by blank space
NONE  This is just a placeholder in case no separator is required (i. e. for non-value options)

Definition at line 22 of file Options.java.

An enum encapsulating the possible prefixes identifying options (and separating them from command line data items)

Enumerator:
DASH  Options start with a "-" (typically on Unix platforms)
SLASH  Options start with a "/" (typically on Windows platforms)

Definition at line 70 of file Options.java.

An enum encapsulating the possible multiplicities for options

Enumerator:
ONCE  Option needs to occur exactly once
ONCE_OR_MORE  Option needs to occur at least once
ZERO_OR_ONE  Option needs to occur either once or not at all
ZERO_OR_MORE  Option can occur any number of times

Definition at line 106 of file Options.java.


Constructor & Destructor Documentation

commandlineprocessing.Options.Options ( String  args[],
Prefix  prefix,
Multiplicity  defaultMultiplicity,
int  defMinData,
int  defMaxData 
)

Constructor

Parameters:
args The command line arguments to check
prefix The prefix to use for all command line options. It can only be set here for all options at the same time
defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
Exceptions:
IllegalArgumentException If either args, prefix, or defaultMultiplicity is null - or if the data range values don't make sense

Definition at line 156 of file Options.java.

commandlineprocessing.Options.Options ( String  args[],
Prefix  prefix,
Multiplicity  defaultMultiplicity,
int  data 
)

Constructor

Parameters:
args The command line arguments to check
prefix The prefix to use for all command line options. It can only be set here for all options at the same time
defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
Exceptions:
IllegalArgumentException If either args, prefix, or defaultMultiplicity is null - or if the data range value doesn't make sense

Definition at line 190 of file Options.java.

commandlineprocessing.Options.Options ( String  args[],
Prefix  prefix,
Multiplicity  defaultMultiplicity 
)

Constructor. The default number of data items is set to 0.

Parameters:
args The command line arguments to check
prefix The prefix to use for all command line options. It can only be set here for all options at the same time
defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
Exceptions:
IllegalArgumentException If either args, prefix, or defaultMultiplicity is null

Definition at line 206 of file Options.java.

commandlineprocessing.Options.Options ( String  args[],
Multiplicity  defaultMultiplicity,
int  defMinData,
int  defMaxData 
)

Constructor. The prefix is set to Prefix#DASH.

Parameters:
args The command line arguments to check
defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
Exceptions:
IllegalArgumentException If either args or defaultMultiplicity is null - or if the data range values don't make sense

Definition at line 222 of file Options.java.

commandlineprocessing.Options.Options ( String  args[],
Multiplicity  defaultMultiplicity,
int  data 
)

Constructor. The prefix is set to Prefix#DASH.

Parameters:
args The command line arguments to check
defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
Exceptions:
IllegalArgumentException If either args or defaultMultiplicity is null - or if the data range value doesn't make sense

Definition at line 237 of file Options.java.

commandlineprocessing.Options.Options ( String  args[],
Multiplicity  defaultMultiplicity 
)

Constructor. The prefix is set to Prefix#DASH, and the default number of data items is set to 0.

Parameters:
args The command line arguments to check
defaultMultiplicity The default multiplicity to use for all options (can be overridden when adding an option)
Exceptions:
IllegalArgumentException If either args or defaultMultiplicity is null

Definition at line 251 of file Options.java.

commandlineprocessing.Options.Options ( String  args[]  ) 

Constructor. The prefix is set to Prefix#DASH, the default number of data items is set to 0, and the multiplicity is set to Multiplicity#ONCE.

Parameters:
args The command line arguments to check
Exceptions:
IllegalArgumentException If args is null

Definition at line 264 of file Options.java.

commandlineprocessing.Options.Options ( String  args[],
int  data 
)

Constructor. The prefix is set to Prefix#DASH, and the multiplicity is set to Multiplicity#ONCE.

Parameters:
args The command line arguments to check
data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
Exceptions:
IllegalArgumentException If args is null - or if the data range value doesn't make sense

Definition at line 278 of file Options.java.

commandlineprocessing.Options.Options ( String  args[],
int  defMinData,
int  defMaxData 
)

Constructor. The prefix is set to Prefix#DASH, and the multiplicity is set to Multiplicity#ONCE.

Parameters:
args The command line arguments to check
defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
Exceptions:
IllegalArgumentException If args is null - or if the data range values don't make sense

Definition at line 293 of file Options.java.

commandlineprocessing.Options.Options ( String  args[],
Prefix  prefix 
)

Constructor. The default number of data items is set to 0, and the multiplicity is set to Multiplicity#ONCE.

Parameters:
args The command line arguments to check
prefix The prefix to use for all command line options. It can only be set here for all options at the same time
Exceptions:
IllegalArgumentException If either args or prefix is null

Definition at line 308 of file Options.java.

commandlineprocessing.Options.Options ( String  args[],
Prefix  prefix,
int  data 
)

Constructor. The multiplicity is set to Multiplicity#ONCE.

Parameters:
args The command line arguments to check
prefix The prefix to use for all command line options. It can only be set here for all options at
data The default minimum and maximum number of data items for all sets (can be overridden when adding a set)
Exceptions:
IllegalArgumentException If either args or prefix is null
  • or if the data range value doesn't make sense

Definition at line 323 of file Options.java.

commandlineprocessing.Options.Options ( String  args[],
Prefix  prefix,
int  defMinData,
int  defMaxData 
)

Constructor. The multiplicity is set to Multiplicity#ONCE.

Parameters:
args The command line arguments to check
prefix The prefix to use for all command line options. It can only be set here for all options at the same time
defMinData The default minimum number of data items for all sets (can be overridden when adding a set)
defMaxData The default maximum number of data items for all sets (can be overridden when adding a set)
Exceptions:
IllegalArgumentException If either args or prefix is null
  • or if the data range values don't make sense

Definition at line 340 of file Options.java.


Member Function Documentation

OptionSet commandlineprocessing.Options.getMatchingSet (  ) 

Return the (first) matching set. This invocation does not ignore unmatched options and requires that data items are the last ones on the command line.

Returns:
The first set which matches (i. e. the check() method returns true) - or null, if no set matches.

Definition at line 352 of file Options.java.

Referenced by commandline.NormalMeshAlgorithm.CommandLineConfiguration.feedArgsToConfiguration().

OptionSet commandlineprocessing.Options.getMatchingSet ( boolean  ignoreUnmatched,
boolean  requireDataLast 
)

Return the (first) matching set.

Parameters:
ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
requireDataLast A boolean to indicate whether the data items have to be the last ones on the command line or not
Returns:
The first set which matches (i. e. the check() method returns true) - or null, if no set matches.

Definition at line 366 of file Options.java.

OptionSet commandlineprocessing.Options.addSet ( String  setName,
int  minData,
int  maxData 
)

Add an option set.

Parameters:
setName The name for the set. This must be a unique identifier
minData The minimum number of data items for this set
maxData The maximum number of data items for this set
Returns:
The new Optionset instance created. This is useful to allow chaining of addOption() calls right after this method

Definition at line 384 of file Options.java.

Referenced by commandlineprocessing.Options.addSet(), commandline.NormalMeshAlgorithm.CommandLineConfiguration.configure_commandline(), and commandlineprocessing.Options.getSet().

OptionSet commandlineprocessing.Options.addSet ( String  setName,
int  data 
)

Add an option set.

Parameters:
setName The name for the set. This must be a unique identifier
data The minimum and maximum number of data items for this set
Returns:
The new Optionset instance created. This is useful to allow chaining of addOption() calls right after this method

Definition at line 403 of file Options.java.

OptionSet commandlineprocessing.Options.addSet ( String  setName  ) 

Add an option set. The defaults for the number of data items are used.

Parameters:
setName The name for the set. This must be a unique identifier
Returns:
The new Optionset instance created. This is useful to allow chaining of addOption() calls right after this method

Definition at line 416 of file Options.java.

OptionSet commandlineprocessing.Options.getSet ( String  setName  ) 

Return an option set - or null, if no set with the given name exists

Parameters:
setName The name for the set to retrieve
Returns:
The set to retrieve (or null, if no set with the given name exists)

Definition at line 428 of file Options.java.

Referenced by commandline.NormalMeshAlgorithm.CommandLineConfiguration.configure_commandline(), and tools.VTKToBmpConvertor.main().

OptionSet commandlineprocessing.Options.getSet (  ) 

This returns the (anonymous) default set

Returns:
The default set

Definition at line 438 of file Options.java.

String commandlineprocessing.Options.getCheckErrors (  ) 

The error messages collected during the last option check (invocation of any of the check() methods). This is useful to determine what was wrong with the command line arguments provided

Returns:
A string with all collected error messages

Definition at line 451 of file Options.java.

Referenced by commandline.NormalMeshAlgorithm.CommandLineConfiguration.feedArgsToConfiguration(), and tools.VTKToBmpConvertor.main().

boolean commandlineprocessing.Options.check (  ) 

Run the checks for the default set. ignoreUnmatched is set to false, and requireDataLast is set to true.

Returns:
A boolean indicating whether all checks were successful or not

Definition at line 462 of file Options.java.

Referenced by commandlineprocessing.Options.check(), commandline.NormalMeshAlgorithm.CommandLineConfiguration.feedArgsToConfiguration(), commandlineprocessing.Options.getMatchingSet(), and tools.VTKToBmpConvertor.main().

boolean commandlineprocessing.Options.check ( boolean  ignoreUnmatched,
boolean  requireDataLast 
)

Run the checks for the default set.

Parameters:
ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
requireDataLast A boolean to indicate whether the data items have to be the last ones on the command line or not
Returns:
A boolean indicating whether all checks were successful or not

Definition at line 475 of file Options.java.

boolean commandlineprocessing.Options.check ( String  setName  ) 

Run the checks for the given set. ignoreUnmatched is set to false, and requireDataLast is set to true.

Parameters:
setName The name for the set to check
Returns:
A boolean indicating whether all checks were successful or not
Exceptions:
IllegalArgumentException If either setName is null, or the set is unknown.

Definition at line 490 of file Options.java.

boolean commandlineprocessing.Options.check ( String  setName,
boolean  ignoreUnmatched,
boolean  requireDataLast 
)

Run the checks for the given set.

Parameters:
setName The name for the set to check
ignoreUnmatched A boolean to select whether unmatched options can be ignored in the checks or not
requireDataLast A boolean to indicate whether the data items have to be the last ones on the command line or not
Returns:
A boolean indicating whether all checks were successful or not
Exceptions:
IllegalArgumentException If either setName is null, or the set is unknown.

Definition at line 506 of file Options.java.

void commandlineprocessing.Options.addOptionAllSets ( String  key  ) 

Add the given non-value option to all known sets. See OptionSet#addOption(String) for details.

Definition at line 685 of file Options.java.

void commandlineprocessing.Options.addOptionAllSets ( String  key,
Multiplicity  multiplicity 
)

Add the given non-value option to all known sets. See OptionSet#addOption(String, Options.Multiplicity) for details.

Definition at line 695 of file Options.java.

void commandlineprocessing.Options.addOptionAllSets ( String  key,
Separator  separator 
)

Add the given value option to all known sets. See OptionSet#addOption(String, Options.Separator) for details.

Definition at line 705 of file Options.java.

void commandlineprocessing.Options.addOptionAllSets ( String  key,
Separator  separator,
Multiplicity  multiplicity 
)

Add the given value option to all known sets. See OptionSet#addOption(String, Options.Separator, Options.Multiplicity) for details.

Definition at line 715 of file Options.java.

void commandlineprocessing.Options.addOptionAllSets ( String  key,
boolean  details,
Separator  separator 
)

Add the given value option to all known sets. See OptionSet#addOption(String, boolean, Options.Separator) for details.

Definition at line 725 of file Options.java.

void commandlineprocessing.Options.addOptionAllSets ( String  key,
boolean  details,
Separator  separator,
Multiplicity  multiplicity 
)

Add the given value option to all known sets. See OptionSet#addOption(String, boolean, Options.Separator, Options.Multiplicity) for details.

Definition at line 735 of file Options.java.

String commandlineprocessing.Options.toString (  ) 

This is the overloaded Object#toString() method, and it is provided mainly for debugging purposes.

Returns:
A string representing the instance

Definition at line 747 of file Options.java.


Member Data Documentation

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

final String commandlineprocessing.Options.DEFAULT_SET = "DEFAULT_OPTION_SET" [static]

The name used internally for the default set

Definition at line 16 of file Options.java.

Referenced by commandlineprocessing.Options.check(), and commandlineprocessing.Options.getSet().

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

String [] commandlineprocessing.Options.arguments = null [private]

StringBuffer commandlineprocessing.Options.checkErrors = null [private]


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

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