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