You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Configuration class will integrate progressively more and
more parameters to be set and loaded from the properties file.
The best way to add new attributes to the configuration will be to add
some helpers on definition and on parsing vaue, but also on help side.
Requesting from the CLI, you would get a well formated and documented
help bout possible parameters and their values.
You would get some ArgParser interface and a CLIManager to support those parser.
In this interface, the main intersting thing are name and description,
useful to generate the help on the cli. Name will be the name of the parameter, and description will help understanding its usage.
An abstract class will provide a default implmentation for all parsers.
An Integer parameter will have to parse int values.
publicclassIntArgParserextendsArgParser<Integer>{
publicIntArgParser() {
super();
}
publicIntArgParser(
Stringname,
StringshortKey,
StringlongKey,
intdefaultValue,
intmin,
intmax,
Stringdescription,
StringerrorMessage) {
super(name, shortKey, longKey, defaultValue, min, max, description, errorMessage);
}
@Overridepublicbooleanvalidate(StringstrValue) {
value = defaultValue;
try {
value = parse(strValue);
if ((min != null && value < min) || (max != null && value > max)) {
errorMessage += String.format(
"value for %s must be between %s and %s. Value has been limited to min/max", name, min, max,
defaultValue);
value = (value < min ? min : (value > max ? max : value));
}
} catch (Exceptione) {
value = defaultValue;
errorMessage += String.format("value %s for argument %s is not possible.reset to default Value %s",
strValue, name, defaultValue);
returnfalse;
}
returntrue;
}
@OverridepublicIntegerparse(StringstrValue) {6intvalue = Integer.parseInt(strValue);
returnvalue;
}
}
The same way to implement Boolean, Double and Float will be used.
BooleanArgParser will parse a boolean value parameter,
DoubleArgParser will parse a double value parameter,
FloatArgParser will parse a float value parameter.
And specific one will be
IntArrayArgParser will parse a list of int values parameter.9
And a final pass would provide a way to load/save those parameter to a configuration file.
But this is another story !
The text was updated successfully, but these errors were encountered:
Evolution
The Configuration class will integrate progressively more and
more parameters to be set and loaded from the properties file.
The best way to add new attributes to the configuration will be to add
some helpers on definition and on parsing vaue, but also on help side.
Requesting from the CLI, you would get a well formated and documented
help bout possible parameters and their values.
You would get some
ArgParser
interface and aCLIManager
to support those parser.the IArgParser interface
In this interface, the main intersting thing are name and description,
useful to generate the help on the cli. Name will be the
name
of the parameter, anddescription
will help understanding its usage.An abstract class will provide a default implmentation for all parsers.
And the CLIManager will be used to parse command line interface parameters, but also to provide the help text.
Implementing a parser
An Integer parameter will have to parse int values.
The same way to implement Boolean, Double and Float will be used.
BooleanArgParser
will parse a boolean value parameter,DoubleArgParser
will parse a double value parameter,FloatArgParser
will parse a float value parameter.And specific one will be
IntArrayArgParser
will parse a list of int values parameter.9And a final pass would provide a way to load/save those parameter to a configuration file.
But this is another story !
The text was updated successfully, but these errors were encountered: