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 SQLInClause extends SQLInvertibleClause {
10: public SQLInClause(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(" IN (");
18: children[0].write(out);
19: out.write(')');
20: }
21:
22: public Object execute(Object context, Object lhs) {
23: boolean result = false;
24:
25: // Evaluate arguments in order until we find a match. Do this lazily to
26: // avoid extra work.
27: Node values = children[0];
28: for (int i = 0, n = values.jjtGetNumChildren(); i < n; i++) {
29: if (compare(lhs, values.jjtGetChild(i).execute(context)) == 0) {
30: result = true;
31: break;
32: }
33: }
34:
35: return result ^ invert ? Boolean.TRUE : Boolean.FALSE;
36: }
37: }
|