Class ASTPrinter

java.lang.Object
org.hibernate.hql.ast.util.ASTPrinter

public class ASTPrinter extends Object
Utility for generating pretty "ASCII art" representations of syntax trees.
  • Constructor Details

    • ASTPrinter

      public ASTPrinter(Class tokenTypeConstants)
      Constructs a printer.

      Delegates to ASTPrinter(Class, boolean) with showClassNames as true

      Parameters:
      tokenTypeConstants - The token types to use during printing; typically the {vocabulary}TokenTypes.java interface generated by ANTLR.
    • ASTPrinter

      public ASTPrinter(boolean showClassNames)
    • ASTPrinter

      public ASTPrinter(Class tokenTypeConstants, boolean showClassNames)
      Constructs a printer.
      Parameters:
      tokenTypeConstants - The token types to use during printing; typically the {vocabulary}TokenTypes.java interface generated by ANTLR.
      showClassNames - Should the AST class names be shown.
  • Method Details

    • isShowClassNames

      public boolean isShowClassNames()
      Getter for property 'showClassNames'.
      Returns:
      Value for property 'showClassNames'.
    • showAsString

      public String showAsString(antlr.collections.AST ast, String header)
      Renders the AST into 'ASCII art' form and returns that string representation.
      Parameters:
      ast - The AST to display.
      header - The header for the display.
      Returns:
      The AST in 'ASCII art' form, as a string.
    • showAst

      public void showAst(antlr.collections.AST ast, PrintStream out)
      Prints the AST in 'ASCII art' form to the specified print stream.
      Parameters:
      ast - The AST to print.
      out - The print stream to which the AST should be printed.
    • showAst

      public void showAst(antlr.collections.AST ast, PrintWriter pw)
      Prints the AST in 'ASCII art' tree form to the specified print writer.
      Parameters:
      ast - The AST to print.
      pw - The print writer to which the AST should be written.
    • getTokenTypeName

      public String getTokenTypeName(int type)
      Returns the token type name for the given token type.
      Parameters:
      type - The token type.
      Returns:
      String - The token type name from the token type constant class, or just the integer as a string if none exists.
    • nodeToString

      public String nodeToString(antlr.collections.AST ast, boolean showClassName)
    • appendEscapedMultibyteChars

      public static void appendEscapedMultibyteChars(String text, StringBuffer buf)
    • escapeMultibyteChars

      public static String escapeMultibyteChars(String text)