Revision 43093 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/ExpressionBuilderBase.java

View differences:

ExpressionBuilderBase.java
2 2

  
3 3
import java.text.MessageFormat;
4 4
import java.util.ArrayList;
5
import java.util.Collection;
5 6
import java.util.Collections;
6 7
import java.util.HashMap;
7 8
import java.util.HashSet;
......
31 32
import org.gvsig.fmap.geom.Geometry;
32 33
import org.gvsig.fmap.geom.primitive.Envelope;
33 34

  
35
@SuppressWarnings("UseSpecificCatch")
34 36
public class ExpressionBuilderBase implements ExpressionBuilder {
37

  
35 38
    public class ConfigBase implements Config {
36 39

  
37
        protected Map<String,Object> values;
38
        
40
        protected Map<String, Object> values;
41

  
39 42
        public ConfigBase() {
40 43
            this.values = new HashMap<>();
41
            
42
            this.values.put(has_spatial_functions,false);
44

  
45
            this.values.put(has_spatial_functions, false);
43 46
            this.values.put(constant_true, "(1=1)");
44 47
            this.values.put(constant_false, "(1=2)");
45 48
            this.values.put(quote_for_identifiers, "\"");
46 49
            this.values.put(quote_for_strings, "'");
47 50
            this.values.put(geometry_type_support, GeometrySupportType.WKT);
48 51
            this.values.put(group, "( {0} )");
49
            
50
            this.values.put(Find_SRID , "Find_SRID(({0}), ({1}), ({2}))");
51
            this.values.put(ST_SRID , "ST_SRID({0})");
52
            this.values.put(ST_AsText , "ST_AsText({0})");
52

  
53
            this.values.put(Find_SRID, "Find_SRID(({0}), ({1}), ({2}))");
54
            this.values.put(ST_SRID, "ST_SRID({0})");
55
            this.values.put(ST_AsText, "ST_AsText({0})");
53 56
            this.values.put(ST_AsBinary, "ST_AsBinary({0})");
54 57
            this.values.put(ST_AsEWKB, "ST_AsWKB({0})");
55
            this.values.put(ST_Contains, "ST_Contains(({0}), ({1}))");            
56
            this.values.put(ST_Crosses,  "ST_Crosses(({0}), ({1}))");
57
            this.values.put(ST_Disjoint ,  "ST_Disjoint(({0}), ({1}))");
58
            this.values.put(ST_Equals ,  "ST_Equals(({0}), ({1}))");
59
            this.values.put(ST_IsClosed,  "ST_IsClosed({0})");
60
            this.values.put(ST_Overlaps,  "ST_Overlaps(({0}), ({1}))");
61
            this.values.put(ST_Touches,  "ST_Touches(({0}), ({1}))");
62
            this.values.put(ST_Within, "ST_Within(({0}), ({1}))");            
58
            this.values.put(ST_Contains, "ST_Contains(({0}), ({1}))");
59
            this.values.put(ST_Crosses, "ST_Crosses(({0}), ({1}))");
60
            this.values.put(ST_Disjoint, "ST_Disjoint(({0}), ({1}))");
61
            this.values.put(ST_Equals, "ST_Equals(({0}), ({1}))");
62
            this.values.put(ST_IsClosed, "ST_IsClosed({0})");
63
            this.values.put(ST_Overlaps, "ST_Overlaps(({0}), ({1}))");
64
            this.values.put(ST_Touches, "ST_Touches(({0}), ({1}))");
65
            this.values.put(ST_Within, "ST_Within(({0}), ({1}))");
63 66
            this.values.put(ST_Envelope, "ST_Envelope({0})");
64 67
            this.values.put(ST_Intersects, "ST_Intersects(({0}), ({1}))");
65 68
            this.values.put(ST_GeomFromText, "ST_GeomFromText({0}, ({1}))");
......
70 73
            this.values.put(isNull, "( ({0}) IS NULL )");
71 74
            this.values.put(notIsNull, "( ({0}) NOT IS NULL )");
72 75
            this.values.put(operator_not, "( NOT ({0}) )");
73
            
76

  
74 77
            this.values.put(operator_AND, "{0} AND {1}");
75 78
            this.values.put(operator_OR, "{0} OR {1}");
76 79
            this.values.put(operator_EQ, "( ({0}) = ({1}) )");
......
93 96
        @Override
94 97
        public boolean has_functionality(String functionality) {
95 98
            Object x = this.values.get(functionality);
96
            if( x == null ) {
99
            if (x == null) {
97 100
                return false;
98 101
            }
99
            if( x instanceof CharSequence && StringUtils.isEmpty((CharSequence) x) ) {
102
            if (x instanceof CharSequence && StringUtils.isEmpty((CharSequence) x)) {
100 103
                return false;
101 104
            }
102 105
            return true;
......
134 137

  
135 138
        @Override
136 139
        public void set(String name, Object value) {
137
            this.values.put(name,value);
140
            this.values.put(name, value);
138 141
        }
139 142
    }
140
    
143

  
141 144
    public abstract class AbstractValue implements Value {
142 145

  
143 146
        @Override
144 147
        public void accept(Visitor visitor, VisitorFilter filter) {
145
            if( filter == null || filter.accept(this) ) {
148
            if (filter == null || filter.accept(this)) {
146 149
                visitor.visit(this);
147 150
            }
148 151
        }
149
        
152

  
150 153
    }
151 154

  
152 155
    public class ClassVisitorFilter implements VisitorFilter {
......
156 159
        public ClassVisitorFilter(Class classFilter) {
157 160
            this.classFilter = classFilter;
158 161
        }
159
        
162

  
160 163
        @Override
161 164
        public boolean accept(Visitable visitable) {
162 165
            return classFilter.isInstance(visitable);
163 166
        }
164
        
167

  
165 168
    }
166
    
169

  
167 170
    public class GroupBase extends AbstractValue implements Group {
171

  
168 172
        protected Value value;
169
        
173

  
170 174
        public GroupBase(Value value) {
171 175
            this.value = value;
172 176
        }
......
178 182

  
179 183
        @Override
180 184
        public void accept(Visitor visitor, VisitorFilter filter) {
181
            super.accept(visitor,filter);
182
            this.value.accept(visitor,filter);
185
            super.accept(visitor, filter);
186
            this.value.accept(visitor, filter);
183 187
        }
184
        
188

  
185 189
        @Override
186 190
        public String toString() {
187 191
            return MessageFormat.format(config.getString(Config.group), this.value.toString());
......
189 193
    }
190 194

  
191 195
    public class VariableBase extends AbstractValue implements Variable {
196

  
192 197
        protected String name;
193
        
198

  
194 199
        public VariableBase(String name) {
195 200
            this.name = name;
196 201
        }
197
        
202

  
198 203
        @Override
199 204
        public String getName() {
200 205
            return this.name;
......
212 217

  
213 218
        @Override
214 219
        public boolean equals(Object obj) {
215
            if( ! (obj instanceof Variable) ) {
220
            if (!(obj instanceof Variable)) {
216 221
                return false;
217 222
            }
218
            return this.name.equals(((Variable)obj).getName());
223
            return this.name.equals(((Variable) obj).getName());
219 224
        }
220 225

  
221 226
        @Override
......
227 232
    }
228 233

  
229 234
    public class ParameterBase extends AbstractValue implements Parameter {
235

  
236
        protected String name;
230 237
        protected Object value;
231 238
        protected ParameterType type;
232 239
        protected Value srs;
233
        
234
        public ParameterBase(Object value) {
235
            this.value = value;
236
            if( this.value instanceof String ) {
237
                this.type = ParameterType.Variable;
238
            } else {
239
                this.type = ParameterType.Constant;
240
            }
240

  
241
        public ParameterBase() {
242
            this.type = ParameterType.Constant;
243
            this.name = null;
244
            this.value = null;
241 245
        }
242 246

  
243 247
        @Override
244 248
        public void accept(Visitor visitor, VisitorFilter filter) {
245 249
            super.accept(visitor, filter);
246
            if( this.srs != null ) {
250
            if (this.srs != null) {
247 251
                this.srs.accept(visitor, filter);
248 252
            }
249 253
        }
250
        
254

  
251 255
        @Override
252
        public Parameter as_geometry() {
256
        public Parameter as_geometry_variable() {
253 257
            this.type = ParameterType.Geometry;
258
            if (this.value == null && this.name != null) {
259
                this.value = this.name;
260
            }
254 261
            return this;
255 262
        }
256
        
263

  
257 264
        @Override
258 265
        public Parameter as_constant() {
259 266
            this.type = ParameterType.Constant;
267
            if (this.value == null && this.name != null) {
268
                this.value = this.name;
269
            }
260 270
            return this;
261 271
        }
262
        
272

  
263 273
        @Override
264 274
        public Parameter as_variable() {
265 275
            this.type = ParameterType.Variable;
276
            if (this.value != null && this.name == null) {
277
                this.name = (String) this.value;
278
            }
266 279
            return this;
267 280
        }
268
        
281

  
269 282
        @Override
270 283
        public Parameter srs(Value srs) {
271 284
            this.srs = srs;
285
            if( this.type == ParameterType.Variable ) {
286
                this.type = ParameterType.Geometry;
287
            }
272 288
            return this;
273 289
        }
274 290

  
275 291
        @Override
276 292
        public Parameter srs(IProjection srs) {
277 293
            this.srs = constant(getSRSId(srs));
294
            if( this.type == ParameterType.Variable ) {
295
                this.type = ParameterType.Geometry;
296
            }
278 297
            return this;
279 298
        }
280
 
299

  
281 300
        @Override
282 301
        public String getName() {
283
            switch(this.type) {
302
            switch (this.type) {
284 303
                case Variable:
285 304
                case Geometry:
286
                    return (String) this.value;
305
                    return this.name;
287 306
                case Constant:
307
                    if (this.value == null) {
308
                        return null;
309
                    }
310
                    return this.value.toString();
288 311
                default:
312
                    if (this.name != null) {
313
                        return this.name;
314
                    }
315
                    if (this.value != null) {
316
                        return this.value.toString();
317
                    }
289 318
                    return null;
290 319
            }
291 320
        }
......
306 335
        }
307 336

  
308 337
        @Override
338
        public Parameter value(Object value) {
339
            this.value = value;
340
            return this;
341
        }
342

  
343
        @Override
344
        public Parameter name(String name) {
345
            this.type = ParameterType.Variable;
346
            this.name = name;
347
            return this;
348
        }
349

  
350
        @Override
309 351
        public Object getValue() {
310 352
            try {
311
                switch(this.type) {
353
                switch (this.type) {
312 354
                    case Constant:
313
                        if( this.value instanceof Geometry ) {
314
                            switch( config.getGeometryTypeSupport() ) {
355
                        if (this.value instanceof Geometry) {
356
                            switch (config.getGeometryTypeSupport()) {
315 357
                                case EWKB:
316
                                    return bytearray(((Geometry)this.value).convertToEWKB());
358
                                    return bytearray(((Geometry) this.value).convertToEWKB());
317 359
                                case WKB:
318
                                    return bytearray(((Geometry)this.value).convertToWKB());
360
                                    return bytearray(((Geometry) this.value).convertToWKB());
319 361
                                case WKT:
320 362
                                default:
321
                                    return ((Geometry)this.value).convertToWKT();
363
                                    return ((Geometry) this.value).convertToWKT();
322 364
                            }
323
                        } else if( this.value instanceof IProjection ) {
365
                        } else if (this.value instanceof IProjection) {
324 366
                            return getSRSId((IProjection) this.value);
325
                        } 
367
                        }
326 368
                        return this.value;
327 369
                    case Variable:
328 370
                    case Geometry:
329 371
                    default:
330
                        return null;
372
                        return this.value;
331 373
                }
332
            } catch(Exception ex) {
333
                throw new RuntimeException("Can't get value from parameter.",ex);
374
            } catch (Exception ex) {
375
                throw new RuntimeException("Can't get value from parameter.", ex);
334 376
            }
335 377
        }
336 378

  
......
338 380
        public ParameterType getType() {
339 381
            return this.type;
340 382
        }
341
        
383

  
342 384
        @Override
343 385
        public Value getSRS() {
344 386
            return this.srs;
345 387
        }
346
        
388

  
347 389
        @Override
348 390
        public String toString() {
349
            switch(this.type) {
391
            switch (this.type) {
350 392
                case Constant:
351 393
                case Variable:
352 394
                default:
353 395
                    return "?";
354 396
                case Geometry:
355
                    switch( config.getGeometryTypeSupport() ) {
397
                    switch (config.getGeometryTypeSupport()) {
356 398
                        case EWKB:
357 399
                            return MessageFormat.format(
358 400
                                    config.getString(Config.ST_GeomFromEWKB),
......
371 413
                                    config.getString(Config.ST_GeomFromText),
372 414
                                    "?",
373 415
                                    String.valueOf(this.srs.toString())
374
                            );                        
375
                    }                            
416
                            );
417
                    }
376 418
            }
377
        }        
419
        }
378 420
    }
379 421

  
380 422
    public class ConstantBase extends AbstractValue implements Constant {
381
        
423

  
382 424
        protected Object value;
383
        
425

  
384 426
        public ConstantBase(Object value) {
385 427
            this.value = value;
386 428
        }
387
        
429

  
388 430
        @Override
389 431
        public Object getValue() {
390 432
            return this.value;
......
392 434

  
393 435
        @Override
394 436
        public String toString() {
395
            if( this.value instanceof String ) {
437
            if (this.value instanceof String) {
396 438
                return string((String) this.value);
397 439
            }
398
            if( this.value instanceof Boolean ) {
399
                if( ((Boolean)this.value) ) {
440
            if (this.value instanceof Boolean) {
441
                if (((Boolean) this.value)) {
400 442
                    return config.getString(Config.constant_true);
401 443
                } else {
402 444
                    return config.getString(Config.constant_false);
......
407 449
    }
408 450

  
409 451
    public class CustomBase extends AbstractValue implements Custom {
410
        
452

  
411 453
        protected Object value;
412
        
454

  
413 455
        // Esto es para permitir declarar parametros y columnas en una seccion
414 456
        // custom.
415 457
        protected List<Value> values;
416
        
458

  
417 459
        public CustomBase(Object value) {
418 460
            this.value = value;
419 461
        }
......
421 463
        @Override
422 464
        public void accept(Visitor visitor, VisitorFilter filter) {
423 465
            super.accept(visitor, filter);
424
            if( this.values!=null ) {
466
            if (this.values != null) {
425 467
                for (Value value : values) {
426 468
                    value.accept(visitor, filter);
427 469
                }
428 470
            }
429 471
        }
430
        
472

  
431 473
        @Override
432 474
        public Object getValue() {
433 475
            return this.value;
......
435 477

  
436 478
        @Override
437 479
        public Custom add(Variable variable) {
438
            if( this.values==null ) {
480
            if (this.values == null) {
439 481
                this.values = new ArrayList<>();
440 482
            }
441 483
            this.values.add(variable);
......
444 486

  
445 487
        @Override
446 488
        public Custom add(Parameter parameter) {
447
            if( this.values==null ) {
489
            if (this.values == null) {
448 490
                this.values = new ArrayList<>();
449 491
            }
450 492
            this.values.add(parameter);
......
461 503

  
462 504
        protected Geometry geometry;
463 505
        protected IProjection projection;
464
        
506

  
465 507
        public GeometryValueBase(Geometry geometry, IProjection projection) {
466 508
            this.geometry = geometry;
467 509
            this.projection = projection;
468 510
        }
469
        
511

  
470 512
        @Override
471 513
        public Geometry getGeometry() {
472 514
            return this.geometry;
......
480 522
        @Override
481 523
        public String toString() {
482 524
            try {
483
                switch( config.getGeometryTypeSupport() ) {
525
                switch (config.getGeometryTypeSupport()) {
484 526
                    case EWKB:
485 527
                        return MessageFormat.format(
486 528
                                config.getString(Config.ST_GeomFromEWKB),
......
499 541
                                config.getString(Config.ST_GeomFromText),
500 542
                                string(this.geometry.convertToWKT()),
501 543
                                String.valueOf(getSRSId(this.projection))
502
                        );                        
544
                        );
503 545
                }
504 546
            } catch (Exception ex) {
505
                throw new RuntimeException("Can't convert geometry to string.",ex);
547
                throw new RuntimeException("Can't convert geometry to string.", ex);
506 548
            }
507 549
        }
508
    } 
550
    }
509 551

  
510 552
    public class FunctionBase extends AbstractValue implements Function {
511 553

  
512 554
        protected String name;
513 555
        protected String format;
514 556
        protected List<Value> parameters;
515
        
557

  
516 558
        public FunctionBase(String name, String format) {
517 559
            this.name = name;
518 560
            this.format = format;
519 561
        }
520
        
562

  
521 563
        @Override
522 564
        public List<Value> parameters() {
523
            if( this.parameters == null ) {
565
            if (this.parameters == null) {
524 566
                this.parameters = new ArrayList<>();
525 567
            }
526 568
            return this.parameters;
527
        }        
569
        }
528 570

  
529 571
        @Override
530 572
        public Function parameter(Value parameter) {
......
539 581

  
540 582
        @Override
541 583
        public void accept(Visitor visitor, VisitorFilter filter) {
542
            super.accept(visitor,filter);
584
            super.accept(visitor, filter);
543 585
            for (Value value : this.parameters) {
544
                value.accept(visitor,filter);
586
                value.accept(visitor, filter);
545 587
            }
546 588
        }
547 589

  
548 590
        @Override
549 591
        public String toString() {
550
            if( this.parameters!=null && !this.parameters.isEmpty() ) {
592
            if (this.parameters != null && !this.parameters.isEmpty()) {
551 593
                List<String> values = new ArrayList<>();
552 594
                for (Value value : this.parameters) {
553 595
                    values.add(value.toString());
......
558 600
            }
559 601
        }
560 602
    }
561
    
603

  
562 604
    public class BinaryOperatorBase extends AbstractValue implements BinaryOperator {
563 605

  
564 606
        protected String name;
565 607
        protected String format;
566 608
        protected Value left;
567 609
        protected Value right;
568
        
610

  
569 611
        public BinaryOperatorBase(String name, String format) {
570 612
            this.name = name;
571 613
            this.format = format;
572 614
        }
573
        
615

  
574 616
        @Override
575 617
        public String getName() {
576 618
            return this.name;
......
578 620

  
579 621
        @Override
580 622
        public void accept(Visitor visitor, VisitorFilter filter) {
581
            super.accept(visitor,filter);
623
            super.accept(visitor, filter);
582 624
            this.left.accept(visitor, filter);
583 625
            this.right.accept(visitor, filter);
584 626
        }
......
604 646
        public Value getRight() {
605 647
            return this.right;
606 648
        }
607
        
649

  
608 650
        @Override
609 651
        public String toString() {
610 652
            return MessageFormat.format(
611
                    format, 
612
                    this.left.toString(), 
653
                    format,
654
                    this.left.toString(),
613 655
                    this.right.toString()
614 656
            );
615 657
        }
......
617 659

  
618 660
    protected Value value;
619 661
    protected Config config;
620
    
662

  
621 663
    public ExpressionBuilderBase() {
622 664
        this.config = new ConfigBase();
623 665
    }
......
626 668
    public ExpressionBuilder createExpressionBuilder() {
627 669
        return new ExpressionBuilderBase();
628 670
    }
629
    
671

  
630 672
    @Override
631 673
    public Config getConfig() {
632 674
        return this.config;
633
    } 
634
    
675
    }
676

  
635 677
    @Override
636 678
    public Value getValue() {
637 679
        return this.value;
638 680
    }
639
    
681

  
640 682
    @Override
641 683
    public ExpressionBuilder setValue(Value value) {
642 684
        this.value = value;
......
650 692

  
651 693
    @Override
652 694
    public void accept(Visitor visitor, VisitorFilter filter) {
695
        if( this.value == null) {
696
            return;
697
        }
653 698
        this.value.accept(visitor, filter);
654 699
    }
655
     
700

  
656 701
    @Override
657 702
    public boolean has_spatial_functions() {
658 703
        return this.config.getBoolean(Config.has_spatial_functions);
......
673 718
        }
674 719
        return quote + s + quote;
675 720
    }
676
    
721

  
677 722
    @Override
678 723
    public String identifier(String id) {
679 724
        String quote = this.config.getString(Config.quote_for_identifiers);
......
701 746
        String abrev = projection.getAbrev();
702 747
        return Integer.valueOf(abrev.split(":")[1]);
703 748
    }
704
    
749

  
705 750
    @Override
706 751
    public Constant srs(IProjection projection) {
707 752
        return constant(getSRSId(projection));
......
718 763
    }
719 764

  
720 765
    @Override
721
    public Parameter parameter(Object  value) {
722
        return new ParameterBase(value);
766
    public Parameter parameter(String name) {
767
        Parameters parameters = this.getParameters();
768
        Parameter parameter = parameters.get(name);
769
        if( parameter != null ) {
770
            return parameter;
771
        }
772
        parameter = this.parameter();
773
        parameter.name(name);
774
        return parameter;
723 775
    }
724

  
776
    
777
    public Parameter parameter() {
778
        return new ParameterBase();
779
    }
780
    
725 781
    @Override
726 782
    public Constant constant(Object value) {
727 783
        return new ConstantBase(value);
......
731 787
    public Group group(Value value) {
732 788
        return new GroupBase(value);
733 789
    }
734
    
790

  
735 791
    @Override
736 792
    public GeometryValue geometry(Geometry geom, IProjection projection) {
737 793
        return new GeometryValueBase(geom, projection);
......
747 803
        return new CustomBase(value);
748 804
    }
749 805

  
750
    public Function function(String name, String format, Value...values) {
751
        FunctionBase func = new FunctionBase(name,format);
806
    public Function function(String name, String format, Value... values) {
807
        FunctionBase func = new FunctionBase(name, format);
752 808
        for (Value value : values) {
753 809
            func.parameter(value);
754 810
        }
755 811
        return func;
756 812
    }
757
    
813

  
758 814
    public BinaryOperator binaryOperator(String name, String format, Value leftOperand, Value rightOperand) {
759
        BinaryOperator operator = new BinaryOperatorBase(name,format);
815
        BinaryOperator operator = new BinaryOperatorBase(name, format);
760 816
        operator.setLeft(leftOperand);
761 817
        operator.setRight(rightOperand);
762 818
        return operator;
763 819
    }
764
    
820

  
765 821
    @Override
766 822
    public List<Variable> getVariables() {
767 823
        final Set<Variable> vars = new HashSet<>();
768 824
        this.accept(new Visitor() {
769 825
            @Override
770 826
            public void visit(Visitable value) {
771
                vars.add((Variable)value);
827
                vars.add((Variable) value);
772 828
            }
773
        }, new ClassVisitorFilter(Variable.class) );
829
        }, new ClassVisitorFilter(Variable.class));
774 830
        List<Variable> lvars = new ArrayList<>(vars);
775 831
        Collections.sort(lvars);
776 832
        return lvars;
777 833
    }
778
    
834

  
835
    private static class ParametersBase extends ArrayList<Parameter> implements Parameters {
836

  
837
        public ParametersBase() {
838
            super();
839
        }
840

  
841
        public ParametersBase(Collection parameters) {
842
            super(parameters);
843
        }
844

  
845
        @Override
846
        public Parameter get(String name) {
847
            if( name == null ) {
848
                return null;
849
            }
850
            for (Parameter param : this) {
851
                if( param.is_variable() || param.is_geometry_variable() ) {
852
                    if( name.equalsIgnoreCase(param.getName()) ) {
853
                        return param;
854
                    }
855
                }
856
            }
857
            return null;
858
        }
859

  
860
        
861
        @Override
862
        public String toString() {
863
            boolean first = true;
864
            StringBuilder builder = new StringBuilder();
865
            builder.append("{ ");
866
            for (Parameter param : this) {
867
                if (!first) {
868
                    builder.append(", ");
869
                } else {
870
                    first = false;
871
                }
872
                String s;
873
                Object value = param.getValue();
874
                if (value == null) {
875
                    s = "null";
876
                } else if (value instanceof String) {
877
                    s = "'" + (String) value + "'";
878
                } else {
879
                    s = value.toString();
880
                }
881
                switch (param.getType()) {
882
                    case Constant:
883
                        builder.append(s);
884
                        break;
885
                    case Geometry:
886
                        builder.append("(Geometry)");
887
                    case Variable:
888
                    default:
889
                        builder.append(param.getName());
890
                        builder.append(": ");
891
                        builder.append(s);
892
                }
893
            }
894
            builder.append(" }");
895
            return builder.toString();
896
        }
897
    }
898

  
779 899
    @Override
780
    public List<Parameter> getParameters() {
781
        final List<Parameter> params = new ArrayList<>();
900
    public Parameters getParameters() {
901
        final Parameters params = new ParametersBase();
782 902
        this.accept(new Visitor() {
783 903
            @Override
784 904
            public void visit(Visitable value) {
785
                params.add((Parameter)value);
905
                params.add((Parameter) value);
786 906
            }
787
        }, new ClassVisitorFilter(Parameter.class) );
907
        }, new ClassVisitorFilter(Parameter.class));
788 908
        return params;
789 909
    }
790
    
910

  
791 911
    @Override
792 912
    public Function getAsGeometry(Value value) {
793 913
        return function("ST_AsBinary", config.getString(Config.ST_AsBinary), value);
......
801 921

  
802 922
    @Override
803 923
    public ExpressionBuilder and(Value value) {
804
        if( this.value == null ) {
924
        if (this.value == null) {
805 925
            return this.set(value);
806 926
        }
807 927
        BinaryOperator operator = binaryOperator("AND", config.getString(Config.operator_AND), this.value, value);
......
811 931

  
812 932
    @Override
813 933
    public ExpressionBuilder or(Value value) {
814
        if( this.value == null ) {
934
        if (this.value == null) {
815 935
            return this.set(value);
816 936
        }
817 937
        BinaryOperator operator = binaryOperator("OR", config.getString(Config.operator_OR), this.value, value);
......
873 993
    public Function ST_Disjoint(Value geom1, Value geom2) {
874 994
        return function("ST_Disjoint", config.getString(Config.ST_Disjoint), geom1, geom2);
875 995
    }
876
    
996

  
877 997
    @Override
878 998
    public Function ST_Contains(Value geom1, Value geom2) {
879 999
        return function("ST_Contains", config.getString(Config.ST_Contains), geom1, geom2);
......
934 1054
        return function("UCASE", config.getString(Config.ucase), s);
935 1055
    }
936 1056

  
937

  
938 1057
    @Override
939 1058
    public BinaryOperator and(Value leftOperand, Value rightOperand) {
940 1059
        return binaryOperator("AND", config.getString(Config.operator_AND), leftOperand, rightOperand);
......
949 1068
    public BinaryOperator eq(Value leftOperand, Value rightOperand) {
950 1069
        return binaryOperator("=", config.getString(Config.operator_EQ), leftOperand, rightOperand);
951 1070
    }
952
    
1071

  
953 1072
    @Override
954 1073
    public BinaryOperator ne(Value leftOperand, Value rightOperand) {
955 1074
        return binaryOperator("<>", config.getString(Config.operator_NE), leftOperand, rightOperand);
956
    }    
1075
    }
957 1076

  
958 1077
    @Override
959 1078
    public BinaryOperator gt(Value op1, Value op2) {
......
1009 1128
    public BinaryOperator concat(Value op1, Value op2) {
1010 1129
        return binaryOperator("CONCAT", config.getString(Config.operator_concat), op1, op2);
1011 1130
    }
1012
    
1131

  
1013 1132
}

Also available in: Unified diff