Class TemplateBuilder
java.lang.Object
org.javacc.utils.TemplateBuilder
Generates boiler-plate files from templates. Only very basic template
processing is supplied - if we need something more sophisticated I suggest we
use a third-party library.
- Since:
- 4.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate final CodeGeneratorSettingsprivate final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanvoidgenerate(PrintWriter writer) Generate the output file.private Stringprivate Stringprivate voidprocess(BufferedReader in, PrintWriter out, boolean ignoring) private voidprocessIf(BufferedReader in, PrintWriter out, boolean ignoring) private Stringsubstitute(String text) private StringsubstituteWithConditional(String variableName, String values) private StringsubstituteWithDefault(String variableName, String defaultValue) private voidwrite(PrintWriter out, String text)
-
Field Details
-
template
-
options
-
currentLine
-
-
Constructor Details
-
TemplateBuilder
TemplateBuilder(String template, CodeGeneratorSettings options) - Parameters:
template- the template. E.g. "/templates/Token.template".options- the processing options in force, such as "STATIC=yes"
-
-
Method Details
-
generate
Generate the output file.- Parameters:
writer-- Throws:
IOException
-
peekLine
- Throws:
IOException
-
getLine
- Throws:
IOException
-
evaluate
-
substitute
- Throws:
IOException
-
substituteWithConditional
- Parameters:
substring-defaultValue-- Returns:
- Throws:
IOException
-
substituteWithDefault
- Parameters:
variableName-defaultValue-- Returns:
- Throws:
IOException
-
write
- Throws:
IOException
-
process
- Throws:
IOException
-
processIf
- Throws:
IOException
-