public abstract class TransformationOperation<T extends TransformationOperation> extends TransformationUtility<T>
TransformationUtility
that applies a modification to the project.
TO
.
TransformationUtility.relative(String)
is null
, which means
it must be set explicitly, unless an absolute path is set via TransformationUtility.absolute(String)
or TransformationUtility.absolute(String, String)
UTILITY_NAME_SYNTAX
Constructor and Description |
---|
TransformationOperation() |
Modifier and Type | Method and Description |
---|---|
protected java.io.File |
getOrCreateReadFile(java.io.File transformedAppFolder,
TransformationContext transformationContext)
Creates and returns a temporary read-only copy of the file to be modified.
|
PerformResult |
perform(java.io.File transformedAppFolder,
TransformationContext transformationContext)
Performs the transformation utility against
the application to be transformed.
|
protected T |
setSaveResult(boolean saveResult)
Sets whether or not the value produced by the transformation utility execution,
and also its result object as a whole, should both be saved in the transformation
context object.
|
abortOnFailure, abortOnFailure, absolute, absolute, applyPropertiesFromContext, checkDependencies, checkForBlankString, checkForEmptyString, checkForNull, clone, copy, dependsOn, equals, executeIf, executeIf, executeUnless, execution, getAbortionMessage, getAbsoluteFile, getContextAttributeName, getDependencies, getDescription, getIfConditionAttributeName, getName, getOrder, getParent, getRelativePath, getRelativePath, getSimpleClassName, getTransformationTemplate, getUnlessConditionAttributeName, hasBeenPerformed, hashCode, hashCode, isAbortOnFailure, isFileSet, isSaveResult, normalizeRelativePathSeparator, relative, set, setContextAttributeName, setName, setParent, toString, wasFileExplicitlySet
protected final T setSaveResult(boolean saveResult)
TransformationUtility
TransformationUtility.isSaveResult()
.setSaveResult
in class TransformationUtility<T extends TransformationOperation>
saveResult
- if the value produced by the transformation utility execution,
and also its result object as a whole, should both be saved in the transformation
context objectprotected final java.io.File getOrCreateReadFile(java.io.File transformedAppFolder, TransformationContext transformationContext) throws java.io.IOException
TransformationUtility.relative(String)
, TransformationUtility.absolute(String)
or TransformationUtility.absolute(String, String)
).
Some transformation operations though might need to read the file to be modified
as a stream, and modify it by writing to an output stream as that same file
is read. Since it is impossible to modify a file at the same time it is being read,
this utility method offers a convenient way to create a temporary read-only
copy of the file to be modified. This copy should be used to be read, while the original
file can be modified.
transformedAppFolder
- the folder where the transformed application code istransformationContext
- the transformation context objectjava.io.IOException
- if the temporary file could not be created, if the specified file is actually a directory, or if it does not existpublic final PerformResult perform(java.io.File transformedAppFolder, TransformationContext transformationContext) throws TransformationUtilityException
TransformationUtility
TransformationUtility.hasBeenPerformed()
has to return true.
TransformationUtility.applyPropertiesFromContext(TransformationContext)
TransformationUtility.execution(File, TransformationContext)
perform
in class TransformationUtility<T extends TransformationOperation>
transformedAppFolder
- the folder where the transformed application code istransformationContext
- the transformation context objectTransformationUtilityException