org.schmant.task.stub
Class AbstractProcessTask<T extends ProcessTaskSpec<T>>

java.lang.Object
  extended by org.schmant.support.AbstractArgumentChecker
      extended by org.schmant.task.stub.AbstractTask<T>
          extended by org.schmant.task.stub.AbstractActionTask<T>
              extended by org.schmant.task.stub.AbstractProcessTask<T>
All Implemented Interfaces:
TaskDependency, ActionTaskConfigurable<T>, ActionTaskSpec<T>, LoggingConfigurable<T>, OverwriteConfigurable<T>, SourceConfigurable<T>, SourceConfigured, TargetConfigurable<T>, TargetConfigured, GeneratorTaskConfigurable<T>, GeneratorTaskSpec<T>, ProcessTaskConfigurable<T>, ProcessTaskSpec<T>, Task, TaskRunnable, TaskSpecification<T>
Direct Known Subclasses:
AbstractAddTextTask, AbstractCallbackRecursiveProcessTask, AbstractJavacTask, AbstractProcessOneFileTask, AbstractProxyTask, AbstractTextInsertionTask, AbstractZipTask, ClosureTask, CopyTask, FormatCharacterFileTask, MoveTask, SchmantTaskrefTask, TarTask, TreeCopyTask, XsltTask

public abstract class AbstractProcessTask<T extends ProcessTaskSpec<T>>
extends AbstractActionTask<T>
implements ProcessTaskSpec<T>

This class may be used as a starting point for process task implementations.

Since:
0.5
Author:
Karl Gustafsson

Field Summary
 
Fields inherited from interface org.schmant.task.confable.OverwriteConfigurable
DEFAULT_OVERWRITE_STRATEGY
 
Constructor Summary
AbstractProcessTask()
           
 
Method Summary
 void copyProperties(T spec)
          Override the implementation from AbstractTask to copy the source properties.
protected  OverwriteStrategy getOverwriteStrategy()
           
 Object getTarget()
          Get the target.
protected  boolean isTargetMandatory()
          Is a target mandatory? This method always returns true.
 T setOverwrite(boolean b)
          Should things be overwritten? If this is set to true, it is equivalent to setting the overwrite strategy to DoOverwriteAndLogWarning.
 T setOverwriteStrategy(OverwriteStrategy strat)
          Set a strategy for how to react to existing entities in locations where the task wants to write.
 T setTarget(Object o)
          Set the target.
 String toString()
          Default implementation for tasks.
protected  Collection<String> validate(Report r)
          Override the method inherited from AbstractTask to give a validation error if no source is set (and AbstractActionTask.isSourcesMandatory() is true).
 
Methods inherited from class org.schmant.task.stub.AbstractActionTask
addSource, addSources, clearSources, getRelativeToBase, getSource, getSources, isMoreThanOneSourceAllowed, isSourcesMandatory, setRelativeToBase, setSource, setSources
 
Methods inherited from class org.schmant.task.stub.AbstractTask
cancel, createTask, getDefaultLogFooter, getDefaultLogHeader, getDependencyForTasksScheduledByThisTask, getDependencyObservable, getFailureCause, getLogFooter, getLogHeader, getSatisfiedStateLock, getThis, isCancelled, isDone, isInterrupted, isRunning, isSatisfied, isSuccessful, run, runInternal, setLogFooter, setLogHeader, setReportLevel, setTraceLogging
 
Methods inherited from class org.schmant.support.AbstractArgumentChecker
check, check, check, check
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.schmant.task.confable.SourceConfigurable
addSource, addSources, clearSources, setRelativeToBase, setSource, setSources
 
Methods inherited from interface org.schmant.task.confable.SourceConfigured
getSource, getSources
 
Methods inherited from interface org.schmant.task.TaskSpecification
createTask
 
Methods inherited from interface org.schmant.task.confable.LoggingConfigurable
setLogFooter, setLogHeader, setReportLevel, setTraceLogging
 

Constructor Detail

AbstractProcessTask

public AbstractProcessTask()
Method Detail

setTarget

public final T setTarget(Object o)
Description copied from interface: TargetConfigurable
Set the target.

Specified by:
setTarget in interface TargetConfigurable<T extends ProcessTaskSpec<T>>
Parameters:
o - The target.
Returns:
this

getTarget

public final Object getTarget()
Description copied from interface: TargetConfigured
Get the target.

Specified by:
getTarget in interface TargetConfigured
Returns:
The target or null if it is not set.

isTargetMandatory

protected boolean isTargetMandatory()
Is a target mandatory? This method always returns true. Subclasses may override this to return false if a target is not mandatory for them.

Returns:
true, always

setOverwrite

public final T setOverwrite(boolean b)
Description copied from interface: OverwriteConfigurable
Should things be overwritten? If this is set to true, it is equivalent to setting the overwrite strategy to DoOverwriteAndLogWarning. If this is set to false, it is equivalent to setting the overwrite strategy to DontOverwriteAndLogWarning.

Specified by:
setOverwrite in interface OverwriteConfigurable<T extends ProcessTaskSpec<T>>
Parameters:
b - Should things be overwritten?
Returns:
this

setOverwriteStrategy

public final T setOverwriteStrategy(OverwriteStrategy strat)
Description copied from interface: OverwriteConfigurable
Set a strategy for how to react to existing entities in locations where the task wants to write.

Specified by:
setOverwriteStrategy in interface OverwriteConfigurable<T extends ProcessTaskSpec<T>>
Parameters:
strat - The overwrite strategy.
Returns:
this

getOverwriteStrategy

protected final OverwriteStrategy getOverwriteStrategy()

validate

protected Collection<String> validate(Report r)
Description copied from class: AbstractActionTask
Override the method inherited from AbstractTask to give a validation error if no source is set (and AbstractActionTask.isSourcesMandatory() is true).

Subclasses may override this to add their own validations.

Overrides:
validate in class AbstractActionTask<T extends ProcessTaskSpec<T>>
Parameters:
r - A report to log warning and debug messages to. Validation errors should not be logged, though. They are logged later.
Returns:
A collection of error messages.

toString

public String toString()
Description copied from class: AbstractTask
Default implementation for tasks. Task implementations may override this. It is used in the default log header that is written (level INFO) before a task is run.

This implementation just returns the class name.

Overrides:
toString in class AbstractActionTask<T extends ProcessTaskSpec<T>>

copyProperties

public void copyProperties(T spec)
Description copied from class: AbstractActionTask
Override the implementation from AbstractTask to copy the source properties. Subclasses must override this to copy their own properties.

Specified by:
copyProperties in interface TaskSpecification<T extends ProcessTaskSpec<T>>
Overrides:
copyProperties in class AbstractActionTask<T extends ProcessTaskSpec<T>>
Parameters:
spec - The specification to copy properties to.