1 package org.hibernate.hql.ast.tree; 3 4 import antlr.SemanticException; 5 import antlr.collections.AST; 6 7 import org.apache.commons.logging.Log; 8 import org.apache.commons.logging.LogFactory; 9 10 15 public abstract class FromReferenceNode extends AbstractSelectExpression 16 implements ResolvableNode, DisplayableNode, InitializeableNode, PathNode { 17 18 private static final Log log = LogFactory.getLog( FromReferenceNode.class ); 19 20 private FromElement fromElement; 21 private boolean resolved = false; 22 public static final int ROOT_LEVEL = 0; 23 24 public FromElement getFromElement() { 25 return fromElement; 26 } 27 28 public void setFromElement(FromElement fromElement) { 29 this.fromElement = fromElement; 30 } 31 32 37 public void resolveFirstChild() throws SemanticException { 38 } 39 40 public String getPath() { 41 return getOriginalText(); 42 } 43 44 public boolean isResolved() { 45 return resolved; 46 } 47 48 public void setResolved() { 49 this.resolved = true; 50 if ( log.isDebugEnabled() ) { 51 log.debug( "Resolved : " + this.getPath() + " -> " + this.getText() ); 52 } 53 } 54 55 public String getDisplayText() { 56 StringBuffer buf = new StringBuffer (); 57 buf.append( "{" ).append( ( fromElement == null ) ? "no fromElement" : fromElement.getDisplayText() ); 58 buf.append( "}" ); 59 return buf.toString(); 60 } 61 62 public void recursiveResolve(int level, boolean impliedAtRoot, String classAlias) throws SemanticException { 63 recursiveResolve( level, impliedAtRoot, classAlias, this ); 64 } 65 66 public void recursiveResolve(int level, boolean impliedAtRoot, String classAlias, AST parent) throws SemanticException { 67 AST lhs = getFirstChild(); 68 int nextLevel = level + 1; 69 if ( lhs != null ) { 70 FromReferenceNode n = ( FromReferenceNode ) lhs; 71 n.recursiveResolve( nextLevel, impliedAtRoot, null, this ); 72 } 73 resolveFirstChild(); 74 boolean impliedJoin = true; 75 if ( level == ROOT_LEVEL && !impliedAtRoot ) { 76 impliedJoin = false; 77 } 78 resolve( true, impliedJoin, classAlias, parent ); 79 } 80 81 public boolean isReturnableEntity() throws SemanticException { 82 return !isScalar() && fromElement.isEntity(); 83 } 84 85 public void resolveInFunctionCall(boolean generateJoin, boolean implicitJoin) throws SemanticException { 86 resolve( generateJoin, implicitJoin ); 87 } 88 89 public void resolve(boolean generateJoin, boolean implicitJoin) throws SemanticException { 90 resolve( generateJoin, implicitJoin, null ); 91 } 92 93 public void resolve(boolean generateJoin, boolean implicitJoin, String classAlias) throws SemanticException { 94 resolve( generateJoin, implicitJoin, classAlias, null ); 95 } 96 97 public void prepareForDot(String propertyName) throws SemanticException { 98 } 99 100 105 public FromElement getImpliedJoin() { 106 return null; 107 } 108 109 } 110 | Popular Tags |