svn-gvsig-desktop / trunk / libraries / libGDBMS / src / com / hardcode / gdbms / engine / values / NumericValue.java @ 1956
History | View | Annotate | Download (4.35 KB)
1 |
package com.hardcode.gdbms.engine.values; |
---|---|
2 |
|
3 |
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException; |
4 |
|
5 |
import java.io.Serializable; |
6 |
|
7 |
|
8 |
/**
|
9 |
* DOCUMENT ME!
|
10 |
*
|
11 |
* @author Fernando Gonz?lez Cort?s
|
12 |
*/
|
13 |
public abstract class NumericValue extends AbstractValue implements Serializable { |
14 |
/**
|
15 |
* DOCUMENT ME!
|
16 |
*
|
17 |
* @return DOCUMENT ME!
|
18 |
*/
|
19 |
public abstract byte byteValue(); |
20 |
|
21 |
/**
|
22 |
* DOCUMENT ME!
|
23 |
*
|
24 |
* @return DOCUMENT ME!
|
25 |
*/
|
26 |
public abstract short shortValue(); |
27 |
|
28 |
/**
|
29 |
* DOCUMENT ME!
|
30 |
*
|
31 |
* @return DOCUMENT ME!
|
32 |
*/
|
33 |
public abstract int intValue(); |
34 |
|
35 |
/**
|
36 |
* DOCUMENT ME!
|
37 |
*
|
38 |
* @return DOCUMENT ME!
|
39 |
*/
|
40 |
public abstract long longValue(); |
41 |
|
42 |
/**
|
43 |
* DOCUMENT ME!
|
44 |
*
|
45 |
* @return DOCUMENT ME!
|
46 |
*/
|
47 |
public abstract float floatValue(); |
48 |
|
49 |
/**
|
50 |
* DOCUMENT ME!
|
51 |
*
|
52 |
* @return DOCUMENT ME!
|
53 |
*/
|
54 |
public abstract double doubleValue(); |
55 |
|
56 |
/**
|
57 |
* DOCUMENT ME!
|
58 |
*
|
59 |
* @return DOCUMENT ME!
|
60 |
*/
|
61 |
public abstract int getType(); |
62 |
|
63 |
/**
|
64 |
* DOCUMENT ME!
|
65 |
*
|
66 |
* @param value DOCUMENT ME!
|
67 |
*
|
68 |
* @return DOCUMENT ME!
|
69 |
*
|
70 |
* @throws IncompatibleTypesException DOCUMENT ME!
|
71 |
*/
|
72 |
public Value producto(Value value) throws IncompatibleTypesException { |
73 |
if (!(value instanceof NumericValue)) { |
74 |
throw new IncompatibleTypesException(); |
75 |
} |
76 |
|
77 |
return ValueFactory.producto(this, (NumericValue) value); |
78 |
} |
79 |
|
80 |
/**
|
81 |
* DOCUMENT ME!
|
82 |
*
|
83 |
* @param value DOCUMENT ME!
|
84 |
*
|
85 |
* @return DOCUMENT ME!
|
86 |
*
|
87 |
* @throws IncompatibleTypesException DOCUMENT ME!
|
88 |
*/
|
89 |
public Value suma(Value value) throws IncompatibleTypesException { |
90 |
if (!(value instanceof NumericValue)) { |
91 |
throw new IncompatibleTypesException(); |
92 |
} |
93 |
|
94 |
return ValueFactory.suma(this, (NumericValue) value); |
95 |
} |
96 |
|
97 |
/**
|
98 |
* DOCUMENT ME!
|
99 |
*
|
100 |
* @return DOCUMENT ME!
|
101 |
*
|
102 |
* @throws IncompatibleTypesException DOCUMENT ME!
|
103 |
*/
|
104 |
public Value inversa() throws IncompatibleTypesException { |
105 |
return ValueFactory.inversa(this); |
106 |
} |
107 |
|
108 |
/**
|
109 |
* DOCUMENT ME!
|
110 |
*
|
111 |
* @param value DOCUMENT ME!
|
112 |
*
|
113 |
* @return DOCUMENT ME!
|
114 |
*
|
115 |
* @throws IncompatibleTypesException DOCUMENT ME!
|
116 |
*/
|
117 |
public Value equals(Value value) throws IncompatibleTypesException { |
118 |
if (!(value instanceof NumericValue)) { |
119 |
throw new IncompatibleTypesException(); |
120 |
} |
121 |
|
122 |
return ValueFactory.createValue(this.doubleValue() == ((NumericValue) value).doubleValue()); |
123 |
} |
124 |
|
125 |
/**
|
126 |
* DOCUMENT ME!
|
127 |
*
|
128 |
* @param value DOCUMENT ME!
|
129 |
*
|
130 |
* @return DOCUMENT ME!
|
131 |
*
|
132 |
* @throws IncompatibleTypesException DOCUMENT ME!
|
133 |
*/
|
134 |
public Value greater(Value value) throws IncompatibleTypesException { |
135 |
if (!(value instanceof NumericValue)) { |
136 |
throw new IncompatibleTypesException(); |
137 |
} |
138 |
|
139 |
return ValueFactory.createValue(this.doubleValue() > ((NumericValue) value).doubleValue()); |
140 |
} |
141 |
|
142 |
/**
|
143 |
* DOCUMENT ME!
|
144 |
*
|
145 |
* @param value DOCUMENT ME!
|
146 |
*
|
147 |
* @return DOCUMENT ME!
|
148 |
*
|
149 |
* @throws IncompatibleTypesException DOCUMENT ME!
|
150 |
*/
|
151 |
public Value greaterEqual(Value value) throws IncompatibleTypesException { |
152 |
if (!(value instanceof NumericValue)) { |
153 |
throw new IncompatibleTypesException(); |
154 |
} |
155 |
|
156 |
return ValueFactory.createValue(this.doubleValue() >= ((NumericValue) value).doubleValue()); |
157 |
} |
158 |
|
159 |
/**
|
160 |
* DOCUMENT ME!
|
161 |
*
|
162 |
* @param value DOCUMENT ME!
|
163 |
*
|
164 |
* @return DOCUMENT ME!
|
165 |
*
|
166 |
* @throws IncompatibleTypesException DOCUMENT ME!
|
167 |
*/
|
168 |
public Value less(Value value) throws IncompatibleTypesException { |
169 |
if (!(value instanceof NumericValue)) { |
170 |
throw new IncompatibleTypesException(); |
171 |
} |
172 |
|
173 |
return ValueFactory.createValue(this.doubleValue() < ((NumericValue) value).doubleValue()); |
174 |
} |
175 |
|
176 |
/**
|
177 |
* DOCUMENT ME!
|
178 |
*
|
179 |
* @param value DOCUMENT ME!
|
180 |
*
|
181 |
* @return DOCUMENT ME!
|
182 |
*
|
183 |
* @throws IncompatibleTypesException DOCUMENT ME!
|
184 |
*/
|
185 |
public Value lessEqual(Value value) throws IncompatibleTypesException { |
186 |
if (!(value instanceof NumericValue)) { |
187 |
throw new IncompatibleTypesException(); |
188 |
} |
189 |
|
190 |
return ValueFactory.createValue(this.doubleValue() <= ((NumericValue) value).doubleValue()); |
191 |
} |
192 |
|
193 |
/**
|
194 |
* DOCUMENT ME!
|
195 |
*
|
196 |
* @param value DOCUMENT ME!
|
197 |
*
|
198 |
* @return DOCUMENT ME!
|
199 |
*
|
200 |
* @throws IncompatibleTypesException DOCUMENT ME!
|
201 |
*/
|
202 |
public Value notEquals(Value value) throws IncompatibleTypesException { |
203 |
if (!(value instanceof NumericValue)) { |
204 |
throw new IncompatibleTypesException(); |
205 |
} |
206 |
|
207 |
return ValueFactory.createValue(this.doubleValue() != ((NumericValue) value).doubleValue()); |
208 |
} |
209 |
|
210 |
/**
|
211 |
* @see com.hardcode.gdbms.engine.values.Value#doHashCode()
|
212 |
*/
|
213 |
public int doHashCode() { |
214 |
return intValue();
|
215 |
} |
216 |
} |