1 19 20 package org.apache.cayenne.exp.parser; 21 22 import java.util.Collection ; 23 import java.util.Iterator ; 24 25 import org.apache.cayenne.exp.Expression; 26 import org.apache.cayenne.util.ConversionUtil; 27 28 34 public class ASTAnd extends AggregateConditionNode { 35 38 ASTAnd(int id) { 39 super(id); 40 } 41 42 public ASTAnd() { 43 super(ExpressionParserTreeConstants.JJTAND); 44 } 45 46 public ASTAnd(Object [] nodes) { 47 super(ExpressionParserTreeConstants.JJTAND); 48 int len = nodes.length; 49 for (int i = 0; i < len; i++) { 50 jjtAddChild((Node) nodes[i], i); 51 } 52 } 53 54 public ASTAnd(Collection nodes) { 55 super(ExpressionParserTreeConstants.JJTAND); 56 int len = nodes.size(); 57 Iterator it = nodes.iterator(); 58 for (int i = 0; i < len; i++) { 59 jjtAddChild((Node) it.next(), i); 60 } 61 } 62 63 protected Object evaluateNode(Object o) throws Exception { 64 int len = jjtGetNumChildren(); 65 if (len == 0) { 66 return Boolean.FALSE; 67 } 68 69 for (int i = 0; i < len; i++) { 70 if (!ConversionUtil.toBoolean(evaluateChild(i, o))) { 71 return Boolean.FALSE; 72 } 73 } 74 75 return Boolean.TRUE; 76 } 77 78 81 public Expression shallowCopy() { 82 return new ASTAnd(id); 83 } 84 85 public int getType() { 86 return Expression.AND; 87 } 88 89 public void jjtClose() { 90 super.jjtClose(); 91 flattenTree(); 92 } 93 94 protected String getExpressionOperator(int index) { 95 return "and"; 96 } 97 } 98 | Popular Tags |