Public Member Functions

alma.acs.util.CmdLineArgs Class Reference

List of all members.

Public Member Functions

 CmdLineArgs ()
void reset ()
void registerOption (String name, int minValuesCount)
void registerOption (CmdLineRegisteredOption opt)
void parseArgs (String[] args)
String[] getAllArgs ()
CmdLineOption[] getRecognizedArgs ()
boolean isSpecified (CmdLineRegisteredOption clo)
String[] getValues (CmdLineOption clo)

Detailed Description

Deals with commandline options (String[] args), for example to merge several sets of option specifications.

An option consists of a key arg and 0...many value arguments. The method parseArgs will attempt to guess which arguments are keys and which are values, e.g. looking for a "-" prefix. This class can therefore be used for unknown sets of options.

To avoid fooling the algorithm with weird values (like "-273"), the expected option keys with their minimum number of values can be specified using the registerOption methods. This mechanism can later be extended to allow validation of required arguments.

TODO: logging and error handling

Author:
hsommer

Constructor & Destructor Documentation

alma.acs.util.CmdLineArgs.CmdLineArgs (  ) 

Member Function Documentation

String [] alma.acs.util.CmdLineArgs.getAllArgs (  ) 

Returns all arguments (both options and values). If arguments were parsed more than once, the values from a later call overwrite earlier ones. Options and values that could not be distinguished during parsing appear in the original order.

Returns:

References alma.acs.util.CmdLineOption.getName().

Referenced by alma.acs.container.corba.OrbConfigurator.getOptions().

CmdLineOption [] alma.acs.util.CmdLineArgs.getRecognizedArgs (  ) 

Gets all arguments that were recognized by the parser. This includes arguments registered before parsing, as well as arguments recognized automatically. The values for these args can be obtained from getValues(CmdLineOption).

Returns:
String [] alma.acs.util.CmdLineArgs.getValues ( CmdLineOption  clo  ) 
boolean alma.acs.util.CmdLineArgs.isSpecified ( CmdLineRegisteredOption  clo  ) 

Returns true if the given option clo appeared in the argument lists that were passed to parseArgs; false otherwise.

Parameters:
clo 
Returns:
boolean

Referenced by alma.acs.config.validators.ConfigFileFinder.configureFromArgs(), alma.acs.eclipse.utils.pluginbuilder.PluginBuilder.parseCmdLineArgs(), and alma.acs.container.AcsContainerRunner.setOptions().

void alma.acs.util.CmdLineArgs.parseArgs ( String[]  args  ) 
void alma.acs.util.CmdLineArgs.registerOption ( String  name,
int  minValuesCount 
)
void alma.acs.util.CmdLineArgs.registerOption ( CmdLineRegisteredOption  opt  ) 
void alma.acs.util.CmdLineArgs.reset (  ) 

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties