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