org.schmant.task.stub
Class AbstractCallbackRecursiveProcessTask<T extends RecursiveProcessTaskSpec<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>
                  extended by org.schmant.task.stub.AbstractCallbackRecursiveProcessTask<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>, RecursiveActionTaskConfigurable<T>, RecursiveActionTaskSpec<T>, RecursiveProcessTaskConfigurable<T>, RecursiveProcessTaskSpec<T>, Task, TaskRunnable, TaskSpecification<T>
Direct Known Subclasses:
RecursiveProcessTask

public abstract class AbstractCallbackRecursiveProcessTask<T extends RecursiveProcessTaskSpec<T>>
extends AbstractProcessTask<T>
implements RecursiveProcessTaskSpec<T>

This is an abstract base class for recursive process task implementations. The runInternal(Report) method iterates over all sources recursively and calls the callback(Report, EntityView, DirectoryView, RelativeLocation) for each returned entity.

This class interprets the sources and target properties using InterpretAsDirectoryStrategy.

Since:
0.5
Author:
Karl Gustafsson

Field Summary
 
Fields inherited from interface org.schmant.task.confable.OverwriteConfigurable
DEFAULT_OVERWRITE_STRATEGY
 
Constructor Summary
AbstractCallbackRecursiveProcessTask()
           
 
Method Summary
protected abstract  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(T spec)
          Override the implementation from AbstractTask to copy the source properties.
protected  boolean isDisableHeaderLogging()
           
protected  boolean isMoreThanOneSourceAllowed()
          Overridden to return true.
protected  void runInternal(Report r)
          Subclasses implement this.
 T setDepthFirstIterator(boolean b)
          Should a depth first iterator be used?
 T setDisableHeaderLogging(boolean b)
          Should logging for nested tasks be disabled?
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.AbstractProcessTask
getOverwriteStrategy, getTarget, isTargetMandatory, setOverwrite, setOverwriteStrategy, setTarget, toString
 
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, getDependencyForTasksScheduledByThisTask, 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
 

Constructor Detail

AbstractCallbackRecursiveProcessTask

public AbstractCallbackRecursiveProcessTask()
Method Detail

setDepthFirstIterator

public final T setDepthFirstIterator(boolean b)
Description copied from interface: RecursiveActionTaskConfigurable
Should a depth first iterator be used?

Specified by:
setDepthFirstIterator in interface RecursiveActionTaskConfigurable<T extends RecursiveProcessTaskSpec<T>>
Parameters:
b - true if a depth first iterator should be used.
Returns:
this

setDisableHeaderLogging

public final T setDisableHeaderLogging(boolean b)
Description copied from interface: RecursiveActionTaskConfigurable
Should logging for nested tasks be disabled?

By default, logging is disabled.

Specified by:
setDisableHeaderLogging in interface RecursiveActionTaskConfigurable<T extends RecursiveProcessTaskSpec<T>>
Parameters:
b - true if logging for nested tasks should be disabled.
Returns:
this

isDisableHeaderLogging

protected final boolean isDisableHeaderLogging()

isMoreThanOneSourceAllowed

protected boolean isMoreThanOneSourceAllowed()
Overridden to return true.

Overrides:
isMoreThanOneSourceAllowed in class AbstractActionTask<T extends RecursiveProcessTaskSpec<T>>
Returns:
false, always

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 AbstractProcessTask<T extends RecursiveProcessTaskSpec<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.

callback

protected abstract 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.

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.

runInternal

protected final void runInternal(Report r)
Description copied from class: AbstractTask
Subclasses implement this. The task is AbstractTask.validate(Report):d before this method is called, see AbstractTask.run().

Specified by:
runInternal in class AbstractTask<T extends RecursiveProcessTaskSpec<T>>
Parameters:
r - The current thread's Report.

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 RecursiveProcessTaskSpec<T>>
Overrides:
copyProperties in class AbstractProcessTask<T extends RecursiveProcessTaskSpec<T>>
Parameters:
spec - The specification to copy properties to.