|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.massimo.tools.scriptrunner.AbstractTask
public abstract class AbstractTask
Abstract implementation of the Task interface, handling much of the housekeeping.
This class introduces and handles the XML attributes:
| Field Summary | |
|---|---|
protected Element |
definition
The task defining XML |
protected String |
name
The Task's unique name |
protected Task |
parent
The parent of this. |
protected Map<String,String> |
properties
Populated with both task element and child connection attributes |
protected String |
type
This Task's type |
| Fields inherited from interface com.massimo.tools.scriptrunner.Task |
|---|
DATA_ERROR, ERROR, FINISHED, INTERRUPTED, PROMPT, RUNNING, START, SUCCESS |
| Constructor Summary | |
|---|---|
protected |
AbstractTask(Task parent,
String type,
Element definition,
Map<String,String> parentProperties)
Basic constructor, as used by TaskFactory. |
| Method Summary | |
|---|---|
protected abstract int |
doProcess(ExecutionContext context)
Implementing classes only need to do their own work and log progress when appropriate. |
protected abstract int |
doValidate(ValidationContext context)
Check whether this task should be able to run. |
protected boolean |
getBooleanProperty(String propertyName,
boolean defaultValue)
Convenience method |
protected String |
getCurrentWorkingDirectory()
Used for bind or parameter substitution. |
Element |
getDefinition()
|
protected int |
getIntProperty(String propertyName,
int defaultValue)
Convenience method |
protected abstract org.apache.log4j.Logger |
getLogger()
|
String |
getName()
|
Task |
getParent()
|
Map<String,String> |
getProperties()
|
protected int |
getStartProcessingRow()
The field returned, startProcessingRow, is set by process(ExecutionContext) is log-progress is true. |
protected String |
getText()
The XOM Node.getValue() method returns the XPath 1.0 string-value of Node. |
String |
getType()
|
void |
interrupt()
Tells the Task to stop processing. |
protected boolean |
isIgnoreableError(int errorCode)
|
protected boolean |
isIgnoreableError(String errorCode)
|
boolean |
isInterrupted()
|
protected boolean |
isLogProgress()
|
protected void |
postProcess(ExecutionContext context,
int result)
Run after doProcess() and result has been checked. |
protected void |
preProcess(ExecutionContext context)
Run immendiately before doProcess() Default implementation: do nothing |
int |
process(ExecutionContext context)
The central work method. |
static String |
resultCodeToString(int resultCode)
|
protected String |
substituteParameters(String text)
Uses MessageFormat to substitute parameter values into text based on position. |
String |
toString()
|
int |
validate(ValidationContext context)
Check whether this task should be able to run. |
protected void |
validateConnections(ValidationContext context)
Validate any child connection elements |
protected int |
validateParameters(ValidationContext context,
String text)
Check MessageFormat parameter values exist for all formats in text. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Element definition
protected String name
protected Task parent
protected Map<String,String> properties
protected String type
| Constructor Detail |
|---|
protected AbstractTask(Task parent,
String type,
Element definition,
Map<String,String> parentProperties)
parent - A parent Task, or null for the root Task.type - The type of task, e.g. SQL, Print, Serialdefinition - Task to execute, including new connection properties.parentProperties - | Method Detail |
|---|
protected abstract int doProcess(ExecutionContext context)
throws Exception
context -
Exceptionprocess(ExecutionContext)
protected abstract int doValidate(ValidationContext context)
throws Exception
context -
Exception
protected boolean getBooleanProperty(String propertyName,
boolean defaultValue)
propertyName - defaultValue -
protected final String getCurrentWorkingDirectory()
public Element getDefinition()
getDefinition in interface Task
protected int getIntProperty(String propertyName,
int defaultValue)
propertyName - defaultValue -
protected abstract org.apache.log4j.Logger getLogger()
public String getName()
getName in interface Taskpublic Task getParent()
getParent in interface Taskpublic Map<String,String> getProperties()
getProperties in interface Taskprotected final int getStartProcessingRow()
protected final String getText()
public String getType()
getType in interface Taskpublic void interrupt()
interrupt in interface Taskprotected final boolean isIgnoreableError(int errorCode)
errorCode -
protected final boolean isIgnoreableError(String errorCode)
errorCode -
public boolean isInterrupted()
protected final boolean isLogProgress()
protected void postProcess(ExecutionContext context,
int result)
context - result - protected void preProcess(ExecutionContext context)
context -
public int process(ExecutionContext context)
throws Exception
process in interface Taskcontext - A concrete ExecutionContext
Exceptionpublic static final String resultCodeToString(int resultCode)
resultCode -
protected final String substituteParameters(String text)
text -
IllegalArgumentException - if a parameter value is not found.public String toString()
toString in class Objectpublic int validate(ValidationContext context)
validate in interface Taskcontext - A concrete ValidationContext
protected void validateConnections(ValidationContext context)
context -
protected final int validateParameters(ValidationContext context,
String text)
context - text -
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||