Package org.javacc.utils
Class CodeBuilder<B extends CodeBuilder<?>>
java.lang.Object
org.javacc.utils.CodeBuilder<B>
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
CodeBuilder.GenericCodeBuilder
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCodeBuilder(Context context, CodeGeneratorSettings options) Constructs an instance ofCodeBuilder. -
Method Summary
Modifier and TypeMethodDescriptionfinal BAdd a tool.final BAdd a tool.protected voidbuild()Write the buffer to the file.final voidclose()escapeToUnicode(String text) protected abstract StringBufferGet theStringBufferprotected final FilegetFile()Gets the targetFile.final Stringprivate Stringfinal StringgetTrailingComments(Token token) final BAppend code snippet to the builder.final voidfinal BAppend code snippet to the builder invalid input: '&' a new line.final BprintTemplate(String name) Append the processed template, optionally provides additional options.final BprintTemplate(String name, CodeGeneratorSettings additionalOptions) final voidprintToken(Token t) final voidprintTokenList(List<Token> list) final voidfinal voidprintTokenSetup(Token token) final voidprintTrailingComments(Token token) final BSets the targetFile.final BsetVersion(String version) Sets the compatible version.protected final voidstore(File file, StringBuffer buffer) static StringGet the string representation of aToken.
-
Field Details
-
context
-
options
-
file
-
version
-
tools
-
option
-
cline
private int cline -
ccol
private int ccol
-
-
Constructor Details
-
CodeBuilder
Constructs an instance ofCodeBuilder.- Parameters:
context-options-
-
-
Method Details
-
getBuffer
Get theStringBuffer -
getFile
Gets the targetFile. -
setFile
Sets the targetFile.- Parameters:
file-
-
setVersion
Sets the compatible version.- Parameters:
version-
-
addTools
Add a tool.- Parameters:
tool-
-
addOption
Add a tool.- Parameters:
tool-
-
print
Append code snippet to the builder.- Parameters:
code-
-
println
Append code snippet to the builder invalid input: '&' a new line.- Parameters:
code-
-
printTemplate
Append the processed template, optionally provides additional options.- Parameters:
name-additionalOptions-- Throws:
IOException
-
printTemplate
public final B printTemplate(String name, CodeGeneratorSettings additionalOptions) throws IOException - Throws:
IOException
-
build
protected void build()Write the buffer to the file. -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
store
-
printTokenSetup
-
printTokenList
-
printTokenOnly
-
getStringForTokenOnly
-
escapeToUnicode
-
printToken
-
printLeadingComments
-
getLeadingComments
-
printTrailingComments
-
getTrailingComments
-
toString
Get the string representation of aToken.- Parameters:
token-
-