org.hibernate.hql.ast.util
Class ASTPrinter

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

public class ASTPrinter
extends Object

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

Author:
Joshua Davis, Steve Ebersole

Constructor Summary
ASTPrinter(boolean showClassNames)
           
ASTPrinter(Class tokenTypeConstants)
          Constructs a printer.
ASTPrinter(Class tokenTypeConstants, boolean showClassNames)
          Constructs a printer.
 
Method Summary
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(antlr.collections.AST ast, boolean showClassName)
           
 String showAsString(antlr.collections.AST ast, String header)
          Renders the AST into 'ASCII art' form and returns that string representation.
 void showAst(antlr.collections.AST ast, PrintStream out)
          Prints the AST in 'ASCII art' form to the specified print stream.
 void showAst(antlr.collections.AST ast, PrintWriter pw)
          Prints the AST in 'ASCII art' tree form to the specified print writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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)


Copyright © null-null Red Hat Middleware, LLC. All Rights Reserved