org.schmant.task.text
Class TextReplaceTask
java.lang.Object
org.schmant.support.AbstractArgumentChecker
org.schmant.task.stub.AbstractTask<T>
org.schmant.task.stub.AbstractActionTask<T>
org.schmant.task.stub.AbstractProcessTask<T>
org.schmant.task.template.text.AbstractTextInsertionTask<TextReplaceTask>
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
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 |
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:
- If it is a
ReplacementTextStrategy
– use it as-is.
- If it is a
CharSequence
(a string for instance) –
create a CapturingGroupAwareStringTextStrategy
on the contents
of the char sequence.
- 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.