01: /*
02: * Copyright 2002 (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: BooleanCharColumnExpression.java,v 1.4 2003/08/11 16:01:51 pierreg0 Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: class BooleanCharColumnExpression extends BooleanExpression {
14: private final QueryStatement.QueryColumn qsc;
15: private boolean truthTest;
16:
17: public BooleanCharColumnExpression(QueryStatement qs,
18: QueryStatement.QueryColumn qsc) {
19: this (qs, qsc, true);
20: }
21:
22: public BooleanCharColumnExpression(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 BooleanCharColumnLiteral(qs, truthTest));
30:
31: lowestOperator = OP_EQ;
32: }
33:
34: public BooleanExpression not() {
35: return new BooleanCharColumnExpression(qs, qsc, !truthTest);
36: }
37:
38: public BooleanExpression eq(SQLExpression expr) {
39: if (expr instanceof NullLiteral)
40: return expr.eq(new CharacterExpression(qs, qsc));
41: else if (expr instanceof BooleanCharColumnExpression)
42: return new BooleanExpression(new CharacterExpression(qs,
43: qsc), OP_EQ, new CharacterExpression(qs,
44: ((BooleanCharColumnExpression) expr).qsc));
45: else
46: return super .eq(expr);
47: }
48:
49: public BooleanExpression noteq(SQLExpression expr) {
50: if (expr instanceof NullLiteral)
51: return expr.noteq(new CharacterExpression(qs, qsc));
52: else if (expr instanceof BooleanCharColumnExpression)
53: return new BooleanExpression(new CharacterExpression(qs,
54: qsc), OP_NOTEQ, new CharacterExpression(qs,
55: ((BooleanCharColumnExpression) expr).qsc));
56: else
57: return super .noteq(expr);
58: }
59:
60: public BooleanExpression in(SQLExpression expr) {
61: return new BooleanExpression(new CharacterExpression(qs, qsc),
62: OP_IN, expr);
63: }
64: }
|