Class CodeBuilder<B extends CodeBuilder<?>>

java.lang.Object
org.javacc.utils.CodeBuilder<B>
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
CodeBuilder.GenericCodeBuilder

public abstract class CodeBuilder<B extends CodeBuilder<?>> extends Object implements Closeable
  • Field Details

    • context

      private final Context context
    • options

      private final CodeGeneratorSettings options
    • file

      private File file
    • version

      private String version
    • tools

      private final Set<String> tools
    • option

      private final List<String> option
    • cline

      private int cline
    • ccol

      private int ccol
  • Constructor Details

  • Method Details

    • getBuffer

      protected abstract StringBuffer getBuffer()
      Get the StringBuffer
    • getFile

      protected final File getFile()
      Gets the target File.
    • setFile

      public final B setFile(File file)
      Sets the target File.
      Parameters:
      file -
    • setVersion

      public final B setVersion(String version)
      Sets the compatible version.
      Parameters:
      version -
    • addTools

      public final B addTools(String... tools)
      Add a tool.
      Parameters:
      tool -
    • addOption

      public final B addOption(String... options)
      Add a tool.
      Parameters:
      tool -
    • print

      public final B print(Object... code)
      Append code snippet to the builder.
      Parameters:
      code -
    • println

      public final B println(Object... code)
      Append code snippet to the builder invalid input: '&' a new line.
      Parameters:
      code -
    • printTemplate

      public final B printTemplate(String name) throws IOException
      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

      public final void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • store

      protected final void store(File file, StringBuffer buffer)
    • printTokenSetup

      public final void printTokenSetup(Token token)
    • printTokenList

      public final void printTokenList(List<Token> list)
    • printTokenOnly

      public final void printTokenOnly(Token t)
    • getStringForTokenOnly

      private String getStringForTokenOnly(Token t)
    • escapeToUnicode

      public String escapeToUnicode(String text)
    • printToken

      public final void printToken(Token t)
    • printLeadingComments

      public final void printLeadingComments(Token t)
    • getLeadingComments

      public final String getLeadingComments(Token t)
    • printTrailingComments

      public final void printTrailingComments(Token token)
    • getTrailingComments

      public final String getTrailingComments(Token token)
    • toString

      public static String toString(Token token)
      Get the string representation of a Token.
      Parameters:
      token -