01: package org.obe.sql;
02:
03: import java.io.IOException;
04: import java.io.Writer;
05:
06: /**
07: * @author Adrian Price
08: */
09: public class SQLBetweenClause extends SQLInvertibleClause {
10: public SQLBetweenClause(int id) {
11: super (id);
12: }
13:
14: public void write(Writer out) throws IOException {
15: if (invert)
16: out.write(" NOT");
17: out.write(" BETWEEN ");
18: children[0].write(out);
19: out.write(" AND ");
20: children[1].write(out);
21: }
22:
23: public Object execute(Object context, Object value) {
24: Object lbound = children[0].execute(context);
25: Object rbound = children[1].execute(context);
26: boolean b = compare(lbound, value) <= 0
27: && compare(value, rbound) <= 0;
28: return b ^ invert ? Boolean.TRUE : Boolean.FALSE;
29: }
30: }
|