1 56 package org.objectstyle.cayenne.exp.parser; 57 58 import java.util.Collection ; 59 import java.util.Iterator ; 60 61 import org.objectstyle.cayenne.exp.Expression; 62 import org.objectstyle.cayenne.util.ConversionUtil; 63 64 70 public class ASTOr extends AggregateConditionNode { 71 ASTOr(int id) { 72 super(id); 73 } 74 75 public ASTOr() { 76 super(ExpressionParserTreeConstants.JJTOR); 77 } 78 79 public ASTOr(Object [] nodes) { 80 super(ExpressionParserTreeConstants.JJTOR); 81 int len = nodes.length; 82 for (int i = 0; i < len; i++) { 83 jjtAddChild((Node) nodes[i], i); 84 } 85 } 86 87 public ASTOr(Collection nodes) { 88 super(ExpressionParserTreeConstants.JJTOR); 89 int len = nodes.size(); 90 Iterator it = nodes.iterator(); 91 for (int i = 0; i < len; i++) { 92 jjtAddChild((Node) it.next(), i); 93 } 94 } 95 96 protected Object evaluateNode(Object o) throws Exception { 97 int len = jjtGetNumChildren(); 98 if (len == 0) { 99 return Boolean.FALSE; 100 } 101 102 for (int i = 0; i < len; i++) { 103 if (ConversionUtil.toBoolean(evaluateChild(i, o))) { 104 return Boolean.TRUE; 105 } 106 } 107 108 return Boolean.FALSE; 109 } 110 111 114 public Expression shallowCopy() { 115 return new ASTOr(id); 116 } 117 118 protected String getExpressionOperator(int index) { 119 return "or"; 120 } 121 122 public int getType() { 123 return Expression.OR; 124 } 125 126 public void jjtClose() { 127 super.jjtClose(); 128 flattenTree(); 129 } 130 } 131 | Popular Tags |