ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Fields | Public Methods | Protected Fields | List of all members
CLIArgs Class Reference
Inheritance diagram for CLIArgs:
[legend]
Collaboration diagram for CLIArgs:
[legend]

Class Description


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 ()
 

Member Function Documentation

◆ load()

boolean load ( Variable  variable,
boolean  searchOnly 
)

Searches the variable in the command line parameters.

Parameters
variableThe variable to retrieve.
searchOnlyIf true, the variable is not set. Defaults to false.
Returns
true if variable was found, false if not.

Reimplemented from ConfigurationPlugin.

◆ setArgs()

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.

Note
In standard application scenarios, this method is invoked by method ALIB.init for the singleton of this class found in ALIB.config.
Parameters
argsParameters taken from standard Java method main() (the list of command line arguments). Accepts null to ignore command line parameters.

Member Data Documentation

◆ allowedMinimumShortCut

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.

◆ args

String [] args
protected

The list of command line arguments.

◆ cliArg

Substring cliArg = new Substring()
protected

One time created, reused variable.

◆ defaultCategories

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_.


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