svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.expressionevaluator / org.gvsig.expressionevaluator.lib / org.gvsig.expressionevaluator.lib.impl / src / main / java / org / gvsig / expressionevaluator / impl / DefaultExpressionBuilder.java @ 44198
History | View | Annotate | Download (48.1 KB)
1 | 44006 | jjdelcerro | package org.gvsig.expressionevaluator.impl; |
---|---|---|---|
2 | 43020 | jjdelcerro | |
3 | import java.text.MessageFormat; |
||
4 | import java.util.ArrayList; |
||
5 | import java.util.Collections; |
||
6 | import java.util.HashSet; |
||
7 | import java.util.List; |
||
8 | import java.util.Objects; |
||
9 | import java.util.Set; |
||
10 | import org.apache.commons.lang3.StringUtils; |
||
11 | import org.cresques.cts.IProjection; |
||
12 | 44198 | jjdelcerro | import org.gvsig.expressionevaluator.Code; |
13 | 43020 | jjdelcerro | import org.gvsig.fmap.geom.Geometry; |
14 | 43034 | jjdelcerro | import org.gvsig.fmap.geom.primitive.Envelope; |
15 | 43020 | jjdelcerro | |
16 | 44006 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionBuilder; |
17 | 44198 | jjdelcerro | import static org.gvsig.expressionevaluator.ExpressionBuilder.EMPTY_FORMATTER; |
18 | import org.gvsig.expressionevaluator.ExpressionUtils; |
||
19 | import org.gvsig.expressionevaluator.Formatter; |
||
20 | import org.gvsig.fmap.geom.GeometryUtils; |
||
21 | 43093 | jjdelcerro | |
22 | 44198 | jjdelcerro | @SuppressWarnings({"UseSpecificCatch" ,"OverridableMethodCallInConstructor"}) |
23 | 44006 | jjdelcerro | public class DefaultExpressionBuilder implements ExpressionBuilder { |
24 | 44198 | jjdelcerro | |
25 | private static final String FORMAT_QUOTE_FOR_STRINGS = "'"; |
||
26 | private static final String FORMAT_QUOTE_FOR_IDENTIFIERS = "\""; |
||
27 | 44006 | jjdelcerro | |
28 | 44198 | jjdelcerro | private static final String FORMAT_TRUE = "TRUE"; |
29 | private static final String FORMAT_FALSE = "FALSE"; |
||
30 | 43020 | jjdelcerro | |
31 | 44198 | jjdelcerro | private static final String FORMAT_GROUP = "( {0} )"; |
32 | 43093 | jjdelcerro | |
33 | 44198 | jjdelcerro | private static final String FORMAT_ST_SRID = "ST_SRID({0})"; |
34 | private static final String FORMAT_ST_ASTEXT = "ST_AsText({0})"; |
||
35 | private static final String FORMAT_ST_ASBINARY = "ST_AsBinary({0})"; |
||
36 | private static final String FORMAT_ST_ASEWKB = "ST_AsEWKB({0})"; |
||
37 | private static final String FORMAT_ST_CONTAINS = "ST_Contains(({0}), ({1}))"; |
||
38 | private static final String FORMAT_ST_CROSSES = "ST_Crosses(({0}), ({1}))"; |
||
39 | private static final String FORMAT_ST_DISJOINT = "ST_Disjoint(({0}), ({1}))"; |
||
40 | private static final String FORMAT_ST_EQUALS = "ST_Equals(({0}), ({1}))"; |
||
41 | private static final String FORMAT_ST_ISCLOSED = "ST_IsClosed({0})"; |
||
42 | private static final String FORMAT_ST_OVERLAPS = "ST_Overlaps(({0}), ({1}))"; |
||
43 | private static final String FORMAT_ST_TOUCHES = "ST_Touches(({0}), ({1}))"; |
||
44 | private static final String FORMAT_ST_WITHIN = "ST_Within(({0}), ({1}))"; |
||
45 | private static final String FORMAT_ST_ENVELOPE = "ST_Envelope({0})"; |
||
46 | private static final String FORMAT_ST_INTERSECTS = "ST_Intersects(({0}), ({1}))"; |
||
47 | private static final String FORMAT_ST_GEOMFROMTEXT = "ST_GeomFromText(({0}), ({1}))"; |
||
48 | private static final String FORMAT_ST_GEOMFROMWKB = "ST_GeomFromWKB(({0}), ({1}))"; |
||
49 | private static final String FORMAT_ST_GEOMFROMEWKB = "ST_GeomFromEWKB(({0}), ({1}))"; |
||
50 | private static final String FORMAT_ST_SIMPLIFY = "ST_Simplify(({0}), ({1}))"; |
||
51 | 43093 | jjdelcerro | |
52 | 44198 | jjdelcerro | private static final String FORMAT_ISNULL = "( ({0}) IS NULL )"; |
53 | private static final String FORMAT_NOTISNULL = "( ({0}) NOT IS NULL )"; |
||
54 | private static final String FORMAT_OPERATOR_NOT = "( NOT ({0}) )"; |
||
55 | 43093 | jjdelcerro | |
56 | 44198 | jjdelcerro | private static final String FORMAT_OPERATOR_AND = "{0} AND {1}"; |
57 | private static final String FORMAT_OPERATOR_OR = "{0} OR {1}"; |
||
58 | private static final String FORMAT_OPERATOR_EQ = "( ({0}) = ({1}) )"; |
||
59 | private static final String FORMAT_OPERATOR_NE = "( ({0}) <> ({1}) )"; |
||
60 | private static final String FORMAT_OPERATOR_GT = "( ({0}) > ({1}) )"; |
||
61 | private static final String FORMAT_OPERATOR_GE = "( ({0}) >= ({1}) )"; |
||
62 | private static final String FORMAT_OPERATOR_LT = "( ({0}) < ({1}) )"; |
||
63 | private static final String FORMAT_OPERATOR_LE = "( ({0}) <= ({1}) )"; |
||
64 | private static final String FORMAT_OPERATOR_LIKE = "( ({0}) LIKE ({1}) )"; |
||
65 | private static final String FORMAT_OPERATOR_ILIKE = "( ({0}) ILIKE ({1}) )"; |
||
66 | private static final String FORMAT_OPERATOR_ADD = "{0} + {1}"; |
||
67 | private static final String FORMAT_OPERATOR_SUBST = "{0} - {1}"; |
||
68 | private static final String FORMAT_OPERATOR_MULT = "{0} * {1}"; |
||
69 | private static final String FORMAT_OPERATOR_DIV = "{0} / {1}"; |
||
70 | private static final String FORMAT_OPERATOR_CONCAT = "{0} || {1}"; |
||
71 | 43093 | jjdelcerro | |
72 | 43020 | jjdelcerro | public class GroupBase extends AbstractValue implements Group { |
73 | 43093 | jjdelcerro | |
74 | 43020 | jjdelcerro | protected Value value;
|
75 | 43093 | jjdelcerro | |
76 | 43020 | jjdelcerro | public GroupBase(Value value) {
|
77 | this.value = value;
|
||
78 | } |
||
79 | |||
80 | @Override
|
||
81 | 44198 | jjdelcerro | public Value value() {
|
82 | 43020 | jjdelcerro | return value;
|
83 | } |
||
84 | |||
85 | @Override
|
||
86 | public void accept(Visitor visitor, VisitorFilter filter) { |
||
87 | 43093 | jjdelcerro | super.accept(visitor, filter);
|
88 | this.value.accept(visitor, filter);
|
||
89 | 43020 | jjdelcerro | } |
90 | 43093 | jjdelcerro | |
91 | 43020 | jjdelcerro | @Override
|
92 | public String toString() { |
||
93 | 44198 | jjdelcerro | return this.toString(EMPTY_FORMATTER); |
94 | 43020 | jjdelcerro | } |
95 | 44198 | jjdelcerro | |
96 | @Override
|
||
97 | public String toString(Formatter<Value> formatter) { |
||
98 | if( formatter.canApply(this) ) { |
||
99 | return formatter.format(this); |
||
100 | } |
||
101 | return MessageFormat.format(FORMAT_GROUP, this.value.toString()); |
||
102 | } |
||
103 | 43020 | jjdelcerro | } |
104 | |||
105 | public class VariableBase extends AbstractValue implements Variable { |
||
106 | 43093 | jjdelcerro | |
107 | 43020 | jjdelcerro | protected String name; |
108 | 43093 | jjdelcerro | |
109 | 43020 | jjdelcerro | public VariableBase(String name) { |
110 | this.name = name;
|
||
111 | } |
||
112 | 43093 | jjdelcerro | |
113 | 43020 | jjdelcerro | @Override
|
114 | 44198 | jjdelcerro | public String name() { |
115 | 43020 | jjdelcerro | return this.name; |
116 | } |
||
117 | |||
118 | @Override
|
||
119 | public String toString() { |
||
120 | 44198 | jjdelcerro | return this.toString(EMPTY_FORMATTER); |
121 | } |
||
122 | |||
123 | @Override
|
||
124 | public String toString(Formatter<Value> formatter) { |
||
125 | if( formatter.canApply(this) ) { |
||
126 | return formatter.format(this); |
||
127 | } |
||
128 | 43020 | jjdelcerro | return identifier(this.name); |
129 | } |
||
130 | |||
131 | @Override
|
||
132 | public int compareTo(Variable o) { |
||
133 | 44198 | jjdelcerro | return this.name.compareTo(o.name()); |
134 | 43020 | jjdelcerro | } |
135 | |||
136 | @Override
|
||
137 | public boolean equals(Object obj) { |
||
138 | 43093 | jjdelcerro | if (!(obj instanceof Variable)) { |
139 | 43020 | jjdelcerro | return false; |
140 | } |
||
141 | 44198 | jjdelcerro | return this.name.equals(((Variable) obj).name()); |
142 | 43020 | jjdelcerro | } |
143 | |||
144 | @Override
|
||
145 | public int hashCode() { |
||
146 | int hash = 7; |
||
147 | hash = 37 * hash + Objects.hashCode(this.name); |
||
148 | return hash;
|
||
149 | } |
||
150 | } |
||
151 | |||
152 | public class ParameterBase extends AbstractValue implements Parameter { |
||
153 | 43093 | jjdelcerro | |
154 | protected String name; |
||
155 | 43020 | jjdelcerro | protected Object value; |
156 | protected ParameterType type;
|
||
157 | protected Value srs;
|
||
158 | 43093 | jjdelcerro | |
159 | 44198 | jjdelcerro | /*
|
160 | Para un parametre de tipo Geometria, el srs sera siempre un Constant
|
||
161 | excepto cuando se le asigne una geometria contante al parametro y esta
|
||
162 | tenga un SRS asignado. En este caso, tanto la geometria como el SRS
|
||
163 | se trataran como parametros.
|
||
164 | |||
165 | Si se quiere que el SRS sea un Parameter, se construira como tal y se
|
||
166 | asignara a traves del metodo srs(Value srs).
|
||
167 | */
|
||
168 | 43093 | jjdelcerro | public ParameterBase() {
|
169 | this.type = ParameterType.Constant;
|
||
170 | this.name = null; |
||
171 | this.value = null; |
||
172 | 43020 | jjdelcerro | } |
173 | |||
174 | @Override
|
||
175 | public void accept(Visitor visitor, VisitorFilter filter) { |
||
176 | super.accept(visitor, filter);
|
||
177 | 43093 | jjdelcerro | if (this.srs != null) { |
178 | 43020 | jjdelcerro | this.srs.accept(visitor, filter);
|
179 | } |
||
180 | } |
||
181 | 43093 | jjdelcerro | |
182 | 43020 | jjdelcerro | @Override
|
183 | 43093 | jjdelcerro | public Parameter as_geometry_variable() {
|
184 | 43020 | jjdelcerro | this.type = ParameterType.Geometry;
|
185 | 43093 | jjdelcerro | if (this.value == null && this.name != null) { |
186 | this.value = this.name; |
||
187 | } |
||
188 | 43020 | jjdelcerro | return this; |
189 | } |
||
190 | 43093 | jjdelcerro | |
191 | 43020 | jjdelcerro | @Override
|
192 | public Parameter as_constant() {
|
||
193 | this.type = ParameterType.Constant;
|
||
194 | 43093 | jjdelcerro | if (this.value == null && this.name != null) { |
195 | this.value = this.name; |
||
196 | } |
||
197 | 43020 | jjdelcerro | return this; |
198 | } |
||
199 | 43093 | jjdelcerro | |
200 | 43020 | jjdelcerro | @Override
|
201 | public Parameter as_variable() {
|
||
202 | this.type = ParameterType.Variable;
|
||
203 | 43093 | jjdelcerro | if (this.value != null && this.name == null) { |
204 | this.name = (String) this.value; |
||
205 | } |
||
206 | 43020 | jjdelcerro | return this; |
207 | } |
||
208 | 43093 | jjdelcerro | |
209 | 43020 | jjdelcerro | @Override
|
210 | public Parameter srs(Value srs) {
|
||
211 | this.srs = srs;
|
||
212 | 43093 | jjdelcerro | if( this.type == ParameterType.Variable ) { |
213 | this.type = ParameterType.Geometry;
|
||
214 | } |
||
215 | 43020 | jjdelcerro | return this; |
216 | } |
||
217 | |||
218 | @Override
|
||
219 | public Parameter srs(IProjection srs) {
|
||
220 | 44198 | jjdelcerro | this.srs = constant(srs_id(srs));
|
221 | 43093 | jjdelcerro | if( this.type == ParameterType.Variable ) { |
222 | this.type = ParameterType.Geometry;
|
||
223 | } |
||
224 | 43020 | jjdelcerro | return this; |
225 | } |
||
226 | 43093 | jjdelcerro | |
227 | 43020 | jjdelcerro | @Override
|
228 | 44198 | jjdelcerro | public String name() { |
229 | 43093 | jjdelcerro | switch (this.type) { |
230 | 43020 | jjdelcerro | case Variable:
|
231 | case Geometry:
|
||
232 | 43093 | jjdelcerro | return this.name; |
233 | 43020 | jjdelcerro | case Constant:
|
234 | 43093 | jjdelcerro | if (this.value == null) { |
235 | return null; |
||
236 | } |
||
237 | return this.value.toString(); |
||
238 | 43020 | jjdelcerro | default:
|
239 | 43093 | jjdelcerro | if (this.name != null) { |
240 | return this.name; |
||
241 | } |
||
242 | if (this.value != null) { |
||
243 | return this.value.toString(); |
||
244 | } |
||
245 | 43020 | jjdelcerro | return null; |
246 | } |
||
247 | } |
||
248 | |||
249 | @Override
|
||
250 | public boolean is_constant() { |
||
251 | return this.type == ParameterType.Constant; |
||
252 | } |
||
253 | |||
254 | @Override
|
||
255 | public boolean is_geometry_variable() { |
||
256 | return this.type == ParameterType.Geometry; |
||
257 | } |
||
258 | |||
259 | @Override
|
||
260 | public boolean is_variable() { |
||
261 | return this.type == ParameterType.Variable; |
||
262 | } |
||
263 | |||
264 | @Override
|
||
265 | 43093 | jjdelcerro | public Parameter value(Object value) { |
266 | 44198 | jjdelcerro | if( value instanceof Geometry ) { |
267 | if( this.srs == null ) { |
||
268 | IProjection proj = ((Geometry)value).getProjection(); |
||
269 | this.srs(parameter().value(proj));
|
||
270 | } |
||
271 | } |
||
272 | 43093 | jjdelcerro | this.value = value;
|
273 | return this; |
||
274 | } |
||
275 | |||
276 | @Override
|
||
277 | public Parameter name(String name) { |
||
278 | this.type = ParameterType.Variable;
|
||
279 | this.name = name;
|
||
280 | return this; |
||
281 | } |
||
282 | |||
283 | @Override
|
||
284 | 44198 | jjdelcerro | public Object value() { |
285 | 43020 | jjdelcerro | try {
|
286 | 43093 | jjdelcerro | switch (this.type) { |
287 | 43020 | jjdelcerro | case Constant:
|
288 | 44198 | jjdelcerro | if( this.value instanceof Geometry ) { |
289 | Geometry geometry = (Geometry) this.value;
|
||
290 | switch (geometry_support_type()) {
|
||
291 | 43020 | jjdelcerro | case EWKB:
|
292 | 44198 | jjdelcerro | return GeometryUtils.toEWKB(geometry);
|
293 | 43020 | jjdelcerro | case WKB:
|
294 | 44198 | jjdelcerro | return GeometryUtils.toWKB(geometry);
|
295 | 43020 | jjdelcerro | case WKT:
|
296 | default:
|
||
297 | 44198 | jjdelcerro | return GeometryUtils.toWKT(geometry);
|
298 | 43020 | jjdelcerro | } |
299 | 43093 | jjdelcerro | } else if (this.value instanceof IProjection) { |
300 | 44198 | jjdelcerro | return srs_id((IProjection) this.value); |
301 | 43093 | jjdelcerro | } |
302 | 43020 | jjdelcerro | return this.value; |
303 | case Variable:
|
||
304 | case Geometry:
|
||
305 | default:
|
||
306 | 43093 | jjdelcerro | return this.value; |
307 | 43020 | jjdelcerro | } |
308 | 43093 | jjdelcerro | } catch (Exception ex) { |
309 | throw new RuntimeException("Can't get value from parameter.", ex); |
||
310 | 43020 | jjdelcerro | } |
311 | } |
||
312 | |||
313 | @Override
|
||
314 | 44198 | jjdelcerro | public ParameterType type() {
|
315 | 43020 | jjdelcerro | return this.type; |
316 | } |
||
317 | 43093 | jjdelcerro | |
318 | 43020 | jjdelcerro | @Override
|
319 | 44198 | jjdelcerro | public Value srs() {
|
320 | 43020 | jjdelcerro | return this.srs; |
321 | } |
||
322 | 43093 | jjdelcerro | |
323 | 43020 | jjdelcerro | @Override
|
324 | public String toString() { |
||
325 | 44198 | jjdelcerro | return this.toString(EMPTY_FORMATTER); |
326 | } |
||
327 | |||
328 | @Override
|
||
329 | public String toString(Formatter<Value> formatter) { |
||
330 | if( formatter.canApply(this) ) { |
||
331 | return formatter.format(this); |
||
332 | } |
||
333 | 43093 | jjdelcerro | switch (this.type) { |
334 | 43020 | jjdelcerro | case Constant:
|
335 | 44198 | jjdelcerro | if( value instanceof Geometry ) { |
336 | switch (geometry_support_type()) {
|
||
337 | case EWKB:
|
||
338 | return MessageFormat.format( |
||
339 | FORMAT_ST_GEOMFROMEWKB, |
||
340 | "?",
|
||
341 | getSRS(formatter) |
||
342 | ); |
||
343 | case WKB:
|
||
344 | return MessageFormat.format( |
||
345 | FORMAT_ST_GEOMFROMWKB, |
||
346 | "?",
|
||
347 | getSRS(formatter) |
||
348 | ); |
||
349 | case WKT:
|
||
350 | default:
|
||
351 | return MessageFormat.format( |
||
352 | FORMAT_ST_GEOMFROMTEXT, |
||
353 | "?",
|
||
354 | getSRS(formatter) |
||
355 | ); |
||
356 | } |
||
357 | } |
||
358 | 43020 | jjdelcerro | case Variable:
|
359 | default:
|
||
360 | return "?"; |
||
361 | case Geometry:
|
||
362 | 44198 | jjdelcerro | switch (geometry_support_type()) {
|
363 | 43020 | jjdelcerro | case EWKB:
|
364 | return MessageFormat.format( |
||
365 | 44198 | jjdelcerro | FORMAT_ST_GEOMFROMEWKB, |
366 | "?",
|
||
367 | getSRS(formatter) |
||
368 | 43020 | jjdelcerro | ); |
369 | case WKB:
|
||
370 | return MessageFormat.format( |
||
371 | 44198 | jjdelcerro | FORMAT_ST_GEOMFROMWKB, |
372 | "?",
|
||
373 | getSRS(formatter) |
||
374 | 43020 | jjdelcerro | ); |
375 | case WKT:
|
||
376 | default:
|
||
377 | return MessageFormat.format( |
||
378 | 44198 | jjdelcerro | FORMAT_ST_GEOMFROMTEXT, |
379 | "?",
|
||
380 | getSRS(formatter) |
||
381 | 43093 | jjdelcerro | ); |
382 | } |
||
383 | 43020 | jjdelcerro | } |
384 | 43093 | jjdelcerro | } |
385 | 44198 | jjdelcerro | |
386 | private String getSRS(Formatter formatter) { |
||
387 | if( this.srs!=null ) { |
||
388 | return this.srs.toString(formatter); |
||
389 | } |
||
390 | if( this.value instanceof Geometry ) { |
||
391 | IProjection proj = ((Geometry)this.value).getProjection();
|
||
392 | Object s = srs_id(proj);
|
||
393 | if( s == null ) { |
||
394 | throw new IllegalArgumentException("A parameter of type Geometry with an invalid SRS."); |
||
395 | } |
||
396 | return s.toString();
|
||
397 | } |
||
398 | throw new IllegalArgumentException("The parameter of type Geometry need a SRS."); |
||
399 | } |
||
400 | 43020 | jjdelcerro | } |
401 | |||
402 | public class ConstantBase extends AbstractValue implements Constant { |
||
403 | 43093 | jjdelcerro | |
404 | 43020 | jjdelcerro | protected Object value; |
405 | 43093 | jjdelcerro | |
406 | 43020 | jjdelcerro | public ConstantBase(Object value) { |
407 | this.value = value;
|
||
408 | } |
||
409 | 43093 | jjdelcerro | |
410 | 43020 | jjdelcerro | @Override
|
411 | 44198 | jjdelcerro | public Object value() { |
412 | 43020 | jjdelcerro | return this.value; |
413 | } |
||
414 | |||
415 | @Override
|
||
416 | public String toString() { |
||
417 | 44198 | jjdelcerro | return this.toString(EMPTY_FORMATTER); |
418 | } |
||
419 | |||
420 | @Override
|
||
421 | public String toString(Formatter<Value> formatter) { |
||
422 | if( formatter.canApply(this) ) { |
||
423 | return formatter.format(this); |
||
424 | } |
||
425 | if( this.value==null ) { |
||
426 | return "NULL"; |
||
427 | } |
||
428 | if( this.value instanceof byte[] ) { |
||
429 | return "DECODE('"+bytearray_hex((byte[])this.value)+"','hex')"; |
||
430 | } |
||
431 | 43093 | jjdelcerro | if (this.value instanceof String) { |
432 | 43020 | jjdelcerro | return string((String) this.value); |
433 | } |
||
434 | 44198 | jjdelcerro | if( this.value instanceof Geometry ) { |
435 | Geometry geometry = (Geometry) this.value;
|
||
436 | switch (geometry_support_type()) {
|
||
437 | case EWKB:
|
||
438 | return MessageFormat.format( |
||
439 | FORMAT_ST_GEOMFROMEWKB, |
||
440 | "DECODE('"+bytearray_hex(GeometryUtils.toEWKB(geometry))+"','hex')", |
||
441 | String.valueOf(srs_id(geometry.getProjection()))
|
||
442 | ); |
||
443 | case WKB:
|
||
444 | return MessageFormat.format( |
||
445 | FORMAT_ST_GEOMFROMWKB, |
||
446 | "DECODE('"+bytearray_hex(GeometryUtils.toWKB(geometry))+"','hex')", |
||
447 | String.valueOf(srs_id(geometry.getProjection()))
|
||
448 | ); |
||
449 | case WKT:
|
||
450 | default:
|
||
451 | return MessageFormat.format( |
||
452 | FORMAT_ST_GEOMFROMTEXT, |
||
453 | string(GeometryUtils.toWKT(geometry)), |
||
454 | String.valueOf(srs_id(geometry.getProjection()))
|
||
455 | ); |
||
456 | } |
||
457 | } |
||
458 | if( this.value instanceof IProjection ) { |
||
459 | return Objects.toString(srs_id((IProjection)(this.value))); |
||
460 | } |
||
461 | 43093 | jjdelcerro | if (this.value instanceof Boolean) { |
462 | if (((Boolean) this.value)) { |
||
463 | 44198 | jjdelcerro | return FORMAT_TRUE;
|
464 | 43020 | jjdelcerro | } else {
|
465 | 44198 | jjdelcerro | return FORMAT_FALSE;
|
466 | 43020 | jjdelcerro | } |
467 | } |
||
468 | 44198 | jjdelcerro | return Objects.toString(this.value, ""); |
469 | 43020 | jjdelcerro | } |
470 | } |
||
471 | |||
472 | public class CustomBase extends AbstractValue implements Custom { |
||
473 | 43093 | jjdelcerro | |
474 | 43020 | jjdelcerro | protected Object value; |
475 | 43093 | jjdelcerro | |
476 | 43020 | jjdelcerro | // Esto es para permitir declarar parametros y columnas en una seccion
|
477 | // custom.
|
||
478 | protected List<Value> values; |
||
479 | 43093 | jjdelcerro | |
480 | 43020 | jjdelcerro | public CustomBase(Object value) { |
481 | this.value = value;
|
||
482 | } |
||
483 | |||
484 | @Override
|
||
485 | public void accept(Visitor visitor, VisitorFilter filter) { |
||
486 | super.accept(visitor, filter);
|
||
487 | 43093 | jjdelcerro | if (this.values != null) { |
488 | 44006 | jjdelcerro | for (Value theValue : values) {
|
489 | theValue.accept(visitor, filter); |
||
490 | 43020 | jjdelcerro | } |
491 | } |
||
492 | } |
||
493 | 43093 | jjdelcerro | |
494 | 43020 | jjdelcerro | @Override
|
495 | 44198 | jjdelcerro | public Object value() { |
496 | 43020 | jjdelcerro | return this.value; |
497 | } |
||
498 | |||
499 | @Override
|
||
500 | public Custom add(Variable variable) {
|
||
501 | 43093 | jjdelcerro | if (this.values == null) { |
502 | 43020 | jjdelcerro | this.values = new ArrayList<>(); |
503 | } |
||
504 | this.values.add(variable);
|
||
505 | return this; |
||
506 | } |
||
507 | |||
508 | @Override
|
||
509 | public Custom add(Parameter parameter) {
|
||
510 | 43093 | jjdelcerro | if (this.values == null) { |
511 | 43020 | jjdelcerro | this.values = new ArrayList<>(); |
512 | } |
||
513 | this.values.add(parameter);
|
||
514 | return this; |
||
515 | } |
||
516 | |||
517 | @Override
|
||
518 | public String toString() { |
||
519 | 44198 | jjdelcerro | return this.toString(EMPTY_FORMATTER); |
520 | 43020 | jjdelcerro | } |
521 | 44198 | jjdelcerro | |
522 | 43020 | jjdelcerro | @Override
|
523 | 44198 | jjdelcerro | public String toString(Formatter<Value> formatter) { |
524 | if( formatter.canApply(this) ) { |
||
525 | return formatter.format(this); |
||
526 | 43020 | jjdelcerro | } |
527 | 44198 | jjdelcerro | return Objects.toString(this.value, ""); |
528 | 43020 | jjdelcerro | } |
529 | 43093 | jjdelcerro | } |
530 | 43020 | jjdelcerro | |
531 | public class FunctionBase extends AbstractValue implements Function { |
||
532 | |||
533 | protected String name; |
||
534 | protected String format; |
||
535 | protected List<Value> parameters; |
||
536 | 43093 | jjdelcerro | |
537 | 43020 | jjdelcerro | public FunctionBase(String name, String format) { |
538 | this.name = name;
|
||
539 | this.format = format;
|
||
540 | } |
||
541 | 43093 | jjdelcerro | |
542 | 44020 | jjdelcerro | public FunctionBase(String name) { |
543 | this(name,null); |
||
544 | } |
||
545 | |||
546 | 43020 | jjdelcerro | @Override
|
547 | public List<Value> parameters() { |
||
548 | 43093 | jjdelcerro | if (this.parameters == null) { |
549 | 43020 | jjdelcerro | this.parameters = new ArrayList<>(); |
550 | } |
||
551 | return this.parameters; |
||
552 | 43093 | jjdelcerro | } |
553 | 43020 | jjdelcerro | |
554 | @Override
|
||
555 | public Function parameter(Value parameter) {
|
||
556 | this.parameters().add(parameter);
|
||
557 | return this; |
||
558 | } |
||
559 | |||
560 | @Override
|
||
561 | 44198 | jjdelcerro | public String name() { |
562 | 43020 | jjdelcerro | return this.name; |
563 | } |
||
564 | |||
565 | @Override
|
||
566 | public void accept(Visitor visitor, VisitorFilter filter) { |
||
567 | 43093 | jjdelcerro | super.accept(visitor, filter);
|
568 | 43020 | jjdelcerro | for (Value value : this.parameters) { |
569 | 43093 | jjdelcerro | value.accept(visitor, filter); |
570 | 43020 | jjdelcerro | } |
571 | } |
||
572 | |||
573 | @Override
|
||
574 | public String toString() { |
||
575 | 44198 | jjdelcerro | return this.toString(EMPTY_FORMATTER); |
576 | } |
||
577 | |||
578 | @Override
|
||
579 | public String toString(Formatter<Value> formatter) { |
||
580 | if( formatter.canApply(this) ) { |
||
581 | return formatter.format(this); |
||
582 | } |
||
583 | 44020 | jjdelcerro | if( this.format==null ) { |
584 | StringBuilder builder = new StringBuilder(); |
||
585 | builder.append(name); |
||
586 | builder.append("(");
|
||
587 | if (this.parameters != null && !this.parameters.isEmpty()) { |
||
588 | boolean first = true; |
||
589 | for (Value value : this.parameters) { |
||
590 | if( first ) {
|
||
591 | first=false;
|
||
592 | 44198 | jjdelcerro | builder.append(value.toString(formatter)); |
593 | 44020 | jjdelcerro | } else {
|
594 | builder.append(", ");
|
||
595 | 44198 | jjdelcerro | builder.append(value.toString(formatter)); |
596 | 44020 | jjdelcerro | } |
597 | } |
||
598 | } |
||
599 | builder.append(")");
|
||
600 | return builder.toString();
|
||
601 | } |
||
602 | 43093 | jjdelcerro | if (this.parameters != null && !this.parameters.isEmpty()) { |
603 | 43020 | jjdelcerro | List<String> values = new ArrayList<>(); |
604 | for (Value value : this.parameters) { |
||
605 | 44198 | jjdelcerro | values.add(value.toString(formatter)); |
606 | 43020 | jjdelcerro | } |
607 | return MessageFormat.format(format, values.toArray()); |
||
608 | } else {
|
||
609 | return this.format; |
||
610 | } |
||
611 | } |
||
612 | } |
||
613 | 43093 | jjdelcerro | |
614 | 44198 | jjdelcerro | public class MethodBase extends FunctionBase implements Method { |
615 | |||
616 | private final Value instance; |
||
617 | |||
618 | public MethodBase(Value instance, String name) { |
||
619 | super(name);
|
||
620 | this.instance = instance;
|
||
621 | } |
||
622 | |||
623 | @Override
|
||
624 | public Value instance() {
|
||
625 | return this.instance; |
||
626 | } |
||
627 | |||
628 | @Override
|
||
629 | public void accept(Visitor visitor, VisitorFilter filter) { |
||
630 | this.instance.accept(visitor, filter);
|
||
631 | super.accept(visitor, filter);
|
||
632 | } |
||
633 | |||
634 | @Override
|
||
635 | public String toString(Formatter<Value> formatter) { |
||
636 | if( formatter.canApply(this) ) { |
||
637 | return formatter.format(this); |
||
638 | } |
||
639 | StringBuilder builder = new StringBuilder(); |
||
640 | builder.append(this.instance.toString(formatter));
|
||
641 | builder.append("->");
|
||
642 | builder.append(this.name());
|
||
643 | builder.append(name); |
||
644 | builder.append("(");
|
||
645 | if (this.parameters != null && !this.parameters.isEmpty()) { |
||
646 | boolean first = true; |
||
647 | for (Value value : this.parameters) { |
||
648 | if( first ) {
|
||
649 | first=false;
|
||
650 | builder.append(value.toString(formatter)); |
||
651 | } else {
|
||
652 | builder.append(", ");
|
||
653 | builder.append(value.toString(formatter)); |
||
654 | } |
||
655 | } |
||
656 | } |
||
657 | builder.append(")");
|
||
658 | return builder.toString();
|
||
659 | } |
||
660 | } |
||
661 | |||
662 | 43020 | jjdelcerro | public class BinaryOperatorBase extends AbstractValue implements BinaryOperator { |
663 | |||
664 | protected String name; |
||
665 | protected String format; |
||
666 | protected Value left;
|
||
667 | protected Value right;
|
||
668 | 43093 | jjdelcerro | |
669 | 43020 | jjdelcerro | public BinaryOperatorBase(String name, String format) { |
670 | this.name = name;
|
||
671 | this.format = format;
|
||
672 | } |
||
673 | 43093 | jjdelcerro | |
674 | 43020 | jjdelcerro | @Override
|
675 | 44198 | jjdelcerro | public String name() { |
676 | 43020 | jjdelcerro | return this.name; |
677 | } |
||
678 | |||
679 | @Override
|
||
680 | public void accept(Visitor visitor, VisitorFilter filter) { |
||
681 | 43093 | jjdelcerro | super.accept(visitor, filter);
|
682 | 43020 | jjdelcerro | this.left.accept(visitor, filter);
|
683 | this.right.accept(visitor, filter);
|
||
684 | } |
||
685 | |||
686 | @Override
|
||
687 | 44198 | jjdelcerro | public BinaryOperator left(Value operand) {
|
688 | 43020 | jjdelcerro | this.left = operand;
|
689 | return this; |
||
690 | } |
||
691 | |||
692 | @Override
|
||
693 | 44198 | jjdelcerro | public BinaryOperator right(Value operand) {
|
694 | 43020 | jjdelcerro | this.right = operand;
|
695 | return this; |
||
696 | } |
||
697 | |||
698 | @Override
|
||
699 | 44198 | jjdelcerro | public Value left() {
|
700 | 43020 | jjdelcerro | return this.left; |
701 | } |
||
702 | |||
703 | @Override
|
||
704 | 44198 | jjdelcerro | public Value right() {
|
705 | 43020 | jjdelcerro | return this.right; |
706 | } |
||
707 | 43093 | jjdelcerro | |
708 | 43020 | jjdelcerro | @Override
|
709 | public String toString() { |
||
710 | 44198 | jjdelcerro | return this.toString(EMPTY_FORMATTER); |
711 | 43020 | jjdelcerro | } |
712 | 44198 | jjdelcerro | |
713 | @Override
|
||
714 | public String toString(Formatter<Value> formatter) { |
||
715 | if( formatter.canApply(this) ) { |
||
716 | return formatter.format(this); |
||
717 | } |
||
718 | if( this.format==null ) { |
||
719 | StringBuilder builder = new StringBuilder(); |
||
720 | builder.append("(");
|
||
721 | builder.append(this.left.toString(formatter));
|
||
722 | builder.append(" ");
|
||
723 | builder.append(this.name);
|
||
724 | builder.append(" ");
|
||
725 | builder.append(this.right.toString(formatter));
|
||
726 | builder.append(")");
|
||
727 | return builder.toString();
|
||
728 | } else {
|
||
729 | return MessageFormat.format( |
||
730 | format, |
||
731 | this.left.toString(formatter),
|
||
732 | this.right.toString(formatter)
|
||
733 | ); |
||
734 | } |
||
735 | } |
||
736 | 43020 | jjdelcerro | } |
737 | |||
738 | 44198 | jjdelcerro | protected GeometrySupportType geometrySupportType;
|
739 | 43020 | jjdelcerro | protected Value value;
|
740 | 43093 | jjdelcerro | |
741 | 44006 | jjdelcerro | public DefaultExpressionBuilder() {
|
742 | 44198 | jjdelcerro | this.geometrySupportType = GeometrySupportType.WKB;
|
743 | 43020 | jjdelcerro | } |
744 | |||
745 | @Override
|
||
746 | public ExpressionBuilder createExpressionBuilder() {
|
||
747 | 44006 | jjdelcerro | return new DefaultExpressionBuilder(); |
748 | 43020 | jjdelcerro | } |
749 | 43093 | jjdelcerro | |
750 | 43020 | jjdelcerro | @Override
|
751 | 44198 | jjdelcerro | public GeometrySupportType geometry_support_type() {
|
752 | return this.geometrySupportType; |
||
753 | 43093 | jjdelcerro | } |
754 | |||
755 | 43020 | jjdelcerro | @Override
|
756 | 44198 | jjdelcerro | public ExpressionBuilder geometry_support_type(GeometrySupportType geometrySupportType) {
|
757 | this.geometrySupportType = geometrySupportType;
|
||
758 | return this; |
||
759 | } |
||
760 | |||
761 | @Override
|
||
762 | public Value value() {
|
||
763 | 43020 | jjdelcerro | return this.value; |
764 | } |
||
765 | 43093 | jjdelcerro | |
766 | 43020 | jjdelcerro | @Override
|
767 | 44198 | jjdelcerro | public ExpressionBuilder value(Value value) {
|
768 | 43020 | jjdelcerro | this.value = value;
|
769 | return this; |
||
770 | } |
||
771 | |||
772 | @Override
|
||
773 | public String toString() { |
||
774 | return this.value.toString(); |
||
775 | } |
||
776 | |||
777 | @Override
|
||
778 | 44198 | jjdelcerro | public String toString(Formatter<Value> formatter) { |
779 | return this.value.toString(formatter); |
||
780 | } |
||
781 | |||
782 | @Override
|
||
783 | public Value toValue(String expression) { |
||
784 | try {
|
||
785 | Code code = ExpressionUtils.compile(expression); |
||
786 | return code.toValue(this); |
||
787 | } catch(Throwable ex) { |
||
788 | return custom(expression);
|
||
789 | } |
||
790 | } |
||
791 | |||
792 | @Override
|
||
793 | 43020 | jjdelcerro | public void accept(Visitor visitor, VisitorFilter filter) { |
794 | 43093 | jjdelcerro | if( this.value == null) { |
795 | return;
|
||
796 | } |
||
797 | 43020 | jjdelcerro | this.value.accept(visitor, filter);
|
798 | } |
||
799 | 43093 | jjdelcerro | |
800 | 43020 | jjdelcerro | @Override
|
801 | 44198 | jjdelcerro | public String quote_for_identifiers() { |
802 | return FORMAT_QUOTE_FOR_IDENTIFIERS;
|
||
803 | 43020 | jjdelcerro | } |
804 | 44198 | jjdelcerro | |
805 | 43020 | jjdelcerro | @Override
|
806 | 44198 | jjdelcerro | public String quote_for_strings() { |
807 | return FORMAT_QUOTE_FOR_STRINGS;
|
||
808 | 43020 | jjdelcerro | } |
809 | 44198 | jjdelcerro | |
810 | 43020 | jjdelcerro | @Override
|
811 | public String string(String s) { |
||
812 | 44198 | jjdelcerro | String quote = this.quote_for_strings(); |
813 | 43034 | jjdelcerro | // No se porque no esta disponible wrapIfMissing
|
814 | // return StringUtils.wrapIfMissing(s,quote);
|
||
815 | 43020 | jjdelcerro | if (s.startsWith(quote)) {
|
816 | return s;
|
||
817 | } |
||
818 | 44198 | jjdelcerro | return quote + StringUtils.replace(s,quote,quote+quote) + quote;
|
819 | 43020 | jjdelcerro | } |
820 | 43093 | jjdelcerro | |
821 | 43020 | jjdelcerro | @Override
|
822 | public String identifier(String id) { |
||
823 | 44198 | jjdelcerro | String quote = this.quote_for_identifiers(); |
824 | 43034 | jjdelcerro | // No se porque no esta disponible wrapIfMissing
|
825 | // return StringUtils.wrapIfMissing(id,quote);
|
||
826 | 43020 | jjdelcerro | if (id.startsWith(quote)) {
|
827 | return id;
|
||
828 | } |
||
829 | return quote + id + quote;
|
||
830 | } |
||
831 | |||
832 | @Override
|
||
833 | 44006 | jjdelcerro | public String bytearray_hex(byte[] data) { |
834 | 43020 | jjdelcerro | StringBuilder builder = new StringBuilder(); |
835 | for (byte abyte : data) { |
||
836 | int v = abyte & 0xff; |
||
837 | builder.append(String.format("%02x", v)); |
||
838 | } |
||
839 | return builder.toString();
|
||
840 | } |
||
841 | |||
842 | 44006 | jjdelcerro | @Override
|
843 | public String bytearray_0x(byte[] data) { |
||
844 | 43355 | jjdelcerro | return "0x" + bytearray_hex(data); |
845 | } |
||
846 | |||
847 | 44006 | jjdelcerro | @Override
|
848 | public String bytearray_x(byte[] data) { |
||
849 | 43355 | jjdelcerro | return "x'" + bytearray_hex(data) + "'"; |
850 | 43302 | jjdelcerro | } |
851 | |||
852 | 43020 | jjdelcerro | @Override
|
853 | 44198 | jjdelcerro | public Object srs_id(IProjection projection) { |
854 | 44006 | jjdelcerro | if( projection==null ) { |
855 | return 0; |
||
856 | } |
||
857 | return ProjectionUtils.getCode(projection);
|
||
858 | 43020 | jjdelcerro | } |
859 | 43093 | jjdelcerro | |
860 | 43020 | jjdelcerro | @Override
|
861 | 44198 | jjdelcerro | public Constant bytearray(byte[] data) { |
862 | return new ConstantBase(data); |
||
863 | } |
||
864 | |||
865 | @Override
|
||
866 | 43020 | jjdelcerro | public Constant srs(IProjection projection) {
|
867 | 44198 | jjdelcerro | return constant(projection);
|
868 | 43020 | jjdelcerro | } |
869 | |||
870 | @Override
|
||
871 | public Variable variable(String name) { |
||
872 | return new VariableBase(name); |
||
873 | } |
||
874 | |||
875 | @Override
|
||
876 | public Variable column(String name) { |
||
877 | return new VariableBase(name); |
||
878 | } |
||
879 | 43739 | jjdelcerro | |
880 | 43020 | jjdelcerro | @Override
|
881 | 43093 | jjdelcerro | public Parameter parameter(String name) { |
882 | 44198 | jjdelcerro | List<Parameter> parameters = this.parameters(); |
883 | for (Parameter parameter : parameters) {
|
||
884 | if( StringUtils.equalsIgnoreCase(name, parameter.name()) ) {
|
||
885 | return parameter;
|
||
886 | } |
||
887 | 43093 | jjdelcerro | } |
888 | 44198 | jjdelcerro | Parameter parameter = this.parameter();
|
889 | 43093 | jjdelcerro | parameter.name(name); |
890 | return parameter;
|
||
891 | 43020 | jjdelcerro | } |
892 | 43093 | jjdelcerro | |
893 | 43687 | jjdelcerro | @Override
|
894 | 43093 | jjdelcerro | public Parameter parameter() {
|
895 | return new ParameterBase(); |
||
896 | } |
||
897 | |||
898 | 43020 | jjdelcerro | @Override
|
899 | public Constant constant(Object value) { |
||
900 | return new ConstantBase(value); |
||
901 | } |
||
902 | |||
903 | @Override
|
||
904 | public Group group(Value value) { |
||
905 | return new GroupBase(value); |
||
906 | } |
||
907 | 43093 | jjdelcerro | |
908 | 43020 | jjdelcerro | @Override
|
909 | 44198 | jjdelcerro | public Constant geometry(Geometry geom, IProjection projection) {
|
910 | geom.setProjection(projection); |
||
911 | return new ConstantBase(geom); |
||
912 | 43020 | jjdelcerro | } |
913 | |||
914 | @Override
|
||
915 | 44198 | jjdelcerro | public Constant geometry(Geometry geom) {
|
916 | 44006 | jjdelcerro | if( geom.getProjection()==null ) { |
917 | throw new IllegalArgumentException("The geometry does not have an associated projection. Use 'geometry(Geometry, IProjection)'."); |
||
918 | } |
||
919 | 44198 | jjdelcerro | return new ConstantBase(geom); |
920 | 44006 | jjdelcerro | } |
921 | |||
922 | @Override
|
||
923 | 44198 | jjdelcerro | public Constant envelope(Envelope envelope, IProjection projection) {
|
924 | Geometry geom = envelope.getGeometry(); |
||
925 | geom.setProjection(projection); |
||
926 | return new ConstantBase(geom); |
||
927 | 43034 | jjdelcerro | } |
928 | |||
929 | @Override
|
||
930 | 44198 | jjdelcerro | public Constant envelope(Envelope envelope) {
|
931 | 44006 | jjdelcerro | if( envelope.getProjection()==null ) { |
932 | throw new IllegalArgumentException("The envelope does not have an associated projection. Use 'envelope(Geometry, IProjection)'."); |
||
933 | } |
||
934 | 44198 | jjdelcerro | Geometry geom = envelope.getGeometry(); |
935 | return new ConstantBase(geom); |
||
936 | 44006 | jjdelcerro | } |
937 | |||
938 | @Override
|
||
939 | 43020 | jjdelcerro | public Custom custom(Object value) { |
940 | return new CustomBase(value); |
||
941 | } |
||
942 | |||
943 | 44198 | jjdelcerro | @Override
|
944 | public Method method(Value instance, String name, Value... values) { |
||
945 | MethodBase method = new MethodBase(instance, name);
|
||
946 | for (Value theValue : values) {
|
||
947 | method.parameter(theValue); |
||
948 | } |
||
949 | return method;
|
||
950 | } |
||
951 | |||
952 | @Override
|
||
953 | 44020 | jjdelcerro | public Function function(String name, Value... values) { |
954 | FunctionBase func = new FunctionBase(name);
|
||
955 | for (Value theValue : values) {
|
||
956 | func.parameter(theValue); |
||
957 | } |
||
958 | return func;
|
||
959 | } |
||
960 | |||
961 | public Function builtin_function(String name, String format, Value... values) { |
||
962 | 43093 | jjdelcerro | FunctionBase func = new FunctionBase(name, format);
|
963 | 44006 | jjdelcerro | for (Value theValue : values) {
|
964 | func.parameter(theValue); |
||
965 | 43020 | jjdelcerro | } |
966 | return func;
|
||
967 | } |
||
968 | 43093 | jjdelcerro | |
969 | 44198 | jjdelcerro | @Override
|
970 | public BinaryOperator binaryOperator(String name, Value leftOperand, Value rightOperand) { |
||
971 | return binaryOperator(name, null, leftOperand, rightOperand); |
||
972 | } |
||
973 | |||
974 | 43020 | jjdelcerro | public BinaryOperator binaryOperator(String name, String format, Value leftOperand, Value rightOperand) { |
975 | 43093 | jjdelcerro | BinaryOperator operator = new BinaryOperatorBase(name, format);
|
976 | 44198 | jjdelcerro | operator.left(leftOperand); |
977 | operator.right(rightOperand); |
||
978 | 43020 | jjdelcerro | return operator;
|
979 | } |
||
980 | 43093 | jjdelcerro | |
981 | 43020 | jjdelcerro | @Override
|
982 | 44198 | jjdelcerro | public List<Variable> variables() { |
983 | 43020 | jjdelcerro | final Set<Variable> vars = new HashSet<>(); |
984 | this.accept(new Visitor() { |
||
985 | @Override
|
||
986 | public void visit(Visitable value) { |
||
987 | 44198 | jjdelcerro | if( !vars.contains((Variable)value) ) {
|
988 | vars.add((Variable)value); |
||
989 | } |
||
990 | 43020 | jjdelcerro | } |
991 | 43093 | jjdelcerro | }, new ClassVisitorFilter(Variable.class));
|
992 | 43020 | jjdelcerro | List<Variable> lvars = new ArrayList<>(vars); |
993 | Collections.sort(lvars);
|
||
994 | return lvars;
|
||
995 | } |
||
996 | 43093 | jjdelcerro | |
997 | 43020 | jjdelcerro | @Override
|
998 | 44198 | jjdelcerro | public List<Parameter> parameters() { |
999 | final List<Parameter> params = new ArrayList<>(); |
||
1000 | 43020 | jjdelcerro | this.accept(new Visitor() { |
1001 | @Override
|
||
1002 | public void visit(Visitable value) { |
||
1003 | 43093 | jjdelcerro | params.add((Parameter) value); |
1004 | 43020 | jjdelcerro | } |
1005 | 43093 | jjdelcerro | }, new ClassVisitorFilter(Parameter.class));
|
1006 | 43020 | jjdelcerro | return params;
|
1007 | } |
||
1008 | 44198 | jjdelcerro | |
1009 | 43020 | jjdelcerro | @Override
|
1010 | 44198 | jjdelcerro | public List<String> parameters_names() { |
1011 | List<String> params = new ArrayList<>(); |
||
1012 | for (Parameter param : parameters()) {
|
||
1013 | Object theValue = param.value();
|
||
1014 | String s;
|
||
1015 | switch(param.type()) {
|
||
1016 | case Constant:
|
||
1017 | if( theValue==null ) { |
||
1018 | s = "NULL";
|
||
1019 | } else if( theValue instanceof String ) { |
||
1020 | s = "'" + (String)theValue + "'"; |
||
1021 | |||
1022 | } else if( theValue instanceof byte[] ) { |
||
1023 | s = bytearray_0x((byte[]) theValue); |
||
1024 | |||
1025 | } else {
|
||
1026 | s = theValue.toString(); |
||
1027 | } |
||
1028 | break;
|
||
1029 | case Geometry:
|
||
1030 | if( param.name()==null ) { |
||
1031 | s = bytearray_0x((byte[]) theValue); |
||
1032 | } else {
|
||
1033 | s = "\"" + param.name() + "\""; |
||
1034 | } |
||
1035 | break;
|
||
1036 | case Variable:
|
||
1037 | default:
|
||
1038 | s = "\"" + param.name() + "\""; |
||
1039 | } |
||
1040 | // if( !params.contains(s) ) { // Ojo que deben ir todos, incluso duplicados.
|
||
1041 | params.add(s); |
||
1042 | // }
|
||
1043 | } |
||
1044 | // Collections.sort(params); Ojo, no deben ordenarse.
|
||
1045 | return params;
|
||
1046 | 43020 | jjdelcerro | } |
1047 | 44198 | jjdelcerro | |
1048 | @Override
|
||
1049 | public List<String> variables_names() { |
||
1050 | List<String> vars = new ArrayList<>(); |
||
1051 | for (Variable var : this.variables()) { |
||
1052 | vars.add(var.name()); |
||
1053 | } |
||
1054 | Collections.sort(vars);
|
||
1055 | return vars;
|
||
1056 | } |
||
1057 | |||
1058 | @Override
|
||
1059 | public Function as_geometry(Value value) {
|
||
1060 | return builtin_function(FUNCTION_ST_ASBINARY, FORMAT_ST_ASBINARY, value);
|
||
1061 | } |
||
1062 | 43020 | jjdelcerro | |
1063 | @Override
|
||
1064 | public ExpressionBuilder set(Value value) {
|
||
1065 | this.value = value;
|
||
1066 | return this; |
||
1067 | } |
||
1068 | |||
1069 | @Override
|
||
1070 | public ExpressionBuilder and(Value value) {
|
||
1071 | 43093 | jjdelcerro | if (this.value == null) { |
1072 | 43020 | jjdelcerro | return this.set(value); |
1073 | } |
||
1074 | 44198 | jjdelcerro | BinaryOperator operator = binaryOperator(OPERATOR_AND, FORMAT_OPERATOR_AND, this.value, value);
|
1075 | 43020 | jjdelcerro | this.value = operator;
|
1076 | return this; |
||
1077 | } |
||
1078 | |||
1079 | @Override
|
||
1080 | public ExpressionBuilder or(Value value) {
|
||
1081 | 43093 | jjdelcerro | if (this.value == null) { |
1082 | 43020 | jjdelcerro | return this.set(value); |
1083 | } |
||
1084 | 44198 | jjdelcerro | BinaryOperator operator = binaryOperator(OPERATOR_OR, FORMAT_OPERATOR_OR, this.value, value);
|
1085 | 43020 | jjdelcerro | this.value = operator;
|
1086 | return this; |
||
1087 | } |
||
1088 | |||
1089 | @Override
|
||
1090 | public Function ST_Intersects(Value geom1, Value geom2) {
|
||
1091 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_INTERSECTS, FORMAT_ST_INTERSECTS, geom1, geom2);
|
1092 | 43020 | jjdelcerro | } |
1093 | |||
1094 | @Override
|
||
1095 | public Function ST_SRID(Value geom) {
|
||
1096 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_SRID, FORMAT_ST_SRID, geom);
|
1097 | 43020 | jjdelcerro | } |
1098 | |||
1099 | @Override
|
||
1100 | public Function ST_Envelope(Value geom) {
|
||
1101 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_ENVELOPE, FORMAT_ST_ENVELOPE, geom);
|
1102 | 43020 | jjdelcerro | } |
1103 | |||
1104 | @Override
|
||
1105 | public Function ST_AsText(Value geom) {
|
||
1106 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_ASTEXT, FORMAT_ST_ASTEXT, geom);
|
1107 | 43020 | jjdelcerro | } |
1108 | |||
1109 | @Override
|
||
1110 | public Function ST_AsBinary(Value geom) {
|
||
1111 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_ASBINARY, FORMAT_ST_ASBINARY, geom);
|
1112 | 43020 | jjdelcerro | } |
1113 | |||
1114 | @Override
|
||
1115 | public Function ST_AsEWKB(Value geom) {
|
||
1116 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_ASEWKB, FORMAT_ST_ASEWKB, geom);
|
1117 | 43020 | jjdelcerro | } |
1118 | |||
1119 | @Override
|
||
1120 | public Function ST_GeomFromText(Value geom, Value crs) {
|
||
1121 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_GEOMFROMTEXT, FORMAT_ST_GEOMFROMTEXT, geom, crs);
|
1122 | 43020 | jjdelcerro | } |
1123 | |||
1124 | @Override
|
||
1125 | public Function ST_GeomFromWKB(Value geom, Value crs) {
|
||
1126 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_GEOMFROMWKB, FORMAT_ST_GEOMFROMWKB, geom, crs);
|
1127 | 43020 | jjdelcerro | } |
1128 | |||
1129 | @Override
|
||
1130 | public Function ST_GeomFromEWKB(Value geom, Value crs) {
|
||
1131 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_GEOMFROMEWKB, FORMAT_ST_GEOMFROMEWKB, geom, crs);
|
1132 | 43020 | jjdelcerro | } |
1133 | |||
1134 | @Override
|
||
1135 | 43355 | jjdelcerro | public Function ST_Simplify(Value geom, Value tolerance) {
|
1136 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_SIMPLIFY, FORMAT_ST_SIMPLIFY, tolerance);
|
1137 | 43355 | jjdelcerro | } |
1138 | |||
1139 | @Override
|
||
1140 | 43034 | jjdelcerro | public Function ST_Disjoint(Value geom1, Value geom2) {
|
1141 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_DISJOINT, FORMAT_ST_DISJOINT, geom1, geom2);
|
1142 | 43034 | jjdelcerro | } |
1143 | 43093 | jjdelcerro | |
1144 | 43034 | jjdelcerro | @Override
|
1145 | 43020 | jjdelcerro | public Function ST_Contains(Value geom1, Value geom2) {
|
1146 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_CONTAINS, FORMAT_ST_CONTAINS, geom1, geom2);
|
1147 | 43020 | jjdelcerro | } |
1148 | |||
1149 | @Override
|
||
1150 | 43034 | jjdelcerro | public Function ST_Equals(Value geom1, Value geom2) {
|
1151 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_EQUALS, FORMAT_ST_EQUALS, geom1, geom2);
|
1152 | 43034 | jjdelcerro | } |
1153 | |||
1154 | @Override
|
||
1155 | 43020 | jjdelcerro | public Function ST_Crosses(Value geom1, Value geom2) {
|
1156 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_CROSSES, FORMAT_ST_CROSSES, geom1, geom2);
|
1157 | 43020 | jjdelcerro | } |
1158 | |||
1159 | @Override
|
||
1160 | public Function ST_IsClosed(Value geom) {
|
||
1161 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_ISCLOSED, FORMAT_ST_ISCLOSED, geom);
|
1162 | 43020 | jjdelcerro | } |
1163 | |||
1164 | @Override
|
||
1165 | public Function ST_Overlaps(Value geom1, Value geom2) {
|
||
1166 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_OVERLAPS, FORMAT_ST_OVERLAPS, geom1, geom2);
|
1167 | 43020 | jjdelcerro | } |
1168 | |||
1169 | @Override
|
||
1170 | public Function ST_Touches(Value geom1, Value geom2) {
|
||
1171 | 44198 | jjdelcerro | return builtin_function(FUNCTION_ST_TOUCHES, FORMAT_ST_TOUCHES, geom1, geom2);
|
1172 | 43020 | jjdelcerro | } |
1173 | |||
1174 | @Override
|
||
1175 | public Function ST_Within(Value geom1, Value geom2) {
|
||
1176 | 44198 | jjdelcerro | return builtin_function("ST_Within", FORMAT_ST_WITHIN, geom1, geom2); |
1177 | 43020 | jjdelcerro | } |
1178 | |||
1179 | @Override
|
||
1180 | 44198 | jjdelcerro | public Function is_null(Value value) {
|
1181 | return builtin_function("IS NULL", FORMAT_ISNULL, value); |
||
1182 | 43020 | jjdelcerro | } |
1183 | |||
1184 | @Override
|
||
1185 | 44198 | jjdelcerro | public Function not_is_null(Value value) {
|
1186 | return builtin_function("NOT IS NULL", FORMAT_NOTISNULL, value); |
||
1187 | 43020 | jjdelcerro | } |
1188 | |||
1189 | @Override
|
||
1190 | public Function not(Value value) {
|
||
1191 | 44198 | jjdelcerro | return builtin_function(OPERATOR_NOT, FORMAT_OPERATOR_NOT, value);
|
1192 | 43020 | jjdelcerro | } |
1193 | |||
1194 | @Override
|
||
1195 | public BinaryOperator and(Value leftOperand, Value rightOperand) {
|
||
1196 | 44198 | jjdelcerro | return binaryOperator(OPERATOR_AND, FORMAT_OPERATOR_AND, leftOperand, rightOperand);
|
1197 | 43020 | jjdelcerro | } |
1198 | |||
1199 | @Override
|
||
1200 | public BinaryOperator or(Value leftOperand, Value rightOperand) {
|
||
1201 | 44198 | jjdelcerro | return binaryOperator(OPERATOR_OR, FORMAT_OPERATOR_OR, leftOperand, rightOperand);
|
1202 | 43020 | jjdelcerro | } |
1203 | |||
1204 | @Override
|
||
1205 | public BinaryOperator eq(Value leftOperand, Value rightOperand) {
|
||
1206 | 44198 | jjdelcerro | return binaryOperator("=", FORMAT_OPERATOR_EQ, leftOperand, rightOperand); |
1207 | 43020 | jjdelcerro | } |
1208 | 43093 | jjdelcerro | |
1209 | 43020 | jjdelcerro | @Override
|
1210 | public BinaryOperator ne(Value leftOperand, Value rightOperand) {
|
||
1211 | 44198 | jjdelcerro | return binaryOperator("<>", FORMAT_OPERATOR_NE, leftOperand, rightOperand); |
1212 | 43093 | jjdelcerro | } |
1213 | 43020 | jjdelcerro | |
1214 | @Override
|
||
1215 | public BinaryOperator gt(Value op1, Value op2) {
|
||
1216 | 44198 | jjdelcerro | return binaryOperator(">", FORMAT_OPERATOR_GT, op1, op2); |
1217 | 43020 | jjdelcerro | } |
1218 | |||
1219 | @Override
|
||
1220 | public BinaryOperator ge(Value op1, Value op2) {
|
||
1221 | 44198 | jjdelcerro | return binaryOperator(">=", FORMAT_OPERATOR_GE, op1, op2); |
1222 | 43020 | jjdelcerro | } |
1223 | |||
1224 | @Override
|
||
1225 | public BinaryOperator lt(Value op1, Value op2) {
|
||
1226 | 44198 | jjdelcerro | return binaryOperator("<", FORMAT_OPERATOR_LT, op1, op2); |
1227 | 43020 | jjdelcerro | } |
1228 | |||
1229 | @Override
|
||
1230 | public BinaryOperator le(Value op1, Value op2) {
|
||
1231 | 44198 | jjdelcerro | return binaryOperator("<=", FORMAT_OPERATOR_LE, op1, op2); |
1232 | 43020 | jjdelcerro | } |
1233 | |||
1234 | @Override
|
||
1235 | public BinaryOperator like(Value op1, Value op2) {
|
||
1236 | 44198 | jjdelcerro | return binaryOperator(OPERATOR_LIKE, FORMAT_OPERATOR_LIKE, op1, op2);
|
1237 | 43020 | jjdelcerro | } |
1238 | |||
1239 | @Override
|
||
1240 | public BinaryOperator ilike(Value op1, Value op2) {
|
||
1241 | 44198 | jjdelcerro | return binaryOperator(OPERATOR_ILIKE, FORMAT_OPERATOR_ILIKE, op1, op2);
|
1242 | 43020 | jjdelcerro | } |
1243 | |||
1244 | @Override
|
||
1245 | public BinaryOperator add(Value op1, Value op2) {
|
||
1246 | 44198 | jjdelcerro | return binaryOperator(OPERATOR_ADD, FORMAT_OPERATOR_ADD, op1, op2);
|
1247 | 43020 | jjdelcerro | } |
1248 | |||
1249 | @Override
|
||
1250 | public BinaryOperator subst(Value op1, Value op2) {
|
||
1251 | 44198 | jjdelcerro | return binaryOperator(OPERATOR_SUBST, FORMAT_OPERATOR_SUBST, op1, op2);
|
1252 | 43020 | jjdelcerro | } |
1253 | |||
1254 | @Override
|
||
1255 | public BinaryOperator mult(Value op1, Value op2) {
|
||
1256 | 44198 | jjdelcerro | return binaryOperator(OPERATOR_MULT, FORMAT_OPERATOR_MULT, op1, op2);
|
1257 | 43020 | jjdelcerro | } |
1258 | |||
1259 | @Override
|
||
1260 | public BinaryOperator div(Value op1, Value op2) {
|
||
1261 | 44198 | jjdelcerro | return binaryOperator(OPERATOR_DIV, FORMAT_OPERATOR_DIV, op1, op2);
|
1262 | 43020 | jjdelcerro | } |
1263 | |||
1264 | @Override
|
||
1265 | public BinaryOperator concat(Value op1, Value op2) {
|
||
1266 | 44198 | jjdelcerro | return binaryOperator(OPERATOR_CONCAT, FORMAT_OPERATOR_CONCAT, op1, op2);
|
1267 | 43020 | jjdelcerro | } |
1268 | 44051 | omartinez | |
1269 | @Override
|
||
1270 | 44038 | jjdelcerro | public Function iif(Value condition, Value iftrue, Value iffalse) {
|
1271 | 44198 | jjdelcerro | return function(FUNCTION_IIF, condition, iftrue, iffalse);
|
1272 | 44038 | jjdelcerro | } |
1273 | |||
1274 | 44051 | omartinez | @Override
|
1275 | 44038 | jjdelcerro | public Function ifnull(Value value, Value iftrue, Value iffalse) {
|
1276 | 44198 | jjdelcerro | return function(FUNCTION_IFNULL, value, iftrue, iffalse);
|
1277 | 44038 | jjdelcerro | } |
1278 | 44051 | omartinez | |
1279 | @Override
|
||
1280 | public Function left(Value str, Value size) {
|
||
1281 | 44198 | jjdelcerro | return function(FUNCTION_LEFT, str, size);
|
1282 | 44051 | omartinez | } |
1283 | |||
1284 | @Override
|
||
1285 | public Function right(Value str, Value len) {
|
||
1286 | 44198 | jjdelcerro | return function(FUNCTION_RIGHT, str, len);
|
1287 | 44051 | omartinez | } |
1288 | |||
1289 | @Override
|
||
1290 | public Function locate(Value search, Value str, Value start) {
|
||
1291 | 44198 | jjdelcerro | return function(FUNCTION_LOCATE, search, str, start);
|
1292 | 44051 | omartinez | } |
1293 | |||
1294 | @Override
|
||
1295 | public Function position(Value search, Value str) {
|
||
1296 | 44198 | jjdelcerro | return function(FUNCTION_POSITION, search, str);
|
1297 | 44051 | omartinez | } |
1298 | |||
1299 | @Override
|
||
1300 | public Function lpad(Value str, Value len, Value padstr) {
|
||
1301 | 44198 | jjdelcerro | return function(FUNCTION_LPAD, str, len, padstr);
|
1302 | 44051 | omartinez | } |
1303 | |||
1304 | @Override
|
||
1305 | public Function rpad(Value str, Value len, Value padstr) {
|
||
1306 | 44198 | jjdelcerro | return function(FUNCTION_RPAD, str, len, padstr);
|
1307 | 44051 | omartinez | } |
1308 | |||
1309 | @Override
|
||
1310 | public Function ltrim(Value str) {
|
||
1311 | 44198 | jjdelcerro | return function(FUNCTION_LTRIM, str);
|
1312 | 44051 | omartinez | } |
1313 | |||
1314 | @Override
|
||
1315 | public Function rtrim(Value str) {
|
||
1316 | 44198 | jjdelcerro | return function(FUNCTION_RTRIM, str);
|
1317 | 44051 | omartinez | } |
1318 | |||
1319 | @Override
|
||
1320 | public Function trim(Value str) {
|
||
1321 | 44198 | jjdelcerro | return function(FUNCTION_TRIM, str);
|
1322 | 44051 | omartinez | } |
1323 | |||
1324 | @Override
|
||
1325 | public Function repeat(Value str, Value size) {
|
||
1326 | 44198 | jjdelcerro | return function(FUNCTION_REPEAT, str, size);
|
1327 | 44051 | omartinez | } |
1328 | |||
1329 | @Override
|
||
1330 | public Function replace(Value str, Value search, Value replstr) {
|
||
1331 | 44198 | jjdelcerro | return function(FUNCTION_REPLACE, str, search, replstr);
|
1332 | 44051 | omartinez | } |
1333 | |||
1334 | @Override
|
||
1335 | public Function ascii(Value str) {
|
||
1336 | 44198 | jjdelcerro | return function(FUNCTION_ASCII, str);
|
1337 | 44051 | omartinez | } |
1338 | |||
1339 | @Override
|
||
1340 | public Function lenght(Value str) {
|
||
1341 | 44198 | jjdelcerro | return function(FUNCTION_LENGHT, str);
|
1342 | 44051 | omartinez | } |
1343 | |||
1344 | @Override
|
||
1345 | public Function instr(Value str, Value search, Value start) {
|
||
1346 | 44198 | jjdelcerro | return function(FUNCTION_INSTR, str, search, start);
|
1347 | 44051 | omartinez | } |
1348 | |||
1349 | @Override
|
||
1350 | public Function lower(Value str) {
|
||
1351 | 44198 | jjdelcerro | return function(FUNCTION_LOWER, str);
|
1352 | 44051 | omartinez | } |
1353 | |||
1354 | @Override
|
||
1355 | public Function upper(Value str) {
|
||
1356 | 44198 | jjdelcerro | return function(FUNCTION_UPPER, str);
|
1357 | 44051 | omartinez | } |
1358 | |||
1359 | @Override
|
||
1360 | public Function space(Value size) {
|
||
1361 | 44198 | jjdelcerro | return function(FUNCTION_SPACE, size);
|
1362 | 44051 | omartinez | } |
1363 | |||
1364 | @Override
|
||
1365 | public Function substring(Value str, Value start, Value len) {
|
||
1366 | 44198 | jjdelcerro | return function(FUNCTION_SUBSTRING, str, start, len);
|
1367 | 44051 | omartinez | } |
1368 | |||
1369 | @Override
|
||
1370 | public Function acos(Value num) {
|
||
1371 | 44198 | jjdelcerro | return function(FUNCTION_ACOS, num);
|
1372 | 44051 | omartinez | } |
1373 | |||
1374 | @Override
|
||
1375 | public Function asin(Value num) {
|
||
1376 | 44198 | jjdelcerro | return function(FUNCTION_ASIN, num);
|
1377 | 44051 | omartinez | } |
1378 | |||
1379 | @Override
|
||
1380 | public Function atan(Value num) {
|
||
1381 | 44198 | jjdelcerro | return function(FUNCTION_ATAN, num);
|
1382 | 44051 | omartinez | } |
1383 | |||
1384 | @Override
|
||
1385 | public Function cos(Value num) {
|
||
1386 | 44198 | jjdelcerro | return function(FUNCTION_COS, num);
|
1387 | 44051 | omartinez | } |
1388 | |||
1389 | @Override
|
||
1390 | public Function cosh(Value num) {
|
||
1391 | 44198 | jjdelcerro | return function(FUNCTION_COSH, num);
|
1392 | 44051 | omartinez | } |
1393 | |||
1394 | @Override
|
||
1395 | public Function cot(Value num) {
|
||
1396 | 44198 | jjdelcerro | return function(FUNCTION_COT, num);
|
1397 | 44051 | omartinez | } |
1398 | |||
1399 | @Override
|
||
1400 | public Function bitand(Value num1, Value num2) {
|
||
1401 | 44198 | jjdelcerro | return function(FUNCTION_BITAND, num1, num2);
|
1402 | 44051 | omartinez | } |
1403 | |||
1404 | @Override
|
||
1405 | public Function bitor(Value num1, Value num2) {
|
||
1406 | 44198 | jjdelcerro | return function(FUNCTION_BITOR, num1, num2);
|
1407 | 44051 | omartinez | } |
1408 | |||
1409 | @Override
|
||
1410 | public Function bitxor(Value num1, Value num2) {
|
||
1411 | 44198 | jjdelcerro | return function(FUNCTION_BITXOR, num1, num2);
|
1412 | 44051 | omartinez | } |
1413 | |||
1414 | @Override
|
||
1415 | public Function ceil(Value num) {
|
||
1416 | 44198 | jjdelcerro | return function(FUNCTION_CEIL, num);
|
1417 | 44051 | omartinez | } |
1418 | |||
1419 | @Override
|
||
1420 | public Function degrees(Value num) {
|
||
1421 | 44198 | jjdelcerro | return function(FUNCTION_DEGREES, num);
|
1422 | 44051 | omartinez | } |
1423 | |||
1424 | @Override
|
||
1425 | public Function exp(Value num) {
|
||
1426 | 44198 | jjdelcerro | return function(FUNCTION_EXP, num);
|
1427 | 44051 | omartinez | } |
1428 | |||
1429 | @Override
|
||
1430 | public Function floor(Value num) {
|
||
1431 | 44198 | jjdelcerro | return function(FUNCTION_FLOOR, num);
|
1432 | 44051 | omartinez | } |
1433 | |||
1434 | @Override
|
||
1435 | public Function log(Value num) {
|
||
1436 | 44198 | jjdelcerro | return function(FUNCTION_LOG, num);
|
1437 | 44051 | omartinez | } |
1438 | |||
1439 | @Override
|
||
1440 | public Function log10(Value num) {
|
||
1441 | 44198 | jjdelcerro | return function(FUNCTION_LOG10, num);
|
1442 | 44051 | omartinez | } |
1443 | |||
1444 | @Override
|
||
1445 | public Function pi(Value num) {
|
||
1446 | 44198 | jjdelcerro | return function(FUNCTION_PI, num);
|
1447 | 44051 | omartinez | } |
1448 | |||
1449 | @Override
|
||
1450 | public Function power(Value num) {
|
||
1451 | 44198 | jjdelcerro | return function(FUNCTION_POWER, num);
|
1452 | 44051 | omartinez | } |
1453 | |||
1454 | @Override
|
||
1455 | public Function radians(Value num) {
|
||
1456 | 44198 | jjdelcerro | return function(FUNCTION_RADIANS, num);
|
1457 | 44051 | omartinez | } |
1458 | |||
1459 | @Override
|
||
1460 | public Function rand(Value num) {
|
||
1461 | 44198 | jjdelcerro | return function(FUNCTION_RAND, num);
|
1462 | 44051 | omartinez | } |
1463 | |||
1464 | @Override
|
||
1465 | public Function round(Value num) {
|
||
1466 | 44198 | jjdelcerro | return function(FUNCTION_ROUND, num);
|
1467 | 44051 | omartinez | } |
1468 | |||
1469 | @Override
|
||
1470 | public Function sqrt(Value num) {
|
||
1471 | 44198 | jjdelcerro | return function(FUNCTION_SQRT, num);
|
1472 | 44051 | omartinez | } |
1473 | |||
1474 | @Override
|
||
1475 | public Function sign(Value num) {
|
||
1476 | 44198 | jjdelcerro | return function(FUNCTION_SIGN, num);
|
1477 | 44051 | omartinez | } |
1478 | |||
1479 | @Override
|
||
1480 | public Function sin(Value num) {
|
||
1481 | 44198 | jjdelcerro | return function(FUNCTION_SIN, num);
|
1482 | 44051 | omartinez | } |
1483 | |||
1484 | @Override
|
||
1485 | public Function sinh(Value num) {
|
||
1486 | 44198 | jjdelcerro | return function(FUNCTION_SINH, num);
|
1487 | 44051 | omartinez | } |
1488 | |||
1489 | @Override
|
||
1490 | public Function tan(Value num) {
|
||
1491 | 44198 | jjdelcerro | return function(FUNCTION_TAN, num);
|
1492 | 44051 | omartinez | } |
1493 | @Override
|
||
1494 | public Function tanh(Value num) {
|
||
1495 | 44198 | jjdelcerro | return function(FUNCTION_TANH, num);
|
1496 | 44051 | omartinez | } |
1497 | |||
1498 | @Override
|
||
1499 | public Function zero() {
|
||
1500 | 44198 | jjdelcerro | return function(FUNCTION_ZERO);
|
1501 | 44051 | omartinez | } |
1502 | 44053 | omartinez | |
1503 | @Override
|
||
1504 | public Function chr(Value num) {
|
||
1505 | 44198 | jjdelcerro | return function(FUNCTION_CHR, num);
|
1506 | } |
||
1507 | |||
1508 | @Override
|
||
1509 | public Function ST_ExtentAggregate(Value geom) {
|
||
1510 | return function(FUNCTION_ST_EXTENTAGGREGATE, geom);
|
||
1511 | 44053 | omartinez | } |
1512 | 44198 | jjdelcerro | |
1513 | @Override
|
||
1514 | public Function ST_UnionAggregate(Value geom) {
|
||
1515 | return function(FUNCTION_ST_UNIONAGGREGATE, geom);
|
||
1516 | } |
||
1517 | |||
1518 | @Override
|
||
1519 | public Function cast(Value object, Value typeName) {
|
||
1520 | return function(FUNCTION_CAST, object, typeName);
|
||
1521 | } |
||
1522 | |||
1523 | @Override
|
||
1524 | public Function decode(Value value, Value format) {
|
||
1525 | return function(FUNCTION_DECODE, value, format);
|
||
1526 | } |
||
1527 | |||
1528 | @Override
|
||
1529 | public Function toDouble(Value num) {
|
||
1530 | return function(FUNCTION_TODOUBLE, num);
|
||
1531 | } |
||
1532 | |||
1533 | @Override
|
||
1534 | public Function toFloat(Value num) {
|
||
1535 | return function(FUNCTION_TOFLOAT, num);
|
||
1536 | } |
||
1537 | |||
1538 | @Override
|
||
1539 | public Function toLong(Value num) {
|
||
1540 | return function(FUNCTION_TOLONG, num);
|
||
1541 | } |
||
1542 | |||
1543 | @Override
|
||
1544 | public Function toInteger(Value num) {
|
||
1545 | return function(FUNCTION_TOINTEGER, num);
|
||
1546 | } |
||
1547 | |||
1548 | @Override
|
||
1549 | public Function toStr(Value object) {
|
||
1550 | return function(FUNCTION_TOSTR, object);
|
||
1551 | } |
||
1552 | |||
1553 | |||
1554 | 43020 | jjdelcerro | } |