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 ASTAnd extends AggregateConditionNode { 71 74 ASTAnd(int id) { 75 super(id); 76 } 77 78 public ASTAnd() { 79 super(ExpressionParserTreeConstants.JJTAND); 80 } 81 82 public ASTAnd(Object [] nodes) { 83 super(ExpressionParserTreeConstants.JJTAND); 84 int len = nodes.length; 85 for (int i = 0; i < len; i++) { 86 jjtAddChild((Node) nodes[i], i); 87 } 88 } 89 90 public ASTAnd(Collection nodes) { 91 super(ExpressionParserTreeConstants.JJTAND); 92 int len = nodes.size(); 93 Iterator it = nodes.iterator(); 94 for (int i = 0; i < len; i++) { 95 jjtAddChild((Node) it.next(), i); 96 } 97 } 98 99 protected Object evaluateNode(Object o) throws Exception { 100 int len = jjtGetNumChildren(); 101 if (len == 0) { 102 return Boolean.FALSE; 103 } 104 105 for (int i = 0; i < len; i++) { 106 if (!ConversionUtil.toBoolean(evaluateChild(i, o))) { 107 return Boolean.FALSE; 108 } 109 } 110 111 return Boolean.TRUE; 112 } 113 114 117 public Expression shallowCopy() { 118 return new ASTAnd(id); 119 } 120 121 public int getType() { 122 return Expression.AND; 123 } 124 125 public void jjtClose() { 126 super.jjtClose(); 127 flattenTree(); 128 } 129 130 protected String getExpressionOperator(int index) { 131 return "and"; 132 } 133 } 134 | Popular Tags |