1 19 20 package org.apache.cayenne.exp.parser; 21 22 import java.math.BigDecimal ; 23 24 import org.apache.cayenne.exp.Expression; 25 26 32 public class ASTEqual extends ConditionNode { 33 36 ASTEqual(int id) { 37 super(id); 38 } 39 40 public ASTEqual() { 41 super(ExpressionParserTreeConstants.JJTEQUAL); 42 } 43 44 47 public ASTEqual(ASTPath path, Object value) { 48 super(ExpressionParserTreeConstants.JJTEQUAL); 49 jjtAddChild(path, 0); 50 jjtAddChild(new ASTScalar(value), 1); 51 } 52 53 protected Object evaluateNode(Object o) throws Exception { 54 int len = jjtGetNumChildren(); 55 if (len != 2) { 56 return Boolean.FALSE; 57 } 58 59 Object o1 = evaluateChild(0, o); 60 Object o2 = evaluateChild(1, o); 61 62 66 if (o1 == null && o2 == null) { 67 return Boolean.TRUE; 68 } 69 else if (o1 != null) { 70 if (o1 instanceof BigDecimal ) { 73 if (o2 instanceof BigDecimal ) { 74 return ((BigDecimal ) o1).compareTo((BigDecimal ) o2) == 0 75 ? Boolean.TRUE 76 : Boolean.FALSE; 77 } 78 79 return Boolean.FALSE; 80 } 81 82 return o1.equals(o2) ? Boolean.TRUE : Boolean.FALSE; 83 } 84 else { 85 return Boolean.FALSE; 86 } 87 } 88 89 92 public Expression shallowCopy() { 93 return new ASTEqual(id); 94 } 95 96 protected String getExpressionOperator(int index) { 97 return "="; 98 } 99 100 public int getType() { 101 return Expression.EQUAL_TO; 102 } 103 } 104 | Popular Tags |