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 ASTOr extends AggregateConditionNode { 35 ASTOr(int id) { 36 super(id); 37 } 38 39 public ASTOr() { 40 super(ExpressionParserTreeConstants.JJTOR); 41 } 42 43 public ASTOr(Object [] nodes) { 44 super(ExpressionParserTreeConstants.JJTOR); 45 int len = nodes.length; 46 for (int i = 0; i < len; i++) { 47 jjtAddChild((Node) nodes[i], i); 48 } 49 } 50 51 public ASTOr(Collection nodes) { 52 super(ExpressionParserTreeConstants.JJTOR); 53 int len = nodes.size(); 54 Iterator it = nodes.iterator(); 55 for (int i = 0; i < len; i++) { 56 jjtAddChild((Node) it.next(), i); 57 } 58 } 59 60 protected Object evaluateNode(Object o) throws Exception { 61 int len = jjtGetNumChildren(); 62 if (len == 0) { 63 return Boolean.FALSE; 64 } 65 66 for (int i = 0; i < len; i++) { 67 if (ConversionUtil.toBoolean(evaluateChild(i, o))) { 68 return Boolean.TRUE; 69 } 70 } 71 72 return Boolean.FALSE; 73 } 74 75 78 public Expression shallowCopy() { 79 return new ASTOr(id); 80 } 81 82 protected String getExpressionOperator(int index) { 83 return "or"; 84 } 85 86 public int getType() { 87 return Expression.OR; 88 } 89 90 public void jjtClose() { 91 super.jjtClose(); 92 flattenTree(); 93 } 94 } 95 | Popular Tags |