KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2002 (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: BooleanCharColumnExpression.java,v 1.4 2003/08/11 16:01:51 pierreg0 Exp $
9  */

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