de.unihalle.informatik.Alida.tools
Class ALDOpRunner

java.lang.Object
  extended by de.unihalle.informatik.Alida.tools.ALDOpRunner

public class ALDOpRunner
extends java.lang.Object

Generic commandline interface to run an Alida operator. The operator needs to be annotated to allows 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).

Author:
Stefan Posch

Field Summary
private  java.lang.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  java.util.LinkedList<java.lang.String> matchingClassNames
          List of fully qualified class names of operators available
private  java.util.HashMap<java.lang.String,java.lang.String> nameParameterMap
          Hashmap to collect parameter name as given on command line and matching parameter name.
private  java.util.HashMap<java.lang.String,java.lang.String> nameValueMap
          Hashmap to collect parameter name as given on command line and correspnding value string
private  boolean noDefaultHistory
          If true, history files are not read and written by default.
private  ALDOperator op
          The operator to be invoked.
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 Summary
ALDOpRunner(java.lang.String[] args)
          Construct a ALDOpRunner using args
 
Method Summary
 java.util.LinkedList<java.lang.String> findALDOperators(java.lang.String opNamePattern)
          Find operator with given pattern among all annotated ALDOperators and return the full qualified names as a list.
protected  void findOperators(java.lang.String opNamePattern)
          This method is call once to populate the member matchingClassNames.
protected  ALDOperator getOperator(java.lang.String opName)
          This method is called to instantiate the ALDOperator.
protected  boolean isExactSubstring(java.lang.String substr, java.lang.String str)
          return true, if substr is a exact substring of str
static void main(java.lang.String[] args)
          Main routine of ALDOpRunner , see usage.
private static void printUsage()
          Print short usage to stderr.
private  void printUsageVerbose()
          Print verbose usage to stderr.
private  void readParameterValues(int firstIndex)
          Read all IN and INOUT parameters specified on the command line.
 void runIt()
          This method does the complete work to scan arguments, read and write parameters and runOp the operator.
private  void validateParameternames(int firstIndex)
          Validate the parametername=valuestring pairs with respect to syntax and validate the existance of the parameter in the operator interface.
private  void writeParameterValues(int firstIndex)
          Write all OUT and INOUT parameters specified on the command line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

args

private java.lang.String[] args
command line arguments.


debug

private boolean debug
debug flag for additional debuging information.


donotrun

private boolean donotrun
If true, the operator will not be invoked but only its interface printed to stdout.


matchingClassNames

protected java.util.LinkedList<java.lang.String> matchingClassNames
List of fully qualified class names of operators available


nameParameterMap

private java.util.HashMap<java.lang.String,java.lang.String> nameParameterMap
Hashmap to collect parameter name as given on command line and matching parameter name.


nameValueMap

private java.util.HashMap<java.lang.String,java.lang.String> nameValueMap
Hashmap to collect parameter name as given on command line and correspnding value string


noDefaultHistory

private boolean noDefaultHistory
If true, history files are not read and written by default.


op

private ALDOperator op
The operator to be invoked.


useRegEx

protected boolean useRegEx
If true, matching of operator name from commandline to the annoteated ALDOperators uses regular expression matching, otherwise exact substring matching


verbose

private boolean verbose
verbose flag to outout additional information to stdout.

Constructor Detail

ALDOpRunner

public ALDOpRunner(java.lang.String[] args)
Construct a ALDOpRunner using args

Parameters:
args - command line arguments
Method Detail

findALDOperators

public java.util.LinkedList<java.lang.String> findALDOperators(java.lang.String opNamePattern)
Find operator with given pattern among all annotated ALDOperators and return the full qualified names as a list. Operators found depend on member variable useRegEx return only ALDOperators annotated with appropriate execution mode.

Parameters:
opNamePattern - string with pattern for operator name

findOperators

protected void findOperators(java.lang.String opNamePattern)
This method is call once to populate the member matchingClassNames. May be overrridden may extending classes.

Parameters:
opNamePattern - string with pattern for operator name

getOperator

protected ALDOperator getOperator(java.lang.String opName)
This method is called to instantiate the ALDOperator. May be overrridden may extending classes.


isExactSubstring

protected boolean isExactSubstring(java.lang.String substr,
                                   java.lang.String str)
return true, if substr is a exact substring of str


main

public static void main(java.lang.String[] args)
Main routine of ALDOpRunner , see usage.

Parameters:
args - command line arguments

printUsage

private static void printUsage()
Print short usage to stderr.


printUsageVerbose

private void printUsageVerbose()
Print verbose usage to stderr.


readParameterValues

private void readParameterValues(int firstIndex)
Read all IN and INOUT parameters specified on the command line.

Parameters:
firstIndex - index of first parametername in args

runIt

public void runIt()
This method does the complete work to scan arguments, read and write parameters and runOp the operator.


validateParameternames

private void validateParameternames(int firstIndex)
Validate the parametername=valuestring pairs with respect to syntax and validate the existance of the parameter in the operator interface.

Parameters:
firstIndex - index of first parametername in args

writeParameterValues

private void writeParameterValues(int firstIndex)
Write all OUT and INOUT parameters specified on the command line.

Parameters:
firstIndex - index of first parametername in args