1 21 22 package oracle.toplink.essentials.internal.parsing; 24 25 import oracle.toplink.essentials.expressions.*; 26 import oracle.toplink.essentials.exceptions.EJBQLException; 27 28 35 public class SizeNode extends ArithmeticFunctionNode { 36 37 40 public SizeNode() { 41 super(); 42 } 43 44 48 public void validate(ParseTreeContext context) { 49 if (left != null) { 50 left.validate(context); 51 } 52 TypeHelper typeHelper = context.getTypeHelper(); 53 setType(typeHelper.getIntType()); 54 } 55 56 60 public Expression generateExpression(GenerationContext context) { 61 DotNode dotNode = (DotNode)getLeft(); 62 Node prefix = dotNode.getLeft(); 63 String variableName = ((AttributeNode)dotNode.getRight()).getAttributeName(); 64 65 if (!dotNode.endsWithCollectionField(context)) { 67 throw EJBQLException.invalidSizeArgument(variableName); 68 } 69 Expression whereClause = prefix.generateExpression(context); 70 whereClause = whereClause.size(variableName); 71 return whereClause; 72 } 73 74 } 75 | Popular Tags |