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 SQLUnaryExpr extends SQLArithmeticExpr {
10: boolean negate;
11:
12: public SQLUnaryExpr(int id) {
13: super (id);
14: }
15:
16: public void invert() {
17: negate = true;
18: }
19:
20: public void write(Writer out) throws IOException {
21: if (negate)
22: out.write('-');
23: children[0].write(out);
24: }
25:
26: public Object execute(Object context) {
27: Object value = children[0].execute(context);
28: return negate ? negate(value) : value;
29: }
30: }
|