KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > hql > ast > tree > CollectionFunction


1 // $Id: CollectionFunction.java,v 1.1 2005/07/12 20:27:16 steveebersole Exp $
2
package org.hibernate.hql.ast.tree;
3
4 import antlr.SemanticException;
5 import antlr.collections.AST;
6
7 /**
8  * Represents 'elements()' or 'indices()'.
9  *
10  * @author josh Dec 6, 2004 8:36:42 AM
11  */

12 public class CollectionFunction extends MethodNode implements DisplayableNode {
13     public void resolve(boolean inSelect) throws SemanticException {
14         initializeMethodNode( this, inSelect );
15         if ( !isCollectionPropertyMethod() ) {
16             throw new SemanticException( this.getText() + " is not a collection property name!" );
17         }
18         AST expr = getFirstChild();
19         if ( expr == null ) {
20             throw new SemanticException( this.getText() + " requires a path!" );
21         }
22         resolveCollectionProperty( expr );
23     }
24
25     protected void prepareSelectColumns(String JavaDoc[] selectColumns) {
26         // we need to strip off the embedded parens so that sql-gen does not double these up
27
String JavaDoc subselect = selectColumns[0].trim();
28         if ( subselect.startsWith( "(") && subselect.endsWith( ")" ) ) {
29             subselect = subselect.substring( 1, subselect.length() -1 );
30         }
31         selectColumns[0] = subselect;
32     }
33 }
34
Popular Tags