1 56 package org.objectstyle.cayenne.exp.parser; 57 58 import org.objectstyle.cayenne.exp.Expression; 59 import org.objectstyle.cayenne.util.ConversionUtil; 60 61 67 public class ASTGreaterOrEqual extends ConditionNode { 68 69 72 ASTGreaterOrEqual(int id) { 73 super(id); 74 } 75 76 public ASTGreaterOrEqual() { 77 super(ExpressionParserTreeConstants.JJTGREATEROREQUAL); 78 } 79 80 public ASTGreaterOrEqual(ASTPath path, Object value) { 81 super(ExpressionParserTreeConstants.JJTGREATEROREQUAL); 82 jjtAddChild(path, 0); 83 jjtAddChild(new ASTScalar(value), 1); 84 } 85 86 protected Object evaluateNode(Object o) throws Exception { 87 int len = jjtGetNumChildren(); 88 if (len != 2) { 89 return Boolean.FALSE; 90 } 91 92 Comparable c1 = ConversionUtil.toComparable(evaluateChild(0, o)); 93 if (c1 == null) { 94 return Boolean.FALSE; 95 } 96 97 Comparable c2 = ConversionUtil.toComparable(evaluateChild(1, o)); 98 if (c2 == null) { 99 return Boolean.FALSE; 100 } 101 102 return c1.compareTo(c2) >= 0 ? Boolean.TRUE : Boolean.FALSE; 103 } 104 105 108 public Expression shallowCopy() { 109 return new ASTGreaterOrEqual(id); 110 } 111 112 protected String getExpressionOperator(int index) { 113 return ">="; 114 } 115 116 public int getType() { 117 return Expression.GREATER_THAN_EQUAL_TO; 118 } 119 } 120 | Popular Tags |