KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > store > BooleanBitColumnExpression


1 /*
2  * Copyright 2003 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: BooleanBitColumnExpression.java,v 1.3 2003/08/11 16:01:51 pierreg0 Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 class BooleanBitColumnExpression extends BooleanExpression
14 {
15     private final QueryStatement.QueryColumn qsc;
16     private boolean truthTest;
17
18     public BooleanBitColumnExpression(QueryStatement qs, QueryStatement.QueryColumn qsc)
19     {
20         this(qs, qsc, true);
21     }
22
23     public BooleanBitColumnExpression(QueryStatement qs, QueryStatement.QueryColumn qsc, boolean truthTest)
24     {
25         super(qs, qsc);
26
27         this.qsc = qsc;
28         this.truthTest = truthTest;
29         st.append(" = ").append(new BooleanBitColumnLiteral(qs, truthTest));
30
31         lowestOperator = OP_EQ;
32     }
33
34     public BooleanExpression not()
35     {
36         return new BooleanBitColumnExpression(qs, qsc, !truthTest);
37     }
38
39     public BooleanExpression eq(SQLExpression expr)
40     {
41         if (expr instanceof NullLiteral)
42             return expr.eq(new NumericExpression(qs, qsc));
43         else if (expr instanceof BooleanBitColumnExpression)
44             return new BooleanExpression(new NumericExpression(qs, qsc),
45                                          OP_EQ,
46                                          new NumericExpression(qs, ((BooleanBitColumnExpression)expr).qsc));
47         else
48             return super.eq(expr);
49     }
50
51     public BooleanExpression noteq(SQLExpression expr)
52     {
53         if (expr instanceof NullLiteral)
54             return expr.noteq(new NumericExpression(qs, qsc));
55         else if (expr instanceof BooleanBitColumnExpression)
56             return new BooleanExpression(new NumericExpression(qs, qsc),
57                                          OP_NOTEQ,
58                                          new NumericExpression(qs, ((BooleanBitColumnExpression)expr).qsc));
59         else
60             return super.noteq(expr);
61     }
62
63     public BooleanExpression in(SQLExpression expr)
64     {
65         return new BooleanExpression(new NumericExpression(qs, qsc), OP_IN, expr);
66     }
67 }
68
Popular Tags