org.schmant.task.meta
Class RecursiveProcessTask

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>
                  extended by org.schmant.task.stub.AbstractCallbackRecursiveProcessTask<RecursiveProcessTask>
                      extended by org.schmant.task.meta.RecursiveProcessTask
All Implemented Interfaces:
TaskDependency, ActionTaskConfigurable<RecursiveProcessTask>, ActionTaskSpec<RecursiveProcessTask>, LoggingConfigurable<RecursiveProcessTask>, OverwriteConfigurable<RecursiveProcessTask>, SourceConfigurable<RecursiveProcessTask>, SourceConfigured, TargetConfigurable<RecursiveProcessTask>, TargetConfigured, GeneratorTaskConfigurable<RecursiveProcessTask>, GeneratorTaskSpec<RecursiveProcessTask>, ProcessTaskConfigurable<RecursiveProcessTask>, ProcessTaskSpec<RecursiveProcessTask>, RecursiveActionTaskConfigurable<RecursiveProcessTask>, RecursiveActionTaskSpec<RecursiveProcessTask>, RecursiveProcessTaskConfigurable<RecursiveProcessTask>, RecursiveProcessTaskSpec<RecursiveProcessTask>, Task, TaskRunnable, TaskSpecification<RecursiveProcessTask>

public final class RecursiveProcessTask
extends AbstractCallbackRecursiveProcessTask<RecursiveProcessTask>

See RecursiveProcessTF

Since:
0.5
Author:
Karl Gustafsson
Task_package:
org.schmant.task.base

Field Summary
 
Fields inherited from interface org.schmant.task.confable.OverwriteConfigurable
DEFAULT_OVERWRITE_STRATEGY
 
Method Summary
protected  void callback(Report r, EntityView ev, DirectoryView targetDir, RelativeLocation rel)
          This callback method is called for every entity returned when iterating recursively over the sources.
 void copyProperties(RecursiveProcessTask spec)
          Override the implementation from AbstractTask to copy the source properties.
 TaskDependency getDependencyForTasksScheduledByThisTask()
          This implementation returns this.
 Object getTargetFromTargetStrategy(EntityView source, DirectoryView targetDir, RelativeLocation rel)
          This method interprets the target strategy into an object that can be used to calculate the target.
 Object getTargetStrategy()
          Since 1.1, this method returns an Object rather than a TargetStrategy object since this now is either a TargetStrategy or a closure.
protected  void runTask(Report r, Task t)
           
 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.AbstractCallbackRecursiveProcessTask
isDisableHeaderLogging, isMoreThanOneSourceAllowed, runInternal, setDepthFirstIterator, setDisableHeaderLogging
 
Methods inherited from class org.schmant.task.stub.AbstractProcessTask
getOverwriteStrategy, getTarget, isTargetMandatory, setOverwrite, setOverwriteStrategy, setTarget
 
Methods inherited from class org.schmant.task.stub.AbstractActionTask
addSource, addSources, clearSources, getRelativeToBase, getSource, getSources, isSourcesMandatory, setRelativeToBase, setSource, setSources
 
Methods inherited from class org.schmant.task.stub.AbstractTask
cancel, createTask, getDefaultLogFooter, getDefaultLogHeader, getDependencyObservable, getFailureCause, getLogFooter, getLogHeader, getSatisfiedStateLock, getThis, isCancelled, isDone, isInterrupted, isRunning, isSatisfied, isSuccessful, run, 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.TargetConfigurable
setTarget
 
Methods inherited from interface org.schmant.task.confable.OverwriteConfigurable
setOverwrite, setOverwriteStrategy
 
Methods inherited from interface org.schmant.task.confable.TargetConfigured
getTarget
 
Methods inherited from interface org.schmant.task.TaskSpecification
createTask
 
Methods inherited from interface org.schmant.task.confable.LoggingConfigurable
setLogFooter, setLogHeader, setReportLevel, setTraceLogging
 
Methods inherited from interface org.schmant.task.confable.SourceConfigured
getSource, getSources
 
Methods inherited from interface org.schmant.task.confable.SourceConfigurable
addSource, addSources, clearSources, setRelativeToBase, setSource, setSources
 

Method Detail

getTargetStrategy

public Object getTargetStrategy()
Since 1.1, this method returns an Object rather than a TargetStrategy object since this now is either a TargetStrategy or a closure.

Returns:
The target strategy, a TargetStrategy or a closure.

runTask

protected void runTask(Report r,
                       Task t)

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 AbstractCallbackRecursiveProcessTask<RecursiveProcessTask>
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.

getTargetFromTargetStrategy

public Object getTargetFromTargetStrategy(EntityView source,
                                          DirectoryView targetDir,
                                          RelativeLocation rel)
This method interprets the target strategy into an object that can be used to calculate the target.

The target strategy may be one of the following:

  1. A TargetStrategy object – The TargetStrategy.getTarget(org.schmant.task.ProcessTaskSpec, DirectoryView, RelativeLocation) method is called to get the target.
  2. A closure taking the following arguments, in this order:
    1. An EntityView – The entity being processed.
    2. A DirectoryView – The target base directory.
    3. A RelativeLocation – The source entity's location relative to the source base directory.
    The closure is evaluated to get the target. It should return something that can be interpreted into a FutureEntity.

Parameters:
targetDir - The base target directory.
rel - The relative location of the processed entity relative to the base source directory.
Returns:
A target location which should be an object that can be interpreted into a FutureEntity.

callback

protected void callback(Report r,
                        EntityView ev,
                        DirectoryView targetDir,
                        RelativeLocation rel)
Description copied from class: AbstractCallbackRecursiveProcessTask
This callback method is called for every entity returned when iterating recursively over the sources.

Specified by:
callback in class AbstractCallbackRecursiveProcessTask<RecursiveProcessTask>
Parameters:
r - The current report.
ev - The entity.
targetDir - The target property.
rel - The entity's location relative to the source it was returned from. If the source object was a file, the relative location is the file's name.

getDependencyForTasksScheduledByThisTask

public TaskDependency getDependencyForTasksScheduledByThisTask()
Description copied from class: AbstractTask
This implementation returns this. Subclasses that use TaskExecutor:s must override this method to return a dependency object for all of its scheduled tasks.

Specified by:
getDependencyForTasksScheduledByThisTask in interface Task
Overrides:
getDependencyForTasksScheduledByThisTask in class AbstractTask<RecursiveProcessTask>
Returns:
this

copyProperties

public void copyProperties(RecursiveProcessTask 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<RecursiveProcessTask>
Overrides:
copyProperties in class AbstractCallbackRecursiveProcessTask<RecursiveProcessTask>
Parameters:
spec - The specification to copy properties to.

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 AbstractProcessTask<RecursiveProcessTask>