public class

ASTPrinter

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

Class Overview

Utility for generating pretty "ASCII art" representations of syntax trees.

Summary

Public Constructors
ASTPrinter(Class tokenTypeConstants)
Constructs a printer.
ASTPrinter(boolean showClassNames)
ASTPrinter(Class tokenTypeConstants, boolean showClassNames)
Constructs a printer.
Public Methods
static void appendEscapedMultibyteChars(String text, StringBuffer buf)
static String escapeMultibyteChars(String text)
String getTokenTypeName(int type)
Returns the token type name for the given token type.
boolean isShowClassNames()
Getter for property 'showClassNames'.
String nodeToString(AST ast, boolean showClassName)
String showAsString(AST ast, String header)
Renders the AST into 'ASCII art' form and returns that string representation.
void showAst(AST ast, PrintStream out)
Prints the AST in 'ASCII art' form to the specified print stream.
void showAst(AST ast, PrintWriter pw)
Prints the AST in 'ASCII art' tree form to the specified print writer.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

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.

public ASTPrinter (boolean showClassNames)

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.

Public Methods

public static void appendEscapedMultibyteChars (String text, StringBuffer buf)

public static String escapeMultibyteChars (String text)

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.

public boolean isShowClassNames ()

Getter for property 'showClassNames'.

Returns
  • Value for property 'showClassNames'.

public String nodeToString (AST ast, boolean showClassName)

public String showAsString (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.

public void showAst (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.

public void showAst (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.