com.massimo.tools.scriptrunner.control
Class IfTask

java.lang.Object
  extended by com.massimo.tools.scriptrunner.AbstractTask
      extended by com.massimo.tools.scriptrunner.control.AbstractCompoundTask
          extended by com.massimo.tools.scriptrunner.control.IfTask
All Implemented Interfaces:
Task

public class IfTask
extends AbstractCompoundTask

Conditional execution of a single child task.
Introduces the attributes ifname and ifvalue. The ifname attribute must exist. The optional ifvalue attribute will be a list of values. If the value of the property named by ifname matches one of the ifvalue list, the contained task will be executed. If ifvalue is not set, the contained task will be executed if the ifname property is set to any value.
If the ifname property is not in the ifvalue list, this Task will still return Task.SUCCESS.


Field Summary
 
Fields inherited from class com.massimo.tools.scriptrunner.AbstractTask
definition, name, parent, properties, type
 
Fields inherited from interface com.massimo.tools.scriptrunner.Task
DATA_ERROR, ERROR, FINISHED, INTERRUPTED, PROMPT, RUNNING, START, SUCCESS
 
Constructor Summary
IfTask(Task parent, String type, Element definition, Map<String,String> contextProperties)
           
 
Method Summary
 int doValidate(ValidationContext context)
          Check whether this task should be able to run.
protected  org.apache.log4j.Logger getLogger()
          
protected  int processCompound(ExecutionContext context, Elements tasks)
          Checks the attributes Constants.ATTRIBUTE_IFNAME and Constants.ATTRIBUTE_IFVALUE to determine whether to run the child task.
 
Methods inherited from class com.massimo.tools.scriptrunner.control.AbstractCompoundTask
addChild, doProcess, getChildren, interrupt
 
Methods inherited from class com.massimo.tools.scriptrunner.AbstractTask
getBooleanProperty, getCurrentWorkingDirectory, getDefinition, getIntProperty, getName, getParent, getProperties, getStartProcessingRow, getText, getType, isIgnoreableError, isIgnoreableError, isInterrupted, isLogProgress, postProcess, preProcess, process, resultCodeToString, substituteParameters, toString, validate, validateConnections, validateParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IfTask

public IfTask(Task parent,
              String type,
              Element definition,
              Map<String,String> contextProperties)
Parameters:
parent -
type -
definition -
contextProperties -
Method Detail

doValidate

public int doValidate(ValidationContext context)
               throws Exception
Check whether this task should be able to run. Implementations should check for the prescence of files, attributes,...
Validates all child tasks Check the attributes Constants.ATTRIBUTE_IFNAME and Constants.ATTRIBUTE_IFVALUE.

Overrides:
doValidate in class AbstractCompoundTask
Returns:
O for success. Anything else is a failure.
Throws:
Exception

getLogger

protected org.apache.log4j.Logger getLogger()

Specified by:
getLogger in class AbstractTask
Returns:
Class logger

processCompound

protected int processCompound(ExecutionContext context,
                              Elements tasks)
                       throws Exception
Checks the attributes Constants.ATTRIBUTE_IFNAME and Constants.ATTRIBUTE_IFVALUE to determine whether to run the child task.

Specified by:
processCompound in class AbstractCompoundTask
Parameters:
context -
tasks - A list of Task definition Elements
Returns:
The result of running all tasks
Throws:
Exception