01: /*
02: * Copyright 2003 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: BooleanBitColumnExpression.java,v 1.3 2003/08/11 16:01:51 pierreg0 Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: class BooleanBitColumnExpression extends BooleanExpression {
14: private final QueryStatement.QueryColumn qsc;
15: private boolean truthTest;
16:
17: public BooleanBitColumnExpression(QueryStatement qs,
18: QueryStatement.QueryColumn qsc) {
19: this (qs, qsc, true);
20: }
21:
22: public BooleanBitColumnExpression(QueryStatement qs,
23: QueryStatement.QueryColumn qsc, boolean truthTest) {
24: super (qs, qsc);
25:
26: this .qsc = qsc;
27: this .truthTest = truthTest;
28: st.append(" = ").append(
29: new BooleanBitColumnLiteral(qs, truthTest));
30:
31: lowestOperator = OP_EQ;
32: }
33:
34: public BooleanExpression not() {
35: return new BooleanBitColumnExpression(qs, qsc, !truthTest);
36: }
37:
38: public BooleanExpression eq(SQLExpression expr) {
39: if (expr instanceof NullLiteral)
40: return expr.eq(new NumericExpression(qs, qsc));
41: else if (expr instanceof BooleanBitColumnExpression)
42: return new BooleanExpression(
43: new NumericExpression(qs, qsc), OP_EQ,
44: new NumericExpression(qs,
45: ((BooleanBitColumnExpression) expr).qsc));
46: else
47: return super .eq(expr);
48: }
49:
50: public BooleanExpression noteq(SQLExpression expr) {
51: if (expr instanceof NullLiteral)
52: return expr.noteq(new NumericExpression(qs, qsc));
53: else if (expr instanceof BooleanBitColumnExpression)
54: return new BooleanExpression(
55: new NumericExpression(qs, qsc), OP_NOTEQ,
56: new NumericExpression(qs,
57: ((BooleanBitColumnExpression) expr).qsc));
58: else
59: return super .noteq(expr);
60: }
61:
62: public BooleanExpression in(SQLExpression expr) {
63: return new BooleanExpression(new NumericExpression(qs, qsc),
64: OP_IN, expr);
65: }
66: }
|