1 56 57 package org.objectstyle.cayenne.exp.parser; 58 59 import org.objectstyle.cayenne.exp.Expression; 60 import org.objectstyle.cayenne.util.Util; 61 62 67 public class ASTNotEqual extends ConditionNode { 68 ASTNotEqual(int id) { 69 super(id); 70 } 71 72 public ASTNotEqual() { 73 super(ExpressionParserTreeConstants.JJTNOTEQUAL); 74 } 75 76 79 public ASTNotEqual(ASTPath path, Object value) { 80 super(ExpressionParserTreeConstants.JJTNOTEQUAL); 81 jjtAddChild(path, 0); 82 jjtAddChild(new ASTScalar(value), 1); 83 } 84 85 protected Object evaluateNode(Object o) throws Exception { 86 int len = jjtGetNumChildren(); 87 if (len != 2) { 88 return Boolean.FALSE; 89 } 90 91 Object o1 = evaluateChild(0, o); 92 Object o2 = evaluateChild(1, o); 93 return Util.nullSafeEquals(o1, o2) ? Boolean.FALSE : Boolean.TRUE; 94 } 95 96 99 public Expression shallowCopy() { 100 return new ASTNotEqual(id); 101 } 102 103 protected String getExpressionOperator(int index) { 104 return "!="; 105 } 106 107 public int getType() { 108 return Expression.NOT_EQUAL_TO; 109 } 110 } 111 | Popular Tags |