1 56 package org.objectstyle.cayenne.exp.parser; 57 58 import org.objectstyle.cayenne.exp.Expression; 59 60 65 public class ASTIn extends ConditionNode { 66 67 70 ASTIn(int id) { 71 super(id); 72 } 73 74 public ASTIn() { 75 super(ExpressionParserTreeConstants.JJTIN); 76 } 77 78 public ASTIn(ASTPath path, ASTList list) { 79 super(ExpressionParserTreeConstants.JJTIN); 80 jjtAddChild(path, 0); 81 jjtAddChild(list, 1); 82 } 83 84 protected Object evaluateNode(Object o) throws Exception { 85 int len = jjtGetNumChildren(); 86 if (len != 2) { 87 return Boolean.FALSE; 88 } 89 90 Object o1 = evaluateChild(0, o); 91 if (o1 == null) { 92 return Boolean.FALSE; 93 } 94 95 Object [] objects = (Object []) evaluateChild(1, o); 96 if (objects == null) { 97 return Boolean.FALSE; 98 } 99 100 int size = objects.length; 101 for (int i = 0; i < size; i++) { 102 if (o1.equals(objects[i])) { 103 return Boolean.TRUE; 104 } 105 } 106 107 return Boolean.FALSE; 108 } 109 110 113 public Expression shallowCopy() { 114 return new ASTIn(id); 115 } 116 117 protected String getExpressionOperator(int index) { 118 return "in"; 119 } 120 121 public int getType() { 122 return Expression.IN; 123 } 124 } 125 | Popular Tags |