FileDocCategorySizeDatePackage
PathHelper.javaAPI DocHibernate 3.2.51400Tue Jul 12 15:27:30 BST 2005org.hibernate.hql.ast.util

PathHelper

public final class PathHelper extends Object
Provides utility methods for paths.
author
josh Sep 14, 2004 8:16:29 AM

Fields Summary
private static final Log
log
Constructors Summary
private PathHelper()


	  
	
Methods Summary
public static java.lang.StringgetAlias(java.lang.String path)

		return StringHelper.root( path );
	
public static antlr.collections.ASTparsePath(java.lang.String path, antlr.ASTFactory factory)
Turns a path into an AST.

param
path The path.
param
factory The AST factory to use.
return
An HQL AST representing the path.

		String[] identifiers = StringHelper.split( ".", path );
		AST lhs = null;
		for ( int i = 0; i < identifiers.length; i++ ) {
			String identifier = identifiers[i];
			AST child = ASTUtil.create( factory, HqlSqlTokenTypes.IDENT, identifier );
			if ( i == 0 ) {
				lhs = child;
			}
			else {
				lhs = ASTUtil.createBinarySubtree( factory, HqlSqlTokenTypes.DOT, ".", lhs, child );
			}
		}
		if ( log.isDebugEnabled() ) {
			log.debug( "parsePath() : " + path + " -> " + ASTUtil.getDebugString( lhs ) );
		}
		return lhs;