KickJava   Java API By Example, From Geeks To Geeks.

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


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: NumericExpression.java,v 1.4 2003/08/11 16:01:52 pierreg0 Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import java.util.List JavaDoc;
14
15
16 class NumericExpression extends SQLExpression
17 {
18     public NumericExpression(QueryStatement qs)
19     {
20         super(qs);
21     }
22
23     public NumericExpression(QueryStatement qs, QueryStatement.QueryColumn qsc)
24     {
25         super(qs, qsc);
26     }
27
28     public NumericExpression(String JavaDoc functionName, List JavaDoc args)
29     {
30         super(functionName, args);
31     }
32
33     public NumericExpression(MonadicOperator op, SQLExpression operand)
34     {
35         super(op, operand);
36     }
37
38     public NumericExpression(SQLExpression operand1, DyadicOperator op, SQLExpression operand2)
39     {
40         super(operand1, op, operand2);
41     }
42
43     public BooleanExpression eq(SQLExpression expr)
44     {
45         if (expr instanceof NullLiteral)
46             return expr.eq(this);
47         else if (expr instanceof NumericExpression)
48             return new BooleanExpression(this, OP_EQ, expr);
49         else
50             return super.eq(expr);
51     }
52
53     public BooleanExpression noteq(SQLExpression expr)
54     {
55         if (expr instanceof NullLiteral)
56             return expr.noteq(this);
57         else if (expr instanceof NumericExpression)
58             return new BooleanExpression(this, OP_NOTEQ, expr);
59         else
60             return super.noteq(expr);
61     }
62
63     public BooleanExpression lt(SQLExpression expr)
64     {
65         if (expr instanceof NumericExpression)
66             return new BooleanExpression(this, OP_LT, expr);
67         else
68             return super.lt(expr);
69     }
70
71     public BooleanExpression lteq(SQLExpression expr)
72     {
73         if (expr instanceof NumericExpression)
74             return new BooleanExpression(this, OP_LTEQ, expr);
75         else
76             return super.lteq(expr);
77     }
78
79     public BooleanExpression gt(SQLExpression expr)
80     {
81         if (expr instanceof NumericExpression)
82             return new BooleanExpression(this, OP_GT, expr);
83         else
84             return super.gt(expr);
85     }
86
87     public BooleanExpression gteq(SQLExpression expr)
88     {
89         if (expr instanceof NumericExpression)
90             return new BooleanExpression(this, OP_GTEQ, expr);
91         else
92             return super.gteq(expr);
93     }
94     
95     public BooleanExpression in(SQLExpression expr)
96     {
97         return new BooleanExpression(this, OP_IN, expr);
98     }
99
100     public SQLExpression add(SQLExpression expr)
101     {
102         if (expr instanceof NumericExpression)
103             return new NumericExpression(this, OP_ADD, expr);
104         else
105             return super.add(expr);
106     }
107
108     public SQLExpression sub(SQLExpression expr)
109     {
110         if (expr instanceof NumericExpression)
111             return new NumericExpression(this, OP_SUB, expr);
112         else
113             return super.sub(expr);
114     }
115
116     public SQLExpression mul(SQLExpression expr)
117     {
118         if (expr instanceof NumericExpression)
119             return new NumericExpression(this, OP_MUL, expr);
120         else
121             return super.mul(expr);
122     }
123
124     public SQLExpression div(SQLExpression expr)
125     {
126         if (expr instanceof NumericExpression)
127             return new NumericExpression(this, OP_DIV, expr);
128         else
129             return super.div(expr);
130     }
131
132     public SQLExpression neg()
133     {
134         return new NumericExpression(OP_NEG, this);
135     }
136 }
137
Popular Tags