KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > medor > expression > lib > Plus


1 /**
2  * MEDOR: Middleware Enabling Distributed Object Requests
3  *
4  * Copyright (C) 2001-2003 France Telecom R&D
5  * Contact: alexandre.lefebvre@rd.francetelecom.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * Initial developers: M. Alia, A. Lefebvre
22  */

23
24 /**
25  * Package definition.
26  */

27 package org.objectweb.medor.expression.lib;
28
29 import org.objectweb.medor.expression.api.Expression;
30 import org.objectweb.medor.expression.api.Operator;
31 import org.objectweb.medor.expression.api.TypingException;
32
33 import java.math.BigDecimal JavaDoc;
34 import java.math.BigInteger JavaDoc;
35 import java.sql.Time JavaDoc;
36 import java.sql.Timestamp JavaDoc;
37 import java.util.Date JavaDoc;
38
39 /**
40  * This operator operates on the numeric Types and the string Type. The
41  * operation performed between string is the concatenation (string1+string2).
42  */

43 public class Plus extends BasicBinaryArithmeticOperator {
44
45     public Plus() {
46     }
47
48     public Plus(Expression l, Expression r) {
49         super(l, r);
50     }
51
52     public int evaluate(int op1, int op2) {
53         int result = op1 + op2;
54         return result;
55     }
56
57     public int evaluate(int op1, short op2) {
58         int result = op1 + op2;
59         return result;
60     }
61
62     public long evaluate(int op1, long op2) {
63         long result = op1 + op2;
64         return result;
65     }
66
67     public float evaluate(int op1, float op2) {
68         float result = op1 + op2;
69         return result;
70     }
71
72     public double evaluate(int op1, double op2) {
73         double result = op1 + op2;
74         return result;
75     }
76
77     public float evaluate(float op1, float op2) {
78         float result = op1 + op2;
79         return result;
80     }
81
82     public float evaluate(float op1, short op2) {
83         float result = op1 + op2;
84         return result;
85     }
86
87     public float evaluate(float op1, int op2) {
88         float result = op1 + op2;
89         return result;
90     }
91
92     public float evaluate(float op1, long op2) {
93         float result = op1 + op2;
94         return result;
95     }
96
97     public double evaluate(float op1, double op2) {
98         double result = op1 + op2;
99         return result;
100     }
101
102     public int evaluate(char op1, char op2) {
103         int result = op1 + op2;
104         return result;
105     }
106
107     public String JavaDoc evaluate(char op1, String JavaDoc op2) throws TypingException {
108         return op1 + op2;
109     }
110
111     public long evaluate(long op1, long op2) {
112         long result = op1 + op2;
113         return result;
114     }
115
116     public long evaluate(long op1, short op2) {
117         long result = op1 + op2;
118         return result;
119     }
120
121     public long evaluate(long op1, int op2) {
122         long result = op1 + op2;
123         return result;
124     }
125
126     public float evaluate(long op1, float op2) {
127         float result = op1 + op2;
128         return result;
129     }
130
131     public double evaluate(long op1, double op2) {
132         double result = op1 + op2;
133         return result;
134     }
135
136     public double evaluate(double op1, double op2) {
137         double result = op1 + op2;
138         return result;
139     }
140
141     public double evaluate(double op1, short op2) {
142         double result = op1 + op2;
143         return result;
144     }
145
146     public double evaluate(double op1, int op2) {
147         double result = op1 + op2;
148         return result;
149     }
150
151     public double evaluate(double op1, float op2) {
152         double result = op1 + op2;
153         return result;
154     }
155
156     public double evaluate(double op1, long op2) {
157         double result = op1 + op2;
158         return result;
159     }
160
161     public BigDecimal JavaDoc evaluate(BigDecimal JavaDoc op1, BigDecimal JavaDoc op2) {
162         BigDecimal JavaDoc result = op1.add(op2);
163         return result;
164     }
165
166     public BigInteger JavaDoc evaluate(BigInteger JavaDoc op1, BigInteger JavaDoc op2) {
167         BigInteger JavaDoc result = op1.add(op2);
168         return result;
169     }
170
171     public String JavaDoc evaluate(String JavaDoc op1, String JavaDoc op2) throws TypingException {
172         return op1 + op2;
173     }
174
175     public String JavaDoc evaluate(String JavaDoc op1, char op2) throws TypingException {
176         return op1 + op2;
177     }
178
179     public Timestamp JavaDoc evaluate(Timestamp JavaDoc op1, Timestamp JavaDoc op2)
180             throws TypingException {
181         throw new TypingException("Mult(Timestamp, Timestamp)");
182     }
183
184     public Time JavaDoc evaluate(Time JavaDoc op1, Time JavaDoc op2) throws TypingException {
185         throw new TypingException("Mult(Time, Time)");
186     }
187
188     public Date JavaDoc evaluate(Date JavaDoc op1, Date JavaDoc op2) throws TypingException {
189         throw new TypingException("Mult(Date, Date)");
190     }
191
192     public String JavaDoc getOperatorString() {
193         return Operator.PLUS;
194     }
195 }
196
Popular Tags