KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2004 (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: BinaryExpression.java,v 1.1 2004/03/22 04:58:13 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import java.util.List JavaDoc;
14
15
16 class BinaryExpression extends SQLExpression
17 {
18     public BinaryExpression(QueryStatement qs)
19     {
20         super(qs);
21     }
22
23     public BinaryExpression(QueryStatement qs, QueryStatement.QueryColumn qsc)
24     {
25         super(qs, qsc);
26     }
27
28     public BinaryExpression(String JavaDoc functionName, List JavaDoc args)
29     {
30         super(functionName, args);
31     }
32
33     public BinaryExpression(SQLExpression operand1, DyadicOperator op, SQLExpression operand2)
34     {
35         super(operand1, op, operand2);
36     }
37
38     public BooleanExpression eq(SQLExpression expr)
39     {
40         if (expr instanceof NullLiteral)
41             return expr.eq(this);
42         else if (expr instanceof BinaryExpression)
43             return new BooleanExpression(this, OP_EQ, expr);
44         else
45             return super.eq(expr);
46     }
47
48     public BooleanExpression noteq(SQLExpression expr)
49     {
50         if (expr instanceof NullLiteral)
51             return expr.noteq(this);
52         else if (expr instanceof BinaryExpression)
53             return new BooleanExpression(this, OP_NOTEQ, expr);
54         else
55             return super.noteq(expr);
56     }
57
58     public BooleanExpression lt(SQLExpression expr)
59     {
60         if (expr instanceof BinaryExpression)
61             return new BooleanExpression(this, OP_LT, expr);
62         else
63             return super.lt(expr);
64     }
65
66     public BooleanExpression lteq(SQLExpression expr)
67     {
68         if (expr instanceof BinaryExpression)
69             return new BooleanExpression(this, OP_LTEQ, expr);
70         else
71             return super.lteq(expr);
72     }
73
74     public BooleanExpression gt(SQLExpression expr)
75     {
76         if (expr instanceof BinaryExpression)
77             return new BooleanExpression(this, OP_GT, expr);
78         else
79             return super.gt(expr);
80     }
81
82     public BooleanExpression gteq(SQLExpression expr)
83     {
84         if (expr instanceof BinaryExpression)
85             return new BooleanExpression(this, OP_GTEQ, expr);
86         else
87             return super.gteq(expr);
88     }
89
90     public SQLExpression add(SQLExpression expr)
91     {
92         if (expr instanceof BinaryExpression)
93             return new BinaryExpression(this, OP_CONCAT, expr);
94         else
95             return super.add(expr);
96     }
97
98     public BooleanExpression in(SQLExpression expr)
99     {
100         return new BooleanExpression(this, OP_IN, expr);
101     }
102 }
103
Popular Tags