Package org.hibernate.hql.ast

Examples of org.hibernate.hql.ast.HqlParser


  /**
   * Test a simple tree, make sure the iterator encounters every node.
   */
  public void testSimpleTree() throws Exception {
    String input = "select foo from foo in class org.hibernate.test.Foo, fee in class org.hibernate.test.Fee where foo.dependent = fee order by foo.string desc, foo.component.count asc, fee.id";
    HqlParser parser = HqlParser.getInstance( input );
    parser.statement();
    AST ast = parser.getAST();
    ASTPrinter printer = new ASTPrinter( HqlTokenTypes.class );
    printer.showAst( ast, new PrintWriter( System.out ) );
    ASTIterator iterator = new ASTIterator( ast );
    int count = 0;
    while ( iterator.hasNext() ) {
View Full Code Here


  private AST parse(String input, boolean logging) throws RecognitionException, TokenStreamException {
    if ( logging ) {
      System.out.println( "input: ->" + input + "<-" );
    }

    HqlParser parser = HqlParser.getInstance( input );
    parser.setFilter( false );
    parser.statement();
    AST ast = parser.getAST();

    if ( logging ) {
      System.out.println( "AST  :  " + ast.toStringTree() + "" );
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      parser.showAst( ast, new PrintStream( baos ) );
      System.out.println( baos.toString() );
    }

    assertEquals( "At least one error occurred during parsing!", 0, parser.getParseErrorHandler().getErrorCount() );

    return ast;
  }
View Full Code Here

  private AST parse(String input, boolean logging) throws RecognitionException, TokenStreamException {
    if ( logging ) {
      System.out.println( "input: ->" + input + "<-" );
    }

    HqlParser parser = HqlParser.getInstance( input );
    parser.setFilter( false );
    parser.statement();
    AST ast = parser.getAST();

    if ( logging ) {
      System.out.println( "AST  :  " + ast.toStringTree() + "" );
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      parser.showAst( ast, new PrintStream( baos ) );
      System.out.println( baos.toString() );
    }

    assertEquals( "At least one error occurred during parsing!", 0, parser.getParseErrorHandler().getErrorCount() );

    return ast;
  }
View Full Code Here

    parseFilter( "where this.name = ?" );
  }

  public void testNoFrom() throws Exception {
    System.out.println( "***** This test ensures that an error is detected ERROR MESSAGES ARE OKAY!  *****" );
    HqlParser parser = HqlParser.getInstance( "" );
    parser.setFilter( false );
    parser.statement();
    assertEquals( "Parser allowed no FROM clause!", 1, parser.getParseErrorHandler().getErrorCount() );
    System.out.println( "***** END OF ERROR TEST  *****" );
  }
View Full Code Here

    doParse( input, false );
  }

  private AST doParse(String input, boolean filter) throws RecognitionException, TokenStreamException {
    System.out.println( "input: ->" + ASTPrinter.escapeMultibyteChars(input) + "<-" );
    HqlParser parser = HqlParser.getInstance( input );
    parser.setFilter( filter );
    parser.statement();
    AST ast = parser.getAST();
    System.out.println( "AST  :  " + ast.toStringTree() + "" );
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    parser.showAst( ast, new PrintStream( baos ) );
    System.out.println( baos.toString() );
    assertEquals( "At least one error occurred during parsing!", 0, parser.getParseErrorHandler().getErrorCount() );
    return ast;
  }
View Full Code Here

  /**
   * Test a simple tree, make sure the iterator encounters every node.
   */
  public void testSimpleTree() throws Exception {
    String input = "select foo from foo in class org.hibernate.test.Foo, fee in class org.hibernate.test.Fee where foo.dependent = fee order by foo.string desc, foo.component.count asc, fee.id";
    HqlParser parser = HqlParser.getInstance( input );
    parser.statement();
    AST ast = parser.getAST();
    ASTPrinter printer = new ASTPrinter( HqlTokenTypes.class );
    printer.showAst( ast, new PrintWriter( System.out ) );
    ASTIterator iterator = new ASTIterator( ast );
    int count = 0;
    while ( iterator.hasNext() ) {
View Full Code Here

    parseFilter( "where this.name = ?" );
  }

  public void testNoFrom() throws Exception {
    System.out.println( "***** This test ensures that an error is detected ERROR MESSAGES ARE OKAY!  *****" );
    HqlParser parser = HqlParser.getInstance( "" );
    parser.setFilter( false );
    parser.statement();
    assertEquals( "Parser allowed no FROM clause!", 1, parser.getParseErrorHandler().getErrorCount() );
    System.out.println( "***** END OF ERROR TEST  *****" );
  }
View Full Code Here

    doParse( input, false );
  }

  private AST doParse(String input, boolean filter) throws RecognitionException, TokenStreamException {
    System.out.println( "input: ->" + ASTPrinter.escapeMultibyteChars(input) + "<-" );
    HqlParser parser = HqlParser.getInstance( input );
    parser.setFilter( filter );
    parser.statement();
    AST ast = parser.getAST();
    System.out.println( "AST  :  " + ast.toStringTree() + "" );
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    parser.showAst( ast, new PrintStream( baos ) );
    System.out.println( baos.toString() );
    assertEquals( "At least one error occurred during parsing!", 0, parser.getParseErrorHandler().getErrorCount() );
    return ast;
  }
View Full Code Here

  private AST parse(String input, boolean logging) throws RecognitionException, TokenStreamException {
    if ( logging ) {
      System.out.println( "input: ->" + input + "<-" );
    }

    HqlParser parser = HqlParser.getInstance( input );
    parser.setFilter( false );
    parser.statement();
    AST ast = parser.getAST();

    if ( logging ) {
      System.out.println( "AST  :  " + ast.toStringTree() + "" );
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      parser.showAst( ast, new PrintStream( baos ) );
      System.out.println( baos.toString() );
    }

    assertEquals( "At least one error occurred during parsing!", 0, parser.getParseErrorHandler().getErrorCount() );

    return ast;
  }
View Full Code Here

  /**
   * Test a simple tree, make sure the iterator encounters every node.
   */
  public void testSimpleTree() throws Exception {
    String input = "select foo from foo in class org.hibernate.test.Foo, fee in class org.hibernate.test.Fee where foo.dependent = fee order by foo.string desc, foo.component.count asc, fee.id";
    HqlParser parser = HqlParser.getInstance( input );
    parser.statement();
    AST ast = parser.getAST();
    ASTPrinter printer = new ASTPrinter( HqlTokenTypes.class );
    printer.showAst( ast, new PrintWriter( System.out ) );
    ASTIterator iterator = new ASTIterator( ast );
    int count = 0;
    while ( iterator.hasNext() ) {
View Full Code Here

TOP

Related Classes of org.hibernate.hql.ast.HqlParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.