public class MyMDI extends AbstractMDIApplication { public MyMDI(String[] args) { super("My MDI"); ... } @Override public URL getCommandLineConfiguration() { return this.getClass().getResource("commandline.xml"); } }
argument
and argumentGroup
elements:argument
specifies an argument which is handled by the listener, and its associated typeargumentGroup
specifies a group of argument which is handled by the listenerargument
element specifies a command-line argument which is handled by the listener. It has the following attributes:key
attribute (mandatory) is the argument nametype
attribute (optional) is the argument type. The handler will parse the argument to try to convert it to the appropriate typestring
(the default type) is for integer argumentsint
is for integer argumentsshort
is for short argumentschar
is for char argumentsfloat
is for float argumentsboolean
is for boolean argumentsurl
is for file paths argumentsproperties
is for an argument which point to a properties file which specifies other argumentsempty
is for arguments which have no value, but will be only be used for their existanceint
, short
, or char
, in order to specify the value of the argument by a significant name. For example:<arguments> <argument key="align" type="int" > <states defaultState="1" > <state name="left" value="0" /> <state name="right" value="1" /> </states> </argument> </arguments>And if we start the application with:
java -jar MyMDI.jar -align=right
Then the arguments map will contain one align
element with the value 1.properties
points to a properties file which specified (key, value) pairs for other arguments.<arguments> <argument key="sizeX" type="int" /> <argument key="sizeY" type="int" /> <argument key="prop" type="properties" /> </arguments>We can for example start the application with:
java -jar MyMDI.jar -prop=properties.properties
If the properties.properties file has the following content:sizeX=800 sizeY=300Then the arguments map will contain two
sizeX
and sizeY
elements.
int
arguments:<arguments> <argument key="sizeX" type="int" /> <argument key="sizeY" type="int" /> </arguments>We can for example start the application with:
java -jar MyMDI.jar -sizeX=800 -sizeY=300
Then the arguments map will contain two sizeX
and sizeY
elements.
java -jar MyMDI.jar -sizeX=800
Then the arguments map will contain one sizeX
element.
empty
and an url
arguments:<arguments> <argument key="import" type="empty" /> <argument key="file" type="url" /> </arguments>We can for example start the application with:
java -jar MyMDI.jar -import -file=L:/my/file.xml
Then the arguments map will contain two import
and file
elements:import
has a null value because it is an empty
argumentfile
has a File value because it is an url
argumentargumentGroup
element specifies a group of command-line arguments which is handled by the listener. It has the following attributes:key
attribute (mandatory) is the argument nameargument
children which specify the arguments which are parts of the group. Each child element have the following attributes: key
attribute (mandatory) is the argument name. This argument msut be present as a top-level argument
in the xml filemandatory
attribute is a boolean specifying if the argument is mandatory (by default the argument is optional)empty
and two url
arguments:<arguments> <argument key="import" type="empty" /> <argument key="file" type="url" /> <argument key="file2" type="url" /> <argumentGroup key="import"> <argument key="import" mandatory="true" /> <argument key="file" mandatory="true"/> </argumentGroup> <argumentGroup key="compare"> <argument key="compare" mandatory="true"/> <argument key="file" mandatory="true"/> <argument key="file2" mandatory="true"/> </argumentGroup> </arguments>We can for example start the application with:
java -jar MyMDI.jar -import -file=L:/my/file.xml
In that case, there will be only one argumentGroup
for the key import
with two arguments:import
which is an empty
argumentfile
which is an url
argument
java -jar MyMDI.jar -import -file=L:/my/file.xml -compare
In that case, we will still have only one argumentGroup
for the key import
with the same two arguments, because there is a compare
argument but the file2
is absent.
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences