1 19 20 package org.apache.cayenne.exp.parser; 21 22 import org.apache.cayenne.exp.Expression; 23 import org.apache.cayenne.util.ConversionUtil; 24 25 31 public class ASTLess extends ConditionNode { 32 35 ASTLess(int id) { 36 super(id); 37 } 38 39 public ASTLess() { 40 super(ExpressionParserTreeConstants.JJTLESS); 41 } 42 43 public ASTLess(ASTPath path, Object value) { 44 super(ExpressionParserTreeConstants.JJTLESS); 45 jjtAddChild(path, 0); 46 jjtAddChild(new ASTScalar(value), 1); 47 } 48 49 protected Object evaluateNode(Object o) throws Exception { 50 int len = jjtGetNumChildren(); 51 if (len != 2) { 52 return Boolean.FALSE; 53 } 54 55 Comparable c1 = ConversionUtil.toComparable(evaluateChild(0, o)); 56 if (c1 == null) { 57 return Boolean.FALSE; 58 } 59 60 Comparable c2 = ConversionUtil.toComparable(evaluateChild(1, o)); 61 if (c2 == null) { 62 return Boolean.FALSE; 63 } 64 65 return c1.compareTo(c2) < 0 ? Boolean.TRUE : Boolean.FALSE; 66 } 67 68 71 public Expression shallowCopy() { 72 return new ASTLess(id); 73 } 74 75 protected String getExpressionOperator(int index) { 76 return "<"; 77 } 78 79 public int getType() { 80 return Expression.LESS_THAN; 81 } 82 } 83 | Popular Tags |