Specialization of abstract interface class ConfigurationPlugin, which takes all command line parameters in the constructor and reads variable values from those parameters on request. Its priority value usually is Configuration.PRIO_CLI_ARGS, which is higher than all other default plug-ins provided.
Variable categories are used as a prefix together with an underscore '_'
. This means, if variable LOCALE in category ALIB is accessed, the command line parameter –ALIB_LOCALE=xyz is read.
Category and Variable names are insensitive in respect to character case.
Command line variables may be passed with either one hyphen ('-') or two ('–'). Both are accepted.
An application can specify one or more "default categories" by adding their string names to public field defaultCategories. Variables of these categories are recognized by the plug-in also when given without the prefix of category name and underscore '_'
.
Furthermore, an application may set public field allowedMinimumShortCut to a value greater than 0
. In this case, the plug-in recognizes variables in CLI arguments already when at least this amount of characters is provided. In other words, when reading an argument as many characters of the variable name as possible are 'consumed' and if a minimum number is given with allowedMinimumShortCut, such minimum is sufficient. If the remaining part of the argument string is either empty or continues with an equal sign '='
, then the variable is recognized (with an empty value or the value after the equal sign).
Fields allowedMinimumShortCut and defaultCategories may also be used in combination.
Public Fields | |
int | allowedMinimumShortCut = 0 |
ArrayList< String > | defaultCategories = new ArrayList<String>() |
Public Fields inherited from ConfigurationPlugin | |
XTernalizer | stringConverter |
Public Methods | |
boolean | load (Variable variable, boolean searchOnly) |
void | setArgs (String[] args) |
Public Methods inherited from ConfigurationPlugin | |
boolean | load (Variable variable) |
boolean | store (Variable variable) |
boolean | store (Variable variable, Object externalizedValue) |
Protected Fields | |
String[] | args |
Substring | cliArg = new Substring() |
Protected Fields inherited from ConfigurationPlugin | |
XTernalizer | defaultStringConverter = new XTernalizer() |
Additional Inherited Members | |
Protected Methods inherited from ConfigurationPlugin | |
ConfigurationPlugin () | |
boolean load | ( | Variable | variable, |
boolean | searchOnly | ||
) |
Searches the variable in the command line parameters.
variable | The variable to retrieve. |
searchOnly | If true , the variable is not set. Defaults to false . |
true
if variable was found, false
if not. Reimplemented from ConfigurationPlugin.
void setArgs | ( | String[] | args | ) |
Sets the command line argument list. Needs to be called once after construction. Should not be invoked directly. Rather use Configuration.setCommandLineArgs.
args | Parameters taken from standard Java method main() (the list of command line arguments). Accepts null to ignore command line parameters. |
int allowedMinimumShortCut = 0 |
If this field is set to a value greater than 0
, this plug-in recognizes variables in CLI arguments already when at least this amount of characters is provided. If the remaining part of the argument string is either empty or continues with an equal sign '='
, then the variable is recognized.
|
protected |
The list of command line arguments.
ArrayList<String> defaultCategories = new ArrayList<String>() |
An application can specify one or more "default categories" by adding the category names here. Variables of these categories are recognized by the plug-in also when given without the prefix of category_
.