public class Replace extends MatchingTask
<replacetoken>
element.Modifier and Type | Class and Description |
---|---|
class |
Replace.NestedString
An inline string to use as the replacement text.
|
class |
Replace.Replacefilter
A filter to apply.
|
fileset
Constructor and Description |
---|
Replace() |
Modifier and Type | Method and Description |
---|---|
void |
addConfigured(ResourceCollection rc)
Support arbitrary file system based resource collections.
|
Replace.Replacefilter |
createReplacefilter()
Add a nested <replacefilter> element.
|
Replace.NestedString |
createReplaceToken()
Create a token to filter as the text of a nested element.
|
Replace.NestedString |
createReplaceValue()
Create a string to replace the token as the text of a nested element.
|
void |
execute()
Do the execution.
|
Properties |
getProperties(File propertyFile)
Load a properties file.
|
Properties |
getProperties(Resource propertyResource)
Load a properties resource.
|
void |
setDir(File dir)
The base directory to use when replacing a token in multiple files;
required if
file is not defined. |
void |
setEncoding(String encoding)
Set the file encoding to use on the files read and written by the task;
optional, defaults to default JVM encoding.
|
void |
setFailOnNoReplacements(boolean b)
Whether the build should fail if nothing has been replaced.
|
void |
setFile(File file)
Set the source file; required unless
dir is set. |
void |
setPreserveLastModified(boolean b)
Whether the file timestamp shall be preserved even if the file
is modified.
|
void |
setPropertyFile(File propertyFile)
The name of a property file from which properties specified using nested
<replacefilter> elements are drawn; required only if
the property attribute of <replacefilter> is used. |
void |
setPropertyResource(Resource propertyResource)
A resource from which properties specified using nested
<replacefilter> elements are drawn; required
only if the property attribute of
<replacefilter> is used. |
void |
setReplaceFilterFile(File replaceFilterFile)
Sets the name of a property file containing filters; optional.
|
void |
setReplaceFilterResource(Resource replaceFilter)
Sets the name of a resource containing filters; optional.
|
void |
setSummary(boolean summary)
Indicates whether a summary of the replace operation should be
produced, detailing how many token occurrences and files were
processed; optional, default=
false . |
void |
setToken(String token)
Set the string token to replace; required unless a nested
replacetoken element or the
replacefilterresource attribute is used. |
void |
setValue(String value)
Set the string value to use as token replacement;
optional, default is the empty string "".
|
void |
validateAttributes()
Validate attributes provided for this task in .xml build file.
|
void |
validateReplacefilters()
Validate nested elements.
|
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
clone, getDescription, getLocation, getProject, setDescription, setLocation
public void addConfigured(ResourceCollection rc)
public Replace.Replacefilter createReplacefilter()
Replacefilter
object to be configured.public Replace.NestedString createReplaceToken()
NestedString
to configure.public Replace.NestedString createReplaceValue()
NestedString
to configure.public void execute() throws BuildException
execute
in class Task
BuildException
- if we can't buildpublic Properties getProperties(File propertyFile) throws BuildException
propertyFile
- the file to load the properties from.Properties
object.BuildException
- if the file could not be found or read.public Properties getProperties(Resource propertyResource) throws BuildException
propertyResource
- the resource to load the properties from.Properties
object.BuildException
- if the resource could not be found or read.public void setDir(File dir)
file
is not defined.dir
- File
representing the base directory.public void setEncoding(String encoding)
encoding
- the encoding to use on the files.public void setFailOnNoReplacements(boolean b)
public void setFile(File file)
dir
is set.file
- source File
.public void setPreserveLastModified(boolean b)
public void setPropertyFile(File propertyFile)
<replacefilter>
elements are drawn; required only if
the property attribute of <replacefilter>
is used.propertyFile
- File
to load.public void setPropertyResource(Resource propertyResource)
<replacefilter>
elements are drawn; required
only if the property attribute of
<replacefilter>
is used.propertyResource
- Resource
to load.public void setReplaceFilterFile(File replaceFilterFile)
replaceFilterFile
- File
to load.public void setReplaceFilterResource(Resource replaceFilter)
replaceFilter
- Resource
to load.public void setSummary(boolean summary)
false
.summary
- boolean
whether a summary of the
replace operation should be logged.public void setToken(String token)
replacetoken
element or the
replacefilterresource
attribute is used.token
- token String
.public void setValue(String value)
value
- replacement value.public void validateAttributes() throws BuildException
BuildException
- if any supplied attribute is invalid or any
mandatory attribute is missing.public void validateReplacefilters() throws BuildException
BuildException
- if any supplied attribute is invalid or any
mandatory attribute is missing.