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