Menu

Access

Ray

Access To The Parsed Values

After the Config parser has been initialized using the standard constructor or the two-argument constructor and the command line arguments have been parsed using parseArguments(), the parsed values can be accessed by one of the three methods described hereunder.

config.isOn(char option)

The isOn() method works for any option, even for those not having been specified within the option string when the Config parser has been initialized by calling one of its constructors. The method always returns false for undefined options. For options that have been specified in the option string the method returns true if such option has been seen at the command line, e.g.

config.isOn('c')

returns true when the array passed to parseArguments() contained "-c" (separate or within a group, e.g. "-cde").

One can obtain the argument values of options that accept them by calling

config.getOptionArgs(char option)

The getOptionArgs() returns
* null for undefined options (not included in the option string)
- empty array for options that had no argument values specified (see Note below)
- non-empty String[] for options whose argument values have been collected

Note: The when the parseArguments() method returned true, every call to getOptionArgs() for an argument-requiring option yields a non-empty array if isOn() returns true for the same option.

Finally, all arguments that haven't belonged to any of the argument-acception options, have been collected as non-option arguments. These can be obtained using

config.getArguments()

The getArguments() method returns those non-option arguments as a String[]. If there were no non-option arguments, the returned value would be null.


Related

Wiki: Overview