Package ru.ispras.castle.codegen
Class FileGeneratorStringTemplate
- java.lang.Object
-
- ru.ispras.castle.codegen.FileGeneratorStringTemplate
-
- All Implemented Interfaces:
FileGenerator
public final class FileGeneratorStringTemplate extends java.lang.Object implements FileGenerator
TheFileGeneratorStringTemplate
class generates source code files on the basis of StringTemplates descriptions.
-
-
Constructor Summary
Constructors Constructor Description FileGeneratorStringTemplate(java.lang.String outputFile, java.lang.String[] templateGroupFiles, StringTemplateBuilder templateBuilder)
Constructs a code generator parameterized with a hierarchy template groups, with a builder that will initialize the code template and with the full name to the target output file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
generate()
Generates the target file.static void
generateFile(java.lang.String fileName, java.lang.String[] templateGroups, StringTemplateBuilder templateBuilder)
Generates a file by the specified template.
-
-
-
Constructor Detail
-
FileGeneratorStringTemplate
public FileGeneratorStringTemplate(java.lang.String outputFile, java.lang.String[] templateGroupFiles, StringTemplateBuilder templateBuilder)
Constructs a code generator parameterized with a hierarchy template groups, with a builder that will initialize the code template and with the full name to the target output file.- Parameters:
outputFile
- The full name of the target output file.templateGroupFiles
- List of template group files. Important: the order is from the root of the hierarchy to child groups.templateBuilder
- Builder that is responsible for initialization of the template.
-
-
Method Detail
-
generateFile
public static void generateFile(java.lang.String fileName, java.lang.String[] templateGroups, StringTemplateBuilder templateBuilder)
Generates a file by the specified template.- Parameters:
fileName
- Full name of the generated file.templateGroups
- List of template group files.templateBuilder
- Builder responsible for initialization of the template.- Throws:
java.lang.IllegalArgumentException
- if any of the arguments isnull
.java.lang.RuntimeException
- if an I/O error occurred during file generation.
-
generate
public void generate() throws java.io.IOException
Generates the target file.- Specified by:
generate
in interfaceFileGenerator
- Throws:
java.io.IOException
- It is raised if the methods fails to create the target file.
-
-