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