svn-gvsig-desktop / trunk / libraries / libGDBMS / src / com / hardcode / gdbms / engine / values / DoubleValue.java @ 466
History | View | Annotate | Download (15.2 KB)
1 |
/* Generated by Together */
|
---|---|
2 |
package com.hardcode.gdbms.engine.values; |
3 |
|
4 |
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException; |
5 |
|
6 |
|
7 |
/**
|
8 |
* Wrapper sobre el valor double
|
9 |
*
|
10 |
* @author Fernando Gonz?lez Cort?s
|
11 |
*/
|
12 |
public class DoubleValue extends Value { |
13 |
private double value; |
14 |
|
15 |
/**
|
16 |
* Creates a new DoubleValue object.
|
17 |
*
|
18 |
* @param val DOCUMENT ME!
|
19 |
*/
|
20 |
public DoubleValue(double val) { |
21 |
value = val; |
22 |
} |
23 |
|
24 |
/**
|
25 |
* Creates a new DoubleValue object.
|
26 |
*/
|
27 |
public DoubleValue() {
|
28 |
} |
29 |
|
30 |
/**
|
31 |
* Establece el valor de este objeto
|
32 |
*
|
33 |
* @param value
|
34 |
*/
|
35 |
public void setValue(double value) { |
36 |
this.value = value;
|
37 |
} |
38 |
|
39 |
/**
|
40 |
* Obtiene el valor de este objeto
|
41 |
*
|
42 |
* @return
|
43 |
*/
|
44 |
public double getValue() { |
45 |
return value;
|
46 |
} |
47 |
|
48 |
/**
|
49 |
* @see java.lang.Object#toString()
|
50 |
*/
|
51 |
public String toString() { |
52 |
return "" + value; |
53 |
} |
54 |
|
55 |
/**
|
56 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.Value)
|
57 |
*/
|
58 |
public Value suma(Value v) throws IncompatibleTypesException { |
59 |
return v.suma((DoubleValue) this); |
60 |
} |
61 |
|
62 |
/**
|
63 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.IntValue)
|
64 |
*/
|
65 |
public Value suma(IntValue value) throws IncompatibleTypesException { |
66 |
DoubleValue ret = new DoubleValue();
|
67 |
ret.setValue(this.value + value.getValue());
|
68 |
|
69 |
return ret;
|
70 |
} |
71 |
|
72 |
/**
|
73 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.LongValue)
|
74 |
*/
|
75 |
public Value suma(LongValue value) throws IncompatibleTypesException { |
76 |
DoubleValue ret = new DoubleValue();
|
77 |
ret.setValue(this.value + value.getValue());
|
78 |
|
79 |
return ret;
|
80 |
} |
81 |
|
82 |
/**
|
83 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.FloatValue)
|
84 |
*/
|
85 |
public Value suma(FloatValue value) throws IncompatibleTypesException { |
86 |
DoubleValue ret = new DoubleValue();
|
87 |
ret.setValue(this.value + value.getValue());
|
88 |
|
89 |
return ret;
|
90 |
} |
91 |
|
92 |
/**
|
93 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.DoubleValue)
|
94 |
*/
|
95 |
public Value suma(DoubleValue value) throws IncompatibleTypesException { |
96 |
DoubleValue ret = new DoubleValue();
|
97 |
ret.setValue(this.value + value.getValue());
|
98 |
|
99 |
return ret;
|
100 |
} |
101 |
|
102 |
/**
|
103 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.StringValue)
|
104 |
*/
|
105 |
public Value suma(StringValue value) throws IncompatibleTypesException { |
106 |
try {
|
107 |
DoubleValue ret = new DoubleValue();
|
108 |
ret.setValue(this.value + Double.parseDouble(value.getValue())); |
109 |
|
110 |
return ret;
|
111 |
} catch (NumberFormatException e) { |
112 |
throw new IncompatibleTypesException(value.getValue() + |
113 |
" is not a number");
|
114 |
} |
115 |
} |
116 |
|
117 |
/**
|
118 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#producto(com.hardcode.gdbms.engine.instruction.expression.Value)
|
119 |
*/
|
120 |
public Value producto(Value v) throws IncompatibleTypesException { |
121 |
return v.producto((DoubleValue) this); |
122 |
} |
123 |
|
124 |
/**
|
125 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.IntValue)
|
126 |
*/
|
127 |
public Value producto(IntValue value) throws IncompatibleTypesException { |
128 |
DoubleValue ret = new DoubleValue();
|
129 |
ret.setValue(this.value * value.getValue());
|
130 |
|
131 |
return ret;
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.LongValue)
|
136 |
*/
|
137 |
public Value producto(LongValue value) throws IncompatibleTypesException { |
138 |
DoubleValue ret = new DoubleValue();
|
139 |
ret.setValue(this.value * value.getValue());
|
140 |
|
141 |
return ret;
|
142 |
} |
143 |
|
144 |
/**
|
145 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.FloatValue)
|
146 |
*/
|
147 |
public Value producto(FloatValue value) throws IncompatibleTypesException { |
148 |
DoubleValue ret = new DoubleValue();
|
149 |
ret.setValue(this.value * value.getValue());
|
150 |
|
151 |
return ret;
|
152 |
} |
153 |
|
154 |
/**
|
155 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.DoubleValue)
|
156 |
*/
|
157 |
public Value producto(DoubleValue value) throws IncompatibleTypesException { |
158 |
DoubleValue ret = new DoubleValue();
|
159 |
ret.setValue(this.value * value.getValue());
|
160 |
|
161 |
return ret;
|
162 |
} |
163 |
|
164 |
/**
|
165 |
* @see com.hardcode.gdbms.engine.instruction.expression.Operations#suma(com.hardcode.gdbms.engine.instruction.expression.StringValue)
|
166 |
*/
|
167 |
public Value producto(StringValue value) throws IncompatibleTypesException { |
168 |
try {
|
169 |
DoubleValue ret = new DoubleValue();
|
170 |
ret.setValue(this.value + Double.parseDouble(value.getValue())); |
171 |
|
172 |
return ret;
|
173 |
} catch (NumberFormatException e) { |
174 |
throw new IncompatibleTypesException(value.getValue() + |
175 |
" is not a number");
|
176 |
} |
177 |
} |
178 |
|
179 |
/**
|
180 |
* @see com.hardcode.gdbms.engine.instruction.Operations#equals(com.hardcode.gdbms.engine.values.DoubleValue)
|
181 |
*/
|
182 |
public Value equals(DoubleValue value) throws IncompatibleTypesException { |
183 |
return new BooleanValue(this.value == value.getValue()); |
184 |
} |
185 |
|
186 |
/**
|
187 |
* @see com.hardcode.gdbms.engine.instruction.Operations#equals(com.hardcode.gdbms.engine.values.FloatValue)
|
188 |
*/
|
189 |
public Value equals(FloatValue value) throws IncompatibleTypesException { |
190 |
return new BooleanValue(this.value == value.getValue()); |
191 |
} |
192 |
|
193 |
/**
|
194 |
* @see com.hardcode.gdbms.engine.instruction.Operations#equals(com.hardcode.gdbms.engine.values.IntValue)
|
195 |
*/
|
196 |
public Value equals(IntValue value) throws IncompatibleTypesException { |
197 |
return new BooleanValue(this.value == value.getValue()); |
198 |
} |
199 |
|
200 |
/**
|
201 |
* @see com.hardcode.gdbms.engine.instruction.Operations#equals(com.hardcode.gdbms.engine.values.LongValue)
|
202 |
*/
|
203 |
public Value equals(LongValue value) throws IncompatibleTypesException { |
204 |
return new BooleanValue(this.value == value.getValue()); |
205 |
} |
206 |
|
207 |
/**
|
208 |
* @see com.hardcode.gdbms.engine.instruction.Operations#equals(com.hardcode.gdbms.engine.values.StringValue)
|
209 |
*/
|
210 |
public Value equals(StringValue value) throws IncompatibleTypesException { |
211 |
return new BooleanValue(this.toString().equals(value.getValue())); |
212 |
} |
213 |
|
214 |
/**
|
215 |
* @see com.hardcode.gdbms.engine.instruction.Operations#equals(com.hardcode.gdbms.engine.values.Value)
|
216 |
*/
|
217 |
public Value equals(Value value) throws IncompatibleTypesException { |
218 |
return value.equals(this); |
219 |
} |
220 |
|
221 |
/**
|
222 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greater(com.hardcode.gdbms.engine.values.DoubleValue)
|
223 |
*/
|
224 |
public Value greater(DoubleValue value) throws IncompatibleTypesException { |
225 |
return new BooleanValue(this.value > value.getValue()); |
226 |
} |
227 |
|
228 |
/**
|
229 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greater(com.hardcode.gdbms.engine.values.FloatValue)
|
230 |
*/
|
231 |
public Value greater(FloatValue value) throws IncompatibleTypesException { |
232 |
return new BooleanValue(this.value > value.getValue()); |
233 |
} |
234 |
|
235 |
/**
|
236 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greater(com.hardcode.gdbms.engine.values.IntValue)
|
237 |
*/
|
238 |
public Value greater(IntValue value) throws IncompatibleTypesException { |
239 |
return new BooleanValue(this.value > value.getValue()); |
240 |
} |
241 |
|
242 |
/**
|
243 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greater(com.hardcode.gdbms.engine.values.LongValue)
|
244 |
*/
|
245 |
public Value greater(LongValue value) throws IncompatibleTypesException { |
246 |
return new BooleanValue(this.value > value.getValue()); |
247 |
} |
248 |
|
249 |
/**
|
250 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greater(com.hardcode.gdbms.engine.values.StringValue)
|
251 |
*/
|
252 |
public Value greater(StringValue value) throws IncompatibleTypesException { |
253 |
return new BooleanValue(this.toString().compareTo(value.getValue()) > 0); |
254 |
} |
255 |
|
256 |
/**
|
257 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greater(com.hardcode.gdbms.engine.values.Value)
|
258 |
*/
|
259 |
public Value greater(Value value) throws IncompatibleTypesException { |
260 |
return value.less(this); |
261 |
} |
262 |
|
263 |
/**
|
264 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greaterEqual(com.hardcode.gdbms.engine.values.DoubleValue)
|
265 |
*/
|
266 |
public Value greaterEqual(DoubleValue value)
|
267 |
throws IncompatibleTypesException {
|
268 |
return new BooleanValue(this.value >= value.getValue()); |
269 |
} |
270 |
|
271 |
/**
|
272 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greaterEqual(com.hardcode.gdbms.engine.values.FloatValue)
|
273 |
*/
|
274 |
public Value greaterEqual(FloatValue value)
|
275 |
throws IncompatibleTypesException {
|
276 |
return new BooleanValue(this.value >= value.getValue()); |
277 |
} |
278 |
|
279 |
/**
|
280 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greaterEqual(com.hardcode.gdbms.engine.values.IntValue)
|
281 |
*/
|
282 |
public Value greaterEqual(IntValue value) throws IncompatibleTypesException { |
283 |
return new BooleanValue(this.value >= value.getValue()); |
284 |
} |
285 |
|
286 |
/**
|
287 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greaterEqual(com.hardcode.gdbms.engine.values.LongValue)
|
288 |
*/
|
289 |
public Value greaterEqual(LongValue value)
|
290 |
throws IncompatibleTypesException {
|
291 |
return new BooleanValue(this.value >= value.getValue()); |
292 |
} |
293 |
|
294 |
/**
|
295 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greaterEqual(com.hardcode.gdbms.engine.values.StringValue)
|
296 |
*/
|
297 |
public Value greaterEqual(StringValue value)
|
298 |
throws IncompatibleTypesException {
|
299 |
return new BooleanValue(this.toString().compareTo(value.getValue()) >= 0); |
300 |
} |
301 |
|
302 |
/**
|
303 |
* @see com.hardcode.gdbms.engine.instruction.Operations#greaterEqual(com.hardcode.gdbms.engine.values.Value)
|
304 |
*/
|
305 |
public Value greaterEqual(Value value) throws IncompatibleTypesException { |
306 |
return value.lessEqual(this); |
307 |
} |
308 |
|
309 |
/**
|
310 |
* @see com.hardcode.gdbms.engine.instruction.Operations#less(com.hardcode.gdbms.engine.values.DoubleValue)
|
311 |
*/
|
312 |
public Value less(DoubleValue value) throws IncompatibleTypesException { |
313 |
return new BooleanValue(this.value < value.getValue()); |
314 |
} |
315 |
|
316 |
/**
|
317 |
* @see com.hardcode.gdbms.engine.instruction.Operations#less(com.hardcode.gdbms.engine.values.FloatValue)
|
318 |
*/
|
319 |
public Value less(FloatValue value) throws IncompatibleTypesException { |
320 |
return new BooleanValue(this.value < value.getValue()); |
321 |
} |
322 |
|
323 |
/**
|
324 |
* @see com.hardcode.gdbms.engine.instruction.Operations#less(com.hardcode.gdbms.engine.values.IntValue)
|
325 |
*/
|
326 |
public Value less(IntValue value) throws IncompatibleTypesException { |
327 |
return new BooleanValue(this.value < value.getValue()); |
328 |
} |
329 |
|
330 |
/**
|
331 |
* @see com.hardcode.gdbms.engine.instruction.Operations#less(com.hardcode.gdbms.engine.values.LongValue)
|
332 |
*/
|
333 |
public Value less(LongValue value) throws IncompatibleTypesException { |
334 |
return new BooleanValue(this.value < value.getValue()); |
335 |
} |
336 |
|
337 |
/**
|
338 |
* @see com.hardcode.gdbms.engine.instruction.Operations#less(com.hardcode.gdbms.engine.values.StringValue)
|
339 |
*/
|
340 |
public Value less(StringValue value) throws IncompatibleTypesException { |
341 |
return new BooleanValue(this.toString().compareTo(value.getValue()) < 0); |
342 |
} |
343 |
|
344 |
/**
|
345 |
* @see com.hardcode.gdbms.engine.instruction.Operations#less(com.hardcode.gdbms.engine.values.Value)
|
346 |
*/
|
347 |
public Value less(Value value) throws IncompatibleTypesException { |
348 |
return value.greater(this); |
349 |
} |
350 |
|
351 |
/**
|
352 |
* @see com.hardcode.gdbms.engine.instruction.Operations#lessEqual(com.hardcode.gdbms.engine.values.DoubleValue)
|
353 |
*/
|
354 |
public Value lessEqual(DoubleValue value) throws IncompatibleTypesException { |
355 |
return new BooleanValue(this.value <= value.getValue()); |
356 |
} |
357 |
|
358 |
/**
|
359 |
* @see com.hardcode.gdbms.engine.instruction.Operations#lessEqual(com.hardcode.gdbms.engine.values.FloatValue)
|
360 |
*/
|
361 |
public Value lessEqual(FloatValue value) throws IncompatibleTypesException { |
362 |
return new BooleanValue(this.value <= value.getValue()); |
363 |
} |
364 |
|
365 |
/**
|
366 |
* @see com.hardcode.gdbms.engine.instruction.Operations#lessEqual(com.hardcode.gdbms.engine.values.IntValue)
|
367 |
*/
|
368 |
public Value lessEqual(IntValue value) throws IncompatibleTypesException { |
369 |
return new BooleanValue(this.value <= value.getValue()); |
370 |
} |
371 |
|
372 |
/**
|
373 |
* @see com.hardcode.gdbms.engine.instruction.Operations#lessEqual(com.hardcode.gdbms.engine.values.LongValue)
|
374 |
*/
|
375 |
public Value lessEqual(LongValue value) throws IncompatibleTypesException { |
376 |
return new BooleanValue(this.value <= value.getValue()); |
377 |
} |
378 |
|
379 |
/**
|
380 |
* @see com.hardcode.gdbms.engine.instruction.Operations#lessEqual(com.hardcode.gdbms.engine.values.StringValue)
|
381 |
*/
|
382 |
public Value lessEqual(StringValue value) throws IncompatibleTypesException { |
383 |
return new BooleanValue(this.toString().compareTo(value.getValue()) <= 0); |
384 |
} |
385 |
|
386 |
/**
|
387 |
* @see com.hardcode.gdbms.engine.instruction.Operations#lessEqual(com.hardcode.gdbms.engine.values.Value)
|
388 |
*/
|
389 |
public Value lessEqual(Value value) throws IncompatibleTypesException { |
390 |
return value.greaterEqual(this); |
391 |
} |
392 |
|
393 |
/**
|
394 |
* @see com.hardcode.gdbms.engine.instruction.Operations#notEquals(com.hardcode.gdbms.engine.values.DoubleValue)
|
395 |
*/
|
396 |
public Value notEquals(DoubleValue value) throws IncompatibleTypesException { |
397 |
return new BooleanValue(this.value != value.getValue()); |
398 |
} |
399 |
|
400 |
/**
|
401 |
* @see com.hardcode.gdbms.engine.instruction.Operations#notEquals(com.hardcode.gdbms.engine.values.FloatValue)
|
402 |
*/
|
403 |
public Value notEquals(FloatValue value) throws IncompatibleTypesException { |
404 |
return new BooleanValue(this.value != value.getValue()); |
405 |
} |
406 |
|
407 |
/**
|
408 |
* @see com.hardcode.gdbms.engine.instruction.Operations#notEquals(com.hardcode.gdbms.engine.values.IntValue)
|
409 |
*/
|
410 |
public Value notEquals(IntValue value) throws IncompatibleTypesException { |
411 |
return new BooleanValue(this.value != value.getValue()); |
412 |
} |
413 |
|
414 |
/**
|
415 |
* @see com.hardcode.gdbms.engine.instruction.Operations#notEquals(com.hardcode.gdbms.engine.values.LongValue)
|
416 |
*/
|
417 |
public Value notEquals(LongValue value) throws IncompatibleTypesException { |
418 |
return new BooleanValue(this.value != value.getValue()); |
419 |
} |
420 |
|
421 |
/**
|
422 |
* @see com.hardcode.gdbms.engine.instruction.Operations#notEquals(com.hardcode.gdbms.engine.values.StringValue)
|
423 |
*/
|
424 |
public Value notEquals(StringValue value) throws IncompatibleTypesException { |
425 |
return new BooleanValue(!this.toString().equals(value.getValue())); |
426 |
} |
427 |
|
428 |
/**
|
429 |
* @see com.hardcode.gdbms.engine.instruction.Operations#notEquals(com.hardcode.gdbms.engine.values.Value)
|
430 |
*/
|
431 |
public Value notEquals(Value value) throws IncompatibleTypesException { |
432 |
return value.notEquals(this); |
433 |
} |
434 |
} |