Package de.spraener.nxtgen
Class CodeBlockImpl
java.lang.Object
de.spraener.nxtgen.CodeBlockImpl
- All Implemented Interfaces:
CodeBlock
- Direct Known Subclasses:
BlueprintCodeBlock,CodeTargetCodeBlockAdapter,GroovyCodeBlockImpl,JavaCodeBlock
A base implementation of a CodeBlock. Most real CodeBlocks do extend this class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCodeBlock(CodeBlock subBlock) Adds onother CodeBlock to the list of conained CodeBlocks.protected booleancheckProtected(File outFile) Checks if the considered outputFile is maybe protected from overwriting.getName()returns the Name of this CodeBlock.voidAdds the given String to a new SimpleStringCodeBlock and adds them to the contained CodeBlocks.voidsetToFileStrategy(ToFileStrategy toFileStrategy) toCode()Write your and the code of all contained codeBlocks to an output string.voidwriteOutput(String workingDir) Do the output wrtiing into the given working directory.
-
Constructor Details
-
CodeBlockImpl
Create a new CodeBlock with the given name.- Parameters:
name- a name of the codeblock for reference purpose.
-
-
Method Details
-
toCode
Write your and the code of all contained codeBlocks to an output string. The implementation calls toCode on all containing CodeBlocks and append them to one long output string. -
println
Adds the given String to a new SimpleStringCodeBlock and adds them to the contained CodeBlocks. -
addCodeBlock
Adds onother CodeBlock to the list of conained CodeBlocks.- Specified by:
addCodeBlockin interfaceCodeBlock- Parameters:
subBlock- a code block can contain other codeblocks. it is inserted at the current postion/line
-
getName
returns the Name of this CodeBlock. The CodeBlock can be referenced by this name. -
checkProtected
Checks if the considered outputFile is maybe protected from overwriting. This does not mean that the file is write protected on file system level. It just decides (some how) that the considered file should no be overwritten.
This implementation delegeates the decision to a changeable ProtectionStrategy.
- Parameters:
outFile-- Returns:
- See Also:
-
writeOutput
Do the output wrtiing into the given working directory. The output file is determined with an changeable ToFileStrategy.- Specified by:
writeOutputin interfaceCodeBlock- Parameters:
workingDir- the full qualified path to the working directory.- See Also:
-
getToFileStrategy
-
setToFileStrategy
- Specified by:
setToFileStrategyin interfaceCodeBlock
-