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 ASTLess extends ConditionNode { 68 71 ASTLess(int id) { 72 super(id); 73 } 74 75 public ASTLess() { 76 super(ExpressionParserTreeConstants.JJTLESS); 77 } 78 79 public ASTLess(ASTPath path, Object value) { 80 super(ExpressionParserTreeConstants.JJTLESS); 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 Comparable c1 = ConversionUtil.toComparable(evaluateChild(0, o)); 92 if (c1 == null) { 93 return Boolean.FALSE; 94 } 95 96 Comparable c2 = ConversionUtil.toComparable(evaluateChild(1, o)); 97 if (c2 == null) { 98 return Boolean.FALSE; 99 } 100 101 return c1.compareTo(c2) < 0 ? Boolean.TRUE : Boolean.FALSE; 102 } 103 104 107 public Expression shallowCopy() { 108 return new ASTLess(id); 109 } 110 111 protected String getExpressionOperator(int index) { 112 return "<"; 113 } 114 115 public int getType() { 116 return Expression.LESS_THAN; 117 } 118 } 119 | Popular Tags |