org.schmant.task.template.text
Class AbstractTextInsertionTask<T extends AbstractTextInsertionTask<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.template.text.AbstractTextInsertionTask<T>
All Implemented Interfaces:
Producer<WritableFile>, 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:
AbstractLinkInsertionTask, ApiLinksTask, IncludeFilesTask, TextReplaceTask

public abstract class AbstractTextInsertionTask<T extends AbstractTextInsertionTask<T>>
extends AbstractProcessTask<T>
implements Producer<WritableFile>

Abstract base class for a task that use regular expressions to find places in a text file where it edits the text using a ReplacementTextStrategy.

Since:
0.8
Author:
Karl Gustafsson

Field Summary
static int DEFAULT_BUFFER_SIZE
           
 
Fields inherited from interface org.schmant.task.confable.OverwriteConfigurable
DEFAULT_OVERWRITE_STRATEGY
 
Constructor Summary
AbstractTextInsertionTask()
           
 
Method Summary
 void copyProperties(T spec)
          Override the implementation from AbstractTask to copy the source properties.
protected abstract  List<? extends PatternAndStrategy> createReplaces(ReadableFile source)
          Subclasses implement this method to create the replaces that it uses.
 WritableFile get()
          Returns the produced object, or null if nothing is produced yet.
protected  int getBufferSize()
           
protected  Charset getInputEncoding()
           
protected  Charset getOutputEncoding()
           
protected  Object getTempDirectory()
           
protected  boolean isErrorIfReplaceNotFound()
          If a replace is not found, is that an error?
protected  void runInternal(Report r)
          Subclasses implement this.
 
Methods inherited from class org.schmant.task.stub.AbstractProcessTask
getOverwriteStrategy, getTarget, isTargetMandatory, setOverwrite, setOverwriteStrategy, setTarget, toString, validate
 
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, 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
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
See Also:
Constant Field Values
Constructor Detail

AbstractTextInsertionTask

public AbstractTextInsertionTask()
Method Detail

getInputEncoding

protected final Charset getInputEncoding()

getOutputEncoding

protected final Charset getOutputEncoding()

getBufferSize

protected final int getBufferSize()

getTempDirectory

protected final Object getTempDirectory()

get

public final WritableFile get()
Description copied from interface: Producer
Returns the produced object, or null if nothing is produced yet.

This method should be implemented thread-safe.

Specified by:
get in interface Producer<WritableFile>
Returns:
The produced object.

isErrorIfReplaceNotFound

protected boolean isErrorIfReplaceNotFound()
If a replace is not found, is that an error?

This method returns false. Subclasses may override it to return something else.

Returns:
false.

createReplaces

protected abstract List<? extends PatternAndStrategy> createReplaces(ReadableFile source)
Subclasses implement this method to create the replaces that it uses.


runInternal

protected void runInternal(Report r)
                    throws Exception
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 AbstractTextInsertionTask<T>>
Parameters:
r - The current thread's Report.
Throws:
Exception - On errors.

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