1 56 package org.objectstyle.cayenne.exp.parser; 57 58 import java.math.BigDecimal ; 59 60 import org.objectstyle.cayenne.exp.Expression; 61 62 68 public class ASTEqual extends ConditionNode { 69 72 ASTEqual(int id) { 73 super(id); 74 } 75 76 public ASTEqual() { 77 super(ExpressionParserTreeConstants.JJTEQUAL); 78 } 79 80 83 public ASTEqual(ASTPath path, Object value) { 84 super(ExpressionParserTreeConstants.JJTEQUAL); 85 jjtAddChild(path, 0); 86 jjtAddChild(new ASTScalar(value), 1); 87 } 88 89 protected Object evaluateNode(Object o) throws Exception { 90 int len = jjtGetNumChildren(); 91 if (len != 2) { 92 return Boolean.FALSE; 93 } 94 95 Object o1 = evaluateChild(0, o); 96 Object o2 = evaluateChild(1, o); 97 98 102 if (o1 == null && o2 == null) { 103 return Boolean.TRUE; 104 } 105 else if (o1 != null) { 106 if (o1 instanceof BigDecimal ) { 109 if (o2 instanceof BigDecimal ) { 110 return ((BigDecimal ) o1).compareTo((BigDecimal ) o2) == 0 111 ? Boolean.TRUE 112 : Boolean.FALSE; 113 } 114 115 return Boolean.FALSE; 116 } 117 118 return o1.equals(o2) ? Boolean.TRUE : Boolean.FALSE; 119 } 120 else { 121 return Boolean.FALSE; 122 } 123 } 124 125 128 public Expression shallowCopy() { 129 return new ASTEqual(id); 130 } 131 132 protected String getExpressionOperator(int index) { 133 return "="; 134 } 135 136 public int getType() { 137 return Expression.EQUAL_TO; 138 } 139 } 140 | Popular Tags |