001: /*
002: * Copyright 2002 (C) TJDO.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the TJDO License version 1.0.
006: * See the terms of the TJDO License in the documentation provided with this software.
007: *
008: * $Id: NumericExpression.java,v 1.4 2003/08/11 16:01:52 pierreg0 Exp $
009: */
010:
011: package com.triactive.jdo.store;
012:
013: import java.util.List;
014:
015: class NumericExpression extends SQLExpression {
016: public NumericExpression(QueryStatement qs) {
017: super (qs);
018: }
019:
020: public NumericExpression(QueryStatement qs,
021: QueryStatement.QueryColumn qsc) {
022: super (qs, qsc);
023: }
024:
025: public NumericExpression(String functionName, List args) {
026: super (functionName, args);
027: }
028:
029: public NumericExpression(MonadicOperator op, SQLExpression operand) {
030: super (op, operand);
031: }
032:
033: public NumericExpression(SQLExpression operand1, DyadicOperator op,
034: SQLExpression operand2) {
035: super (operand1, op, operand2);
036: }
037:
038: public BooleanExpression eq(SQLExpression expr) {
039: if (expr instanceof NullLiteral)
040: return expr.eq(this );
041: else if (expr instanceof NumericExpression)
042: return new BooleanExpression(this , OP_EQ, expr);
043: else
044: return super .eq(expr);
045: }
046:
047: public BooleanExpression noteq(SQLExpression expr) {
048: if (expr instanceof NullLiteral)
049: return expr.noteq(this );
050: else if (expr instanceof NumericExpression)
051: return new BooleanExpression(this , OP_NOTEQ, expr);
052: else
053: return super .noteq(expr);
054: }
055:
056: public BooleanExpression lt(SQLExpression expr) {
057: if (expr instanceof NumericExpression)
058: return new BooleanExpression(this , OP_LT, expr);
059: else
060: return super .lt(expr);
061: }
062:
063: public BooleanExpression lteq(SQLExpression expr) {
064: if (expr instanceof NumericExpression)
065: return new BooleanExpression(this , OP_LTEQ, expr);
066: else
067: return super .lteq(expr);
068: }
069:
070: public BooleanExpression gt(SQLExpression expr) {
071: if (expr instanceof NumericExpression)
072: return new BooleanExpression(this , OP_GT, expr);
073: else
074: return super .gt(expr);
075: }
076:
077: public BooleanExpression gteq(SQLExpression expr) {
078: if (expr instanceof NumericExpression)
079: return new BooleanExpression(this , OP_GTEQ, expr);
080: else
081: return super .gteq(expr);
082: }
083:
084: public BooleanExpression in(SQLExpression expr) {
085: return new BooleanExpression(this , OP_IN, expr);
086: }
087:
088: public SQLExpression add(SQLExpression expr) {
089: if (expr instanceof NumericExpression)
090: return new NumericExpression(this , OP_ADD, expr);
091: else
092: return super .add(expr);
093: }
094:
095: public SQLExpression sub(SQLExpression expr) {
096: if (expr instanceof NumericExpression)
097: return new NumericExpression(this , OP_SUB, expr);
098: else
099: return super .sub(expr);
100: }
101:
102: public SQLExpression mul(SQLExpression expr) {
103: if (expr instanceof NumericExpression)
104: return new NumericExpression(this , OP_MUL, expr);
105: else
106: return super .mul(expr);
107: }
108:
109: public SQLExpression div(SQLExpression expr) {
110: if (expr instanceof NumericExpression)
111: return new NumericExpression(this , OP_DIV, expr);
112: else
113: return super .div(expr);
114: }
115:
116: public SQLExpression neg() {
117: return new NumericExpression(OP_NEG, this);
118: }
119: }
|