org.schmant.task.text
Class TextReplaceTask

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<TextReplaceTask>
                      extended by org.schmant.task.text.TextReplaceTask
All Implemented Interfaces:
Producer<WritableFile>, TaskDependency, ActionTaskConfigurable<TextReplaceTask>, ActionTaskSpec<TextReplaceTask>, LoggingConfigurable<TextReplaceTask>, OverwriteConfigurable<TextReplaceTask>, SourceConfigurable<TextReplaceTask>, SourceConfigured, TargetConfigurable<TextReplaceTask>, TargetConfigured, GeneratorTaskConfigurable<TextReplaceTask>, GeneratorTaskSpec<TextReplaceTask>, ProcessTaskConfigurable<TextReplaceTask>, ProcessTaskSpec<TextReplaceTask>, Task, TaskRunnable, TaskSpecification<TextReplaceTask>

public final class TextReplaceTask
extends AbstractTextInsertionTask<TextReplaceTask>

See TextReplaceTF

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

Field Summary
 
Fields inherited from class org.schmant.task.template.text.AbstractTextInsertionTask
DEFAULT_BUFFER_SIZE
 
Fields inherited from interface org.schmant.task.confable.OverwriteConfigurable
DEFAULT_OVERWRITE_STRATEGY
 
Method Summary
 void copyProperties(TextReplaceTask spec)
          Override the implementation from AbstractTask to copy the source properties.
protected  List<PatternAndStrategy> createReplaces(ReadableFile source)
          Create replaces in the form of ReplacementTextStrategy objects from the replaces property.
protected  String getDefaultLogHeader()
          Get the default log header to log (to level INFO) before the task is run if the task user has not set a custom header.
protected  boolean isErrorIfReplaceNotFound()
          If a replace is not found, is that an error?
 
Methods inherited from class org.schmant.task.template.text.AbstractTextInsertionTask
get, getBufferSize, getInputEncoding, getOutputEncoding, getTempDirectory, runInternal
 
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, 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
 

Method Detail

isErrorIfReplaceNotFound

protected boolean isErrorIfReplaceNotFound()
Description copied from class: AbstractTextInsertionTask
If a replace is not found, is that an error?

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

Overrides:
isErrorIfReplaceNotFound in class AbstractTextInsertionTask<TextReplaceTask>
Returns:
false.

getDefaultLogHeader

protected String getDefaultLogHeader()
Description copied from class: AbstractTask
Get the default log header to log (to level INFO) before the task is run if the task user has not set a custom header. Subclasses may override this to return better headers.

This is called after validating the task.

Return null to disable logging.

Overrides:
getDefaultLogHeader in class AbstractTask<TextReplaceTask>
Returns:
"Running " + toString()

createReplaces

protected List<PatternAndStrategy> createReplaces(ReadableFile source)
Create replaces in the form of ReplacementTextStrategy objects from the replaces property. Each replace may be one of a following:
  1. If it is a ReplacementTextStrategy – use it as-is.
  2. If it is a CharSequence (a string for instance) – create a CapturingGroupAwareStringTextStrategy on the contents of the char sequence.
  3. If it is a closure – create a ClosureReplacementTextStrategy for the closure. The closure may take one or two arguments. The first, mandatory, argument is a string containing the text to replace. The second, optional, argument is the Matcher that matched the text to replace. The closure must not modify that matcher's internal state. The closure should return a string containing the replacement text.

Specified by:
createReplaces in class AbstractTextInsertionTask<TextReplaceTask>

copyProperties

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