public class ALDOpRunner extends Object implements ALDOperatorExecutionProgressEventListener
An operator needs to be annotated to allow execution mode CMDLINE.
Reading of IN and INOUT parameters and writing of OUT and INOUT parameters
is accomplished using the interface
ALDDataIOCmdline
in conjunction with ALDDataIOManagerCmdline
.
For each parameter which should be read or written according to its
annotated direction
, a name=value pair has to be given as
argument.
If the flag --donotrun
or -n
is given, only the
parameters of the operator and there details will be printed but the
operator is not invoked.
The flag noDefaultHistory
specifies that not for each input
parameter a history file should be read and associated with the parameter
for all data types (irrespective whether the corresponding provider does so).
Likewise this flags specifies if a history is to be written for all output
parameters.
If the flag --verbose
or -v
the interface of the
operator will be printed to stdout (and potentially further information).
In addition the flag --showProgress
or -s
is
available to switch on display of progress messages.
The values of IN and INOUT parameters are set in the following order: first existing modifying parameters are set. As their callback functions my add parameters to the interface of the operator, this process is repeated where only modifying parameters not already handled are considered. During this iteration the non-existence of a parameter specified on the command line is not considered as an error (as it may become visible during this iteration). Finally values for all non-modifying parameters are set.
Modifier and Type | Field and Description |
---|---|
private String[] |
args
command line arguments.
|
private boolean |
debug
debug flag for additional debuging information.
|
private boolean |
donotrun
If true, the operator will not be invoked but only its
interface printed to stdout.
|
protected LinkedList<String> |
matchingClassNames
List of fully qualified class names of operators available
|
(package private) LinkedList<String> |
modifyingParametersAlreadySet
Names of modifying parameters which have already been set (i.e. values from commandline
|
private HashMap<String,String> |
nameParameterMap
Hashmap to collect parameter name as given on command line and matching
parameter name to be handled next
|
private HashMap<String,String> |
nameValueMap
Hashmap to collect parameter name as given on command line and
corresponding value string
|
private boolean |
noDefaultHistory
If true, history files are not read and written by default.
|
private ALDOperator |
op
The operator to be invoked.
|
private boolean |
showProgressEvents
Flag to enable/disable display of progress events.
|
protected boolean |
useRegEx
If true, matching of operator name from commandline to the
annoteated ALDOperators uses regular expression matching,
otherwise exact substring matching
|
private boolean |
verbose
verbose flag to outout additional information to stdout.
|
Constructor and Description |
---|
ALDOpRunner(String[] arguments)
Construct a
ALDOpRunner using args |
Modifier and Type | Method and Description |
---|---|
private void |
collectParameternames(int firstIndex,
boolean modifyingParameters)
Collect IN and INOUT parameters to be set next.
|
LinkedList<String> |
findALDOperators(String opNamePattern)
Find operator with given pattern among all annotated ALDOperators
and return the full qualified names as a list.
|
protected void |
findOperators(String opNamePattern)
This method is call once to populate the member
matchingClassNames . |
protected ALDOperator |
getOperator(String opName)
This method is called to instantiate the ALDOperator.
|
void |
handleOperatorExecutionProgressEvent(ALDOperatorExecutionProgressEvent e)
Method which is called on event occurence.
|
protected boolean |
isExactSubstring(String substr,
String str)
return true, if
substr is a exact substring of str |
static void |
main(String[] args)
Main routine of
ALDOpRunner , see usage. |
private void |
printException(ALDException e) |
private static void |
printUsage()
Print short usage to stderr.
|
private void |
printUsageVerbose()
Print verbose usage to stderr.
|
void |
runIt()
This method does the complete work to scan arguments, read and write parameters
and
runOp the operator. |
private void |
setParameterValues(int firstIndex)
Set all parameters contained in
nameParameterMap in this.op
with values from commandline |
private void |
validateParameternames(int firstIndex)
Validate the
parametername=valuestring pairs with respect to syntax |
private void |
writeParameterValues(int firstIndex)
Write all OUT and INOUT parameters specified on the command line.
|
private boolean donotrun
private boolean noDefaultHistory
protected boolean useRegEx
private boolean verbose
private boolean showProgressEvents
The flag is set to false by default and can be set to true using the
command line parameters --showProgress
or -s
.
private boolean debug
private String[] args
private ALDOperator op
protected LinkedList<String> matchingClassNames
private HashMap<String,String> nameValueMap
private HashMap<String,String> nameParameterMap
LinkedList<String> modifyingParametersAlreadySet
public ALDOpRunner(String[] arguments)
ALDOpRunner
using args
arguments
- command line argumentsprivate static void printUsage()
private void printUsageVerbose()
public static void main(String[] args)
ALDOpRunner
, see usage.args
- command line argumentspublic void runIt()
runOp
the operator.private void validateParameternames(int firstIndex)
parametername=valuestring
pairs with respect to syntaxfirstIndex
- index of first parametername in argsprivate void collectParameternames(int firstIndex, boolean modifyingParameters)
If modifyingParameters
is true, only parameters which indicate
they might modifyParameterDescriptors and have not been already handled (i.e. contained in
modifyingParametersAlreadySet
) are considered. Non-existing parameters are ignored.
If modifyingParameters
is false, all non-modifying parameters are considered and non-existence
is considered an error.
The parameter names found to be set next and the corresponding value strings are collected
in the hash maps nameParameterMap
and nameValueMap
respectively
as a side effect.
firstIndex
- index of first parametername in argsmodifyingParameters
- if true only parameters which indicate they might modifyParameterDescriptors and have not been already handled (i.e. contained in
* modifyingParametersAlreadySet
) are consideredprivate void setParameterValues(int firstIndex)
nameParameterMap
in this.op
with values from commandlinefirstIndex
- index of first parametername in argsprivate void writeParameterValues(int firstIndex)
firstIndex
- index of first parametername in argsprotected ALDOperator getOperator(String opName)
protected void findOperators(String opNamePattern)
matchingClassNames
.
May be overrridden may extending classes.opNamePattern
- string with pattern for operator namepublic LinkedList<String> findALDOperators(String opNamePattern)
opNamePattern
- string with pattern for operator nameprotected boolean isExactSubstring(String substr, String str)
substr
is a exact substring of str
private void printException(ALDException e)
public void handleOperatorExecutionProgressEvent(ALDOperatorExecutionProgressEvent e)
ALDOperatorExecutionProgressEventListener
handleOperatorExecutionProgressEvent
in interface ALDOperatorExecutionProgressEventListener
e
- Event to be handled.Copyright © 2010–2021 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.