Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/pom.xml
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/pom.xml	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/pom.xml	(revision 44198)
@@ -35,6 +35,11 @@
             <scope>compile</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-text</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
             <groupId>org.gvsig</groupId>
             <artifactId>${org.gvsig.fmap.geometry.impl}</artifactId>
             <scope>test</scope>
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCodeToStringConverter.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCodeToStringConverter.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCodeToStringConverter.java	(revision 44198)
@@ -1,108 +0,0 @@
-package org.gvsig.expresionevaluator.impl;
-
-import static junit.framework.Assert.assertEquals;
-import junit.framework.TestCase;
-import org.gvsig.expressionevaluator.spi.AbstractCodeToStringConverter;
-import org.gvsig.expressionevaluator.Code;
-import org.gvsig.expressionevaluator.CodeToStringConverter;
-import org.gvsig.expressionevaluator.Codes;
-import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
-import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
-import org.gvsig.expressionevaluator.Function;
-import org.gvsig.expressionevaluator.Compiler;
-import org.gvsig.expressionevaluator.LexicalAnalyzer;
-import org.gvsig.expressionevaluator.SymbolTable;
-import org.gvsig.expressionevaluator.impl.DefaultCompiler;
-import org.gvsig.expressionevaluator.impl.SQLLexicalAnalyzer;
-import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
-
-/**
- *
- * @author jjdelcerro
- */
-public class TestCodeToStringConverter extends TestCase {
-
-    public TestCodeToStringConverter(String testName) {
-        super(testName);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        new DefaultLibrariesInitializer().fullInitialize();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
-    // TODO add test methods here. The name must begin with 'test'. For example:
-    // public void testHello() {}
-    
-    protected LexicalAnalyzer createLexicalAnalyzer() {
-        SQLLexicalAnalyzer lexer = new SQLLexicalAnalyzer();
-        return lexer;
-    }
-        
-    protected Compiler createCompiler() {
-        Compiler compiler = new DefaultCompiler();
-        compiler.setLexicalAnalyzer(createLexicalAnalyzer());
-        return compiler;
-    }
-
-    private static class SimpleCodeToStringConverter extends AbstractCodeToStringConverter {
-
-        public SimpleCodeToStringConverter() {
-            super();
-            initFunctions();
-        }
-
-        private void initFunctions() {
-            ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
-            SymbolTable symbolTable = manager.getSymbolTable("SQL");
-            for (Function function : symbolTable.functions()) {
-                this.addSupportedFunction(function.name());
-            }
-            symbolTable = manager.getSymbolTable("OGC");
-            for (Function function : symbolTable.functions()) {
-                this.addSupportedFunction(function.name());
-            }
-        }
-
-        @Override
-        protected String functionToString(String functionName, Codes args) {
-            switch (functionName.toLowerCase()) {
-                case "date":
-                    return "DATE " + toString(args.get(0)) + " ";
-                case "time":
-                    return "TIME " + toString(args.get(0)) + " ";
-                case "timestamp":
-                    return "TIMESTAMP " + toString(args.get(0)) + " ";
-            }
-            return super.functionToString(functionName, args);
-        }
-
-    }
-        
-    public void testSimpleExpression() {
-        String source = "(precio + 10) * 2 + 20 + 30 / 2";
-
-        CodeToStringConverter converter = new SimpleCodeToStringConverter();
-        Compiler compiler = createCompiler();
-        
-        Code code = compiler.compileExpression(source);
-        assertEquals("(((\"precio\" + 10) * 2) + 20) + (30 / 2)", converter.toString(code));
-    }    
-
-    public void testFunctionExpression1() {
-        String source = "(precio + 10) * abs(2 + 20) + 30 / 2";
-
-        CodeToStringConverter converter = new SimpleCodeToStringConverter();
-        Compiler compiler = createCompiler();
-        
-        Code code = compiler.compileExpression(source);
-        assertEquals(true, converter.isValid(code));
-        assertEquals("((\"precio\" + 10) * (abs(2 + 20))) + (30 / 2)", converter.toString(code));
-    }    
-}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCodeToValue.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCodeToValue.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCodeToValue.java	(revision 44198)
@@ -0,0 +1,282 @@
+package org.gvsig.expresionevaluator.impl;
+
+import static junit.framework.Assert.assertEquals;
+import junit.framework.TestCase;
+import org.cresques.cts.IProjection;
+import org.gvsig.expressionevaluator.Code;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
+import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
+import org.gvsig.expressionevaluator.ExpressionUtils;
+import org.gvsig.expressionevaluator.LexicalAnalyzer;
+import org.gvsig.fmap.crs.CRSFactory;
+import org.gvsig.fmap.geom.GeometryUtils;
+import org.gvsig.fmap.geom.exception.CreateGeometryException;
+import org.gvsig.fmap.geom.primitive.Point;
+import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
+
+public class TestCodeToValue extends TestCase {
+    
+    public TestCodeToValue(String testName) {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        new DefaultLibrariesInitializer().fullInitialize();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    // TODO add test methods here. The name must begin with 'test'. For example:
+    // public void testHello() {}
+    
+    protected LexicalAnalyzer createLexicalAnalyzer() {
+        ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
+        LexicalAnalyzer lexer = manager.createLexicalAnalyzer();
+        return lexer;
+    }
+
+    protected org.gvsig.expressionevaluator.Compiler createCompiler() {
+        ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
+        org.gvsig.expressionevaluator.Compiler compiler = manager.createCompiler();
+        compiler.setLexicalAnalyzer(createLexicalAnalyzer());
+        return compiler;
+    }
+    
+    public Code compileExpression(String source) {
+        org.gvsig.expressionevaluator.Compiler compiler = createCompiler();
+        Code code = compiler.compileExpression(source);
+        return code;
+    }
+    
+    public void testIdentifier1() {
+        String source = "precio";
+
+        Code code = compileExpression(source);
+        assertEquals("\"precio\"", code.toValue().toString());
+    }
+
+    public void testIdentifier2() {
+        org.gvsig.expressionevaluator.Compiler compiler = createCompiler();
+        compiler.getLexicalAnalyzer().setUseBracketsForIdentifiers(true);
+
+        String source = "[precio]";
+
+        Code code = compiler.compileExpression(source);
+        assertEquals("\"precio\"", code.toValue().toString());
+    }
+
+    public void testIdentifier3() {
+        String source = "\"precio\"";
+
+        Code code = compileExpression(source);
+        assertEquals("\"precio\"", code.toValue().toString());
+    }
+
+
+    public void testTrue() {
+        String source = "true";
+
+        Code code = compileExpression(source);
+        assertEquals("TRUE", code.toValue().toString());
+    }
+
+    public void testFalse() {
+        String source = "false";
+
+        Code code = compileExpression(source);
+        assertEquals("FALSE", code.toValue().toString());
+    }
+
+    public void testNull() {
+        String source = "null";
+
+        Code code = compileExpression(source);
+        assertEquals("NULL", code.toValue().toString());
+    }
+
+    public void testNotTrue() {
+        String source = "not true";
+
+        Code code = compileExpression(source);
+        assertEquals("NOT(TRUE)", code.toValue().toString());
+    }
+
+    public void testInteger() {
+        String source = "23";
+
+        Code code = compileExpression(source);
+        assertEquals("23", code.toValue().toString());
+    }
+
+    public void operator(String operatorName) {
+        String source = "precio " + operatorName + " 23";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"precio\" "+ operatorName + " 23)", code.toValue().toString());
+    }
+    
+    public void testOperators() {
+
+        operator("=");
+        operator("<>");
+        operator(">");
+        operator(">=");
+        operator("<");
+        operator("<=");
+        operator("LIKE");
+        operator("ILIKE");
+        operator("||");
+        operator("+");
+        operator("-");
+        operator("*");
+        operator("OR");
+        operator("AND");
+        operator("%");
+        operator("IS");
+
+        operator("~");
+    }
+
+//    public void testILike() {
+//        String source = "precio ILike 23";
+//
+//        Code code = compileExpression(source);
+//        assertEquals("LOWER(\"precio\") LIKE LOWER(23)", code.toValue().toString());
+//    }
+    
+    public void testAddMul() {
+        String source = "precio + 10 * 2 + 20 + 30";
+
+        Code code = compileExpression(source);
+        assertEquals("(((\"precio\" + (10 * 2)) + 20) + 30)", code.toValue().toString());
+    }
+    
+    public void testAddMulPar() {
+        String source = "(precio + 10) * 2 + 20 + 30";
+
+        Code code = compileExpression(source);
+        assertEquals("((((\"precio\" + 10) * 2) + 20) + 30)", code.toValue().toString());
+    }
+    
+    public void testAbs() {
+        String source = "precio + abs(10)";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"precio\" + abs(10))", code.toValue().toString());
+    }
+    
+    public void testAbs2() {
+        String source = "precio + abs(-10)";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"precio\" + abs(-(10)))", code.toValue().toString());
+    }
+    
+    public void testPI() {
+        String source = "precio + PI()";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"precio\" + PI())", code.toValue().toString());
+    }
+    
+    public void testCeil() {
+        String source = "precio + CEIL(PI())";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"precio\" + CEIL(PI()))", code.toValue().toString());
+    }
+    
+    public void testGetitem1() {
+        String source = "LIST('uno','dos','tres')[1]" ;
+
+        Code code = compileExpression(source);
+        assertEquals("GETITEM(LIST('uno', 'dos', 'tres'), 1)", code.toValue().toString());
+    }
+    
+    public void testConcat() {
+        String source = "CONCAT(precio,' euros')";
+
+        Code code = compileExpression(source);
+        assertEquals("CONCAT(\"precio\", ' euros')", code.toValue().toString());
+    }
+    
+    public void test1() {
+        String source = "NOMBRE03 = 'Torre d''En Besora (la)'";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"NOMBRE03\" = 'Torre d''En Besora (la)')", code.toValue().toString());
+    }
+    
+    public void test2() {
+        org.gvsig.expressionevaluator.Compiler compiler = createCompiler();
+        compiler.getLexicalAnalyzer().setUseBracketsForIdentifiers(true);
+
+        String source = "[1990] = 0.168873933773767";
+
+        Code code = compiler.compileExpression(source);
+        assertEquals("(\"1990\" = 0.168873933773767)", code.toValue().toString());
+    }
+
+    public void test2fields() {
+        org.gvsig.expressionevaluator.Compiler compiler = createCompiler();
+        compiler.getLexicalAnalyzer().setUseBracketsForIdentifiers(true);
+
+        String source = "[1990] = [precio]";
+
+        Code code = compiler.compileExpression(source);
+        assertEquals("(\"1990\" = \"precio\")", code.toValue().toString());
+    }
+    
+    
+    public void testInvokeFunction1() {
+        String source = "ST_Area(GEOMETRY)";
+
+        Code code = compileExpression(source);
+        assertEquals("ST_Area(\"GEOMETRY\")", code.toValue().toString());
+    }
+
+    public void test3() throws CreateGeometryException {
+        ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder();
+
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        Point point = GeometryUtils.createPoint(10, 20);
+
+        builder.set(        
+            builder.ST_Intersects(
+              builder.geometry(point,proj),
+              builder.variable("the_geom")
+            )
+        );
+        Code code = compileExpression(builder.toString());
+        assertEquals(
+                "ST_Intersects(ST_GeomFromWKB(DECODE('000000000140240000000000004034000000000000', 'hex'), 4326), \"the_geom\")",
+                code.toValue().toString()
+        );
+    }
+    
+    public void test4() throws CreateGeometryException {
+        ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder();
+
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        Point point = GeometryUtils.createPoint(10, 20);
+
+        builder.set(        
+            builder.function("ST_Intersects2",
+                builder.geometry(point,proj),
+                builder.variable("the_geom")
+            )
+        );
+        Code code = compileExpression(builder.toString());
+        assertEquals(
+                "ST_Intersects2(ST_GeomFromWKB(DECODE('000000000140240000000000004034000000000000', 'hex'), 4326), \"the_geom\")",
+                code.toValue().toString()
+        );
+    }
+    
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCompiler.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCompiler.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCompiler.java	(revision 44198)
@@ -117,7 +117,7 @@
 
         Compiler compiler = createCompiler();
         Code code = compiler.compileExpression(source);
-        assertEquals(operatorName+"(\"precio\", 23)", code.toString());
+        assertEquals("(\"precio\" "+ operatorName + " 23)", code.toString());
     }
     
     public void testOperators() {
@@ -148,7 +148,7 @@
         Compiler compiler = createCompiler();
         
         Code code = compiler.compileExpression(source);
-        assertEquals("+(+(+(\"precio\", *(10, 2)), 20), 30)", code.toString());
+        assertEquals("(((\"precio\" + (10 * 2)) + 20) + 30)", code.toString());
     }
     
     public void testAddMulPar() {
@@ -157,7 +157,7 @@
         Compiler compiler = createCompiler();
         
         Code code = compiler.compileExpression(source);
-        assertEquals("+(+(*(+(\"precio\", 10), 2), 20), 30)", code.toString());
+        assertEquals("((((\"precio\" + 10) * 2) + 20) + 30)", code.toString());
     }
     
     public void testAbs() {
@@ -166,7 +166,7 @@
         Compiler compiler = createCompiler();
         
         Code code = compiler.compileExpression(source);
-        assertEquals("+(\"precio\", abs(10))", code.toString());
+        assertEquals("(\"precio\" + abs(10))", code.toString());
     }
     
     public void testAbs2() {
@@ -175,7 +175,7 @@
         Compiler compiler = createCompiler();
         
         Code code = compiler.compileExpression(source);
-        assertEquals("+(\"precio\", abs(NEGATE(10)))", code.toString());
+        assertEquals("(\"precio\" + abs(-(10)))", code.toString());
     }
     
     public void testPI() {
@@ -184,7 +184,7 @@
         Compiler compiler = createCompiler();
         
         Code code = compiler.compileExpression(source);
-        assertEquals("+(\"precio\", PI())", code.toString());
+        assertEquals("(\"precio\" + PI())", code.toString());
     }
     
     public void testCeil() {
@@ -193,7 +193,7 @@
         Compiler compiler = createCompiler();
         
         Code code = compiler.compileExpression(source);
-        assertEquals("+(\"precio\", CEIL(PI()))", code.toString());
+        assertEquals("(\"precio\" + CEIL(PI()))", code.toString());
     }
     
     public void testGetitem1() {
@@ -220,7 +220,7 @@
         Compiler compiler = createCompiler();
         
         Code code = compiler.compileExpression(source);
-        assertEquals("=(\"NOMBRE03\", 'Torre d'En Besora (la)')", code.toString());
+        assertEquals("(\"NOMBRE03\" = 'Torre d''En Besora (la)')", code.toString());
     }
     
     public void test2() {
@@ -230,7 +230,7 @@
         String source = "[1990] = 0.168873933773767";
 
         Code code = compiler.compileExpression(source);
-        assertEquals("=(\"1990\", 0.168873933773767)", code.toString());
+        assertEquals("(\"1990\" = 0.168873933773767)", code.toString());
     }
 
     public void test2fields() {
@@ -240,7 +240,7 @@
         String source = "[1990] = [precio]";
 
         Code code = compiler.compileExpression(source);
-        assertEquals("=(\"1990\", \"precio\")", code.toString());
+        assertEquals("(\"1990\" = \"precio\")", code.toString());
     }
     
     
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestExpressionBuilderFormatter.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestExpressionBuilderFormatter.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestExpressionBuilderFormatter.java	(revision 44198)
@@ -0,0 +1,463 @@
+package org.gvsig.expresionevaluator.impl;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import junit.framework.TestCase;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.cresques.cts.IProjection;
+import org.gvsig.expressionevaluator.Formatter;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Constant;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Function;
+import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
+import org.gvsig.expressionevaluator.impl.DefaultExpressionBuilder;
+import org.gvsig.fmap.crs.CRSFactory;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.GeometryUtils;
+import org.gvsig.fmap.geom.exception.CreateGeometryException;
+import org.gvsig.fmap.geom.primitive.Point;
+import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
+
+public class TestExpressionBuilderFormatter extends TestCase {
+
+    private static class MyFormatter implements Formatter<Value> {
+    
+        private class Formatter_constant_bytearray implements Formatter<Value> {
+
+            @Override
+            public boolean canApply(Value value) {
+                if( value instanceof Constant ) {
+                    return ((Constant)value).value() instanceof byte[];
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Value constant) {
+                return builder.bytearray_x((byte[]) ((Constant)constant).value());
+            }
+        }
+
+        private class Formatter_constant_geometry implements Formatter<Value> {
+
+            @Override
+            public boolean canApply(Value value) {
+                if( value instanceof Constant ) {
+                    return ((Constant)value).value() instanceof Geometry;
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Value constant) {
+                Geometry geometry = (Geometry) ((Constant)constant).value();
+                switch (builder.geometry_support_type()) {
+                    case EWKB:
+                        return MessageFormat.format(
+                                "ST_GeomFromEWKB(({0}), ({1}))",
+                                builder.bytearray_x(GeometryUtils.toEWKB(geometry)),
+                                String.valueOf(builder.srs_id(geometry.getProjection()))
+                        );
+                    case WKB:
+                        return MessageFormat.format(
+                                "ST_GeomFromWKB(({0}), ({1}))",
+                                builder.bytearray_x(GeometryUtils.toWKB(geometry)),
+                                String.valueOf(builder.srs_id(geometry.getProjection()))
+                        );
+                    case WKT:
+                    default:
+                        return MessageFormat.format(
+                                "ST_GeomFromText({0}, ({1}))",
+                                builder.string(GeometryUtils.toWKT(geometry)),
+                                String.valueOf(builder.srs_id(geometry.getProjection()))
+                        );
+                }
+            }
+        }
+
+        private class Formatter_ST_intersects implements Formatter<Value> {
+
+            @Override
+            public boolean canApply(Value value) {
+                if( value instanceof Function ) {
+                    return StringUtils.equalsIgnoreCase("ST_intersects",((Function)value).name());
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Value function) {
+                List<Value> parameters = ((Function)function).parameters();
+                String p1 = parameters.get(0).toString(formatter());
+                String p2 = parameters.get(1).toString(formatter());
+                String r = MessageFormat.format(
+                        "( (({0}) && ({1})) AND ST_Intersects(({0}),({1}) ))", 
+                        p1,
+                        p2
+                );
+                return r;
+            }
+        }
+
+        private class Formatter_ST_GeomFromEWKB implements Formatter<Value> {
+
+            @Override
+            public boolean canApply(Value value) {
+                if( value instanceof Function ) {
+                    return StringUtils.equalsIgnoreCase("ST_GeomFromEWKB",((Function)value).name());
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Value function) {
+                List<Value> parameters = ((Function)function).parameters();
+                String p1 = parameters.get(0).toString(formatter());
+                String p2 = parameters.get(1).toString(formatter());
+                String r = MessageFormat.format(
+                        "GeomFromWKB({0}, {1})", 
+                        p1,
+                        p2
+                );
+                return r;
+            }
+        }
+    
+        private class Formatter_IFNULL implements Formatter<Value> {
+
+            @Override
+            public boolean canApply(Value value) {
+                if( value instanceof Function ) {
+                    return StringUtils.equalsIgnoreCase("IFNULL",((Function)value).name());
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Value function) {
+                List<Value> parameters = ((Function)function).parameters();
+                String p1 = parameters.get(0).toString(formatter());
+                String p2 = parameters.get(1).toString(formatter());
+                String p3 = parameters.get(2).toString(formatter());
+                String r = MessageFormat.format(
+                        "NVL2({0}, {1}, {2})", 
+                        p1,
+                        p3,
+                        p2
+                );
+                return r;
+            }
+        }
+    
+        private class Formatter_ST_AsEWKB implements Formatter<Value> {
+
+            @Override
+            public boolean canApply(Value value) {
+                if( value instanceof Function ) {
+                    return StringUtils.equalsIgnoreCase("ST_AsEWKB",((Function)value).name());
+                }
+                return false;
+            }
+
+            public String format(Value function) {
+                List<Value> parameters = ((Function)function).parameters();
+                String p1 = parameters.get(0).toString(formatter());
+                String r = MessageFormat.format(
+                        "AsWKB(({0}))", 
+                        p1
+                );
+                return r;
+            }
+        }
+        
+        private class Formatter_NOT_IS_NULL implements Formatter<Value> {
+
+            @Override
+            public boolean canApply(Value value) {
+                if( value instanceof Function ) {
+                    return StringUtils.equalsIgnoreCase("NOT_IS_NULL",((Function)value).name());
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Value function) {
+                List<Value> parameters = ((Function)function).parameters();
+                String p1 = parameters.get(0).toString(MyFormatter.this);
+                String r = MessageFormat.format(
+                        "( ({0}) IS NOT NULL )", 
+                        p1
+                );
+                return r;
+            }
+        }
+
+        private final Formatter<Value>[] formatters;
+        private final ExpressionBuilder builder;
+
+        public MyFormatter(ExpressionBuilder builder) {
+            this.builder = builder;
+            this.formatters = new Formatter[] {
+                new Formatter_IFNULL(),
+                new Formatter_NOT_IS_NULL(),
+                new Formatter_ST_AsEWKB(),
+                new Formatter_ST_GeomFromEWKB(),
+                new Formatter_constant_bytearray(),
+                new Formatter_constant_geometry(),
+                new Formatter_ST_intersects()
+            };
+        }
+
+        @Override
+        public boolean canApply(Value value) {
+            for (Formatter<Value> formatter : formatters) {
+                if( formatter.canApply(value) ) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        @Override
+        public String format(Value value) {
+            for (Formatter<Value> formatter : formatters) {
+                if( formatter.canApply(value) ) {
+                    return formatter.format(value);
+                }
+            }
+            return value.toString(this);
+        }
+        
+        private Formatter formatter() {
+            return this;
+        }
+    }
+    
+    public TestExpressionBuilderFormatter(String testName) {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        new DefaultLibrariesInitializer().fullInitialize();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    // TODO add test methods here. The name must begin with 'test'. For example:
+    // public void testHello() {}
+    
+    List<String> getVariableNames(ExpressionBuilder builder) {
+        List<String> vars = new ArrayList<>();
+        for (Variable var : builder.variables()) {
+            vars.add(var.name());
+        }
+        return vars;
+    }
+    
+    List<String> getParameterNames(ExpressionBuilder builder) {
+        List<String> params = new ArrayList<>();
+        for (Parameter param : builder.parameters()) {
+            String s;
+            switch(param.type()) {
+                case Constant:
+                    Object value = param.value();
+                    if( value==null ) {
+                        s = "null";
+                    } else if( value instanceof String ) {
+                        s = "'" + (String)value + "'";
+                    } else {
+                        s = value.toString();
+                    }    
+                    break;
+                case Geometry:
+                case Variable:
+                default:
+                    s = "\"" + param.name() + "\"";
+            }
+            params.add(s);
+        }
+        return params;
+    }
+    
+    public void test2() {
+        ExpressionBuilder builder = new DefaultExpressionBuilder();
+        
+        builder.and(
+          builder.eq(
+            builder.lower(builder.variable("colum_name_c")),
+            builder.parameter("colum_name_p")
+          )
+        );
+        builder.and(
+            builder.group(
+                builder.or(
+                    builder.like(
+                        builder.lower( builder.variable("uno")),
+                        builder.constant("%10")
+                    ),
+                    builder.lt(
+                        builder.variable("dos"),
+                        builder.constant(-3.5)
+                    )
+                )
+            )
+        );
+        builder.and(
+                builder.ST_Intersects(
+                    builder.variable("geom1"), 
+                    builder.ST_Envelope(
+                        builder.ST_GeomFromWKB(
+                                builder.parameter("geom2"), 
+                                builder.parameter().value(4326).as_constant()
+                        )
+                    )
+                )
+        );
+        builder.and(
+            builder.gt(
+                builder.variable("tres"),
+                builder.constant(123456789)
+            )
+        );
+        assertEquals(
+                "( (LOWER(\"colum_name_c\")) = (?) ) AND ( ( (LOWER(\"uno\")) LIKE ('%10') ) OR ( (\"dos\") < (-3.5) ) ) AND ST_Intersects((\"geom1\"), (ST_Envelope(ST_GeomFromWKB((?), (?))))) AND ( (\"tres\") > (123456789) )",
+                builder.toString()
+        );
+        assertEquals(
+                "( (LOWER(\"colum_name_c\")) = (?) ) AND ( ( (LOWER(\"uno\")) LIKE ('%10') ) OR ( (\"dos\") < (-3.5) ) ) AND ( ((\"geom1\") && (ST_Envelope(ST_GeomFromWKB((?), (?))))) AND ST_Intersects((\"geom1\"),(ST_Envelope(ST_GeomFromWKB((?), (?)))) )) AND ( (\"tres\") > (123456789) )",
+                builder.toString(new MyFormatter(builder))
+        );
+        
+        assertEquals(
+                "[colum_name_c, dos, geom1, tres, uno]",
+                ArrayUtils.toString(getVariableNames(builder))
+        );
+        assertEquals(
+                "[\"colum_name_p\", \"geom2\", 4326]",
+                ArrayUtils.toString(getParameterNames(builder))
+        );
+    }
+    
+    public void test3() throws CreateGeometryException {
+        ExpressionBuilder builder = new DefaultExpressionBuilder();
+                
+        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        
+        Point point = geometryManager.createPoint(10, 20, Geometry.SUBTYPES.GEOM2D);
+        builder.set(        
+            builder.ST_Intersects(
+              builder.geometry(point,proj),
+              builder.variable("the_geom")
+            )
+        );
+        builder.geometry_support_type(GeometrySupportType.WKT);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromText(('POINT (10 20)'), (4326))), (\"the_geom\"))",
+                builder.toString()
+        );
+        assertEquals(
+                "( ((ST_GeomFromText('POINT (10 20)', (4326))) && (\"the_geom\")) AND ST_Intersects((ST_GeomFromText('POINT (10 20)', (4326))),(\"the_geom\") ))",
+                builder.toString(new MyFormatter(builder))
+        );
+
+        builder.geometry_support_type(GeometrySupportType.WKB);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromWKB((DECODE('000000000140240000000000004034000000000000','hex')), (4326))), (\"the_geom\"))",
+                builder.toString()
+        );
+        assertEquals(
+                "( ((ST_GeomFromWKB((x'000000000140240000000000004034000000000000'), (4326))) && (\"the_geom\")) AND ST_Intersects((ST_GeomFromWKB((x'000000000140240000000000004034000000000000'), (4326))),(\"the_geom\") ))",
+                builder.toString(new MyFormatter(builder))
+        );
+        assertEquals(
+                "[the_geom]",
+                ArrayUtils.toString(getVariableNames(builder))
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(getParameterNames(builder))
+        );
+    }
+    
+    public void test4() throws CreateGeometryException {
+        ExpressionBuilder builder = new DefaultExpressionBuilder();
+                
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        
+        builder.and(
+                builder.ST_Intersects(
+                    builder.variable("geom1"), 
+                    builder.ST_Envelope(
+                        builder.ST_GeomFromWKB(
+                                builder.parameter("geom2"), 
+                                builder.parameter().value(proj).as_constant()
+                        )
+                    )
+                )
+        );
+        
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((\"geom1\"), (ST_Envelope(ST_GeomFromWKB((?), (?)))))",
+                builder.toString()
+        );
+        assertEquals(
+                "( ((\"geom1\") && (ST_Envelope(ST_GeomFromWKB((?), (?))))) AND ST_Intersects((\"geom1\"),(ST_Envelope(ST_GeomFromWKB((?), (?)))) ))",
+                builder.toString(new MyFormatter(builder))
+        );
+        assertEquals(
+                "[geom1]",
+                ArrayUtils.toString(getVariableNames(builder))
+        );
+        assertEquals(
+                "[\"geom2\", 4326]",
+                ArrayUtils.toString(getParameterNames(builder))
+        );
+    }
+        
+    public void test5() throws CreateGeometryException {
+        ExpressionBuilder builder = new DefaultExpressionBuilder();
+                
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        
+        builder.and(
+                builder.eq(
+                        builder.ST_SRID( builder.variable("geom") ),
+                        builder.srs(proj)
+                )
+        );
+        
+        System.out.println(builder.toString());
+        assertEquals(
+                "( (ST_SRID(\"geom\")) = (4326) )",
+                builder.toString()
+        );
+        assertEquals(
+                "( (ST_SRID(\"geom\")) = (4326) )",
+                builder.toString(new MyFormatter(builder))
+        );
+        assertEquals(
+                "[geom]",
+                ArrayUtils.toString(getVariableNames(builder))
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(getParameterNames(builder))
+        );
+    }
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCase1.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCase1.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCase1.java	(revision 44198)
@@ -5,7 +5,6 @@
 import org.cresques.cts.IProjection;
 import org.gvsig.expressionevaluator.Code;
 import org.gvsig.expressionevaluator.ExpressionBuilder;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Config;
 import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType;
 import org.gvsig.expressionevaluator.LexicalAnalyzer;
 import org.gvsig.expressionevaluator.impl.DefaultCompiler;
@@ -116,13 +115,13 @@
                         builder.column("GEOMETRY")
                 )
         );
-        builder.getConfig().set(Config.geometry_type_support, GeometrySupportType.WKT);
+        builder.geometry_support_type(GeometrySupportType.WKT);
         System.out.println(expr2.toString());
         assertEquals(
-                "( (\"campo1\") > (10) ) AND ST_Intersects((ST_GeomFromText('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))', (4326))), (\"GEOMETRY\"))",
+                "( (\"campo1\") > (10) ) AND ST_Intersects((ST_GeomFromText(('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))'), (4326))), (\"GEOMETRY\"))",
                 expr2.toString()
         );
-        builder.getConfig().set(Config.geometry_type_support, GeometrySupportType.WKB);
+        builder.geometry_support_type(GeometrySupportType.WKB);
         System.out.println(expr2.toString());
         assertEquals(
                 "( (\"campo1\") > (10) ) AND ST_Intersects((ST_GeomFromWKB((DECODE('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000','hex')), (4326))), (\"GEOMETRY\"))",
@@ -145,19 +144,19 @@
         Compiler compiler = createCompiler();
         Code code;
         
-        builder.getConfig().set(Config.geometry_type_support, GeometrySupportType.WKT);
+        builder.geometry_support_type(GeometrySupportType.WKT);
         code = compiler.compileExpression(expr2.toString());
         System.out.println(code.toString());
         assertEquals(
-                "AND(>(\"campo1\", 10), ST_Intersects(ST_GeomFromText('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))', 4326), \"GEOMETRY\"))", 
+                "((\"campo1\" > 10) AND ST_Intersects(ST_GeomFromText('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))', 4326), \"GEOMETRY\"))", 
                 code.toString()
         );
 
-        builder.getConfig().set(Config.geometry_type_support, GeometrySupportType.WKB);
+        builder.geometry_support_type(GeometrySupportType.WKB);
         code = compiler.compileExpression(expr2.toString());
         System.out.println(code.toString());
         assertEquals(
-                "AND(>(\"campo1\", 10), ST_Intersects(ST_GeomFromWKB(DECODE('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000', 'hex'), 4326), \"GEOMETRY\"))", 
+                "((\"campo1\" > 10) AND ST_Intersects(ST_GeomFromWKB(DECODE('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000', 'hex'), 4326), \"GEOMETRY\"))", 
                 code.toString()
         );
         
@@ -166,7 +165,7 @@
     public void testRunExpression() throws Exception {
 
         ExpressionBuilder builder = new DefaultExpressionBuilder();
-        builder.getConfig().set(Config.geometry_type_support, GeometrySupportType.WKB);
+        builder.geometry_support_type(GeometrySupportType.WKB);
         
         String expr2 = builder.and(
             builder.custom(this.createExpr1()),
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCodeFormatter.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCodeFormatter.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestCodeFormatter.java	(revision 44198)
@@ -0,0 +1,542 @@
+package org.gvsig.expresionevaluator.impl;
+
+import java.text.MessageFormat;
+import static junit.framework.Assert.assertEquals;
+import junit.framework.TestCase;
+import org.apache.commons.lang3.StringUtils;
+import org.cresques.cts.IProjection;
+import org.gvsig.expressionevaluator.Code;
+import org.gvsig.expressionevaluator.Code.Caller;
+import org.gvsig.expressionevaluator.Code.Constant;
+import org.gvsig.expressionevaluator.Codes;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
+import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
+import org.gvsig.expressionevaluator.ExpressionUtils;
+import org.gvsig.expressionevaluator.Formatter;
+import org.gvsig.expressionevaluator.LexicalAnalyzer;
+import org.gvsig.fmap.crs.CRSFactory;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryUtils;
+import org.gvsig.fmap.geom.exception.CreateGeometryException;
+import org.gvsig.fmap.geom.primitive.Point;
+import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
+
+public class TestCodeFormatter extends TestCase {
+
+    private static class MyFormatter implements Formatter<Code> {
+    
+        private class Formatter_constant_bytearray implements Formatter<Code> {
+
+            @Override
+            public boolean canApply(Code code) {
+                if( code instanceof Constant ) {
+                    return ((Constant)code).value() instanceof byte[];
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Code code) {
+                return builder.bytearray_x((byte[]) ((Constant)code).value());
+            }
+        }
+
+        private class Formatter_constant_geometry implements Formatter<Code> {
+
+            @Override
+            public boolean canApply(Code code) {
+                if( code instanceof Constant ) {
+                    return ((Constant)code).value() instanceof Geometry;
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Code code) {
+                Geometry geometry = (Geometry) ((Constant)code).value();
+                return MessageFormat.format(
+                        "ST_GeomFromWKB(({0}), ({1}))",
+                        builder.bytearray_x(GeometryUtils.toWKB(geometry)),
+                        String.valueOf(builder.srs_id(geometry.getProjection()))
+                );
+                
+            }
+        }
+
+        
+        private class Formatter_ST_intersects_H2Spatial implements Formatter<Code> {
+            // Need for H2Spatial
+            @Override
+            public boolean canApply(Code code) {
+                if( code instanceof Caller ) {
+                    return StringUtils.equalsIgnoreCase("ST_intersects",((Caller)code).name());
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Code code) {
+                Codes parameters = ((Caller)code).parameters();
+                String p1 = parameters.get(0).toString(MyFormatter.this);
+                String p2 = parameters.get(1).toString(MyFormatter.this);
+                String r = MessageFormat.format(
+                        "( (({0}) && ({1})) AND ST_Intersects(({0}),({1}) ))", 
+                        p1,
+                        p2
+                );
+                return r;
+            }
+        }
+  
+        private class Formatter_ST_intersects_SpatiaLite implements Formatter<Code> {
+            // Need for SpatiaLite
+
+            private final String table;
+            private final String geomcolumn;
+
+            public Formatter_ST_intersects_SpatiaLite(String table, String geomcolumn) {
+                this.table = table;
+                this.geomcolumn = geomcolumn;
+            }
+
+            @Override
+            public boolean canApply(Code code) {
+                if( code instanceof Caller ) {
+                    return StringUtils.equalsIgnoreCase("ST_intersects2",((Caller)code).name());
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Code code) {
+                Codes parameters = ((Caller)code).parameters();
+                String p1 = parameters.get(0).toString(MyFormatter.this);
+                String p2 = parameters.get(1).toString(MyFormatter.this);
+                String r = MessageFormat.format(
+                    "(ST_Intersects({0},{1}) AND ROWID IN ( SELECT ROWID FROM SpatialIndex WHERE f_table_name = ''{2}'' AND f_geometry_column = ''{3}'' AND search_frame = \"{2}\".\"{3}\"))",
+                    p1,
+                    p2,
+                    table,
+                    geomcolumn
+                );
+                return r;
+            }
+        }
+  
+        private class Formatter_DECODE implements Formatter<Code> {
+            // Need for SpatiaLite 
+            @Override
+            public boolean canApply(Code code) {
+                if( code instanceof Caller ) {
+                    if( StringUtils.equalsIgnoreCase("DECODE",((Caller)code).name()) ) {
+                        Codes parameters = ((Caller)code).parameters();
+                        Code code_p1 = parameters.get(0);
+                        Code code_p2 = parameters.get(1);
+                        if( code_p1 instanceof Constant && code_p2 instanceof Constant ) {
+                            Object p1 = ((Constant)code_p1).value();
+                            Object p2 = ((Constant)code_p2).value();
+                            if( p1 instanceof String && p1 instanceof String && 
+                                StringUtils.equalsIgnoreCase((CharSequence) p2,"hex") ) {
+                                return true;
+                            }
+                        }
+                    }
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Code code) {
+                Codes parameters = ((Caller)code).parameters();
+                Object p1 = ((Constant)parameters.get(0)).value();
+                return "x'"+ (String)p1 + "'";
+            }
+        }
+  
+        private class Formatter_IFNULL implements Formatter<Code> {
+            // Need for H2Spatial
+            @Override
+            public boolean canApply(Code code) {
+                if( code instanceof Caller ) {
+                    return StringUtils.equalsIgnoreCase("IFNULL",((Caller)code).name());
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Code code) {
+                Codes parameters = ((Caller)code).parameters();
+                String p1 = parameters.get(0).toString(MyFormatter.this);
+                String p2 = parameters.get(1).toString(MyFormatter.this);
+                String p3 = parameters.get(2).toString(MyFormatter.this);
+                String r = MessageFormat.format(
+                        "NVL2({0}, {1}, {2})", 
+                        p1,
+                        p3,
+                        p2
+                );
+                return r;
+            }
+        }
+    
+        private class Formatter_ILIKE implements Formatter<Code> {
+            // Need for SpatiaLite
+            @Override
+            public boolean canApply(Code code) {
+                if( code instanceof Caller ) {
+                    return StringUtils.equalsIgnoreCase("ILIKE",((Caller)code).name());
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Code code) {
+                Codes parameters = ((Caller)code).parameters();
+                String p1 = parameters.get(0).toString(MyFormatter.this);
+                String p2 = parameters.get(1).toString(MyFormatter.this);
+                String r = MessageFormat.format(
+                        "LOWER({0}) LIKE LOWER({1})", 
+                        p1,
+                        p2
+                );
+                return r;
+            }
+        }
+    
+        private class Formatter_NOT_IS_NULL implements Formatter<Code> {
+            // Need for H2Spatial
+            @Override
+            public boolean canApply(Code code) {
+                if( code instanceof Caller ) {
+                    return StringUtils.equalsIgnoreCase("NOT_IS_NULL",((Caller)code).name());
+                }
+                return false;
+            }
+
+            @Override
+            public String format(Code code) {
+                Codes parameters = ((Caller)code).parameters();
+                String p1 = parameters.get(0).toString(MyFormatter.this);
+                String r = MessageFormat.format(
+                        "( ({0}) IS NOT NULL )", 
+                        p1
+                );
+                return r;
+            }
+        }
+
+        private final Formatter<Code>[] formatters;
+        private final ExpressionBuilder builder;
+
+        public MyFormatter() {
+            this.builder = ExpressionUtils.createExpressionBuilder();
+            this.formatters = new Formatter[] {
+//                new Formatter_constant_bytearray(),
+//                new Formatter_constant_geometry(),
+                new Formatter_IFNULL(),
+                new Formatter_NOT_IS_NULL(),
+                new Formatter_ST_intersects_H2Spatial(),
+                new Formatter_ST_intersects_SpatiaLite("mytable", "the_geom"),
+                new Formatter_ILIKE(),
+                new Formatter_DECODE(),
+            };
+        }
+
+        @Override
+        public boolean canApply(Code code) {
+            for (Formatter<Code> formatter : formatters) {
+                if( formatter.canApply(code) ) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        @Override
+        public String format(Code code) {
+            for (Formatter<Code> formatter : formatters) {
+                if( formatter.canApply(code) ) {
+                    return formatter.format(code);
+                }
+            }
+            return code.toString(this);
+        }
+        
+    }
+    
+    public TestCodeFormatter(String testName) {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        new DefaultLibrariesInitializer().fullInitialize();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    // TODO add test methods here. The name must begin with 'test'. For example:
+    // public void testHello() {}
+    
+    protected LexicalAnalyzer createLexicalAnalyzer() {
+        ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
+        LexicalAnalyzer lexer = manager.createLexicalAnalyzer();
+        return lexer;
+    }
+
+    protected org.gvsig.expressionevaluator.Compiler createCompiler() {
+        ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
+        org.gvsig.expressionevaluator.Compiler compiler = manager.createCompiler();
+        compiler.setLexicalAnalyzer(createLexicalAnalyzer());
+        return compiler;
+    }
+    
+    private Formatter<Code> formatter() {
+        return new MyFormatter();
+    }
+
+    public Code compileExpression(String source) {
+        org.gvsig.expressionevaluator.Compiler compiler = createCompiler();
+        Code code = compiler.compileExpression(source);
+        return code;
+    }
+    
+    public void testIdentifier1() {
+        String source = "precio";
+
+        Code code = compileExpression(source);
+        assertEquals("\"precio\"", code.toString(formatter()));
+    }
+
+    public void testIdentifier2() {
+        org.gvsig.expressionevaluator.Compiler compiler = createCompiler();
+        compiler.getLexicalAnalyzer().setUseBracketsForIdentifiers(true);
+
+        String source = "[precio]";
+
+        Code code = compiler.compileExpression(source);
+        assertEquals("\"precio\"", code.toString(formatter()));
+    }
+
+    public void testIdentifier3() {
+        String source = "\"precio\"";
+
+        Code code = compileExpression(source);
+        assertEquals("\"precio\"", code.toString(formatter()));
+    }
+
+
+    public void testTrue() {
+        String source = "true";
+
+        Code code = compileExpression(source);
+        assertEquals("TRUE", code.toString(formatter()));
+    }
+
+    public void testFalse() {
+        String source = "false";
+
+        Code code = compileExpression(source);
+        assertEquals("FALSE", code.toString(formatter()));
+    }
+
+    public void testNull() {
+        String source = "null";
+
+        Code code = compileExpression(source);
+        assertEquals("NULL", code.toString(formatter()));
+    }
+
+    public void testNotTrue() {
+        String source = "not true";
+
+        Code code = compileExpression(source);
+        assertEquals("NOT(TRUE)", code.toString(formatter()));
+    }
+
+    public void testInteger() {
+        String source = "23";
+
+        Code code = compileExpression(source);
+        assertEquals("23", code.toString(formatter()));
+    }
+
+    public void operator(String operatorName) {
+        String source = "precio " + operatorName + " 23";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"precio\" "+ operatorName + " 23)", code.toString(formatter()));
+    }
+    
+    public void testOperators() {
+
+        operator("=");
+        operator("<>");
+        operator(">");
+        operator(">=");
+        operator("<");
+        operator("<=");
+        operator("LIKE");
+//        operator("ILIKE");
+        operator("||");
+        operator("+");
+        operator("-");
+        operator("*");
+        operator("OR");
+        operator("AND");
+        operator("%");
+        operator("IS");
+
+        operator("~");
+    }
+
+    public void testILike() {
+        String source = "precio ILike 23";
+
+        Code code = compileExpression(source);
+        assertEquals("LOWER(\"precio\") LIKE LOWER(23)", code.toString(formatter()));
+    }
+    
+    public void testAddMul() {
+        String source = "precio + 10 * 2 + 20 + 30";
+
+        Code code = compileExpression(source);
+        assertEquals("(((\"precio\" + (10 * 2)) + 20) + 30)", code.toString(formatter()));
+    }
+    
+    public void testAddMulPar() {
+        String source = "(precio + 10) * 2 + 20 + 30";
+
+        Code code = compileExpression(source);
+        assertEquals("((((\"precio\" + 10) * 2) + 20) + 30)", code.toString(formatter()));
+    }
+    
+    public void testAbs() {
+        String source = "precio + abs(10)";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"precio\" + abs(10))", code.toString(formatter()));
+    }
+    
+    public void testAbs2() {
+        String source = "precio + abs(-10)";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"precio\" + abs(-(10)))", code.toString(formatter()));
+    }
+    
+    public void testPI() {
+        String source = "precio + PI()";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"precio\" + PI())", code.toString(formatter()));
+    }
+    
+    public void testCeil() {
+        String source = "precio + CEIL(PI())";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"precio\" + CEIL(PI()))", code.toString(formatter()));
+    }
+    
+    public void testGetitem1() {
+        String source = "LIST('uno','dos','tres')[1]" ;
+
+        Code code = compileExpression(source);
+        assertEquals("GETITEM(LIST('uno', 'dos', 'tres'), 1)", code.toString(formatter()));
+    }
+    
+    public void testConcat() {
+        String source = "CONCAT(precio,' euros')";
+
+        Code code = compileExpression(source);
+        assertEquals("CONCAT(\"precio\", ' euros')", code.toString(formatter()));
+    }
+    
+    public void test1() {
+        String source = "NOMBRE03 = 'Torre d''En Besora (la)'";
+
+        Code code = compileExpression(source);
+        assertEquals("(\"NOMBRE03\" = 'Torre d''En Besora (la)')", code.toString(formatter()));
+    }
+    
+    public void test2() {
+        org.gvsig.expressionevaluator.Compiler compiler = createCompiler();
+        compiler.getLexicalAnalyzer().setUseBracketsForIdentifiers(true);
+
+        String source = "[1990] = 0.168873933773767";
+
+        Code code = compiler.compileExpression(source);
+        assertEquals("(\"1990\" = 0.168873933773767)", code.toString(formatter()));
+    }
+
+    public void test2fields() {
+        org.gvsig.expressionevaluator.Compiler compiler = createCompiler();
+        compiler.getLexicalAnalyzer().setUseBracketsForIdentifiers(true);
+
+        String source = "[1990] = [precio]";
+
+        Code code = compiler.compileExpression(source);
+        assertEquals("(\"1990\" = \"precio\")", code.toString(formatter()));
+    }
+    
+    
+    public void testInvokeFunction1() {
+        String source = "ST_Area(GEOMETRY)";
+
+        Code code = compileExpression(source);
+        assertEquals("ST_Area(\"GEOMETRY\")", code.toString(formatter()));
+    }
+
+    public void test3() throws CreateGeometryException {
+        ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder();
+
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        Point point = GeometryUtils.createPoint(10, 20);
+
+        builder.set(        
+            builder.ST_Intersects(
+              builder.geometry(point,proj),
+              builder.variable("the_geom")
+            )
+        );
+        Code code = compileExpression(builder.toString());
+        assertEquals(
+                "ST_Intersects(ST_GeomFromWKB(DECODE('000000000140240000000000004034000000000000', 'hex'), 4326), \"the_geom\")",
+                code.toString()
+        );
+        assertEquals(
+                "( ((ST_GeomFromWKB(x'000000000140240000000000004034000000000000', 4326)) && (\"the_geom\")) AND ST_Intersects((ST_GeomFromWKB(x'000000000140240000000000004034000000000000', 4326)),(\"the_geom\") ))",
+                code.toString(formatter())
+        );
+    }
+    
+    public void test4() throws CreateGeometryException {
+        ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder();
+
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        Point point = GeometryUtils.createPoint(10, 20);
+
+        builder.set(        
+            builder.function("ST_Intersects2",
+                builder.geometry(point,proj),
+                builder.variable("the_geom")
+            )
+        );
+        Code code = compileExpression(builder.toString());
+        assertEquals(
+                "ST_Intersects2(ST_GeomFromWKB(DECODE('000000000140240000000000004034000000000000', 'hex'), 4326), \"the_geom\")",
+                code.toString()
+        );
+        assertEquals(
+                "(ST_Intersects(ST_GeomFromWKB(x'000000000140240000000000004034000000000000', 4326),\"the_geom\") AND ROWID IN ( SELECT ROWID FROM SpatialIndex WHERE f_table_name = 'mytable' AND f_geometry_column = 'the_geom' AND search_frame = \"mytable\".\"the_geom\"))",
+                code.toString(formatter())
+        );
+    }
+    
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestGrammarCompiler.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestGrammarCompiler.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestGrammarCompiler.java	(revision 44198)
@@ -109,7 +109,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("IFF(=(\"V1\", 11), LET('V2', 22))", code.toString());
+        assertEquals("IFF((\"V1\" = 11), LET('V2', 22))", code.toString());
     }
 
     public void testIfThen2() {
@@ -118,7 +118,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("IFF(=(\"V1\", 11), LET('V2', 22))", code.toString());
+        assertEquals("IFF((\"V1\" = 11), LET('V2', 22))", code.toString());
     }
 
     public void testIfThen3() {
@@ -127,7 +127,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("IFF(=(\"V1\", 11), LET('V2', 22))", code.toString());
+        assertEquals("IFF((\"V1\" = 11), LET('V2', 22))", code.toString());
     }
 
     public void testIfThenElse() {
@@ -136,7 +136,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("IFF(=(\"V1\", 11), LET('V2', 11), LET('V2', 22))", code.toString());
+        assertEquals("IFF((\"V1\" = 11), LET('V2', 11), LET('V2', 22))", code.toString());
     }
 
     public void testIfThenBlock() {
@@ -145,7 +145,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("IFF(=(\"V1\", 11), BLOCK(LET('V2', 22), LET('V1', 10)))", code.toString());
+        assertEquals("IFF((\"V1\" = 11), BLOCK(LET('V2', 22), LET('V1', 10)))", code.toString());
     }
 
     public void testWhile() {
@@ -154,7 +154,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("WHILE(<(\"n\", 10), LET('n', +(\"n\", 1)))", code.toString());
+        assertEquals("WHILE((\"n\" < 10), LET('n', (\"n\" + 1)))", code.toString());
     }
 
     public void testWhileBlock() {
@@ -163,7 +163,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("WHILE(<(\"n\", 10), BLOCK(LET('n', +(\"n\", 1)), print(\"n\")))", code.toString());
+        assertEquals("WHILE((\"n\" < 10), BLOCK(LET('n', (\"n\" + 1)), print(\"n\")))", code.toString());
     }
 
     public void testCast() {
@@ -226,7 +226,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("CASE(LIKE(\"software\", '%gvSIG%'), 'gvSIG', 'Other')", code.toString());
+        assertEquals("CASE((\"software\" LIKE '%gvSIG%'), 'gvSIG', 'Other')", code.toString());
     }
 
     public void testCase1() {
@@ -235,7 +235,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("CASE(LIKE(\"software\", '%gvSIG%'), 'gvSIG', 'Other')", code.toString());
+        assertEquals("CASE((\"software\" LIKE '%gvSIG%'), 'gvSIG', 'Other')", code.toString());
     }
 
     public void testCase2() {
@@ -244,7 +244,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("CASE(AND(>=(\"Field_1\", 75), <=(\"Field_1\", 79)), AND(>=(\"Field_1\", 80), <=(\"Field_1\", 84)), 100, 110)", code.toString());
+        assertEquals("CASE(((\"Field_1\" >= 75) AND (\"Field_1\" <= 79)), ((\"Field_1\" >= 80) AND (\"Field_1\" <= 84)), 100, 110)", code.toString());
     }
     
     public void testCase3() {
@@ -253,7 +253,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("CASE(AND(>=(\"Field_1\", 75), <=(\"Field_1\", 79)), AND(>=(\"Field_1\", 80), <=(\"Field_1\", 84)), 100, 110, 120)", code.toString());
+        assertEquals("CASE(((\"Field_1\" >= 75) AND (\"Field_1\" <= 79)), ((\"Field_1\" >= 80) AND (\"Field_1\" <= 84)), 100, 110, 120)", code.toString());
     }
     
     public void testDef1() {
@@ -271,7 +271,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("CREATE_FUNCTION('test1', LIST('nombre'), print(+('Hola ', \"nombre\")))", code.toString());
+        assertEquals("CREATE_FUNCTION('test1', LIST('nombre'), print(('Hola ' + \"nombre\")))", code.toString());
     }
 
     public void testDef3() {
@@ -280,7 +280,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("CREATE_FUNCTION('test1', LIST('nombre'), BLOCK(RETURN(||('Hola ', \"nombre\"))))", code.toString());
+        assertEquals("CREATE_FUNCTION('test1', LIST('nombre'), BLOCK(RETURN(('Hola ' || \"nombre\"))))", code.toString());
     }
 
     public void testUseCase1() {
@@ -289,7 +289,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("BLOCK(LET('x', ''), FOREACH('n', list('hola', 'adios', 'fin'), LET('x', ||(||(\"x\", ' '), \"n\"))))", code.toString());
+        assertEquals("BLOCK(LET('x', ''), FOREACH('n', list('hola', 'adios', 'fin'), LET('x', ((\"x\" || ' ') || \"n\"))))", code.toString());
     }
 
     public void testUseCase2() {
@@ -298,7 +298,7 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("BLOCK(LET('s', ''), LET('x', LIST('hola', 'adios', 'fin')), FOREACH('n', RANGE(3), LET('s', ||(||(\"s\", ' '), GETITEM(\"x\", \"n\")))))", code.toString());
+        assertEquals("BLOCK(LET('s', ''), LET('x', LIST('hola', 'adios', 'fin')), FOREACH('n', RANGE(3), LET('s', ((\"s\" || ' ') || GETITEM(\"x\", \"n\")))))", code.toString());
     }
 
 
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestOptimizer.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestOptimizer.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestOptimizer.java	(revision 44198)
@@ -223,12 +223,12 @@
 
         Compiler compiler = createCompiler();
         Code code = compiler.compileExpression(source);
-        assertEquals(operatorName + "(\"precio\", 23)", code.toString());
+        assertEquals( "(\"precio\" "+operatorName+" 23)", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals(operatorName + "(\"precio\", 23)", code2.toString());
+        assertEquals( "(\"precio\" "+operatorName+" 23)", code2.toString());
     }
 
     public void testOperators() {
@@ -259,12 +259,12 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("+(+(+(\"precio\", *(10, 2)), 20), 30)", code.toString());
+        assertEquals("(((\"precio\" + (10 * 2)) + 20) + 30)", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals("+(+(+(\"precio\", 20), 20), 30)", code2.toString());
+        assertEquals("(((\"precio\" + 20) + 20) + 30)", code2.toString());
     }
     
     public void testMul0() {
@@ -273,12 +273,12 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("+(+(+(\"precio\", *(10, 0)), 20), 30)", code.toString());
+        assertEquals("(((\"precio\" + (10 * 0)) + 20) + 30)", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals("+(+(\"precio\", 20), 30)", code2.toString());
+        assertEquals("((\"precio\" + 20) + 30)", code2.toString());
     }
 
     public void testMul1() {
@@ -287,12 +287,12 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("+(+(+(\"precio\", *(10, 1)), 20), 30)", code.toString());
+        assertEquals("(((\"precio\" + (10 * 1)) + 20) + 30)", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals("+(+(+(\"precio\", 10), 20), 30)", code2.toString());
+        assertEquals("(((\"precio\" + 10) + 20) + 30)", code2.toString());
     }
 
     public void testDiv1() {
@@ -301,12 +301,12 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("+(+(+(\"precio\", /(10, 1)), 20), 30)", code.toString());
+        assertEquals("(((\"precio\" + (10 / 1)) + 20) + 30)", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals("+(+(+(\"precio\", 10), 20), 30)", code2.toString());
+        assertEquals("(((\"precio\" + 10) + 20) + 30)", code2.toString());
     }
 
     public void testDiv0() {
@@ -315,12 +315,12 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("+(+(+(\"precio\", /(0, 10)), 20), 30)", code.toString());
+        assertEquals("(((\"precio\" + (0 / 10)) + 20) + 30)", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals("+(+(\"precio\", 20), 30)", code2.toString());
+        assertEquals("((\"precio\" + 20) + 30)", code2.toString());
     }
 
     public void testAddMulPar() {
@@ -329,12 +329,12 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("+(+(*(+(\"precio\", 10), 2), 20), 30)", code.toString());
+        assertEquals("((((\"precio\" + 10) * 2) + 20) + 30)", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals("+(+(*(+(\"precio\", 10), 2), 20), 30)", code2.toString());
+        assertEquals("((((\"precio\" + 10) * 2) + 20) + 30)", code2.toString());
     }
 
     public void testAbs() {
@@ -343,12 +343,12 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("+(\"precio\", abs(10))", code.toString());
+        assertEquals("(\"precio\" + abs(10))", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals("+(\"precio\", 10)", code2.toString());
+        assertEquals("(\"precio\" + 10)", code2.toString());
     }
 
     public void testAbs2() {
@@ -357,12 +357,12 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("+(\"precio\", abs(NEGATE(10)))", code.toString());
+        assertEquals("(\"precio\" + abs(-(10)))", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals("+(\"precio\", 10)", code2.toString());
+        assertEquals("(\"precio\" + 10)", code2.toString());
     }
 
     public void testPI() {
@@ -371,12 +371,12 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("+(\"precio\", PI())", code.toString());
+        assertEquals("(\"precio\" + PI())", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals("+(\"precio\", 3.141592653589793)", code2.toString());
+        assertEquals("(\"precio\" + 3.141592653589793)", code2.toString());
     }
 
     public void testCeil() {
@@ -385,12 +385,12 @@
         Compiler compiler = createCompiler();
 
         Code code = compiler.compileExpression(source);
-        assertEquals("+(\"precio\", CEIL(PI()))", code.toString());
+        assertEquals("(\"precio\" + CEIL(PI()))", code.toString());
 
         SymbolTable symbolTable = createSymbolTable();
         Optimizer optimizer = createOptimizer(symbolTable);
         Code code2 = optimizer.optimize(code);
-        assertEquals("+(\"precio\", 4.0)", code2.toString());
+        assertEquals("(\"precio\" + 4.0)", code2.toString());
     }
 
     public void testConcat() {
@@ -452,7 +452,7 @@
     public void testSpatialExpression1() throws Exception {
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
         ExpressionBuilder builder = new DefaultExpressionBuilder();
-        builder.getConfig().set(ExpressionBuilder.Config.geometry_type_support, ExpressionBuilder.GeometrySupportType.WKB);
+        builder.geometry_support_type(ExpressionBuilder.GeometrySupportType.WKB);
 
         String source = builder.and(
                 builder.custom(this.createExpr1()),
@@ -471,7 +471,7 @@
         Code code = compiler.compileExpression(source);
         System.out.println(code.toString());
         assertEquals(
-                "AND(>(\"campo1\", 10), ST_Intersects(ST_GeomFromWKB(DECODE('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000', 'hex'), 4326), \"GEOMETRY\"))",
+                "((\"campo1\" > 10) AND ST_Intersects(ST_GeomFromWKB(DECODE('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000', 'hex'), 4326), \"GEOMETRY\"))",
                 code.toString()
         );
 
@@ -487,7 +487,7 @@
 //        System.out.println("Tiempo de optimizacion: " + (System.currentTimeMillis() - t1));
         System.out.println(code2.toString());
         assertEquals(
-                "AND(>(\"campo1\", 10), ST_Intersects('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))'::geometry, \"GEOMETRY\"))",
+                "((\"campo1\" > 10) AND ST_Intersects('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))'::geometry, \"GEOMETRY\"))",
                 code2.toString()
         );
 
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestExpressionBuilder.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestExpressionBuilder.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/test/java/org/gvsig/expresionevaluator/impl/TestExpressionBuilder.java	(revision 44198)
@@ -1,15 +1,10 @@
 package org.gvsig.expresionevaluator.impl;
 
-import java.util.ArrayList;
-import java.util.List;
 import junit.framework.TestCase;
 import org.apache.commons.lang3.ArrayUtils;
 import org.cresques.cts.IProjection;
 import org.gvsig.expressionevaluator.ExpressionBuilder;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Config;
 import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
 import org.gvsig.expressionevaluator.impl.DefaultExpressionBuilder;
 import org.gvsig.fmap.crs.CRSFactory;
 import org.gvsig.fmap.geom.Geometry;
@@ -29,7 +24,6 @@
     protected void setUp() throws Exception {
         super.setUp();
         new DefaultLibrariesInitializer().fullInitialize();
-//        new ExpressionEvaluatorImplLibrary().initialize();
     }
 
     @Override
@@ -40,45 +34,12 @@
     // TODO add test methods here. The name must begin with 'test'. For example:
     // public void testHello() {}
     
-    List<String> getVariableNames(ExpressionBuilder builder) {
-        List<String> vars = new ArrayList<>();
-        for (Variable var : builder.getVariables()) {
-            vars.add(var.getName());
-        }
-        return vars;
-    }
-    
-    List<String> getParameterNames(ExpressionBuilder builder) {
-        List<String> params = new ArrayList<>();
-        for (Parameter param : builder.getParameters()) {
-            String s;
-            switch(param.getType()) {
-                case Constant:
-                    Object value = param.getValue();
-                    if( value==null ) {
-                        s = "null";
-                    } else if( value instanceof String ) {
-                        s = "'" + (String)value + "'";
-                    } else {
-                        s = value.toString();
-                    }    
-                    break;
-                case Geometry:
-                case Variable:
-                default:
-                    s = "\"" + param.getName() + "\"";
-            }
-            params.add(s);
-        }
-        return params;
-    }
-    
     public void test2() {
         ExpressionBuilder builder = new DefaultExpressionBuilder();
         
         builder.and(
           builder.eq(
-            builder.lcase(builder.variable("colum_name_c")),
+            builder.lower(builder.variable("colum_name_c")),
             builder.parameter("colum_name_p")
           )
         );
@@ -86,7 +47,7 @@
             builder.group(
                 builder.or(
                     builder.like(
-                        builder.lcase( builder.variable("uno")),
+                        builder.lower( builder.variable("uno")),
                         builder.constant("%10")
                     ),
                     builder.lt(
@@ -114,16 +75,16 @@
             )
         );
         assertEquals(
-                "( (LCASE(\"colum_name_c\")) = (?) ) AND ( ( (LCASE(\"uno\")) LIKE ('%10') ) OR ( (\"dos\") < (-3.5) ) ) AND ST_Intersects((\"geom1\"), (ST_Envelope(ST_GeomFromWKB((?), (?))))) AND ( (\"tres\") > (123456789) )",
+                "( (LOWER(\"colum_name_c\")) = (?) ) AND ( ( (LOWER(\"uno\")) LIKE ('%10') ) OR ( (\"dos\") < (-3.5) ) ) AND ST_Intersects((\"geom1\"), (ST_Envelope(ST_GeomFromWKB((?), (?))))) AND ( (\"tres\") > (123456789) )",
                 builder.toString()
         );
         assertEquals(
                 "[colum_name_c, dos, geom1, tres, uno]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(builder.variables_names())
         );
         assertEquals(
                 "[\"colum_name_p\", \"geom2\", 4326]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(builder.parameters_names())
         );
     }
     
@@ -140,13 +101,13 @@
               builder.variable("the_geom")
             )
         );
-        builder.getConfig().set(Config.geometry_type_support, GeometrySupportType.WKT);
+        builder.geometry_support_type(GeometrySupportType.WKT);
         System.out.println(builder.toString());
         assertEquals(
-                "ST_Intersects((ST_GeomFromText('POINT (10 20)', (4326))), (\"the_geom\"))",
+                "ST_Intersects((ST_GeomFromText(('POINT (10 20)'), (4326))), (\"the_geom\"))",
                 builder.toString()
         );
-        builder.getConfig().set(Config.geometry_type_support, GeometrySupportType.WKB);
+        builder.geometry_support_type(GeometrySupportType.WKB);
         System.out.println(builder.toString());
         assertEquals(
                 "ST_Intersects((ST_GeomFromWKB((DECODE('000000000140240000000000004034000000000000','hex')), (4326))), (\"the_geom\"))",
@@ -154,14 +115,214 @@
         );
         assertEquals(
                 "[the_geom]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(builder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(builder.parameters_names())
         );
     }
     
+    public void testParameter() throws CreateGeometryException {
+        ExpressionBuilder builder = new DefaultExpressionBuilder();
+                
+        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        
+        Point point = geometryManager.createPoint(10, 20, Geometry.SUBTYPES.GEOM2D);
+        builder.set(        
+            builder.ST_Intersects(
+              builder.geometry(point,proj),
+              builder.parameter("the_geom")
+            )
+        );
+        builder.geometry_support_type(GeometrySupportType.WKT);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromText(('POINT (10 20)'), (4326))), (?))",
+                builder.toString()
+        );
+        builder.geometry_support_type(GeometrySupportType.WKB);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromWKB((DECODE('000000000140240000000000004034000000000000','hex')), (4326))), (?))",
+                builder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(builder.variables_names())
+        );
+        assertEquals(
+                "[\"the_geom\"]",
+                ArrayUtils.toString(builder.parameters_names())
+        );
+    }
+    
+    public void testParameterGeomWhitoutSRS() throws CreateGeometryException {
+        ExpressionBuilder builder = new DefaultExpressionBuilder();
+                
+        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        
+        Point point = geometryManager.createPoint(10, 20, Geometry.SUBTYPES.GEOM2D);
+        builder.set(        
+            builder.ST_Intersects(
+              builder.geometry(point,proj),
+              builder.parameter("the_geom").as_geometry_variable()
+            )
+        );
+        try {
+            builder.toString();
+            fail("Geometry parameter without SRS not detected.");
+        } catch(IllegalArgumentException ex) {
+            // Do nothing, it's ok that fail if not SRS is specified.
+        }
+    }
+    
+    public void testPatameterGeomWithSRS1() throws CreateGeometryException {
+        ExpressionBuilder builder = new DefaultExpressionBuilder();
+                
+        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        
+        Point point = geometryManager.createPoint(10, 20, Geometry.SUBTYPES.GEOM2D);
+        builder.set(        
+            builder.ST_Intersects(
+              builder.geometry(point,proj),
+              builder.parameter("the_geom").srs(proj)
+            )
+        );
+        builder.geometry_support_type(GeometrySupportType.WKT);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromText(('POINT (10 20)'), (4326))), (ST_GeomFromText((?), (4326))))",
+                builder.toString()
+        );
+        builder.geometry_support_type(GeometrySupportType.WKB);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromWKB((DECODE('000000000140240000000000004034000000000000','hex')), (4326))), (ST_GeomFromWKB((?), (4326))))",
+                builder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(builder.variables_names())
+        );
+        assertEquals(
+                "[\"the_geom\"]",
+                ArrayUtils.toString(builder.parameters_names())
+        );
+    }
+    
+    public void testParameterGeomWithSRS2() throws CreateGeometryException {
+        ExpressionBuilder builder = new DefaultExpressionBuilder();
+                
+        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        
+        Point point = geometryManager.createPoint(10, 20, Geometry.SUBTYPES.GEOM2D);
+        builder.set(        
+            builder.ST_Intersects(
+              builder.geometry(point,proj),
+              builder.parameter("the_geom").srs(builder.constant(4326))
+            )
+        );
+        builder.geometry_support_type(GeometrySupportType.WKT);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromText(('POINT (10 20)'), (4326))), (ST_GeomFromText((?), (4326))))",
+                builder.toString()
+        );
+        builder.geometry_support_type(GeometrySupportType.WKB);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromWKB((DECODE('000000000140240000000000004034000000000000','hex')), (4326))), (ST_GeomFromWKB((?), (4326))))",
+                builder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(builder.variables_names())
+        );
+        assertEquals(
+                "[\"the_geom\"]",
+                ArrayUtils.toString(builder.parameters_names())
+        );
+    }
+    
+    public void testParameterGeomWithParameterSRS() throws CreateGeometryException {
+        ExpressionBuilder builder = new DefaultExpressionBuilder();
+                
+        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        
+        Point point = geometryManager.createPoint(10, 20, Geometry.SUBTYPES.GEOM2D);
+        builder.set(        
+            builder.ST_Intersects(
+              builder.geometry(point,proj),
+              builder.parameter("the_geom").srs(
+                      builder.parameter().value(proj)
+              )
+            )
+        );
+        builder.geometry_support_type(GeometrySupportType.WKT);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromText(('POINT (10 20)'), (4326))), (ST_GeomFromText((?), (?))))",
+                builder.toString()
+        );
+        builder.geometry_support_type(GeometrySupportType.WKB);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromWKB((DECODE('000000000140240000000000004034000000000000','hex')), (4326))), (ST_GeomFromWKB((?), (?))))",
+                builder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(builder.variables_names())
+        );
+        assertEquals(
+                "[\"the_geom\", 4326]",
+                ArrayUtils.toString(builder.parameters_names())
+        );
+    }
+    
+    public void testParameterGeomConstant() throws CreateGeometryException {
+        ExpressionBuilder builder = new DefaultExpressionBuilder();
+                
+        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        
+        Point point = geometryManager.createPoint(10, 20, Geometry.SUBTYPES.GEOM2D);
+        Point point2 = geometryManager.createPoint(10, 20, Geometry.SUBTYPES.GEOM2D);
+        point2.setProjection(proj);
+        builder.set(        
+            builder.ST_Intersects(
+              builder.geometry(point,proj),
+              builder.parameter().value(point2)
+            )
+        );
+        builder.geometry_support_type(GeometrySupportType.WKT);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromText(('POINT (10 20)'), (4326))), (ST_GeomFromText((?), (?))))",
+                builder.toString()
+        );
+        builder.geometry_support_type(GeometrySupportType.WKB);
+        System.out.println(builder.toString());
+        assertEquals(
+                "ST_Intersects((ST_GeomFromWKB((DECODE('000000000140240000000000004034000000000000','hex')), (4326))), (ST_GeomFromWKB((?), (?))))",
+                builder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(builder.variables_names())
+        );
+        assertEquals(
+                "[0x000000000140240000000000004034000000000000, 4326]",
+                ArrayUtils.toString(builder.parameters_names())
+        );
+    }
+    
     public void test4() throws CreateGeometryException {
         ExpressionBuilder builder = new DefaultExpressionBuilder();
                 
@@ -186,11 +347,11 @@
         );
         assertEquals(
                 "[geom1]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(builder.variables_names())
         );
         assertEquals(
                 "[\"geom2\", 4326]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(builder.parameters_names())
         );
     }
         
@@ -213,11 +374,11 @@
         );
         assertEquals(
                 "[geom]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(builder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(builder.parameters_names())
         );
     }
 }
Index: 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/function/operator/AddOperator.java
===================================================================
--- 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/function/operator/AddOperator.java	(revision 44197)
+++ 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/function/operator/AddOperator.java	(revision 44198)
@@ -61,8 +61,8 @@
 
     @Override
     public Code optimize(Optimizer optimizer, Caller caller) {
-        Code op1 = optimizer.optimize(caller.args().get(0));
-        Code op2 = optimizer.optimize(caller.args().get(1));
+        Code op1 = optimizer.optimize(caller.parameters().get(0));
+        Code op2 = optimizer.optimize(caller.parameters().get(1));
         
         if ( op1.code() == Code.CONSTANT && op2.code() == Code.CONSTANT) {
             Code newCode = optimizer.getCodeBuilder().constant(
Index: 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/function/operator/MulOperator.java
===================================================================
--- 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/function/operator/MulOperator.java	(revision 44197)
+++ 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/function/operator/MulOperator.java	(revision 44198)
@@ -45,8 +45,8 @@
 
     @Override
     public Code optimize(Optimizer optimizer, Code.Caller caller) {
-        Code op1 = optimizer.optimize(caller.args().get(0));
-        Code op2 = optimizer.optimize(caller.args().get(1));
+        Code op1 = optimizer.optimize(caller.parameters().get(0));
+        Code op2 = optimizer.optimize(caller.parameters().get(1));
         
         if ( op1.code() == Code.CONSTANT && op2.code() == Code.CONSTANT) {
             Code newCode = optimizer.getCodeBuilder().constant(
Index: 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/function/operator/SubstOperator.java
===================================================================
--- 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/function/operator/SubstOperator.java	(revision 44197)
+++ 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/function/operator/SubstOperator.java	(revision 44198)
@@ -45,8 +45,8 @@
     
     @Override
     public Code optimize(Optimizer optimizer, Code.Caller caller) {
-        Code op1 = optimizer.optimize(caller.args().get(0));
-        Code op2 = optimizer.optimize(caller.args().get(1));
+        Code op1 = optimizer.optimize(caller.parameters().get(0));
+        Code op2 = optimizer.optimize(caller.parameters().get(1));
         
         if ( op1.code() == Code.CONSTANT && op2.code() == Code.CONSTANT) {
             Code newCode = optimizer.getCodeBuilder().constant(
Index: 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/function/operator/ConcatOperator.java
===================================================================
--- 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/function/operator/ConcatOperator.java	(revision 44197)
+++ 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/function/operator/ConcatOperator.java	(revision 44198)
@@ -33,8 +33,8 @@
 
     @Override
     public Code optimize(Optimizer optimizer, Caller caller) {
-        Code op1 = optimizer.optimize(caller.args().get(0));
-        Code op2 = optimizer.optimize(caller.args().get(1));
+        Code op1 = optimizer.optimize(caller.parameters().get(0));
+        Code op2 = optimizer.optimize(caller.parameters().get(1));
         
         if ( op1.code() == Code.CONSTANT && op2.code() == Code.CONSTANT) {
             Code newCode = optimizer.getCodeBuilder().constant(
Index: 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/function/operator/DivOperator.java
===================================================================
--- 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/function/operator/DivOperator.java	(revision 44197)
+++ 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/function/operator/DivOperator.java	(revision 44198)
@@ -45,8 +45,8 @@
 
     @Override
     public Code optimize(Optimizer optimizer, Code.Caller caller) {
-        Code op1 = optimizer.optimize(caller.args().get(0));
-        Code op2 = optimizer.optimize(caller.args().get(1));
+        Code op1 = optimizer.optimize(caller.parameters().get(0));
+        Code op2 = optimizer.optimize(caller.parameters().get(1));
         
         if ( op1.code() == Code.CONSTANT && op2.code() == Code.CONSTANT) {
             Code newCode = optimizer.getCodeBuilder().constant(
Index: 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/function/date/DateFunction.java
===================================================================
--- 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/function/date/DateFunction.java	(revision 44197)
+++ 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/function/date/DateFunction.java	(revision 44198)
@@ -4,15 +4,16 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_DATE;
 import org.gvsig.expressionevaluator.Interpreter;
 import org.gvsig.expressionevaluator.spi.AbstractFunction;
 
 public class DateFunction extends AbstractFunction {
 
     public DateFunction() {
-        super("Date", "DATE",Range.between(1,2),
+        super("Date", FUNCTION_DATE,Range.between(1,2),
             "Returns a date from the arguments",
-            "DATE({{date}}, format)",
+            FUNCTION_DATE+"({{date}}, format)",
             new String[]{
                 "date - a string with a date",
                 "format - Optional. Format to use to parse the date"
Index: 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/function/date/TimeFunction.java
===================================================================
--- 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/function/date/TimeFunction.java	(revision 44197)
+++ 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/function/date/TimeFunction.java	(revision 44198)
@@ -4,15 +4,16 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_TIME;
 import org.gvsig.expressionevaluator.Interpreter;
 import org.gvsig.expressionevaluator.spi.AbstractFunction;
 
 public class TimeFunction extends AbstractFunction {
 
     public TimeFunction() {
-        super("Date", "TIME",Range.between(1,2),
+        super("Date", FUNCTION_TIME,Range.between(1,2),
             "Returns a time from the arguments",
-            "TIME({{time}}, format)",
+            FUNCTION_TIME+"({{time}}, format)",
             new String[]{
                 "time - a string with a time",
                 "format - Optional. Format to use to parse the time"
Index: 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/function/date/NowFunction.java
===================================================================
--- 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/function/date/NowFunction.java	(revision 44197)
+++ 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/function/date/NowFunction.java	(revision 44198)
@@ -2,15 +2,16 @@
 
 import java.util.Date;
 import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_NOW;
 import org.gvsig.expressionevaluator.Interpreter;
 import org.gvsig.expressionevaluator.spi.AbstractFunction;
 
 public class NowFunction extends AbstractFunction {
 
     public NowFunction() {
-        super("Date", "NOW",Range.is(0),
+        super("Date", FUNCTION_NOW,Range.is(0),
             "Returns current date and time\n",
-            "NOW()",
+            FUNCTION_NOW+"()",
             null,
             "TIMESTAMP"
         );
Index: 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/function/date/TimestampFunction.java
===================================================================
--- 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/function/date/TimestampFunction.java	(revision 44197)
+++ 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/function/date/TimestampFunction.java	(revision 44198)
@@ -4,15 +4,16 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_TIMESTAMP;
 import org.gvsig.expressionevaluator.Interpreter;
 import org.gvsig.expressionevaluator.spi.AbstractFunction;
 
 public class TimestampFunction extends AbstractFunction {
 
     public TimestampFunction() {
-        super("Date", "TIMESTAMP",Range.between(1,2),
+        super("Date", FUNCTION_TIMESTAMP,Range.between(1,2),
             "Returns a time stamp from the arguments",
-            "TIMESTAMP({{timestamp}}, format)",
+            FUNCTION_TIMESTAMP+"({{timestamp}}, format)",
             new String[]{
                 "timestamp - a string with a date/time",
                 "format - Optional. Format to use to parse the timestamp"
Index: 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/function/spatial/AndAndOperator.java
===================================================================
--- 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/function/spatial/AndAndOperator.java	(revision 0)
+++ 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/function/spatial/AndAndOperator.java	(revision 44198)
@@ -0,0 +1,32 @@
+package org.gvsig.expressionevaluator.impl.function.spatial;
+
+import org.gvsig.expressionevaluator.impl.function.operator.*;
+import org.gvsig.expressionevaluator.Function;
+import org.gvsig.expressionevaluator.Interpreter;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryUtils;
+
+public class AndAndOperator extends AbstractBinaryOperator {
+    
+    public static final String NAME = "&&";
+
+    public AndAndOperator() {
+        super(Function.GROUP_OGC, NAME);
+    }
+
+    @Override
+    public boolean allowConstantFolding() {
+        return true;
+    }
+    
+    @Override
+    public Object call(Interpreter interpreter, Object op1, Object op2) {       
+        if( op1 instanceof Geometry && op2 instanceof Geometry ) {
+            boolean value = GeometryUtils.intersects((Geometry)op1,(Geometry) op2);
+            return value;
+        }
+        throw new IllegalArgumentException("Types not allowed in '"+name()+"' operand.");
+    }
+    
+
+}
Index: 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/function/string/DecodeFunction.java
===================================================================
--- 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/function/string/DecodeFunction.java	(revision 44197)
+++ 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/function/string/DecodeFunction.java	(revision 44198)
@@ -1,46 +0,0 @@
-package org.gvsig.expressionevaluator.impl.function.string;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.codec.binary.Hex;
-import org.apache.commons.lang3.Range;
-import org.gvsig.expressionevaluator.Interpreter;
-import org.gvsig.expressionevaluator.spi.AbstractFunction;
-
-public class DecodeFunction extends AbstractFunction {
-
-    public DecodeFunction() {
-        super(
-            "String", "DECODE", Range.is(2),
-            "Decode binary data from textual representation in string.\nSupported formats are: base64, hex.",
-            "DECODE({{data}}, 'hex')",
-            new String[]{
-                "data - A string value with the data to be converted",
-                "format - A string value indicating the format of the input data. The default value is 'hex'."
-            },
-            "Byte array",
-            true
-        );
-    }
-
-    @Override
-    public boolean allowConstantFolding() {
-        return true;
-    }
-    
-    @Override
-    public Object call(Interpreter interpreter, Object[] args) throws Exception {
-        String data_s = getStr(args,0);
-        String type = getStr(args,1);
-        if( "hex".equalsIgnoreCase(type) ) {
-            byte[] data = Hex.decodeHex(data_s.toCharArray());
-            return data;
-        } else if( "base64".equalsIgnoreCase(type) ) {
-            byte[] data = Base64.decodeBase64(data_s);
-            return data;
-        } else if( "escape".equalsIgnoreCase(type) ) {
-            // Not supported
-        }
-        throw new IllegalArgumentException("Unsupported format type '"+type+"'.");
-    }
-
-}
Index: 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/function/string/LowerFunction.java
===================================================================
--- 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/function/string/LowerFunction.java	(revision 44197)
+++ 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/function/string/LowerFunction.java	(revision 44198)
@@ -1,13 +1,14 @@
 package org.gvsig.expressionevaluator.impl.function.string;
 
 import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_LOWER;
 import org.gvsig.expressionevaluator.Interpreter;
 import org.gvsig.expressionevaluator.spi.AbstractFunction;
 
 public class LowerFunction extends AbstractFunction {
 
     public LowerFunction() {
-        super("String", "LOWER", Range.is(1));
+        super("String", FUNCTION_LOWER, Range.is(1));
         this.addAlias("LCASE");
         this.addAlias("toLowerCase");
     }
Index: 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/function/typeconversion/DoubleFunction.java
===================================================================
--- 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/function/typeconversion/DoubleFunction.java	(revision 44197)
+++ 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/function/typeconversion/DoubleFunction.java	(revision 44198)
@@ -1,30 +0,0 @@
-package org.gvsig.expressionevaluator.impl.function.typeconversion;
-
-import org.apache.commons.lang3.Range;
-import org.gvsig.expressionevaluator.Interpreter;
-import org.gvsig.expressionevaluator.spi.AbstractFunction;
-import org.gvsig.tools.ToolsLocator;
-import org.gvsig.tools.dataTypes.DataTypes;
-import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
-
-public class DoubleFunction extends AbstractFunction {
-
-    public DoubleFunction() {
-        super("Conversion", "DOUBLE", Range.is(1));
-        this.addAlias("toReal");
-        this.addAlias("toNumber");
-    }
-
-    @Override
-    public boolean allowConstantFolding() {
-        return true;
-    }
-    
-    @Override
-    public Object call(Interpreter interpreter, Object[] args) throws Exception {
-        Coercion toStr = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.DOUBLE);
-        Object value = toStr.coerce(this.getObject(args, 0));
-        return value;
-    }
-    
-}
Index: 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/function/typeconversion/IntFunction.java
===================================================================
--- 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/function/typeconversion/IntFunction.java	(revision 44197)
+++ 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/function/typeconversion/IntFunction.java	(revision 44198)
@@ -1,29 +0,0 @@
-package org.gvsig.expressionevaluator.impl.function.typeconversion;
-
-import org.apache.commons.lang3.Range;
-import org.gvsig.expressionevaluator.Interpreter;
-import org.gvsig.expressionevaluator.spi.AbstractFunction;
-import org.gvsig.tools.ToolsLocator;
-import org.gvsig.tools.dataTypes.DataTypes;
-import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
-
-public class IntFunction extends AbstractFunction {
-
-    public IntFunction() {
-        super("Conversion", "INT", Range.is(1));
-        this.addAlias("toint");
-    }
-
-    @Override
-    public boolean allowConstantFolding() {
-        return true;
-    }
-    
-    @Override
-    public Object call(Interpreter interpreter, Object[] args) throws Exception {
-        Coercion toStr = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.INT);
-        Object value = toStr.coerce(this.getObject(args, 0));
-        return value;
-    }
-    
-}
Index: 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/function/typeconversion/LongFunction.java
===================================================================
--- 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/function/typeconversion/LongFunction.java	(revision 44197)
+++ 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/function/typeconversion/LongFunction.java	(revision 44198)
@@ -1,28 +0,0 @@
-package org.gvsig.expressionevaluator.impl.function.typeconversion;
-
-import org.apache.commons.lang3.Range;
-import org.gvsig.expressionevaluator.Interpreter;
-import org.gvsig.expressionevaluator.spi.AbstractFunction;
-import org.gvsig.tools.ToolsLocator;
-import org.gvsig.tools.dataTypes.DataTypes;
-import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
-
-public class LongFunction extends AbstractFunction {
-
-    public LongFunction() {
-        super("Conversion", "LONG", Range.is(1));
-    }
-
-    @Override
-    public boolean allowConstantFolding() {
-        return true;
-    }
-    
-    @Override
-    public Object call(Interpreter interpreter, Object[] args) throws Exception {
-        Coercion toStr = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.LONG);
-        Object value = toStr.coerce(this.getObject(args, 0));
-        return value;
-    }
-    
-}
Index: 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/function/typeconversion/FloatFunction.java
===================================================================
--- 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/function/typeconversion/FloatFunction.java	(revision 44197)
+++ 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/function/typeconversion/FloatFunction.java	(revision 44198)
@@ -1,28 +0,0 @@
-package org.gvsig.expressionevaluator.impl.function.typeconversion;
-
-import org.apache.commons.lang3.Range;
-import org.gvsig.expressionevaluator.Interpreter;
-import org.gvsig.expressionevaluator.spi.AbstractFunction;
-import org.gvsig.tools.ToolsLocator;
-import org.gvsig.tools.dataTypes.DataTypes;
-import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
-
-public class FloatFunction extends AbstractFunction {
-
-    public FloatFunction() {
-        super("Conversion", "FLOAT", Range.is(1));
-    }
-
-    @Override
-    public boolean allowConstantFolding() {
-        return true;
-    }
-    
-    @Override
-    public Object call(Interpreter interpreter, Object[] args) throws Exception {
-        Coercion toStr = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.FLOAT);
-        Object value = toStr.coerce(this.getObject(args, 0));
-        return value;
-    }
-    
-}
Index: 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/function/typeconversion/StrFunction.java
===================================================================
--- 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/function/typeconversion/StrFunction.java	(revision 44197)
+++ 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/function/typeconversion/StrFunction.java	(revision 44198)
@@ -1,30 +0,0 @@
-package org.gvsig.expressionevaluator.impl.function.typeconversion;
-
-import java.util.Objects;
-import org.apache.commons.lang3.Range;
-import org.gvsig.expressionevaluator.Interpreter;
-import org.gvsig.expressionevaluator.spi.AbstractFunction;
-import org.gvsig.tools.ToolsLocator;
-import org.gvsig.tools.dataTypes.DataTypes;
-import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
-
-public class StrFunction extends AbstractFunction {
-
-    public StrFunction() {
-        super("Conversion", "STR", Range.is(1));
-        this.addAlias("toString");
-    }
-
-    @Override
-    public boolean allowConstantFolding() {
-        return true;
-    }
-    
-    @Override
-    public Object call(Interpreter interpreter, Object[] args) throws Exception {
-        Coercion toStr = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.STRING);
-        Object value = toStr.coerce(this.getObject(args, 0));
-        return value;
-    }
-    
-}
Index: 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/function/typeconversion/ToFloatFunction.java
===================================================================
--- 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/function/typeconversion/ToFloatFunction.java	(revision 0)
+++ 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/function/typeconversion/ToFloatFunction.java	(revision 44198)
@@ -0,0 +1,30 @@
+package org.gvsig.expressionevaluator.impl.function.typeconversion;
+
+import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_TOFLOAT;
+import org.gvsig.expressionevaluator.Interpreter;
+import org.gvsig.expressionevaluator.spi.AbstractFunction;
+import org.gvsig.tools.ToolsLocator;
+import org.gvsig.tools.dataTypes.DataTypes;
+import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
+
+public class ToFloatFunction extends AbstractFunction {
+
+    public ToFloatFunction() {
+        super(GROUP_CONVERSION, FUNCTION_TOFLOAT, Range.is(1));
+        this.addAlias("float");
+    }
+
+    @Override
+    public boolean allowConstantFolding() {
+        return true;
+    }
+    
+    @Override
+    public Object call(Interpreter interpreter, Object[] args) throws Exception {
+        Coercion toStr = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.FLOAT);
+        Object value = toStr.coerce(this.getObject(args, 0));
+        return value;
+    }
+    
+}
Index: 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/function/typeconversion/CastFunction.java
===================================================================
--- 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/function/typeconversion/CastFunction.java	(revision 44197)
+++ 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/function/typeconversion/CastFunction.java	(revision 44198)
@@ -2,6 +2,7 @@
 
 import java.util.Iterator;
 import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_CAST;
 import org.gvsig.expressionevaluator.ExpressionRuntimeException;
 import org.gvsig.expressionevaluator.Interpreter;
 import org.gvsig.expressionevaluator.spi.AbstractFunction;
@@ -13,10 +14,8 @@
 
 public class CastFunction extends AbstractFunction {
     
-    public static final String NAME = "CAST";
-
     public CastFunction() {
-        super("Conversion", NAME, Range.is(2));
+        super(GROUP_CONVERSION, FUNCTION_CAST, Range.is(2));
     }
 
     @Override
Index: 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/function/typeconversion/ToStrFunction.java
===================================================================
--- 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/function/typeconversion/ToStrFunction.java	(revision 0)
+++ 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/function/typeconversion/ToStrFunction.java	(revision 44198)
@@ -0,0 +1,31 @@
+package org.gvsig.expressionevaluator.impl.function.typeconversion;
+
+import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_TOSTR;
+import org.gvsig.expressionevaluator.Interpreter;
+import org.gvsig.expressionevaluator.spi.AbstractFunction;
+import org.gvsig.tools.ToolsLocator;
+import org.gvsig.tools.dataTypes.DataTypes;
+import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
+
+public class ToStrFunction extends AbstractFunction {
+
+    public ToStrFunction() {
+        super(GROUP_CONVERSION, FUNCTION_TOSTR, Range.is(1));
+        this.addAlias("STR");
+        this.addAlias("toString");
+    }
+
+    @Override
+    public boolean allowConstantFolding() {
+        return true;
+    }
+    
+    @Override
+    public Object call(Interpreter interpreter, Object[] args) throws Exception {
+        Coercion toStr = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.STRING);
+        Object value = toStr.coerce(this.getObject(args, 0));
+        return value;
+    }
+    
+}
Index: 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/function/typeconversion/ToDoubleFunction.java
===================================================================
--- 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/function/typeconversion/ToDoubleFunction.java	(revision 0)
+++ 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/function/typeconversion/ToDoubleFunction.java	(revision 44198)
@@ -0,0 +1,32 @@
+package org.gvsig.expressionevaluator.impl.function.typeconversion;
+
+import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_TODOUBLE;
+import org.gvsig.expressionevaluator.Interpreter;
+import org.gvsig.expressionevaluator.spi.AbstractFunction;
+import org.gvsig.tools.ToolsLocator;
+import org.gvsig.tools.dataTypes.DataTypes;
+import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
+
+public class ToDoubleFunction extends AbstractFunction {
+
+    public ToDoubleFunction() {
+        super(GROUP_CONVERSION, FUNCTION_TODOUBLE, Range.is(1));
+        this.addAlias("double");
+        this.addAlias("toReal");
+        this.addAlias("toNumber");
+    }
+
+    @Override
+    public boolean allowConstantFolding() {
+        return true;
+    }
+    
+    @Override
+    public Object call(Interpreter interpreter, Object[] args) throws Exception {
+        Coercion toStr = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.DOUBLE);
+        Object value = toStr.coerce(this.getObject(args, 0));
+        return value;
+    }
+    
+}
Index: 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/function/typeconversion/ToIntegerFunction.java
===================================================================
--- 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/function/typeconversion/ToIntegerFunction.java	(revision 0)
+++ 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/function/typeconversion/ToIntegerFunction.java	(revision 44198)
@@ -0,0 +1,31 @@
+package org.gvsig.expressionevaluator.impl.function.typeconversion;
+
+import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_TOINTEGER;
+import org.gvsig.expressionevaluator.Interpreter;
+import org.gvsig.expressionevaluator.spi.AbstractFunction;
+import org.gvsig.tools.ToolsLocator;
+import org.gvsig.tools.dataTypes.DataTypes;
+import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
+
+public class ToIntegerFunction extends AbstractFunction {
+
+    public ToIntegerFunction() {
+        super(GROUP_CONVERSION, FUNCTION_TOINTEGER, Range.is(1));
+        this.addAlias("int");
+        this.addAlias("toint");
+    }
+
+    @Override
+    public boolean allowConstantFolding() {
+        return true;
+    }
+    
+    @Override
+    public Object call(Interpreter interpreter, Object[] args) throws Exception {
+        Coercion toStr = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.INT);
+        Object value = toStr.coerce(this.getObject(args, 0));
+        return value;
+    }
+    
+}
Index: 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/function/typeconversion/ToLongFunction.java
===================================================================
--- 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/function/typeconversion/ToLongFunction.java	(revision 0)
+++ 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/function/typeconversion/ToLongFunction.java	(revision 44198)
@@ -0,0 +1,30 @@
+package org.gvsig.expressionevaluator.impl.function.typeconversion;
+
+import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_TOLONG;
+import org.gvsig.expressionevaluator.Interpreter;
+import org.gvsig.expressionevaluator.spi.AbstractFunction;
+import org.gvsig.tools.ToolsLocator;
+import org.gvsig.tools.dataTypes.DataTypes;
+import org.gvsig.tools.dataTypes.DataTypesManager.Coercion;
+
+public class ToLongFunction extends AbstractFunction {
+
+    public ToLongFunction() {
+        super(GROUP_CONVERSION, FUNCTION_TOLONG, Range.is(1));
+        this.addAlias("long");
+    }
+
+    @Override
+    public boolean allowConstantFolding() {
+        return true;
+    }
+    
+    @Override
+    public Object call(Interpreter interpreter, Object[] args) throws Exception {
+        Coercion toStr = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.LONG);
+        Object value = toStr.coerce(this.getObject(args, 0));
+        return value;
+    }
+    
+}
Index: 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/function/typeconversion/DecodeFunction.java
===================================================================
--- 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/function/typeconversion/DecodeFunction.java	(revision 0)
+++ 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/function/typeconversion/DecodeFunction.java	(revision 44198)
@@ -0,0 +1,47 @@
+package org.gvsig.expressionevaluator.impl.function.typeconversion;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang3.Range;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_DECODE;
+import org.gvsig.expressionevaluator.Interpreter;
+import org.gvsig.expressionevaluator.spi.AbstractFunction;
+
+public class DecodeFunction extends AbstractFunction {
+
+    public DecodeFunction() {
+        super(
+            GROUP_CONVERSION, FUNCTION_DECODE, Range.is(2),
+            "Decode binary data from textual representation in string.\nSupported formats are: base64, hex.",
+            FUNCTION_DECODE+"({{data}}, 'hex')",
+            new String[]{
+                "data - A string value with the data to be converted",
+                "format - A string value indicating the format of the input data. The default value is 'hex'."
+            },
+            "Byte array",
+            true
+        );
+    }
+
+    @Override
+    public boolean allowConstantFolding() {
+        return true;
+    }
+    
+    @Override
+    public Object call(Interpreter interpreter, Object[] args) throws Exception {
+        String data_s = getStr(args,0);
+        String type = getStr(args,1);
+        if( "hex".equalsIgnoreCase(type) ) {
+            byte[] data = Hex.decodeHex(data_s.toCharArray());
+            return data;
+        } else if( "base64".equalsIgnoreCase(type) ) {
+            byte[] data = Base64.decodeBase64(data_s);
+            return data;
+        } else if( "escape".equalsIgnoreCase(type) ) {
+            // Not supported
+        }
+        throw new IllegalArgumentException("Unsupported format type '"+type+"'.");
+    }
+
+}
Index: 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/DefaultInterpreter.java
===================================================================
--- 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/DefaultInterpreter.java	(revision 44197)
+++ 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/DefaultInterpreter.java	(revision 44198)
@@ -165,23 +165,9 @@
 
     @Override
     public void link(Code code) {
-        linkCode(code);
+        code.link(this.getSymbolTable());
     }
 
-    private void linkCode(Code code) {
-        if( code.code() == Code.CALLER ) {
-            Caller caller = (Caller) code;
-            if( caller.function() == null ) {
-                caller.function(this.getSymbolTable().function(caller.name()));
-            }
-            if( caller.args() != null ) {
-                for( Code arg : caller.args() ) {
-                    linkCode(arg);
-                }
-            }
-        }
-    }
-
     public Object runCode(Code code) throws Exception {
         RecursionControlSupport recursionControl = null;
         if( code instanceof RecursionControlSupport ) {
@@ -235,7 +221,7 @@
                 if( !function.isSQLCompatible() && this.sqlCompatible ) {
                     throw new ExpressionRuntimeException(code, I18N.Cant_use_non_SQL_compatible_functions(function.name()));
                 }
-                Codes args = caller.args();
+                Codes args = caller.parameters();
                 try {
                     switch( caller.type() ) {
                     case Caller.UNARY_OPERATOR:
Index: 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/DefaultStatement.java
===================================================================
--- 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/DefaultStatement.java	(revision 44197)
+++ 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/DefaultStatement.java	(revision 44198)
@@ -315,7 +315,7 @@
             for (Code arg : base_args) {
                 if( arg.code() == Code.CALLER && 
                     ((Caller)arg).name().equals(CodeBlockFunction.NAME) ) {
-                    Codes block_args = ((Caller)arg).args();
+                    Codes block_args = ((Caller)arg).parameters();
                     for (Code block_arg : block_args) {
                         args.add(block_arg);
                     }
Index: 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
===================================================================
--- 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	(revision 44197)
+++ 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	(revision 44198)
@@ -2,165 +2,73 @@
 
 import java.text.MessageFormat;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
-import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.cresques.cts.IProjection;
+import org.gvsig.expressionevaluator.Code;
 import org.gvsig.fmap.geom.Geometry;
 import org.gvsig.fmap.geom.primitive.Envelope;
 
 import org.gvsig.expressionevaluator.ExpressionBuilder;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.EMPTY_FORMATTER;
+import org.gvsig.expressionevaluator.ExpressionUtils;
+import org.gvsig.expressionevaluator.Formatter;
+import org.gvsig.fmap.geom.GeometryUtils;
 
-@SuppressWarnings({"UseSpecificCatch","OverridableMethodCallInConstructor"})
+@SuppressWarnings({"UseSpecificCatch" ,"OverridableMethodCallInConstructor"})
 public class DefaultExpressionBuilder implements ExpressionBuilder {
+    
+    private static final String FORMAT_QUOTE_FOR_STRINGS = "'";
+    private static final String FORMAT_QUOTE_FOR_IDENTIFIERS = "\"";
 
-    public class ConfigBase implements Config {
+    private static final String FORMAT_TRUE = "TRUE";
+    private static final String FORMAT_FALSE = "FALSE";
 
-        protected Map<String, Object> values;
+    private static final String FORMAT_GROUP = "( {0} )";
 
-        public ConfigBase() {
-            this.values = new HashMap<>();
+    private static final String FORMAT_ST_SRID = "ST_SRID({0})";
+    private static final String FORMAT_ST_ASTEXT = "ST_AsText({0})";
+    private static final String FORMAT_ST_ASBINARY = "ST_AsBinary({0})";
+    private static final String FORMAT_ST_ASEWKB = "ST_AsEWKB({0})";
+    private static final String FORMAT_ST_CONTAINS = "ST_Contains(({0}), ({1}))";
+    private static final String FORMAT_ST_CROSSES = "ST_Crosses(({0}), ({1}))";
+    private static final String FORMAT_ST_DISJOINT = "ST_Disjoint(({0}), ({1}))";
+    private static final String FORMAT_ST_EQUALS = "ST_Equals(({0}), ({1}))";
+    private static final String FORMAT_ST_ISCLOSED = "ST_IsClosed({0})";
+    private static final String FORMAT_ST_OVERLAPS = "ST_Overlaps(({0}), ({1}))";
+    private static final String FORMAT_ST_TOUCHES = "ST_Touches(({0}), ({1}))";
+    private static final String FORMAT_ST_WITHIN = "ST_Within(({0}), ({1}))";
+    private static final String FORMAT_ST_ENVELOPE = "ST_Envelope({0})";
+    private static final String FORMAT_ST_INTERSECTS = "ST_Intersects(({0}), ({1}))";
+    private static final String FORMAT_ST_GEOMFROMTEXT = "ST_GeomFromText(({0}), ({1}))";
+    private static final String FORMAT_ST_GEOMFROMWKB = "ST_GeomFromWKB(({0}), ({1}))";
+    private static final String FORMAT_ST_GEOMFROMEWKB = "ST_GeomFromEWKB(({0}), ({1}))";
+    private static final String FORMAT_ST_SIMPLIFY = "ST_Simplify(({0}), ({1}))";
 
-            this.set(Config.has_spatial_functions, true);
-            this.set(Config.support_schemas, true);
-            this.set(Config.constant_true, "(1=1)");
-            this.set(Config.constant_false, "(1=2)");
-            this.set(Config.quote_for_identifiers, "\"");
-            this.set(Config.quote_for_strings, "'");
-            this.set(Config.geometry_type_support, GeometrySupportType.WKB);
-            this.set(Config.group, "( {0} )");
+    private static final String FORMAT_ISNULL = "( ({0}) IS NULL )";
+    private static final String FORMAT_NOTISNULL = "( ({0}) NOT IS NULL )";
+    private static final String FORMAT_OPERATOR_NOT = "( NOT ({0}) )";
 
-            this.set(Config.ST_SRID, "ST_SRID({0})");
-            this.set(Config.ST_AsText, "ST_AsText({0})");
-            this.set(Config.ST_AsBinary, "ST_AsBinary({0})");
-            this.set(Config.ST_AsEWKB, "ST_AsEWKB({0})");
-            this.set(Config.ST_Contains, "ST_Contains(({0}), ({1}))");
-            this.set(Config.ST_Crosses, "ST_Crosses(({0}), ({1}))");
-            this.set(Config.ST_Disjoint, "ST_Disjoint(({0}), ({1}))");
-            this.set(Config.ST_Equals, "ST_Equals(({0}), ({1}))");
-            this.set(Config.ST_IsClosed, "ST_IsClosed({0})");
-            this.set(Config.ST_Overlaps, "ST_Overlaps(({0}), ({1}))");
-            this.set(Config.ST_Touches, "ST_Touches(({0}), ({1}))");
-            this.set(Config.ST_Within, "ST_Within(({0}), ({1}))");
-            this.set(Config.ST_Envelope, "ST_Envelope({0})");
-            this.set(Config.ST_Intersects, "ST_Intersects(({0}), ({1}))");
-            this.set(Config.ST_GeomFromText, "ST_GeomFromText({0}, ({1}))");
-            this.set(Config.ST_GeomFromWKB, "ST_GeomFromWKB(({0}), ({1}))");
-            this.set(Config.ST_GeomFromEWKB, "ST_GeomFromEWKB(({0}), ({1}))");
-            
-            // Por defecto no esta disponible la funcion ST_Simplify
-            // this.set(Config.ST_Simplify, "ST_Simplify(({0}), ({1}))");
-            this.remove_functionality(Config.ST_Simplify);
-            
-            this.set(Config.lcase, "LCASE({0})");
-            this.set(Config.ucase, "UCASE({0})");
-            this.set(Config.iif, "IIF({0},{1},{2})");
-            this.set(Config.ifnull, "IFNULL({0},{1},{2})");
-            
-            this.set(Config.isNull, "( ({0}) IS NULL )");
-            this.set(Config.notIsNull, "( ({0}) NOT IS NULL )");
-            this.set(Config.operator_not, "( NOT ({0}) )");
+    private static final String FORMAT_OPERATOR_AND = "{0} AND {1}";
+    private static final String FORMAT_OPERATOR_OR = "{0} OR {1}";
+    private static final String FORMAT_OPERATOR_EQ = "( ({0}) = ({1}) )";
+    private static final String FORMAT_OPERATOR_NE = "( ({0}) <> ({1}) )";
+    private static final String FORMAT_OPERATOR_GT = "( ({0}) > ({1}) )";
+    private static final String FORMAT_OPERATOR_GE = "( ({0}) >= ({1}) )";
+    private static final String FORMAT_OPERATOR_LT = "( ({0}) < ({1}) )";
+    private static final String FORMAT_OPERATOR_LE = "( ({0}) <= ({1}) )";
+    private static final String FORMAT_OPERATOR_LIKE = "( ({0}) LIKE ({1}) )";
+    private static final String FORMAT_OPERATOR_ILIKE = "( ({0}) ILIKE ({1}) )";
+    private static final String FORMAT_OPERATOR_ADD = "{0} + {1}";
+    private static final String FORMAT_OPERATOR_SUBST = "{0} - {1}";
+    private static final String FORMAT_OPERATOR_MULT = "{0} * {1}";
+    private static final String FORMAT_OPERATOR_DIV = "{0} / {1}";
+    private static final String FORMAT_OPERATOR_CONCAT = "{0} || {1}";
 
-            this.set(Config.operator_AND, "{0} AND {1}");
-            this.set(Config.operator_OR, "{0} OR {1}");
-            this.set(Config.operator_EQ, "( ({0}) = ({1}) )");
-            this.set(Config.operator_NE, "( ({0}) <> ({1}) )");
-            this.set(Config.operator_GT, "( ({0}) > ({1}) )");
-            this.set(Config.operator_GE, "( ({0}) >= ({1}) )");
-            this.set(Config.operator_LT, "( ({0}) < ({1}) )");
-            this.set(Config.operator_LE, "( ({0}) <= ({1}) )");
-            this.set(Config.operator_LIKE, "( ({0}) LIKE ({1}) )");
-            this.set(Config.operator_ILIKE, "( ({0}) ILIKE ({1}) )");
-
-            this.set(Config.operator_add, "{0} + {1}");
-            this.set(Config.operator_subst, "{0} - {1}");
-            this.set(Config.operator_mult, "{0} * {1}");
-            this.set(Config.operator_div, "{0} / {1}");
-            this.set(Config.operator_concat, "{0} || {1}");
-
-        }
-
-        @Override
-        public boolean has_functionality(String functionality) {
-            Object x = this.values.get(functionality);
-            if (x == null) {
-                return false;
-            }
-            if (x instanceof CharSequence && StringUtils.isEmpty((CharSequence) x)) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public void remove_functionality(String functionality) {
-            this.values.remove(functionality);
-        }
-
-        @Override
-        public boolean has_spatial_functions() {
-            return this.getBoolean(has_spatial_functions);
-        }
-
-        @Override
-        public GeometrySupportType getGeometryTypeSupport() {
-            return (GeometrySupportType) this.get(geometry_type_support);
-        }
-
-        @Override
-        public boolean getBoolean(String name) {
-            return (boolean) this.values.get(name);
-        }
-
-        @Override
-        public String getString(String name) {
-            return (String) this.values.get(name);
-        }
-
-        @Override
-        public Object get(String name) {
-            return this.values.get(name);
-        }
-
-        @Override
-        public void set(String name, Object value) {
-            this.values.put(name, value);
-        }
-    }
-
-    public abstract class AbstractValue implements Value {
-
-        @Override
-        public void accept(Visitor visitor, VisitorFilter filter) {
-            if (filter == null || filter.accept(this)) {
-                visitor.visit(this);
-            }
-        }
-
-    }
-
-    public class ClassVisitorFilter implements VisitorFilter {
-
-        private final Class classFilter;
-
-        public ClassVisitorFilter(Class classFilter) {
-            this.classFilter = classFilter;
-        }
-
-        @Override
-        public boolean accept(Visitable visitable) {
-            return classFilter.isInstance(visitable);
-        }
-
-    }
-
     public class GroupBase extends AbstractValue implements Group {
 
         protected Value value;
@@ -170,7 +78,7 @@
         }
 
         @Override
-        public Value getValue() {
+        public Value value() {
             return value;
         }
 
@@ -182,8 +90,16 @@
 
         @Override
         public String toString() {
-            return MessageFormat.format(config.getString(Config.group), this.value.toString());
+            return this.toString(EMPTY_FORMATTER);
         }
+        
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
+            return MessageFormat.format(FORMAT_GROUP, this.value.toString());
+        }
     }
 
     public class VariableBase extends AbstractValue implements Variable {
@@ -195,18 +111,26 @@
         }
 
         @Override
-        public String getName() {
+        public String name() {
             return this.name;
         }
 
         @Override
         public String toString() {
+            return this.toString(EMPTY_FORMATTER);
+        }
+        
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
             return identifier(this.name);
         }
 
         @Override
         public int compareTo(Variable o) {
-            return this.name.compareTo(o.getName());
+            return this.name.compareTo(o.name());
         }
 
         @Override
@@ -214,7 +138,7 @@
             if (!(obj instanceof Variable)) {
                 return false;
             }
-            return this.name.equals(((Variable) obj).getName());
+            return this.name.equals(((Variable) obj).name());
         }
 
         @Override
@@ -232,6 +156,15 @@
         protected ParameterType type;
         protected Value srs;
 
+        /*
+        Para un parametre de tipo Geometria, el srs sera siempre un Constant
+        excepto cuando se le asigne una geometria contante al parametro y esta
+        tenga un SRS asignado. En este caso, tanto la geometria como el SRS
+        se trataran como parametros.
+        
+        Si se quiere que el SRS sea un Parameter, se construira como tal y se 
+        asignara a traves del metodo srs(Value srs).
+        */
         public ParameterBase() {
             this.type = ParameterType.Constant;
             this.name = null;
@@ -284,7 +217,7 @@
 
         @Override
         public Parameter srs(IProjection srs) {
-            this.srs = constant(getSRSId(srs));
+            this.srs = constant(srs_id(srs));
             if( this.type == ParameterType.Variable ) {
                 this.type = ParameterType.Geometry;
             }
@@ -292,7 +225,7 @@
         }
 
         @Override
-        public String getName() {
+        public String name() {
             switch (this.type) {
                 case Variable:
                 case Geometry:
@@ -330,6 +263,12 @@
 
         @Override
         public Parameter value(Object value) {
+            if( value instanceof Geometry ) {
+                if( this.srs == null ) {
+                    IProjection proj = ((Geometry)value).getProjection();
+                    this.srs(parameter().value(proj));
+                }
+            }
             this.value = value;
             return this;
         }
@@ -342,23 +281,23 @@
         }
 
         @Override
-        public Object getValue() {
+        public Object value() {
             try {
                 switch (this.type) {
                     case Constant:
-                        if (this.value instanceof Geometry) {
-                            switch (config.getGeometryTypeSupport()) {
+                        if( this.value instanceof Geometry ) {
+                            Geometry geometry = (Geometry) this.value;
+                            switch (geometry_support_type()) {
                                 case EWKB:
-                                    return bytearray(((Geometry) this.value).convertToEWKB());
-                                case NATIVE:
+                                    return GeometryUtils.toEWKB(geometry);
                                 case WKB:
-                                    return bytearray(((Geometry) this.value).convertToWKB());
+                                    return GeometryUtils.toWKB(geometry);
                                 case WKT:
                                 default:
-                                    return ((Geometry) this.value).convertToWKT();
+                                    return GeometryUtils.toWKT(geometry);
                             }
                         } else if (this.value instanceof IProjection) {
-                            return getSRSId((IProjection) this.value);
+                            return srs_id((IProjection) this.value);
                         }
                         return this.value;
                     case Variable:
@@ -372,46 +311,92 @@
         }
 
         @Override
-        public ParameterType getType() {
+        public ParameterType type() {
             return this.type;
         }
 
         @Override
-        public Value getSRS() {
+        public Value srs() {
             return this.srs;
         }
 
         @Override
         public String toString() {
+            return this.toString(EMPTY_FORMATTER);
+        }
+        
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
             switch (this.type) {
                 case Constant:
+                    if( value instanceof Geometry ) {
+                        switch (geometry_support_type()) {
+                            case EWKB:
+                                return MessageFormat.format(
+                                    FORMAT_ST_GEOMFROMEWKB,
+                                    "?",
+                                    getSRS(formatter)
+                                );
+                            case WKB:
+                                return MessageFormat.format(
+                                    FORMAT_ST_GEOMFROMWKB,
+                                    "?",
+                                    getSRS(formatter)
+                                );
+                            case WKT:
+                            default:
+                                return MessageFormat.format(
+                                    FORMAT_ST_GEOMFROMTEXT,
+                                    "?",
+                                    getSRS(formatter)
+                                );
+                        }
+                    }
                 case Variable:
                 default:
                     return "?";
                 case Geometry:
-                    switch (config.getGeometryTypeSupport()) {
+                    switch (geometry_support_type()) {
                         case EWKB:
                             return MessageFormat.format(
-                                    config.getString(Config.ST_GeomFromEWKB),
-                                    "?",
-                                    String.valueOf(this.srs.toString())
+                                FORMAT_ST_GEOMFROMEWKB,
+                                "?",
+                                getSRS(formatter)
                             );
                         case WKB:
                             return MessageFormat.format(
-                                    config.getString(Config.ST_GeomFromWKB),
-                                    "?",
-                                    String.valueOf(this.srs.toString())
+                                FORMAT_ST_GEOMFROMWKB,
+                                "?",
+                                getSRS(formatter)
                             );
                         case WKT:
                         default:
                             return MessageFormat.format(
-                                    config.getString(Config.ST_GeomFromText),
-                                    "?",
-                                    String.valueOf(this.srs.toString())
+                                FORMAT_ST_GEOMFROMTEXT,
+                                "?",
+                                getSRS(formatter)
                             );
                     }
             }
         }
+        
+        private String getSRS(Formatter formatter) {
+            if( this.srs!=null ) {
+                return this.srs.toString(formatter);
+            }
+            if( this.value instanceof Geometry ) {
+                IProjection proj = ((Geometry)this.value).getProjection();
+                Object s = srs_id(proj);
+                if( s == null ) {
+                    throw new IllegalArgumentException("A parameter of type Geometry with an invalid SRS.");
+                }
+                return s.toString();
+            }
+            throw new IllegalArgumentException("The parameter of type Geometry need a SRS.");
+        }
     }
 
     public class ConstantBase extends AbstractValue implements Constant {
@@ -423,23 +408,64 @@
         }
 
         @Override
-        public Object getValue() {
+        public Object value() {
             return this.value;
         }
 
         @Override
         public String toString() {
+            return this.toString(EMPTY_FORMATTER);
+        }
+        
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
+            if( this.value==null ) {
+                return "NULL";
+            }
+            if( this.value instanceof byte[] ) {
+                return "DECODE('"+bytearray_hex((byte[])this.value)+"','hex')";
+            }
             if (this.value instanceof String) {
                 return string((String) this.value);
             }
+            if( this.value instanceof Geometry ) {
+                Geometry geometry = (Geometry) this.value;
+                switch (geometry_support_type()) {
+                    case EWKB:
+                        return MessageFormat.format(
+                                FORMAT_ST_GEOMFROMEWKB,
+                                "DECODE('"+bytearray_hex(GeometryUtils.toEWKB(geometry))+"','hex')",
+                                String.valueOf(srs_id(geometry.getProjection()))
+                        );
+                    case WKB:
+                        return MessageFormat.format(
+                                FORMAT_ST_GEOMFROMWKB,
+                                "DECODE('"+bytearray_hex(GeometryUtils.toWKB(geometry))+"','hex')",
+                                String.valueOf(srs_id(geometry.getProjection()))
+                        );
+                    case WKT:
+                    default:
+                        return MessageFormat.format(
+                                FORMAT_ST_GEOMFROMTEXT,
+                                string(GeometryUtils.toWKT(geometry)),
+                                String.valueOf(srs_id(geometry.getProjection()))
+                        );
+                }
+            }
+            if( this.value instanceof IProjection ) {
+                return Objects.toString(srs_id((IProjection)(this.value)));
+            }
             if (this.value instanceof Boolean) {
                 if (((Boolean) this.value)) {
-                    return config.getString(Config.constant_true);
+                    return FORMAT_TRUE;
                 } else {
-                    return config.getString(Config.constant_false);
+                    return FORMAT_FALSE;
                 }
             }
-            return ObjectUtils.toString(this.value, "");
+            return Objects.toString(this.value, "");
         }
     }
 
@@ -466,7 +492,7 @@
         }
 
         @Override
-        public Object getValue() {
+        public Object value() {
             return this.value;
         }
 
@@ -490,57 +516,15 @@
 
         @Override
         public String toString() {
-            return ObjectUtils.toString(this.value, "");
+            return this.toString(EMPTY_FORMATTER);
         }
-    }
-
-    public class GeometryValueBase extends AbstractValue implements GeometryValue {
-
-        protected Geometry geometry;
-        protected IProjection projection;
-
-        public GeometryValueBase(Geometry geometry, IProjection projection) {
-            this.geometry = geometry;
-            this.projection = projection;
-        }
-
+        
         @Override
-        public Geometry getGeometry() {
-            return this.geometry;
-        }
-
-        @Override
-        public IProjection getSRS() {
-            return this.projection;
-        }
-
-        @Override
-        public String toString() {
-            try {
-                switch (config.getGeometryTypeSupport()) {
-                    case EWKB:
-                        return MessageFormat.format(
-                                config.getString(Config.ST_GeomFromEWKB),
-                                bytearray(this.geometry.convertToEWKB()),
-                                String.valueOf(getSRSId(this.projection))
-                        );
-                    case WKB:
-                        return MessageFormat.format(
-                                config.getString(Config.ST_GeomFromWKB),
-                                bytearray(this.geometry.convertToWKB()),
-                                String.valueOf(getSRSId(this.projection))
-                        );
-                    case WKT:
-                    default:
-                        return MessageFormat.format(
-                                config.getString(Config.ST_GeomFromText),
-                                string(this.geometry.convertToWKT()),
-                                String.valueOf(getSRSId(this.projection))
-                        );
-                }
-            } catch (Exception ex) {
-                throw new RuntimeException("Can't convert geometry to string.", ex);
+        public String toString(Formatter<Value> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
             }
+            return Objects.toString(this.value, "");
         }
     }
 
@@ -574,7 +558,7 @@
         }
 
         @Override
-        public String getName() {
+        public String name() {
             return this.name;
         }
 
@@ -588,6 +572,14 @@
 
         @Override
         public String toString() {
+            return this.toString(EMPTY_FORMATTER);
+        }
+        
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
             if( this.format==null ) {
                 StringBuilder builder = new StringBuilder();
                 builder.append(name);
@@ -597,10 +589,10 @@
                     for (Value value : this.parameters) {
                         if( first ) {
                             first=false;
-                            builder.append(value.toString());
+                            builder.append(value.toString(formatter));
                         } else {
                             builder.append(", ");
-                            builder.append(value.toString());
+                            builder.append(value.toString(formatter));
                         }
                     }
                 }
@@ -610,7 +602,7 @@
             if (this.parameters != null && !this.parameters.isEmpty()) {
                 List<String> values = new ArrayList<>();
                 for (Value value : this.parameters) {
-                    values.add(value.toString());
+                    values.add(value.toString(formatter));
                 }
                 return MessageFormat.format(format, values.toArray());
             } else {
@@ -619,6 +611,54 @@
         }
     }
 
+    public class MethodBase extends FunctionBase implements Method {
+
+        private final Value instance;
+        
+        public MethodBase(Value instance, String name) {
+            super(name);
+            this.instance = instance;
+        }
+
+        @Override
+        public Value instance() {
+            return this.instance;
+        }
+
+        @Override
+        public void accept(Visitor visitor, VisitorFilter filter) {
+            this.instance.accept(visitor, filter);
+            super.accept(visitor, filter);
+        }
+        
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
+            StringBuilder builder = new StringBuilder();
+            builder.append(this.instance.toString(formatter));
+            builder.append("->");
+            builder.append(this.name());
+            builder.append(name);
+            builder.append("(");
+            if (this.parameters != null && !this.parameters.isEmpty()) {
+                boolean first = true;
+                for (Value value : this.parameters) {
+                    if( first ) {
+                        first=false;
+                        builder.append(value.toString(formatter));
+                    } else {
+                        builder.append(", ");
+                        builder.append(value.toString(formatter));
+                    }
+                }
+            }
+            builder.append(")");
+            return builder.toString();
+        }
+    }
+
     public class BinaryOperatorBase extends AbstractValue implements BinaryOperator {
 
         protected String name;
@@ -632,7 +672,7 @@
         }
 
         @Override
-        public String getName() {
+        public String name() {
             return this.name;
         }
 
@@ -644,42 +684,62 @@
         }
 
         @Override
-        public BinaryOperator setLeft(Value operand) {
+        public BinaryOperator left(Value operand) {
             this.left = operand;
             return this;
         }
 
         @Override
-        public BinaryOperator setRight(Value operand) {
+        public BinaryOperator right(Value operand) {
             this.right = operand;
             return this;
         }
 
         @Override
-        public Value getLeft() {
+        public Value left() {
             return this.left;
         }
 
         @Override
-        public Value getRight() {
+        public Value right() {
             return this.right;
         }
 
         @Override
         public String toString() {
-            return MessageFormat.format(
-                    format,
-                    this.left.toString(),
-                    this.right.toString()
-            );
+            return this.toString(EMPTY_FORMATTER);
         }
+        
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
+            if( this.format==null ) {
+                StringBuilder builder = new StringBuilder();
+                builder.append("(");
+                builder.append(this.left.toString(formatter));
+                builder.append(" ");
+                builder.append(this.name);
+                builder.append(" ");
+                builder.append(this.right.toString(formatter));
+                builder.append(")");
+                return builder.toString();
+            } else {
+                return MessageFormat.format(
+                        format,
+                        this.left.toString(formatter),
+                        this.right.toString(formatter)
+                );
+            }
+        }
     }
 
+    protected GeometrySupportType geometrySupportType;
     protected Value value;
-    protected Config config;
 
     public DefaultExpressionBuilder() {
-        this.config = new ConfigBase();
+        this.geometrySupportType = GeometrySupportType.WKB;
     }
 
     @Override
@@ -688,17 +748,23 @@
     }
 
     @Override
-    public Config getConfig() {
-        return this.config;
+    public GeometrySupportType geometry_support_type() {
+        return this.geometrySupportType;
     }
 
     @Override
-    public Value getValue() {
+    public ExpressionBuilder geometry_support_type(GeometrySupportType geometrySupportType) {
+        this.geometrySupportType = geometrySupportType;
+        return this;
+    }
+
+    @Override
+    public Value value() {
         return this.value;
     }
 
     @Override
-    public ExpressionBuilder setValue(Value value) {
+    public ExpressionBuilder value(Value value) {
         this.value = value;
         return this;
     }
@@ -709,6 +775,21 @@
     }
 
     @Override
+    public String toString(Formatter<Value> formatter) {
+        return this.value.toString(formatter);
+    }
+
+    @Override
+    public Value toValue(String expression) {
+        try {
+            Code code = ExpressionUtils.compile(expression);
+            return code.toValue(this);
+        } catch(Throwable ex) {
+            return custom(expression);
+        }
+    }
+
+    @Override
     public void accept(Visitor visitor, VisitorFilter filter) {
         if( this.value == null) {
             return;
@@ -717,29 +798,29 @@
     }
 
     @Override
-    public boolean has_spatial_functions() {
-        return this.config.getBoolean(Config.has_spatial_functions);
+    public String quote_for_identifiers() {
+        return FORMAT_QUOTE_FOR_IDENTIFIERS;
     }
-
+    
     @Override
-    public GeometrySupportType geometry_support_type() {
-        return (GeometrySupportType) this.config.get(Config.geometry_type_support);
+    public String quote_for_strings() {
+        return FORMAT_QUOTE_FOR_STRINGS;
     }
-
+       
     @Override
     public String string(String s) {
-        String quote = this.config.getString(Config.quote_for_strings);
+        String quote = this.quote_for_strings();
 //        No se porque no esta disponible wrapIfMissing
 //        return StringUtils.wrapIfMissing(s,quote);
         if (s.startsWith(quote)) {
             return s;
         }
-        return quote + s + quote;
+        return quote + StringUtils.replace(s,quote,quote+quote) + quote;
     }
 
     @Override
     public String identifier(String id) {
-        String quote = this.config.getString(Config.quote_for_identifiers);
+        String quote = this.quote_for_identifiers();
 //        No se porque no esta disponible wrapIfMissing
 //        return StringUtils.wrapIfMissing(id,quote);
         if (id.startsWith(quote)) {
@@ -749,11 +830,6 @@
     }
 
     @Override
-    public String bytearray(byte[] data) {
-        return "DECODE('"+bytearray_hex(data)+"','hex')";
-    }
-    
-    @Override
     public String bytearray_hex(byte[] data) {
         StringBuilder builder = new StringBuilder();
         for (byte abyte : data) {
@@ -774,7 +850,7 @@
     }
     
     @Override
-    public Object getSRSId(IProjection projection) {
+    public Object srs_id(IProjection projection) {
         if( projection==null ) {
             return 0;
         }
@@ -782,8 +858,13 @@
     }
 
     @Override
+    public Constant bytearray(byte[] data) {
+        return new ConstantBase(data);
+    }
+    
+    @Override
     public Constant srs(IProjection projection) {
-        return constant(getSRSId(projection));
+        return constant(projection);
     }
 
     @Override
@@ -798,12 +879,13 @@
     
     @Override
     public Parameter parameter(String name) {
-        Parameters parameters = this.getParameters();
-        Parameter parameter = parameters.get(name);
-        if( parameter != null ) {
-            return parameter;
+        List<Parameter> parameters = this.parameters();
+        for (Parameter parameter : parameters) {
+            if( StringUtils.equalsIgnoreCase(name, parameter.name()) ) {
+                return parameter;
+            }
         }
-        parameter = this.parameter();
+        Parameter parameter = this.parameter();
         parameter.name(name);
         return parameter;
     }
@@ -824,29 +906,33 @@
     }
 
     @Override
-    public GeometryValue geometry(Geometry geom, IProjection projection) {
-        return new GeometryValueBase(geom, projection);
+    public Constant geometry(Geometry geom, IProjection projection) {
+        geom.setProjection(projection);
+        return new ConstantBase(geom);
     }
 
     @Override
-    public GeometryValue geometry(Geometry geom) {
+    public Constant geometry(Geometry geom) {
         if( geom.getProjection()==null ) {
             throw new IllegalArgumentException("The geometry does not have an associated projection. Use 'geometry(Geometry, IProjection)'.");
         }
-        return new GeometryValueBase(geom, geom.getProjection());
+        return new ConstantBase(geom);
     }
 
     @Override
-    public GeometryValue envelope(Envelope envelope, IProjection projection) {
-        return new GeometryValueBase(envelope.getGeometry(), projection);
+    public Constant envelope(Envelope envelope, IProjection projection) {
+        Geometry geom = envelope.getGeometry();
+        geom.setProjection(projection);
+        return new ConstantBase(geom);
     }
 
     @Override
-    public GeometryValue envelope(Envelope envelope) {
+    public Constant envelope(Envelope envelope) {
         if( envelope.getProjection()==null ) {
             throw new IllegalArgumentException("The envelope does not have an associated projection. Use 'envelope(Geometry, IProjection)'.");
         }
-        return new GeometryValueBase(envelope.getGeometry(), envelope.getProjection());
+        Geometry geom = envelope.getGeometry();
+        return new ConstantBase(geom);
     }
 
     @Override
@@ -854,6 +940,16 @@
         return new CustomBase(value);
     }
 
+    @Override
+    public Method method(Value instance, String name, Value... values) {
+        MethodBase method = new MethodBase(instance, name);
+        for (Value theValue : values) {
+            method.parameter(theValue);
+        }
+        return method;
+    }
+    
+    @Override
     public Function function(String name, Value... values) {
         FunctionBase func = new FunctionBase(name);
         for (Value theValue : values) {
@@ -870,20 +966,27 @@
         return func;
     }
 
+    @Override
+    public BinaryOperator binaryOperator(String name, Value leftOperand, Value rightOperand) {
+        return binaryOperator(name, null, leftOperand, rightOperand);
+    }
+    
     public BinaryOperator binaryOperator(String name, String format, Value leftOperand, Value rightOperand) {
         BinaryOperator operator = new BinaryOperatorBase(name, format);
-        operator.setLeft(leftOperand);
-        operator.setRight(rightOperand);
+        operator.left(leftOperand);
+        operator.right(rightOperand);
         return operator;
     }
 
     @Override
-    public List<Variable> getVariables() {
+    public List<Variable> variables() {
         final Set<Variable> vars = new HashSet<>();
         this.accept(new Visitor() {
             @Override
             public void visit(Visitable value) {
-                vars.add((Variable) value);
+                if( !vars.contains((Variable)value) ) {
+                    vars.add((Variable)value);
+                }
             }
         }, new ClassVisitorFilter(Variable.class));
         List<Variable> lvars = new ArrayList<>(vars);
@@ -891,75 +994,9 @@
         return lvars;
     }
 
-    private static class ParametersBase extends ArrayList<Parameter> implements Parameters {
-
-        private static final long serialVersionUID = -2188534574151780470L;
-
-        public ParametersBase() {
-            super();
-        }
-
-        public ParametersBase(Collection parameters) {
-            super(parameters);
-        }
-
-        @Override
-        public Parameter get(String name) {
-            if( name == null ) {
-                return null;
-            }
-            for (Parameter param : this) {
-                if( param.is_variable() || param.is_geometry_variable() ) {
-                    if( name.equalsIgnoreCase(param.getName()) ) {
-                        return param;
-                    }
-                }
-            }
-            return null;
-        }
-
-        
-        @Override
-        public String toString() {
-            boolean first = true;
-            StringBuilder builder = new StringBuilder();
-            builder.append("{ ");
-            for (Parameter param : this) {
-                if (!first) {
-                    builder.append(", ");
-                } else {
-                    first = false;
-                }
-                String s;
-                Object value = param.getValue();
-                if (value == null) {
-                    s = "null";
-                } else if (value instanceof String) {
-                    s = "'" + (String) value + "'";
-                } else {
-                    s = value.toString();
-                }
-                switch (param.getType()) {
-                    case Constant:
-                        builder.append(s);
-                        break;
-                    case Geometry:
-                        builder.append("(Geometry)");
-                    case Variable:
-                    default:
-                        builder.append(param.getName());
-                        builder.append(": ");
-                        builder.append(s);
-                }
-            }
-            builder.append(" }");
-            return builder.toString();
-        }
-    }
-
     @Override
-    public Parameters getParameters() {
-        final Parameters params = new ParametersBase();
+    public List<Parameter> parameters() {
+        final List<Parameter>  params = new ArrayList<>();
         this.accept(new Visitor() {
             @Override
             public void visit(Visitable value) {
@@ -968,11 +1005,60 @@
         }, new ClassVisitorFilter(Parameter.class));
         return params;
     }
-
+    
     @Override
-    public Function getAsGeometry(Value value) {
-        return builtin_function("ST_AsBinary", config.getString(Config.ST_AsBinary), value);
+    public List<String> parameters_names() {
+        List<String> params = new ArrayList<>();
+        for (Parameter param : parameters()) {
+            Object theValue = param.value();
+            String s;
+            switch(param.type()) {
+                case Constant:
+                    if( theValue==null ) {
+                        s = "NULL";
+                    } else if( theValue instanceof String ) {
+                        s = "'" + (String)theValue + "'";
+                        
+                    } else if( theValue instanceof byte[] ) {
+                        s = bytearray_0x((byte[]) theValue);
+                        
+                    } else {
+                        s = theValue.toString();
+                    }    
+                    break;
+                case Geometry:
+                    if( param.name()==null ) {
+                        s = bytearray_0x((byte[]) theValue);
+                    } else {
+                        s = "\"" + param.name() + "\"";
+                    }
+                    break;
+                case Variable:
+                default:
+                    s = "\"" + param.name() + "\"";
+            }
+//            if( !params.contains(s) ) { // Ojo que deben ir todos, incluso duplicados.
+                params.add(s);
+//            }
+        }
+        // Collections.sort(params); Ojo, no deben ordenarse.
+        return params;
     }
+    
+    @Override
+    public List<String> variables_names() {
+        List<String> vars = new ArrayList<>();
+        for (Variable var : this.variables()) {
+            vars.add(var.name());
+        }
+        Collections.sort(vars);
+        return vars;
+    }
+    
+    @Override
+    public Function as_geometry(Value value) {
+        return builtin_function(FUNCTION_ST_ASBINARY, FORMAT_ST_ASBINARY, value);
+    }
 
     @Override
     public ExpressionBuilder set(Value value) {
@@ -985,7 +1071,7 @@
         if (this.value == null) {
             return this.set(value);
         }
-        BinaryOperator operator = binaryOperator("AND", config.getString(Config.operator_AND), this.value, value);
+        BinaryOperator operator = binaryOperator(OPERATOR_AND, FORMAT_OPERATOR_AND, this.value, value);
         this.value = operator;
         return this;
     }
@@ -995,438 +1081,474 @@
         if (this.value == null) {
             return this.set(value);
         }
-        BinaryOperator operator = binaryOperator("OR", config.getString(Config.operator_OR), this.value, value);
+        BinaryOperator operator = binaryOperator(OPERATOR_OR, FORMAT_OPERATOR_OR, this.value, value);
         this.value = operator;
         return this;
     }
 
     @Override
     public Function ST_Intersects(Value geom1, Value geom2) {
-        return builtin_function("ST_Intersects", config.getString(Config.ST_Intersects), geom1, geom2);
+        return builtin_function(FUNCTION_ST_INTERSECTS, FORMAT_ST_INTERSECTS, geom1, geom2);
     }
 
     @Override
     public Function ST_SRID(Value geom) {
-        return builtin_function("ST_SRID", config.getString(Config.ST_SRID), geom);
+        return builtin_function(FUNCTION_ST_SRID, FORMAT_ST_SRID, geom);
     }
 
     @Override
     public Function ST_Envelope(Value geom) {
-        return builtin_function("ST_Envelope", config.getString(Config.ST_Envelope), geom);
+        return builtin_function(FUNCTION_ST_ENVELOPE, FORMAT_ST_ENVELOPE, geom);
     }
 
     @Override
     public Function ST_AsText(Value geom) {
-        return builtin_function("ST_AsText", config.getString(Config.ST_AsText), geom);
+        return builtin_function(FUNCTION_ST_ASTEXT, FORMAT_ST_ASTEXT, geom);
     }
 
     @Override
     public Function ST_AsBinary(Value geom) {
-        return builtin_function("ST_AsBinary", config.getString(Config.ST_AsBinary), geom);
+        return builtin_function(FUNCTION_ST_ASBINARY, FORMAT_ST_ASBINARY, geom);
     }
 
     @Override
     public Function ST_AsEWKB(Value geom) {
-        return builtin_function("ST_AsEWKB", config.getString(Config.ST_AsEWKB), geom);
+        return builtin_function(FUNCTION_ST_ASEWKB, FORMAT_ST_ASEWKB, geom);
     }
 
     @Override
     public Function ST_GeomFromText(Value geom, Value crs) {
-        return builtin_function("ST_GeomFromText", config.getString(Config.ST_GeomFromText), geom, crs);
+        return builtin_function(FUNCTION_ST_GEOMFROMTEXT, FORMAT_ST_GEOMFROMTEXT, geom, crs);
     }
 
     @Override
     public Function ST_GeomFromWKB(Value geom, Value crs) {
-        return builtin_function("ST_GeomFromWKB", config.getString(Config.ST_GeomFromWKB), geom, crs);
+        return builtin_function(FUNCTION_ST_GEOMFROMWKB, FORMAT_ST_GEOMFROMWKB, geom, crs);
     }
 
     @Override
     public Function ST_GeomFromEWKB(Value geom, Value crs) {
-        return builtin_function("ST_GeomFromEWKB", config.getString(Config.ST_GeomFromEWKB), geom, crs);
+        return builtin_function(FUNCTION_ST_GEOMFROMEWKB, FORMAT_ST_GEOMFROMEWKB, geom, crs);
     }
 
     @Override
     public Function ST_Simplify(Value geom, Value tolerance) {
-        return builtin_function("ST_Simplify", config.getString(Config.ST_Simplify), tolerance);
+        return builtin_function(FUNCTION_ST_SIMPLIFY, FORMAT_ST_SIMPLIFY, tolerance);
     }
 
     @Override
     public Function ST_Disjoint(Value geom1, Value geom2) {
-        return builtin_function("ST_Disjoint", config.getString(Config.ST_Disjoint), geom1, geom2);
+        return builtin_function(FUNCTION_ST_DISJOINT, FORMAT_ST_DISJOINT, geom1, geom2);
     }
 
     @Override
     public Function ST_Contains(Value geom1, Value geom2) {
-        return builtin_function("ST_Contains", config.getString(Config.ST_Contains), geom1, geom2);
+        return builtin_function(FUNCTION_ST_CONTAINS, FORMAT_ST_CONTAINS, geom1, geom2);
     }
 
     @Override
     public Function ST_Equals(Value geom1, Value geom2) {
-        return builtin_function("ST_Equals", config.getString(Config.ST_Equals), geom1, geom2);
+        return builtin_function(FUNCTION_ST_EQUALS, FORMAT_ST_EQUALS, geom1, geom2);
     }
 
     @Override
     public Function ST_Crosses(Value geom1, Value geom2) {
-        return builtin_function("ST_Crosses", config.getString(Config.ST_Crosses), geom1, geom2);
+        return builtin_function(FUNCTION_ST_CROSSES, FORMAT_ST_CROSSES, geom1, geom2);
     }
 
     @Override
     public Function ST_IsClosed(Value geom) {
-        return builtin_function("ST_IsClosed", config.getString(Config.ST_IsClosed), geom);
+        return builtin_function(FUNCTION_ST_ISCLOSED, FORMAT_ST_ISCLOSED, geom);
     }
 
     @Override
     public Function ST_Overlaps(Value geom1, Value geom2) {
-        return builtin_function("ST_Overlaps", config.getString(Config.ST_Overlaps), geom1, geom2);
+        return builtin_function(FUNCTION_ST_OVERLAPS, FORMAT_ST_OVERLAPS, geom1, geom2);
     }
 
     @Override
     public Function ST_Touches(Value geom1, Value geom2) {
-        return builtin_function("ST_Touches", config.getString(Config.ST_Touches), geom1, geom2);
+        return builtin_function(FUNCTION_ST_TOUCHES, FORMAT_ST_TOUCHES, geom1, geom2);
     }
 
     @Override
     public Function ST_Within(Value geom1, Value geom2) {
-        return builtin_function("ST_Within", config.getString(Config.ST_Within), geom1, geom2);
+        return builtin_function("ST_Within", FORMAT_ST_WITHIN, geom1, geom2);
     }
 
     @Override
-    public Function isNull(Value value) {
-        return builtin_function("IS NULL", config.getString(Config.isNull), value);
+    public Function is_null(Value value) {
+        return builtin_function("IS NULL", FORMAT_ISNULL, value);
     }
 
     @Override
-    public Function notIsNull(Value value) {
-        return builtin_function("NOT IS NULL", config.getString(Config.notIsNull), value);
+    public Function not_is_null(Value value) {
+        return builtin_function("NOT IS NULL", FORMAT_NOTISNULL, value);
     }
 
     @Override
     public Function not(Value value) {
-        return builtin_function("NOT", config.getString(Config.operator_not), value);
+        return builtin_function(OPERATOR_NOT, FORMAT_OPERATOR_NOT, value);
     }
 
     @Override
-    public Function lcase(Value s) {
-        return builtin_function("LCASE", config.getString(Config.lcase), s);
-    }
-
-    @Override
-    public Function ucase(Value s) {
-        return builtin_function("UCASE", config.getString(Config.ucase), s);
-    }
-
-    @Override
     public BinaryOperator and(Value leftOperand, Value rightOperand) {
-        return binaryOperator("AND", config.getString(Config.operator_AND), leftOperand, rightOperand);
+        return binaryOperator(OPERATOR_AND, FORMAT_OPERATOR_AND, leftOperand, rightOperand);
     }
 
     @Override
     public BinaryOperator or(Value leftOperand, Value rightOperand) {
-        return binaryOperator("OR", config.getString(Config.operator_OR), leftOperand, rightOperand);
+        return binaryOperator(OPERATOR_OR, FORMAT_OPERATOR_OR, leftOperand, rightOperand);
     }
 
     @Override
     public BinaryOperator eq(Value leftOperand, Value rightOperand) {
-        return binaryOperator("=", config.getString(Config.operator_EQ), leftOperand, rightOperand);
+        return binaryOperator("=", FORMAT_OPERATOR_EQ, leftOperand, rightOperand);
     }
 
     @Override
     public BinaryOperator ne(Value leftOperand, Value rightOperand) {
-        return binaryOperator("<>", config.getString(Config.operator_NE), leftOperand, rightOperand);
+        return binaryOperator("<>", FORMAT_OPERATOR_NE, leftOperand, rightOperand);
     }
 
     @Override
     public BinaryOperator gt(Value op1, Value op2) {
-        return binaryOperator(">", config.getString(Config.operator_GT), op1, op2);
+        return binaryOperator(">", FORMAT_OPERATOR_GT, op1, op2);
     }
 
     @Override
     public BinaryOperator ge(Value op1, Value op2) {
-        return binaryOperator(">=", config.getString(Config.operator_GE), op1, op2);
+        return binaryOperator(">=", FORMAT_OPERATOR_GE, op1, op2);
     }
 
     @Override
     public BinaryOperator lt(Value op1, Value op2) {
-        return binaryOperator("<", config.getString(Config.operator_LT), op1, op2);
+        return binaryOperator("<", FORMAT_OPERATOR_LT, op1, op2);
     }
 
     @Override
     public BinaryOperator le(Value op1, Value op2) {
-        return binaryOperator("<=", config.getString(Config.operator_LE), op1, op2);
+        return binaryOperator("<=", FORMAT_OPERATOR_LE, op1, op2);
     }
 
     @Override
     public BinaryOperator like(Value op1, Value op2) {
-        return binaryOperator("LIKE", config.getString(Config.operator_LIKE), op1, op2);
+        return binaryOperator(OPERATOR_LIKE, FORMAT_OPERATOR_LIKE, op1, op2);
     }
 
     @Override
     public BinaryOperator ilike(Value op1, Value op2) {
-        return binaryOperator("ILIKE", config.getString(Config.operator_ILIKE), op1, op2);
+        return binaryOperator(OPERATOR_ILIKE, FORMAT_OPERATOR_ILIKE, op1, op2);
     }
 
     @Override
     public BinaryOperator add(Value op1, Value op2) {
-        return binaryOperator("ADD", config.getString(Config.operator_add), op1, op2);
+        return binaryOperator(OPERATOR_ADD, FORMAT_OPERATOR_ADD, op1, op2);
     }
 
     @Override
     public BinaryOperator subst(Value op1, Value op2) {
-        return binaryOperator("SUBST", config.getString(Config.operator_subst), op1, op2);
+        return binaryOperator(OPERATOR_SUBST, FORMAT_OPERATOR_SUBST, op1, op2);
     }
 
     @Override
     public BinaryOperator mult(Value op1, Value op2) {
-        return binaryOperator("MULT", config.getString(Config.operator_mult), op1, op2);
+        return binaryOperator(OPERATOR_MULT, FORMAT_OPERATOR_MULT, op1, op2);
     }
 
     @Override
     public BinaryOperator div(Value op1, Value op2) {
-        return binaryOperator("DIV", config.getString(Config.operator_div), op1, op2);
+        return binaryOperator(OPERATOR_DIV, FORMAT_OPERATOR_DIV, op1, op2);
     }
 
     @Override
     public BinaryOperator concat(Value op1, Value op2) {
-        return binaryOperator("CONCAT", config.getString(Config.operator_concat), op1, op2);
+        return binaryOperator(OPERATOR_CONCAT, FORMAT_OPERATOR_CONCAT, op1, op2);
     }
     
     @Override
     public Function iif(Value condition, Value iftrue, Value iffalse) {
-        return builtin_function("IIF", config.getString(Config.iif), condition, iftrue, iffalse);
+        return function(FUNCTION_IIF, condition, iftrue, iffalse);
     }
 
     @Override
     public Function ifnull(Value value, Value iftrue, Value iffalse) {
-        return builtin_function("IFNULL", config.getString(Config.ifnull), value, iftrue, iffalse);
+        return function(FUNCTION_IFNULL, value, iftrue, iffalse);
     }
     
     @Override
     public Function left(Value str, Value size) {
-       return function("left", str, size);
-       // return builtin_function("left", "left({1})",str,size);
+       return function(FUNCTION_LEFT, str, size);
     }
     
     @Override
     public Function right(Value str, Value len) {
-       return function("right", str, len);
+       return function(FUNCTION_RIGHT, str, len);
     }
     
     @Override
     public Function locate(Value search, Value str, Value start) {
-       return function("locate", search, str, start);
+       return function(FUNCTION_LOCATE, search, str, start);
     }
     
     @Override
     public Function position(Value search, Value str) {
-       return function("position", search, str);
+       return function(FUNCTION_POSITION, search, str);
     }
     
     @Override
     public Function lpad(Value str, Value len, Value padstr) {
-       return function("lpad", str, len, padstr);
+       return function(FUNCTION_LPAD, str, len, padstr);
     }
     
     @Override
     public Function rpad(Value str, Value len, Value padstr) {
-       return function("rpad", str, len, padstr);
+       return function(FUNCTION_RPAD, str, len, padstr);
     }
     
     @Override
     public Function ltrim(Value str) {
-       return function("ltrim", str);
+       return function(FUNCTION_LTRIM, str);
     }
     
     @Override
     public Function rtrim(Value str) {
-       return function("rtrim", str);
+       return function(FUNCTION_RTRIM, str);
     }
     
     @Override
     public Function trim(Value str) {
-       return function("trim", str);
+       return function(FUNCTION_TRIM, str);
     }
     
     @Override
     public Function repeat(Value str, Value size) {
-       return function("repeat", str, size);
+       return function(FUNCTION_REPEAT, str, size);
     }
     
     @Override
     public Function replace(Value str, Value search, Value replstr) {
-       return function("replace", str, search, replstr);
+       return function(FUNCTION_REPLACE, str, search, replstr);
     }
     
     @Override
     public Function ascii(Value str) {
-       return function("ascii", str);
+       return function(FUNCTION_ASCII, str);
     }
     
     @Override
     public Function lenght(Value str) {
-       return function("lenght", str);
+       return function(FUNCTION_LENGHT, str);
     }
 
     @Override
     public Function instr(Value str, Value search, Value start) {
-       return function("instr", str, search, start);
+       return function(FUNCTION_INSTR, str, search, start);
     }
     
     @Override
     public Function lower(Value str) {
-       return function("lower", str);
+       return function(FUNCTION_LOWER, str);
     }
     
     @Override
     public Function upper(Value str) {
-       return function("upper", str);
+       return function(FUNCTION_UPPER, str);
     }
     
     @Override
     public Function space(Value size) {
-       return function("space", size);
+       return function(FUNCTION_SPACE, size);
     }
     
     @Override
     public Function substring(Value str, Value start, Value len) {
-       return function("substring", str, start, len);
+       return function(FUNCTION_SUBSTRING, str, start, len);
     }
     
     @Override
     public Function acos(Value num) {
-       return function("acos", num);
+       return function(FUNCTION_ACOS, num);
     } 
     
     @Override
     public Function asin(Value num) {
-       return function("asin", num);
+       return function(FUNCTION_ASIN, num);
     }
     
     @Override
     public Function atan(Value num) {
-       return function("atan", num);
+       return function(FUNCTION_ATAN, num);
     }
     
     @Override
     public Function cos(Value num) {
-       return function("cos", num);
+       return function(FUNCTION_COS, num);
     }
     
     @Override
     public Function cosh(Value num) {
-       return function("cosh", num);
+       return function(FUNCTION_COSH, num);
     }
     
     @Override
     public Function cot(Value num) {
-       return function("cot", num);
+       return function(FUNCTION_COT, num);
     }  
     
     @Override
     public Function bitand(Value num1, Value num2) {
-       return function("bitand", num1, num2);
+       return function(FUNCTION_BITAND, num1, num2);
     } 
     
     @Override
     public Function bitor(Value num1, Value num2) {
-       return function("bitor", num1, num2);
+       return function(FUNCTION_BITOR, num1, num2);
     }
     
     @Override
     public Function bitxor(Value num1, Value num2) {
-       return function("bitxor", num1, num2);
+       return function(FUNCTION_BITXOR, num1, num2);
     }
     
     @Override
     public Function ceil(Value num) {
-       return function("ceil", num);
+       return function(FUNCTION_CEIL, num);
     }
     
     @Override
     public Function degrees(Value num) {
-       return function("degrees", num);
+       return function(FUNCTION_DEGREES, num);
     }  
     
     @Override
     public Function exp(Value num) {
-       return function("exp", num);
+       return function(FUNCTION_EXP, num);
     }  
     
     @Override
     public Function floor(Value num) {
-       return function("floor", num);
+       return function(FUNCTION_FLOOR, num);
     }  
     
     @Override
     public Function log(Value num) {
-       return function("log", num);
+       return function(FUNCTION_LOG, num);
     }  
     
     @Override
     public Function log10(Value num) {
-       return function("log10", num);
+       return function(FUNCTION_LOG10, num);
     }  
     
     @Override
     public Function pi(Value num) {
-       return function("pi", num);
+       return function(FUNCTION_PI, num);
     }
     
     @Override
     public Function power(Value num) {
-       return function("power", num);
+       return function(FUNCTION_POWER, num);
     }
     
     @Override
     public Function radians(Value num) {
-       return function("radians", num);
+       return function(FUNCTION_RADIANS, num);
     }
     
     @Override
     public Function rand(Value num) {
-       return function("rand", num);
+       return function(FUNCTION_RAND, num);
     }
     
     @Override
     public Function round(Value num) {
-       return function("round", num);
+       return function(FUNCTION_ROUND, num);
     }
     
     @Override
     public Function sqrt(Value num) {
-       return function("sqrt", num);
+       return function(FUNCTION_SQRT, num);
     }
     
     @Override
     public Function sign(Value num) {
-       return function("sign", num);
+       return function(FUNCTION_SIGN, num);
     }
     
     @Override
     public Function sin(Value num) {
-       return function("sin", num);
+       return function(FUNCTION_SIN, num);
     }
     
     @Override
     public Function sinh(Value num) {
-       return function("sinh", num);
+       return function(FUNCTION_SINH, num);
     }
     
     @Override
     public Function tan(Value num) {
-       return function("tan", num);
+       return function(FUNCTION_TAN, num);
     }
     @Override
     public Function tanh(Value num) {
-       return function("cosh", num);
+       return function(FUNCTION_TANH, num);
     }  
     
     @Override
     public Function zero() {
-       return function("zero");
+       return function(FUNCTION_ZERO);
     }
     
     @Override
     public Function chr(Value num) {
-       return function("chr", num);
+       return function(FUNCTION_CHR, num);
+    }    
+
+    @Override
+    public Function ST_ExtentAggregate(Value geom) {
+       return function(FUNCTION_ST_EXTENTAGGREGATE, geom);
     }
+
+    @Override
+    public Function ST_UnionAggregate(Value geom) {
+       return function(FUNCTION_ST_UNIONAGGREGATE, geom);
+    }
+
+    @Override
+    public Function cast(Value object, Value typeName) {
+       return function(FUNCTION_CAST, object, typeName);
+    }    
+
+    @Override
+    public Function decode(Value value, Value format) {
+       return function(FUNCTION_DECODE, value, format);
+    }    
+
+    @Override
+    public Function toDouble(Value num) {
+       return function(FUNCTION_TODOUBLE, num);
+    }    
+
+    @Override
+    public Function toFloat(Value num) {
+       return function(FUNCTION_TOFLOAT, num);
+    }    
+
+    @Override
+    public Function toLong(Value num) {
+       return function(FUNCTION_TOLONG, num);
+    }    
+
+    @Override
+    public Function toInteger(Value num) {
+       return function(FUNCTION_TOINTEGER, num);
+    }    
+
+    @Override
+    public Function toStr(Value object) {
+       return function(FUNCTION_TOSTR, object);
+    }    
+
+
 }
Index: 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/DefaultCodeBuilder.java
===================================================================
--- 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/DefaultCodeBuilder.java	(revision 44197)
+++ 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/DefaultCodeBuilder.java	(revision 44198)
@@ -10,14 +10,21 @@
 import static org.gvsig.expressionevaluator.Code.CONSTANT;
 import static org.gvsig.expressionevaluator.Code.IDENTIFIER;
 import static org.gvsig.expressionevaluator.Code.UNDEFINED;
+import static org.gvsig.expressionevaluator.Code.CODES;
 import org.gvsig.expressionevaluator.Code.Caller;
 import org.gvsig.expressionevaluator.Code.Constant;
+import static org.gvsig.expressionevaluator.Code.EMPTY_FORMATTER;
 import org.gvsig.expressionevaluator.Code.Identifier;
 import org.gvsig.expressionevaluator.Code.Method;
 import org.gvsig.expressionevaluator.CodeBuilder;
 import org.gvsig.expressionevaluator.Codes;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
+import org.gvsig.expressionevaluator.ExpressionUtils;
+import org.gvsig.expressionevaluator.Formatter;
 import org.gvsig.expressionevaluator.Function;
 import org.gvsig.expressionevaluator.Interpreter;
+import org.gvsig.expressionevaluator.SymbolTable;
 import org.gvsig.expressionevaluator.impl.function.operator.AddOperator;
 import org.gvsig.expressionevaluator.impl.function.operator.AndOperator;
 import org.gvsig.expressionevaluator.impl.function.operator.ConcatOperator;
@@ -45,9 +52,9 @@
 import org.gvsig.tools.visitor.Visitor;
 
 @SuppressWarnings("UseSpecificCatch")
-    public class DefaultCodeBuilder implements CodeBuilder {
+public class DefaultCodeBuilder implements CodeBuilder {
 
-    public class BaseCode implements Code {
+    public abstract class BaseCode implements Code {
 
         @Override
         public int code() {
@@ -59,6 +66,31 @@
             visitor.visit(this);
         }
 
+        @Override
+        public Value toValue(ExpressionBuilder builder) {
+            return null;
+        }
+
+        @Override
+        public Value toValue() {
+            ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder();
+            return this.toValue(builder);
+        }
+        
+        @Override
+        public void link(SymbolTable symbolTable) {
+            if( this.code() == Code.CALLER ) {
+                Caller caller = (Caller) this;
+                if( caller.function() == null ) {
+                    caller.function(symbolTable.function(caller.name()));
+                }
+                if( caller.parameters() != null ) {
+                    for( Code arg : caller.parameters() ) {
+                        arg.link(symbolTable);
+                    }
+                }
+            }
+        }
     }
 
     class BaseConstant extends BaseCode implements Constant {
@@ -80,7 +112,20 @@
         }
 
         @Override
+        public Value toValue(ExpressionBuilder builder) {
+            return builder.constant(this.value);
+        }
+
+        @Override
         public String toString() {
+            return this.toString(EMPTY_FORMATTER);
+        }
+        
+        @Override
+        public String toString(Formatter<Code> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
             Object v = this.value();
             if( v == null ) {
@@ -89,7 +134,7 @@
                 if( StringUtils.isEmpty((CharSequence)v) ) {
                     builder.append("''");
                 } else {
-                    v = StringUtils.wrap(v.toString(), "'");
+                    v = "'" + StringUtils.replace(v.toString(), "'", "''") + "'";
                     builder.append(v);
                 }
                 
@@ -150,8 +195,8 @@
     
     public class BaseIdentifier extends BaseCode implements Identifier, RecursionControlSupport {
 
-        private String name;
-        private RecursionSupport recursionSupport;
+        private final String name;
+        private final RecursionSupport recursionSupport;
 
         public BaseIdentifier(String name) {
             this.name = name;
@@ -169,7 +214,20 @@
         }
 
         @Override
+        public Value toValue(ExpressionBuilder builder) {
+            return builder.variable(this.name);
+        }
+
+        @Override
         public String toString() {
+            return this.toString(EMPTY_FORMATTER);
+        }
+        
+        @Override
+        public String toString(Formatter<Code> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
             builder.append("\"");
             builder.append(this.name());
@@ -203,6 +261,11 @@
         }
 
         @Override
+        public int code() {
+            return CODES;
+        }
+        
+        @Override
         public int size() {
             if( codes == null ) {
                 return 0;
@@ -243,6 +306,24 @@
 
         @Override
         public String toString() {
+            return this.toString(EMPTY_FORMATTER);
+        }
+        
+        @Override
+        public Value toValue(ExpressionBuilder builder) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public Value toValue() {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public String toString(Formatter<Code> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
             if( codes != null ) {
                 StringBuilder builder = new StringBuilder();
                 boolean skipcoma = true;
@@ -255,13 +336,20 @@
                     } else {
                         builder.append(", ");
                     }
-                    builder.append(code.toString());
+                    builder.append(code.toString(formatter));
                 }
                 return builder.toString();
             }
             return "";
         }
 
+        @Override
+        public void link(SymbolTable symbolTable) {
+            for (Code code : this.codes) {
+                code.link(symbolTable);
+            }
+        }
+
     }
 
     public class BaseCaller extends BaseCode implements Caller, RecursionControlSupport {
@@ -270,7 +358,7 @@
         private final Codes args;
         private Function function;
         private final int type;
-        private RecursionSupport recursionSupport;
+        private final RecursionSupport recursionSupport;
 
         public BaseCaller(String name, int type, Codes args) {
             this.name = name;
@@ -307,7 +395,7 @@
         }
 
         @Override
-        public Codes args() {
+        public Codes parameters() {
             return this.args;
         }
 
@@ -325,14 +413,75 @@
         }
 
         @Override
+        public Value toValue(ExpressionBuilder builder) {
+            switch(this.type) {
+                case UNARY_OPERATOR:
+                    return builder.function(
+                            NegOperator.NAME.equalsIgnoreCase(this.name())?
+                                "-" :
+                                this.name(),
+                            this.parameters().get(0).toValue(builder)
+                    );
+                case BINARY_OPERATOR:
+                    return builder.binaryOperator(
+                            this.name(),
+                            this.parameters().get(0).toValue(builder),
+                            this.parameters().get(1).toValue(builder)
+                    );
+                case FUNCTION:
+                default:
+                    ExpressionBuilder.Function f = builder.function(this.name());
+                    if( this.parameters()!=null ) {
+                        for (Code parameter : this.parameters()) {
+                            f.parameter(parameter.toValue(builder));
+                        }
+                        
+                    }
+                    return f;
+
+            }
+        }
+
+        @Override
         public String toString() {
+            return this.toString(EMPTY_FORMATTER);
+        }
+        
+        @Override
+        public String toString(Formatter<Code> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
-            builder.append(this.name());
-            builder.append("(");
-            if( this.args()!=null ) {
-                builder.append(this.args().toString());
+            switch(this.type) {
+                case UNARY_OPERATOR:
+                    if( NegOperator.NAME.equalsIgnoreCase(this.name()) ) {
+                        builder.append("-");
+                    } else {
+                        builder.append(this.name());
+                    }
+                    builder.append("(");
+                    builder.append(this.parameters().get(0).toString(formatter));
+                    builder.append(")");
+                    break;
+                case BINARY_OPERATOR:
+                    builder.append("(");
+                    builder.append(this.parameters().get(0).toString(formatter));
+                    builder.append(" ");
+                    builder.append(this.name());
+                    builder.append(" ");
+                    builder.append(this.parameters().get(1).toString(formatter));
+                    builder.append(")");
+                    break;
+                case FUNCTION:
+                default:
+                    builder.append(this.name());
+                    builder.append("(");
+                    if( this.parameters()!=null ) {
+                        builder.append(this.parameters().toString(formatter));
+                    }
+                    builder.append(")");
             }
-            builder.append(")");
             return builder.toString();
         }
 
@@ -380,13 +529,32 @@
 
         @Override
         public String toString() {
+            return this.toString(EMPTY_FORMATTER);
+        }
+
+        @Override
+        public Value toValue(ExpressionBuilder builder) {
+            ExpressionBuilder.Method m = builder.method(this.obj.toValue(builder), this.methodname);
+            if( this.parameters()!=null ) {
+                for (Code parameter : this.parameters()) {
+                    m.parameter(parameter.toValue(builder));
+                }
+            }
+            return m;
+        }
+
+        @Override
+        public String toString(Formatter<Code> formatter) {
+            if( formatter.canApply(this) ) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
-            builder.append(this.obj.toString());
+            builder.append(this.obj.toString(formatter));
             builder.append("->");
             builder.append(this.methodname());
             builder.append("(");
-            if( this.args()!=null ) {
-                builder.append(this.args().toString());
+            if( this.parameters()!=null ) {
+                builder.append(this.parameters().toString(formatter));
             }
             builder.append(")");
             return builder.toString();
@@ -446,7 +614,7 @@
         args.add(arg2);
         return function(name, Caller.BINARY_OPERATOR, args);
     }
-
+    
     @Override
     public Code not(Code op1) {
         return operator(NotOperator.NAME, op1);
@@ -564,4 +732,5 @@
     }
 
     
+    
 }
Index: 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/DefaultOptimizer.java
===================================================================
--- 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/DefaultOptimizer.java	(revision 44197)
+++ 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/DefaultOptimizer.java	(revision 44198)
@@ -153,8 +153,8 @@
                 } else {
                     switch (caller.type()) {
                         case Caller.BINARY_OPERATOR: {
-                            Code op1 = this.doOptimize(caller.args().get(0));
-                            Code op2 = this.doOptimize(caller.args().get(1));
+                            Code op1 = this.doOptimize(caller.parameters().get(0));
+                            Code op2 = this.doOptimize(caller.parameters().get(1));
                             if (caller.function().allowConstantFolding()) {
                                 if (op1.code() == Code.CONSTANT && op2.code() == Code.CONSTANT) {
                                     Object value = this.getInterpreter().run(code);
@@ -167,7 +167,7 @@
                         }
 
                         case Code.Caller.UNARY_OPERATOR: {
-                            Code op1 = this.doOptimize(caller.args().get(0));
+                            Code op1 = this.doOptimize(caller.parameters().get(0));
                             if (caller.function().allowConstantFolding()
                                     && op1.code() == Code.CONSTANT) {
                                 Object value = this.getInterpreter().run(code);
@@ -181,9 +181,9 @@
                         default: {
                             BaseCodes newArgs = null;
                             boolean canOptimize = true;
-                            if (caller.args() != null) {
+                            if (caller.parameters() != null) {
                                 newArgs = (BaseCodes) this.getCodeBuilder().args();
-                                for (Code arg : caller.args()) {
+                                for (Code arg : caller.parameters()) {
                                     Code newArg = this.doOptimize(arg);
                                     newArgs.add(newArg);
                                     if (newArg.code() != Code.CONSTANT) {
Index: 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/grammars/BasicGrammarFactory.java
===================================================================
--- 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/grammars/BasicGrammarFactory.java	(revision 44197)
+++ 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/grammars/BasicGrammarFactory.java	(revision 44198)
@@ -1,5 +1,6 @@
 package org.gvsig.expressionevaluator.impl.grammars;
 
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_CAST;
 import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
 import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
 import org.gvsig.expressionevaluator.Grammar;
@@ -112,7 +113,7 @@
                 .addRuleOnFalse(stmt.require_identifier("TYPE"))
             );
             stmt.code(
-                    CastFunction.NAME,
+                    FUNCTION_CAST,
                     stmt.args_names("VALUE","TYPE")
             );
             theGrammar.addStatement(stmt);
Index: 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/symboltable/OGCSymbolTable.java
===================================================================
--- 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/symboltable/OGCSymbolTable.java	(revision 44197)
+++ 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/symboltable/OGCSymbolTable.java	(revision 44198)
@@ -1,5 +1,6 @@
 package org.gvsig.expressionevaluator.impl.symboltable;
 
+import org.gvsig.expressionevaluator.impl.function.spatial.AndAndOperator;
 import org.gvsig.expressionevaluator.impl.function.spatial.STAreaFunction;
 import org.gvsig.expressionevaluator.impl.function.spatial.STAsTextFunction;
 import org.gvsig.expressionevaluator.impl.function.spatial.STBufferFunction;
@@ -89,5 +90,6 @@
         this.addFunction(new STZFunction());
         this.addFunction(new STSRIDFunction());
         
+        this.addFunction(new AndAndOperator());
     }    
 }
Index: 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/symboltable/SQLSymbolTable.java
===================================================================
--- 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/symboltable/SQLSymbolTable.java	(revision 44197)
+++ 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/symboltable/SQLSymbolTable.java	(revision 44198)
@@ -59,7 +59,7 @@
 import org.gvsig.expressionevaluator.impl.function.string.AsciiFunction;
 import org.gvsig.expressionevaluator.impl.function.string.CharFunction;
 import org.gvsig.expressionevaluator.impl.function.string.ConcatFunction;
-import org.gvsig.expressionevaluator.impl.function.string.DecodeFunction;
+import org.gvsig.expressionevaluator.impl.function.typeconversion.DecodeFunction;
 import org.gvsig.expressionevaluator.impl.function.string.FormatFunction;
 import org.gvsig.expressionevaluator.impl.function.string.InstrFunction;
 import org.gvsig.expressionevaluator.impl.function.string.LTrimFunction;
@@ -80,11 +80,11 @@
 import org.gvsig.expressionevaluator.impl.function.string.TrimFunction;
 import org.gvsig.expressionevaluator.impl.function.string.UpperFunction;
 import org.gvsig.expressionevaluator.impl.function.typeconversion.CastFunction;
-import org.gvsig.expressionevaluator.impl.function.typeconversion.DoubleFunction;
-import org.gvsig.expressionevaluator.impl.function.typeconversion.FloatFunction;
-import org.gvsig.expressionevaluator.impl.function.typeconversion.IntFunction;
-import org.gvsig.expressionevaluator.impl.function.typeconversion.LongFunction;
-import org.gvsig.expressionevaluator.impl.function.typeconversion.StrFunction;
+import org.gvsig.expressionevaluator.impl.function.typeconversion.ToDoubleFunction;
+import org.gvsig.expressionevaluator.impl.function.typeconversion.ToFloatFunction;
+import org.gvsig.expressionevaluator.impl.function.typeconversion.ToIntegerFunction;
+import org.gvsig.expressionevaluator.impl.function.typeconversion.ToLongFunction;
+import org.gvsig.expressionevaluator.impl.function.typeconversion.ToStrFunction;
 import org.gvsig.expressionevaluator.spi.AbstractSymbolTable;
 
 /**
@@ -179,18 +179,17 @@
         this.addFunction(new TimeFunction());
         this.addFunction(new TimestampFunction());
 
-        this.addFunction(new DecodeFunction());
-
         this.addFunction(new IIFFunction());
         this.addFunction(new IFNULLFunction());
         this.addFunction(new FormatFunction());
 
         this.addFunction(new CastFunction());
-        this.addFunction(new StrFunction());
-        this.addFunction(new DoubleFunction());
-        this.addFunction(new FloatFunction());
-        this.addFunction(new IntFunction());
-        this.addFunction(new LongFunction());
+        this.addFunction(new DecodeFunction());
+        this.addFunction(new ToStrFunction());
+        this.addFunction(new ToDoubleFunction());
+        this.addFunction(new ToFloatFunction());
+        this.addFunction(new ToIntegerFunction());
+        this.addFunction(new ToLongFunction());
         
         
     }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/CodeToStringConverter.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/CodeToStringConverter.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/CodeToStringConverter.java	(revision 44198)
@@ -1,18 +0,0 @@
-package org.gvsig.expressionevaluator;
-
-/**
- *
- * @author jjdelcerro
- */
-public interface CodeToStringConverter {
-
-    public boolean isValid();
-
-    public boolean isValid(Code code);
-
-    @Override
-    public String toString();
-
-    public String toString(Code code);
-    
-}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Codes.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Codes.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Codes.java	(revision 44198)
@@ -7,6 +7,6 @@
  *
  * @author jjdelcerro
  */
-public interface Codes extends Visitable, UnmodifiableBasicList<Code> {
+public interface Codes extends Code, Visitable, UnmodifiableBasicList<Code> {
 
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Formatter.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Formatter.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Formatter.java	(revision 44198)
@@ -0,0 +1,14 @@
+package org.gvsig.expressionevaluator;
+
+/**
+ *
+ * @author jjdelcerro
+ * @param <T>
+ */
+public interface Formatter<T> {
+
+    public boolean canApply(T value);
+
+    public String format(T value);
+    
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/ExpressionBuilder.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/ExpressionBuilder.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/ExpressionBuilder.java	(revision 44198)
@@ -1,12 +1,116 @@
 package org.gvsig.expressionevaluator;
 
 import java.util.List;
+import java.util.Map;
 import org.cresques.cts.IProjection;
 import org.gvsig.fmap.geom.Geometry;
 import org.gvsig.fmap.geom.primitive.Envelope;
+import org.gvsig.tools.util.PropertiesSupport;
+import org.gvsig.tools.util.PropertiesSupportHelper;
 
 public interface ExpressionBuilder {
 
+    public static final String OPERATOR_NOT = "NOT";
+    public static final String OPERATOR_IS = "IS";
+    public static final String OPERATOR_AND = "AND";
+    public static final String OPERATOR_OR = "OR";
+    public static final String OPERATOR_EQ = "EQ";
+    public static final String OPERATOR_NE = "NE";
+    public static final String OPERATOR_GT = "GT";
+    public static final String OPERATOR_GE = "GE";
+    public static final String OPERATOR_LT = "LT";
+    public static final String OPERATOR_LE = "LE";
+    public static final String OPERATOR_LIKE = "LIKE";
+    public static final String OPERATOR_ILIKE = "ILIKE";
+    public static final String OPERATOR_ADD = "ADD";
+    public static final String OPERATOR_SUBST = "SUBST";
+    public static final String OPERATOR_MULT = "MULT";
+    public static final String OPERATOR_DIV = "DIV";
+    public static final String OPERATOR_CONCAT = "CONCAT";
+    
+    public static final String FUNCTION_ST_SRID = "ST_SRID";
+    public static final String FUNCTION_ST_ASTEXT = "ST_AsText";
+    public static final String FUNCTION_ST_ASBINARY = "ST_AsBinary";
+    public static final String FUNCTION_ST_ASEWKB = "ST_AsEWKB";
+    public static final String FUNCTION_ST_ENVELOPE = "ST_Envelope";
+    public static final String FUNCTION_ST_GEOMFROMTEXT = "ST_GeomFromText";
+    public static final String FUNCTION_ST_GEOMFROMWKB = "ST_GeomFromWKB";
+    public static final String FUNCTION_ST_GEOMFROMEWKB = "ST_GeomFromEWKB";
+    public static final String FUNCTION_ST_SIMPLIFY = "ST_Simplify";
+    public static final String FUNCTION_ST_EQUALS = "ST_Equals";
+    public static final String FUNCTION_ST_INTERSECTS = "ST_Intersects";
+    public static final String FUNCTION_ST_CONTAINS = "ST_Contains";
+    public static final String FUNCTION_ST_DISJOINT = "ST_Disjoint";
+    public static final String FUNCTION_ST_CROSSES = "ST_Crosses";
+    public static final String FUNCTION_ST_ISCLOSED = "ST_IsClosed";
+    public static final String FUNCTION_ST_OVERLAPS = "ST_Overlaps";
+    public static final String FUNCTION_ST_TOUCHES = "ST_Touches";
+    public static final String FUNCTION_ST_WITHIN = "ST_Within";
+    public static final String FUNCTION_ST_UNIONAGGREGATE = "ST_UnionAggregate";
+    public static final String FUNCTION_ST_EXTENTAGGREGATE = "ST_ExtentAggregate";
+
+    public static final String FUNCTION_IIF = "IIF";
+    public static final String FUNCTION_IFNULL = "IFNULL";
+    
+    public static final String FUNCTION_LEFT = "LEFT";
+    public static final String FUNCTION_RIGHT = "RIGHT";
+    public static final String FUNCTION_LOCATE = "LOCATE";
+    public static final String FUNCTION_POSITION = "POSITION";
+    public static final String FUNCTION_LPAD = "LPAD";
+    public static final String FUNCTION_RPAD = "RPAD";
+    public static final String FUNCTION_LTRIM = "LTRIM";
+    public static final String FUNCTION_RTRIM = "RTRIM";
+    public static final String FUNCTION_TRIM = "TRIM";
+    public static final String FUNCTION_REPEAT = "REPEAT";
+    public static final String FUNCTION_REPLACE = "REPLACE";
+    public static final String FUNCTION_ASCII = "ASCII";
+    public static final String FUNCTION_LENGHT = "LENGHT";
+    public static final String FUNCTION_INSTR = "INSTR";
+    public static final String FUNCTION_LOWER = "LOWER";
+    public static final String FUNCTION_UPPER = "UPPER";
+    public static final String FUNCTION_SPACE = "SPACE";
+    public static final String FUNCTION_SUBSTRING = "SUBSTRING";
+    public static final String FUNCTION_ACOS = "ACOS";
+    public static final String FUNCTION_ASIN = "ASIN";
+    public static final String FUNCTION_ATAN = "ATAN";
+    public static final String FUNCTION_COS = "COS";
+    public static final String FUNCTION_COSH = "COSH";
+    public static final String FUNCTION_COT = "COT";
+    public static final String FUNCTION_BITAND = "BITAND";
+    public static final String FUNCTION_BITOR = "BITOR";
+    public static final String FUNCTION_BITXOR = "BITXOR";
+    public static final String FUNCTION_CEIL = "CEIL";
+    public static final String FUNCTION_DEGREES = "DEGREES";
+    public static final String FUNCTION_EXP = "EXP";
+    public static final String FUNCTION_FLOOR = "FLOOR";
+    public static final String FUNCTION_LOG = "LOG";
+    public static final String FUNCTION_LOG10 = "LOG10";
+    public static final String FUNCTION_PI = "PI";
+    public static final String FUNCTION_POWER = "POWER";
+    public static final String FUNCTION_RADIANS = "RADIANS";
+    public static final String FUNCTION_RAND = "RAND";
+    public static final String FUNCTION_ROUND = "ROUND";
+    public static final String FUNCTION_SQRT = "SQRT";
+    public static final String FUNCTION_SIGN = "SIGN";
+    public static final String FUNCTION_SIN = "SIN";
+    public static final String FUNCTION_SINH = "SINH";
+    public static final String FUNCTION_TAN = "TAN";
+    public static final String FUNCTION_TANH = "TANH";
+    public static final String FUNCTION_ZERO = "ZERO";
+    public static final String FUNCTION_CHR = "CHR";
+    public static final String FUNCTION_DATE = "DATE";
+    public static final String FUNCTION_NOW = "NOW";
+    public static final String FUNCTION_TIME = "TIME";
+    public static final String FUNCTION_TIMESTAMP = "TIMESTAMP";
+
+    public static final String FUNCTION_CAST = "CAST";
+    public static final String FUNCTION_DECODE = "DECODE";
+    public static final String FUNCTION_TODOUBLE = "TODOUBLE";
+    public static final String FUNCTION_TOFLOAT = "TOFLOAT";
+    public static final String FUNCTION_TOINTEGER = "TOINTEGER";
+    public static final String FUNCTION_TOLONG = "TOLONG";
+    public static final String FUNCTION_TOSTR = "TOSTR";
+    
     public enum GeometrySupportType {
         WKT,
         WKB,
@@ -19,7 +123,7 @@
         Constant,
         Geometry
     }
-
+    
     public interface VisitorFilter {
         boolean accept(Visitable visitable);
     }
@@ -31,100 +135,27 @@
     public interface Visitable {
         public void accept(Visitor visitor, VisitorFilter filter);
     }
-    
-    public interface Config {
-        public final static String has_spatial_functions = "has_spatial_functions";
-        public final static String support_schemas = "support_schemas";
-        public final static String quote_for_identifiers = "quote_for_identifiers";
-        public final static String quote_for_strings = "quote_for_strings";
-        public final static String geometry_type_support = "geometry_type_support";
-        public final static String constant_true = "constant_true";
-        public final static String constant_false = "constant_false";
-        public final static String group = "group";
-        public final static String attribute_crs = "crs";
         
-        public final static String ST_SRID = "ST_SRID";
-        public final static String ST_AsText = "ST_AsText";
-        public final static String ST_AsBinary = "ST_AsBinary";
-        public final static String ST_AsEWKB = "ST_AsEWKB";
-        public final static String ST_Contains = "ST_Contains";
-        public final static String ST_Crosses = "ST_Crosses";
-        public final static String ST_Disjoint = "ST_Disjoint";
-        public final static String ST_Equals = "ST_Equals";
-        public final static String ST_IsClosed = "ST_IsClosed";
-        public final static String ST_Overlaps = "ST_Overlaps";
-        public final static String ST_Touches = "ST_Touches";
-        public final static String ST_Within = "ST_Within";
-        public final static String ST_Intersects = "ST_Intersects";
-        public final static String ST_Envelope = "ST_Envelope";
-        public final static String ST_GeomFromText = "ST_GeomFromText";
-        public final static String ST_GeomFromWKB = "ST_GeomFromWKB";
-        public final static String ST_GeomFromEWKB = "ST_GeomFromEWKB";
-        public final static String ST_Simplify = "ST_Simplify";        
-        
-        public final static String lcase = "lcase";
-        public final static String ucase = "ucase";
-        public final static String iif = "iif";
-        public final static String ifnull = "ifnull";
-        
-        public final static String isNull = "isNull";
-        public final static String notIsNull = "notIsNull";
-        public final static String operator_not = "operator_not";
-     
-        public final static String operator_AND = "operator_AND";
-        public final static String operator_OR = "operator_OR";
-        public final static String operator_EQ = "operator_EQ";
-        public final static String operator_NE = "operator_NE";
-        public final static String operator_GT = "operator_GT";
-        public final static String operator_GE = "operator_GE";
-        public final static String operator_LT = "operator_LT";
-        public final static String operator_LE = "operator_LE";
-        public final static String operator_LIKE = "operator_LIKE";
-        public final static String operator_ILIKE = "operator_ILIKE";
-        
-        public final static String operator_add = "operator_add";
-        public final static String operator_subst = "operator_subst";
-        public final static String operator_mult = "operator_mult";
-        public final static String operator_div = "operator_div";
-        public final static String operator_concat = "operator_concat";
-
-
-        public GeometrySupportType getGeometryTypeSupport();
-        public boolean has_spatial_functions();
-        public boolean has_functionality(String functionality);
-        public void remove_functionality(String functionality);
-        
-        public boolean getBoolean(String name);
-        public String getString(String name);
-        public Object get(String name);
-        public void set(String name, Object value);
+    public interface Value extends Visitable, PropertiesSupport {
+        public String toString(Formatter<Value> formatter);
     }
-    
-    public interface Value extends Visitable {
 
-    }
-
     public interface Group extends Value {
-        public Value getValue();
+        public Value value();
     }
 
     public interface Constant extends Value {
-        public Object getValue();
+        public Object value();
     }
 
     public interface Custom extends Value {
-        public Object getValue();
+        public Object value();
         public Custom add(Variable variable);
         public Custom add(Parameter parameter);
     }
 
-    public interface GeometryValue extends Value {
-        public Geometry getGeometry();
-        public IProjection getSRS();
-    }
-    
     public interface Variable extends Value, Comparable<Variable> {
-        public String getName();
+        public String name();
     }
 
     public interface Parameter extends Value {
@@ -133,49 +164,117 @@
         public Parameter as_geometry_variable();
         public Parameter srs(Value srs);
         public Parameter srs(IProjection srs);
-        public String getName();
-        public Object getValue();
         public Parameter value(Object value);
         public Parameter name(String value);
-        public ParameterType getType();
-        public Value getSRS();
+        public String name();
+        public Object value();
+        public ParameterType type();
+        public Value srs();
         public boolean is_constant();
         public boolean is_variable();
         public boolean is_geometry_variable();        
     }
     
-    public interface Parameters extends List<Parameter> {
-        public Parameter get(String name);
+    public interface Function extends Value {
+        public String name();
+        public List<Value> parameters();
+        public Function parameter(Value parameter);
     }
 
-    public interface Function extends Value {
-        public String getName();
+    public interface Method extends Value {
+        public String name();
+        public Value instance();
         public List<Value> parameters();
         public Function parameter(Value parameter);
     }
 
     public interface BinaryOperator extends Value {
-        public String getName();
-        public Value getLeft();
-        public Value getRight();
-        public BinaryOperator setLeft(Value operand);
-        public BinaryOperator setRight(Value operand);
+        public String name();
+        public Value left();
+        public Value right();
+        public BinaryOperator left(Value operand);
+        public BinaryOperator right(Value operand);
     }
+
+    public abstract class AbstractValue implements Value {
+
+        private PropertiesSupport properties;
+        
+        protected AbstractValue() {
+            this.properties = new PropertiesSupportHelper();
+        }
+        
+        @Override
+        public void accept(Visitor visitor, VisitorFilter filter) {
+            if (filter == null || filter.accept(this)) {
+                visitor.visit(this);
+            }
+        }
+
+        @Override
+        public Map<String, Object> getProperties() {
+            return this.properties.getProperties();
+        }
+
+        @Override
+        public Object getProperty(String name) {
+            return this.properties.getProperty(name);
+        }
+
+        @Override
+        public void setProperty(String name, Object value) {
+            this.properties.setProperty(name, value);
+        }
+
+    }
+
+    public class ClassVisitorFilter implements VisitorFilter {
+
+        private final Class classFilter;
+
+        public ClassVisitorFilter(Class classFilter) {
+            this.classFilter = classFilter;
+        }
+
+        @Override
+        public boolean accept(Visitable visitable) {
+            return classFilter.isInstance(visitable);
+        }
+
+    }
+
+    public static final Formatter<Value> EMPTY_FORMATTER = new Formatter<Value>() {
+        @Override
+        public boolean canApply(Value value) {
+            return false;
+        }
+
+        @Override
+        public String format(Value value) {
+            return "";
+        }
+    };
+            
+    public String quote_for_identifiers();
     
+    public String quote_for_strings();
+    
     public void accept(Visitor visitor, VisitorFilter filter);
 
-    public List<Variable> getVariables();
+    public List<Variable> variables();
     
-    public Parameters getParameters();
+    public List<String> variables_names();
     
-    public boolean has_spatial_functions();
+    public List<Parameter> parameters();
     
+    public List<String> parameters_names();
+    
     public GeometrySupportType geometry_support_type();
+    
+    public ExpressionBuilder geometry_support_type(GeometrySupportType geometrySupportType);
 
     public String identifier(String name);
 
-    public String bytearray(byte[] data);
-    
     public String bytearray_hex(byte[] data);
 
     public String bytearray_0x(byte[] data);
@@ -184,13 +283,15 @@
 
     public String string(String s);
    
-    public Object getSRSId(IProjection projection);
+    public Object srs_id(IProjection projection);
     
-    public Config getConfig();
+    public Value value();
+    
+    public ExpressionBuilder value(Value value);
 
-    public Value getValue();
+    public Group group(Value group);
     
-    public ExpressionBuilder setValue(Value value);
+    public Constant bytearray(byte[] data);
     
     public Variable variable(String name);
     
@@ -202,30 +303,35 @@
 
     public Constant constant(Object value);
     
-    public Group group(Value group);
+    public Constant geometry(Geometry geom, IProjection projection);
 
-    public GeometryValue geometry(Geometry geom, IProjection projection);
+    public Constant geometry(Geometry geom);
 
-    public GeometryValue geometry(Geometry geom);
+    public Constant envelope(Envelope envelope, IProjection projection);
 
-    public GeometryValue envelope(Envelope envelope, IProjection projection);
+    public Constant envelope(Envelope envelope);
 
-    public GeometryValue envelope(Envelope envelope);
+    public Constant srs(IProjection projection);
 
     public Custom custom(Object value);
     
-    public Function function(String name, Value... values);
+    public Function as_geometry(Value value);
 
-    public Constant srs(IProjection projection);
+    public Method method(Value instance, String name, Value... values);
 
-    public Function getAsGeometry(Value value);
+    public Function function(String name, Value... values);
+    
+    public BinaryOperator binaryOperator(String name, Value leftOperand, Value rightOperand);
 
+    public Value toValue(String expression);
     
+    public String toString(Formatter<Value> formatter);
+    
     public Function not(Value value);
 
-    public Function notIsNull(Value value);
+    public Function not_is_null(Value value);
     
-    public Function isNull(Value value);
+    public Function is_null(Value value);
 
     public Function ST_SRID(Value geom);
     
@@ -263,10 +369,10 @@
 
     public Function ST_Within(Value geom1, Value geom2);
 
-    public Function lcase(Value s);
+    public Function ST_UnionAggregate(Value geom);
     
-    public Function ucase(Value s);
-
+    public Function ST_ExtentAggregate(Value geom);
+    
     public BinaryOperator and(Value op1, Value op2);
 
     public BinaryOperator or(Value op1, Value op2);
@@ -298,7 +404,7 @@
     public BinaryOperator concat(Value op1, Value op2);
 
     public ExpressionBuilder set(Value value);
-
+    
     public ExpressionBuilder and(Value value);
 
     public ExpressionBuilder or(Value value);
@@ -400,4 +506,19 @@
     public Function zero();
     
     public Function chr(Value num);
+
+    public Function decode(Value value, Value format);
+
+    public Function cast(Value object, Value typeName);
+
+    public Function toDouble(Value object);
+
+    public Function toFloat(Value object);
+
+    public Function toLong(Value object);
+
+    public Function toInteger(Value object);
+
+    public Function toStr(Value object);
+
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Code.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Code.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Code.java	(revision 44198)
@@ -1,5 +1,6 @@
 package org.gvsig.expressionevaluator;
 
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
 import org.gvsig.tools.visitor.Visitable;
 
 public interface Code extends Visitable {
@@ -9,8 +10,8 @@
     public static final int IDENTIFIER = 1;
     public static final int CALLER = 2;
     public static final int METHOD = 3;
+    public static final int CODES = 4;
     
-
     public interface Constant extends Code {
 
         public Object value();
@@ -29,6 +30,7 @@
         public static final int BINARY_OPERATOR = 1;
         public static final int UNARY_OPERATOR = 2;
 
+
         public String name();
 
         public Object call(Interpreter interpreter, Object[] args) throws Exception;
@@ -37,7 +39,7 @@
 
         public Function function(Function function);
 
-        public Codes args();
+        public Codes parameters();
 
         public int type();
 
@@ -49,5 +51,26 @@
         public String methodname();
     }
 
-    int code();
+    public static final Formatter<Code> EMPTY_FORMATTER = new Formatter<Code>() {
+        @Override
+        public boolean canApply(Code value) {
+            return false;
+        }
+
+        @Override
+        public String format(Code value) {
+            return "";
+        }
+    };
+
+    public int code();
+
+    public Value toValue();
+
+    public Value toValue(ExpressionBuilder builder);
+    
+    public String toString(Formatter<Code> formatter);
+    
+    public void link(SymbolTable symbolTable);
+    
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/spi/AbstractCodeToStringConverter.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/spi/AbstractCodeToStringConverter.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/spi/AbstractCodeToStringConverter.java	(revision 44198)
@@ -1,204 +0,0 @@
-package org.gvsig.expressionevaluator.spi;
-
-import org.gvsig.expressionevaluator.CodeToStringConverter;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.gvsig.expressionevaluator.Code;
-import org.gvsig.expressionevaluator.Code.Caller;
-import org.gvsig.expressionevaluator.Code.Constant;
-import org.gvsig.expressionevaluator.Code.Identifier;
-import org.gvsig.expressionevaluator.Code.Method;
-import org.gvsig.expressionevaluator.Codes;
-import org.gvsig.tools.exception.BaseException;
-import org.gvsig.tools.visitor.VisitCanceledException;
-import org.gvsig.tools.visitor.Visitor;
-
-/**
- *
- * @author jjdelcerro
- */
-public class AbstractCodeToStringConverter implements CodeToStringConverter {
-
-    private final Code code;
-    protected Set<String> supportedFunctionsNames;
-    protected Map<String, String> translatedFunctionsNames;
-
-    public AbstractCodeToStringConverter() {
-        this(null);
-    }
-    
-    public AbstractCodeToStringConverter(Code code) {
-        this.supportedFunctionsNames = new HashSet<>();
-        this.translatedFunctionsNames = new HashMap<>();
-        this.code = code;
-    }
-
-    protected final void addSupportedFunction(String name) {
-        this.supportedFunctionsNames.add(name.toLowerCase());
-    }
-
-    protected final void addSupportedFunction(String name, String outputName) {
-        this.supportedFunctionsNames.add(name.toLowerCase());
-        this.translatedFunctionsNames.put(name.toLowerCase(), outputName);
-    }
-
-    protected final boolean isFunctionSupported(String functionName) {
-        functionName = functionName.toLowerCase();
-        for (String name : supportedFunctionsNames) {
-            if (functionName.equals(name)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    protected final String translateFunctionName(String functionName) {
-        return this.translatedFunctionsNames.getOrDefault(functionName, functionName);
-    }
-
-    @Override
-    public boolean isValid() {
-        if( code == null ) {
-            return false;
-        }
-        return this.isValid(code);
-    }
-
-    @SuppressWarnings("UseSpecificCatch")
-    @Override
-    public boolean isValid(Code code) {
-        try {
-            code.accept(new Visitor() {
-                @Override
-                public void visit(Object o) throws VisitCanceledException, BaseException {
-                    Code code = (Code) o;
-                    switch (code.code()) {
-                        case Code.CALLER:
-                            Caller caller = (Caller) code;
-                            if (!isFunctionSupported(caller.name())) {
-                                throw new UnsupportedOperationException("Function '" + caller.name() + "' not supported.");
-                            }
-                        case Code.CONSTANT:
-                        case Code.IDENTIFIER:
-                            break;
-                            
-                        case Code.METHOD:
-                            throw new UnsupportedOperationException("Method call not supported.");
-                            
-                        default:
-                            throw new UnsupportedOperationException("Code type not supported.");
-                    }
-                }
-            });
-            return true;
-        } catch (Exception ex) {
-            return false;
-        }
-    }
-
-    @Override
-    public String toString() {
-        if( code == null ) {
-            return null;
-        }
-        return this.toString(code);
-    }
-
-    @Override
-    public String toString(Code code) {
-        switch (code.code()) {
-            case Code.CONSTANT:
-                return constantToString((Constant) code);
-
-            case Code.IDENTIFIER:
-                return identifierToString((Identifier) code);
-
-            case Code.CALLER:
-                return callerToString((Caller) code);
-
-            case Code.METHOD:
-                return methodToString((Method) code);
-
-            default:
-                return "";
-        }
-    }
-
-    protected String callerToString(Caller code) {
-        switch (code.type()) {
-            case Caller.BINARY_OPERATOR:
-                if (!this.isFunctionSupported(code.name())) {
-                    throw new UnsupportedOperationException("Operator '" + code.name() + "' not supported.");
-                }
-                return binaryOperatorToString(code.name(), code.args().get(0), code.args().get(1));
-
-            case Caller.UNARY_OPERATOR:
-                if (!this.isFunctionSupported(code.name())) {
-                    throw new UnsupportedOperationException("Operator '" + code.name() + "' not supported.");
-                }
-                return unaryOperatorToString(code.name(), code.args().get(0));
-
-            case Caller.FUNCTION:
-            default:
-                if (!this.isFunctionSupported(code.name())) {
-                    throw new UnsupportedOperationException("Function '" + code.name() + "' not supported.");
-                }
-                String fname = this.translateFunctionName(code.name());
-                return functionToString(fname, code.args());
-
-        }
-    }
-
-    protected String constantToString(Constant code) {
-        return code.toString();
-    }
-
-    protected String identifierToString(Identifier code) {
-        return "\"" + code.name() + "\"";
-    }
-
-    protected String methodToString(Method code) {
-        throw new UnsupportedOperationException("Method call not supported (method name '" + code.name() + "').");
-    }
-
-    protected String binaryOperatorToString(String name, Code oper1, Code oper2) {
-        if (oper1.code() == Code.CONSTANT || oper1.code() == Code.IDENTIFIER) {
-            if (oper2.code() == Code.CONSTANT || oper2.code() == Code.IDENTIFIER) {
-                return this.toString(oper1) + " " + name + " " + this.toString(oper2);
-            } else {
-                return this.toString(oper1) + " " + name + " (" + this.toString(oper2) + ")";
-            }
-        } else if (oper2.code() == Code.CONSTANT || oper2.code() == Code.IDENTIFIER) {
-            return "(" + this.toString(oper1) + ") " + name + " " + this.toString(oper2);
-        }
-        return "(" + this.toString(oper1) + ") " + name + " (" + this.toString(oper2) + ")";
-    }
-
-    protected String unaryOperatorToString(String name, Code oper) {
-        if (oper.code() == Code.CONSTANT || oper.code() == Code.IDENTIFIER) {
-            return name + " " + this.toString(oper);
-        }
-        return name + " (" + this.toString(oper) + ")";
-    }
-
-    protected String functionToString(String functionName, Codes args) {
-        StringBuilder builder = new StringBuilder();
-        builder.append(functionName);
-        builder.append("(");
-        boolean firstArg = true;
-        for (Code arg : args) {
-            if (firstArg) {
-                firstArg = false;
-                builder.append(this.toString(arg));
-            } else {
-                builder.append(", ");
-                builder.append(this.toString(arg));
-            }
-        }
-        builder.append(")");
-        return builder.toString();
-    }
-
-}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/ExpressionUtils.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/ExpressionUtils.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/ExpressionUtils.java	(revision 44198)
@@ -1,5 +1,6 @@
 package org.gvsig.expressionevaluator;
 
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
 import org.gvsig.tools.script.Script;
 
 /**
@@ -74,4 +75,68 @@
         }
         return expression;
     }
+
+    public static ExpressionBuilder createExpressionBuilder() {
+        ExpressionBuilder builder = ExpressionEvaluatorLocator.getManager().createExpressionBuilder();
+        return builder;
+    }
+
+    public static Code compile(String expression) {
+        ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
+        Code code = manager.compile(expression);
+        return code;
+    }
+
+    public static Object evaluate(SymbolTable symbolTable, String expression) {
+        ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
+        Object x = manager.evaluate(symbolTable, expression);
+        return x;
+    }
+
+    public static Object evaluate(SymbolTable symbolTable, Code code) {
+        ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
+        Object x = manager.evaluate(symbolTable, code);
+        return x;
+    }
+
+    public static Code optimize(SymbolTable symbolTable, Code code) {
+        ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
+        code = manager.optimize(symbolTable, code);
+        return code;
+    }
+
+    public static String toString(Value value, Formatter formatter) {
+        if( value == null ) {
+            return null;
+        }
+        if( formatter==null ) {
+            formatter = ExpressionBuilder.EMPTY_FORMATTER;
+        }
+        return value.toString(formatter);
+    }
+
+    public static String toString(Value value) {
+        if( value == null ) {
+            return null;
+        }
+        return value.toString(ExpressionBuilder.EMPTY_FORMATTER);
+    }
+
+    public static String toString(Code code, Formatter formatter) {
+        if( code == null ) {
+            return null;
+        }
+        if( formatter==null ) {
+            formatter = Code.EMPTY_FORMATTER;
+        }
+        return code.toString(formatter);
+    }
+
+    public static String toString(Code code) {
+        if( code == null ) {
+            return null;
+        }
+        return code.toString(Code.EMPTY_FORMATTER);
+    }
+
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Function.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Function.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/Function.java	(revision 44198)
@@ -11,6 +11,7 @@
     public final String GROUP_BOOLEAN = "Boolean";
     public final String GROUP_OGC = "OGC";
     public final String GROUP_PROGRAMMING = "Programming";
+    public final String GROUP_CONVERSION = "Conversion";
     public final String GROUP_OTHER = "Other";
    
     public String group();
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/export/jdbc/swing/panels/SelectTableNamePanel.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/export/jdbc/swing/panels/SelectTableNamePanel.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/export/jdbc/swing/panels/SelectTableNamePanel.java	(revision 44198)
@@ -238,7 +238,7 @@
             );
         }
         String schema = this.getSchema();
-        if( sqlbuilder.supportSchemas() ) {
+        if( sqlbuilder.support_schemas() ) {
             if (schema == null) {
                 throw new ExportPanelValidationException(
                         i18nManager.getTranslation(
@@ -380,7 +380,7 @@
 
                     @Override
                     public void run() {
-                        if( sqlbuilder.supportSchemas() ) {
+                        if( sqlbuilder.support_schemas() ) {
                             txtSchema.setText(sqlbuilder.default_schema());
                         } else {
                             txtSchema.setText("");
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/SQLBuilder.java	(revision 44198)
@@ -3,14 +3,18 @@
 import java.util.List;
 import org.cresques.cts.IProjection;
 import org.gvsig.expressionevaluator.ExpressionBuilder;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Config;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Function;
+import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter;
 import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Visitable;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
+import org.gvsig.expressionevaluator.Formatter;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
+import org.gvsig.fmap.dal.feature.FeatureType;
 
-public interface SQLBuilder extends ExpressionBuilder {
-    
+public interface SQLBuilder {
+
+    public static final String FEATURE_ATTRIBUTE_DESCRIPTOR = "FeatureAttributeDescriptor";
+
     public enum Privilege {
         SELECT,
         INSERT,
@@ -22,336 +26,429 @@
         ALL
     };
 
-    public interface Statement extends Visitable {
-        
-    }
-    
-    public interface SQLConfig extends Config {
-        public final static String default_schema = "default_schema";
-        
-        public final static String allowAutomaticValues = "allowAutomaticValues";
-        
-        public final static String Find_SRID = "Find_SRID";
-        public final static String ST_ExtentAggregate = "ST_ExtentAggregate";
-        public final static String ST_UnionAggregate = "ST_UnionAggregate";
-        public final static String count = "count";
-        public final static String count_distinct = "count_distinct";
+    public interface ColumnDescriptor {
 
-        public final static String type_boolean = "type_boolean";
-        public final static String type_byte = "type_byte";
-        public final static String type_bytearray = "type_bytearray";
-        public final static String type_geometry = "type_geometry";
-        public final static String type_char = "type_char";
-        public final static String type_date = "type_date";
-        public final static String type_double = "type_double";
-        public final static String type_numeric_p = "type_numeric_p";
-        public final static String type_numeric_ps = "type_numeric_ps";
-        public final static String type_bigdecimal = "type_bigdecimal";
-        public final static String type_float = "type_float";
-        public final static String type_int = "type_int";
-        public final static String type_long = "type_long";
-        public final static String type_string = "type_string";
-        public final static String type_string_p = "type_string_p";
-        public final static String type_time = "type_time";
-        public final static String type_timestamp = "type_timestamp";
-        public final static String type_version = "type_version";
-        public final static String type_URI = "type_URI";
-        public final static String type_URL = "type_URL";
-        public final static String type_FILE = "type_FILE";
-        public final static String type_FOLDER = "type_FOLDER";
-     
-        public final static String DELETE_FROM_table_WHERE_expresion = "DELETE_FROM_table_WHERE_expresion";
-        public final static String DELETE_FROM_table = "DELETE_FROM_table";
-        public final static String INSERT_INTO_table_columns_VALUES_values = "INSERT_INTO_table_columns_VALUES_values";
-        public final static String UPDATE_TABLE_STATISTICS_table = "UPDATE_TABLE_STATISTICS_table";        
-        public final static String DROP_TABLE_table = "DROP_TABLE_table";
-        public final static String DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table = "DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table";
-        public final static String DELETE_GEOMETRY_COLUMN_FROM_TABLE_table = "DELETE_GEOMETRY_COLUMN_FROM_TABLE_table";
-        public final static String UPDATE_table_SET_columnsAndValues_WHERE_expresion = "UPDATE_table_SET_columnsAndValues_WHERE_expresion";
-        public final static String UPDATE_table_SET_columnsAndValues = "UPDATE_table_SET_columnsAndValues";
-        public final static String GRANT_privileges_ON_table_TO_role = "GRANT_privileges_ON_table_TO_role";
-//        public final static String CREATE_INDEX_name_ON_table_column = "CREATE_INDEX_name_ON_table_column";
-//        public final static String CREATE_INDEX_name_ON_table_USING_GIST_column = "CREATE_INDEX_name_ON_table_USING_GIST_column";
-   
-    }
-    
-    public interface ColumnDescriptor {
         public String getName();
+
         public int getType();
+
         public int getSize();
+
         public int getPrecision();
+
         public boolean isPrimaryKey();
+
         public boolean isIndexed();
+
         public boolean isAutomatic();
+
         boolean allowNulls();
+
         public Object getDefaultValue();
+
         public int getGeometryType();
+
         public int getGeometrySubtype();
+
         public Object getGeometrySRSId();
+
         public boolean isGeometry();
-        
+
         public DataStoreParameters getStoreParameters();
-        
+
         public void setName(String name);
+
         public void setType(int type);
+
         public void setSize(int size);
+
         public void setPrecision(int precision);
+
         public void setIsPrimaryKey(boolean isPk);
+
         public void setIsAutomatic(boolean isAutomatic);
+
         public void setAllowNulls(boolean allowNulls);
+
         public void setDefaultValue(Object defaultValue);
+
         public void setGeometryType(int geom_type);
+
         public void setGeometrySubtype(int geom_subtype);
+
         public void setGeometrySRSId(Object geom_srsid);
     }
-    
-    public interface Column extends Variable {
-        public ColumnDescriptor getDescriptor();
+
+//    public interface ColumnDescriptorBuilder {
+//        public String getName();
+//        public int getType();
+//        public int getSize();
+//        public int getPrecision();
+//        public boolean isPrimaryKey();
+//        public boolean isIndexed();
+//        public boolean isAutomatic();
+//        boolean allowNulls();
+//        public Object getDefaultValue();
+//        public int getGeometryType();
+//        public int getGeometrySubtype();
+//        public Object getGeometrySRSId();
+//        public boolean isGeometry();
+//        
+//        public void setName(String name);
+//        public void setType(int type);
+//        public void setSize(int size);
+//        public void setPrecision(int precision);
+//        public void setIsPrimaryKey(boolean isPk);
+//        public void setIsAutomatic(boolean isAutomatic);
+//        public void setAllowNulls(boolean allowNulls);
+//        public void setDefaultValue(Object defaultValue);
+//        public void setGeometryType(int geom_type);
+//        public void setGeometrySubtype(int geom_subtype);
+//        public void setGeometrySRSId(Object geom_srsid);
+//    }
+//
+//    public interface Column extends Variable {
+//        public ColumnDescriptor getDescriptor();
+//    }
+    public interface StatementPart extends Value {
+
     }
-    
-    public interface TableNameBuilder extends Visitable {
+
+    public interface Statement extends StatementPart {
+
+    }
+
+    public interface TableNameBuilder extends StatementPart {
+
         public TableNameBuilder database(String name);
+
         public TableNameBuilder schema(String name);
+
         public TableNameBuilder name(String name);
+
         public String getDatabase();
+
         public String getSchema();
+
         public String getName();
+
         public boolean has_database();
+
         public boolean has_schema();
     }
-    
-    public interface ColumnDescriptorBuilder {
-        public String getName();
-        public int getType();
-        public int getSize();
-        public int getPrecision();
-        public boolean isPrimaryKey();
-        public boolean isIndexed();
-        public boolean isAutomatic();
-        boolean allowNulls();
-        public Object getDefaultValue();
-        public int getGeometryType();
-        public int getGeometrySubtype();
-        public Object getGeometrySRSId();
-        public boolean isGeometry();
-        
-        public void setName(String name);
-        public void setType(int type);
-        public void setSize(int size);
-        public void setPrecision(int precision);
-        public void setIsPrimaryKey(boolean isPk);
-        public void setIsAutomatic(boolean isAutomatic);
-        public void setAllowNulls(boolean allowNulls);
-        public void setDefaultValue(Object defaultValue);
-        public void setGeometryType(int geom_type);
-        public void setGeometrySubtype(int geom_subtype);
-        public void setGeometrySRSId(Object geom_srsid);
-    }
 
-    public interface CountBuilder extends Value {
+    public interface CountBuilder extends StatementPart {
+
         public CountBuilder all();
+
         public CountBuilder column(Value value);
+
         public CountBuilder distinct();
     }
-    
-    public interface SelectColumnBuilder extends Visitable {
+
+    public interface SelectColumnBuilder extends StatementPart {
+
         public SelectColumnBuilder name(String name);
+
         public SelectColumnBuilder value(Value value);
+
         public SelectColumnBuilder as(String alias);
+
         public SelectColumnBuilder as_geometry();
+
         public SelectColumnBuilder all();
+
         public String getName();
+
         public String getAlias();
+
         public String getValue();
     }
-    
-    public interface InsertColumnBuilder extends Visitable {
+
+    public interface InsertColumnBuilder extends StatementPart {
+
         public InsertColumnBuilder name(String name);
+
         public InsertColumnBuilder with_value(Value value);
+
         public String getName();
+
         public Value getValue();
     }
-    
+
     public interface UpdateColumnBuilder extends InsertColumnBuilder {
+
         @Override
         public UpdateColumnBuilder name(String name);
+
         @Override
         public UpdateColumnBuilder with_value(Value value);
+
         @Override
         public String getName();
+
         @Override
         public Value getValue();
     }
-        
-    public interface FromBuilder extends Visitable {
+
+    public interface FromBuilder extends StatementPart {
+
         public TableNameBuilder table();
+
         public FromBuilder subquery(String subquery);
+
         public FromBuilder custom(String passthrough);
     }
 
-    public interface OrderByBuilder extends Visitable {
+    public interface OrderByBuilder extends StatementPart {
+
         public OrderByBuilder column(String name);
+
         public OrderByBuilder ascending(boolean asc);
+
         public OrderByBuilder ascending();
+
         public OrderByBuilder descending();
+
         public OrderByBuilder custom(String order);
     }
-    
+
     public interface SelectBuilder extends Statement {
+
         public SelectColumnBuilder column();
+
         public FromBuilder from();
+
         public ExpressionBuilder where();
+
         public OrderByBuilder order_by();
+
         public SelectBuilder distinct();
+
         public SelectBuilder limit(long limit);
+
         public SelectBuilder limit(Long limit);
-        
+
         /**
-         * Specifies an offset to be applied to the SQL statement.
-         * Only an offset can be applied if an order has been specified. 
-         * Otherwise an IllegalStateException exception will be thrown when 
-         * constructing the SQL statement invoking the toString method.
-         * 
+         * Specifies an offset to be applied to the SQL statement. Only an
+         * offset can be applied if an order has been specified. Otherwise an
+         * IllegalStateException exception will be thrown when constructing the
+         * SQL statement invoking the toString method.
+         *
          * @param offset
          * @return this SelectBuilder
          */
         public SelectBuilder offset(long offset);
-        
+
         public boolean has_column(String name);
+
         public boolean has_where();
+
         public boolean has_from();
+
         public boolean has_order_by();
+
         public boolean has_limit();
+
         public boolean has_offset();
 
         /**
-         * Constructs the SQL statement.
-         * If the values associated with the SQL statement are not valid 
-         * an IllegalStateException exception is thrown.
-         * 
+         * Constructs the SQL statement. If the values associated with the SQL
+         * statement are not valid an IllegalStateException exception is thrown.
+         *
          * @return the SQL select statement.
-         * @throws IllegalStateException if the values of select statement are not valids.
+         * @throws IllegalStateException if the values of select statement are
+         * not valids.
          */
         @Override
         public String toString();
-        
+
     }
-    
+
     public interface UpdateBuilder extends Statement {
+
         public TableNameBuilder table();
+
         public UpdateColumnBuilder column();
+
         public ExpressionBuilder where();
+
         public boolean has_where();
     }
-    
+
     public interface InsertBuilder extends Statement {
+
         public TableNameBuilder table();
+
         public InsertColumnBuilder column();
     }
-    
+
     public interface DeleteBuilder extends Statement {
+
         public TableNameBuilder table();
+
         public ExpressionBuilder where();
+
         public boolean has_where();
     }
-    
+
     public interface AlterTableBuilder extends Statement {
+
         public TableNameBuilder table();
+
         public AlterTableBuilder drop_column(String columnName);
+
         public AlterTableBuilder add_column(FeatureAttributeDescriptor fad);
-        public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue);    
+
+        public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue);
+
         public AlterTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls);
+
         public AlterTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls);
+
         public AlterTableBuilder alter_column(FeatureAttributeDescriptor fad);
+
         public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue);
+
         public AlterTableBuilder alter_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls);
+
         public AlterTableBuilder alter_geometry_column(String columnName, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls);
+
         public AlterTableBuilder rename_column(String source, String target);
+
         public boolean isEmpty();
+
         public List<String> toStrings();
+
+        public List<String> toStrings(Formatter formatter);
     }
-    
+
     public interface CreateTableBuilder extends Statement {
+
         public TableNameBuilder table();
+
         public CreateTableBuilder add_column(FeatureAttributeDescriptor fad);
+
         public CreateTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue);
+
         public CreateTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls);
+
         public CreateTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls);
+
         public ColumnDescriptor getColumnDescriptor(String columnName);
+
         public List<String> toStrings();
+
+        public List<String> toStrings(Formatter formatter);
     }
-    
+
     public interface UpdateTableStatisticsBuilder extends Statement {
+
         public TableNameBuilder table();
+
         public List<String> toStrings();
+
+        public List<String> toStrings(Formatter formatter);
     }
-        
-    public interface GrantRoleBuilder {
+
+    public interface GrantRoleBuilder extends StatementPart {
+
         public GrantRoleBuilder privilege(Privilege privilege);
+
         public GrantRoleBuilder select();
+
         public GrantRoleBuilder insert();
+
         public GrantRoleBuilder delete();
+
         public GrantRoleBuilder truncate();
+
         public GrantRoleBuilder reference();
+
         public GrantRoleBuilder update();
+
         public GrantRoleBuilder trigger();
+
         public GrantRoleBuilder all();
     }
-    
+
     public interface GrantBuilder extends Statement {
+
         public TableNameBuilder table();
-        public GrantRoleBuilder role(String name);        
+
+        public GrantRoleBuilder role(String name);
+
         public List<String> toStrings();
+
+        public List<String> toStrings(Formatter formatter);
     }
-        
+
     public interface DropTableBuilder extends Statement {
+
         public TableNameBuilder table();
+
         public List<String> toStrings();
+
+        public List<String> toStrings(Formatter formatter);
     }
-    
+
     public interface CreateIndexBuilder extends Statement {
+
         public CreateIndexBuilder if_not_exist();
+
         public CreateIndexBuilder unique();
+
         public CreateIndexBuilder name(String name);
+
         public CreateIndexBuilder spatial();
+
         public CreateIndexBuilder column(String name);
+
         public TableNameBuilder table();
+
         public List<String> toStrings();
+
+        public List<String> toStrings(Formatter formatter);
     }
 
-    @Override
-    public Column column(String name); 
+    public String default_schema();
 
-    public Column column(FeatureAttributeDescriptor fad); 
+    public boolean support_schemas();
 
-    @Override
-    public List<Variable> getVariables();
-    
-    public String default_schema();
-    
-    public boolean supportSchemas();
+    public boolean has_spatial_functions();
 
-    @Deprecated
-    public String sqltype(int dataType, int p, int s);
-    
+    public GeometrySupportType geometry_support_type();
+
     public String sqltype(int dataType, int p, int s, int geomType, int geomSubtype);
-    
+
     public Object sqlgeometrytype(int type, int subtype);
 
     public Object sqlgeometrydimension(int type, int subtype);
-    
+
+    public Object srs_id(IProjection projection);
+
+    public String toString(Formatter formatter);
+
+    public List<Variable> variables();
+
+    public List<String> variables_names();
+
+    public List<Parameter> parameters();
+
+    public List<String> parameters_names();
+
     public SelectBuilder select();
-    
+
     public UpdateBuilder update();
 
     public InsertBuilder insert();
-    
+
     public DeleteBuilder delete();
-    
+
     public AlterTableBuilder alter_table();
 
     public CreateTableBuilder create_table();
-    
+
     public CreateIndexBuilder create_index();
 
     public GrantBuilder grant();
@@ -361,12 +458,21 @@
     public UpdateTableStatisticsBuilder update_table_statistics();
 
     public CountBuilder count();
-    
-    public Function ST_ExtentAggregate(Value geom);
 
-    public Function ST_UnionAggregate(Value geom);
+    public ExpressionBuilder expression();
 
-    public Function Find_SRID(Value schema, Value table, Value column);
-    
-    
+    public String as_identifier(String id);
+
+    public String as_string(String s);
+
+    public String as_string(byte[] s);
+
+    public String as_string(boolean value);
+
+    public String as_string(Number value);
+
+    public String as_string(Object value);
+
+    public void setProperties(Class classToApply, Object... values);
+
 }
Index: 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/SQLBuilderBase.java
===================================================================
--- 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/SQLBuilderBase.java	(revision 44197)
+++ 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/SQLBuilderBase.java	(revision 44198)
@@ -2,7 +2,6 @@
 
 import java.text.MessageFormat;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -10,15 +9,22 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
-import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.cresques.cts.IProjection;
 import org.gvsig.expressionevaluator.ExpressionBuilder;
-import static org.gvsig.expressionevaluator.ExpressionBuilder.Config.geometry_type_support;
-import static org.gvsig.expressionevaluator.ExpressionBuilder.Config.has_spatial_functions;
+import org.gvsig.expressionevaluator.ExpressionBuilder.AbstractValue;
+import org.gvsig.expressionevaluator.ExpressionBuilder.ClassVisitorFilter;
+import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Visitable;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Visitor;
+import org.gvsig.expressionevaluator.ExpressionBuilder.VisitorFilter;
 import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
+import org.gvsig.expressionevaluator.Formatter;
 import org.gvsig.fmap.dal.DataStoreParameters;
 import org.gvsig.fmap.dal.DataTypes;
 import org.gvsig.fmap.dal.SQLBuilder;
@@ -32,7 +38,6 @@
 import org.gvsig.fmap.dal.SQLBuilder.InsertColumnBuilder;
 import org.gvsig.fmap.dal.SQLBuilder.OrderByBuilder;
 import org.gvsig.fmap.dal.SQLBuilder.Privilege;
-import org.gvsig.fmap.dal.SQLBuilder.SQLConfig;
 import org.gvsig.fmap.dal.SQLBuilder.SelectBuilder;
 import org.gvsig.fmap.dal.SQLBuilder.SelectColumnBuilder;
 import org.gvsig.fmap.dal.SQLBuilder.TableNameBuilder;
@@ -40,16 +45,15 @@
 import org.gvsig.fmap.dal.SQLBuilder.UpdateColumnBuilder;
 import org.gvsig.fmap.dal.SQLBuilder.UpdateTableStatisticsBuilder;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
-import org.gvsig.fmap.dal.feature.FeatureStore;
 import org.gvsig.fmap.geom.Geometry;
-import org.gvsig.fmap.geom.primitive.Envelope;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@SuppressWarnings("UseSpecificCatch")
 public class SQLBuilderBase implements SQLBuilder {
-    
-    protected static final Logger logger = LoggerFactory.getLogger(SQLBuilderBase.class);
-    
+
+    protected static final Logger LOGGER = LoggerFactory.getLogger(SQLBuilderBase.class);
+
     protected SelectBuilder select;
     protected UpdateBuilder update;
     protected InsertBuilder insert;
@@ -60,116 +64,15 @@
     protected DropTableBuilder drop_table;
     protected UpdateTableStatisticsBuilder update_table_statistics;
     protected CreateIndexBuilder create_index;
-    protected List<Parameter> parameters;
 
-    public class ConfigBase implements Config {
+    protected abstract class AbstractStatementPart extends AbstractValue {
 
-        protected Map<String, Object> values;
-
-        public ConfigBase() {
-            this.values = new HashMap<>();
-
-        }
-
-        @Override
-        public boolean has_functionality(String functionality) {
-            Object x = this.values.get(functionality);
-            if (x == null) {
-                return false;
-            }
-            if (x instanceof CharSequence && StringUtils.isEmpty((CharSequence) x)) {
-                return false;
-            }
-            return true;
-        }
-
-        @Override
-        public void remove_functionality(String functionality) {
-            this.values.remove(functionality);
-        }
-
-        @Override
-        public boolean has_spatial_functions() {
-            return this.getBoolean(has_spatial_functions);
-        }
-
-        @Override
-        public GeometrySupportType getGeometryTypeSupport() {
-            return (GeometrySupportType) this.get(geometry_type_support);
-        }
-
-        @Override
-        public boolean getBoolean(String name) {
-            return (boolean) this.values.get(name);
-        }
-
-        @Override
-        public String getString(String name) {
-            return (String) this.values.get(name);
-        }
-
-        @Override
-        public Object get(String name) {
-            return this.values.get(name);
-        }
-
-        @Override
-        public void set(String name, Object value) {
-            this.values.put(name, value);
-        }
     }
 
-    public abstract class AbstractValue implements Value {
+    protected abstract class AbstractStatement extends AbstractStatementPart {
 
-        @Override
-        public void accept(Visitor visitor, VisitorFilter filter) {
-            if (filter == null || filter.accept(this)) {
-                visitor.visit(this);
-            }
-        }
-
     }
 
-    public class ClassVisitorFilter implements VisitorFilter {
-
-        private final Class classFilter;
-
-        public ClassVisitorFilter(Class classFilter) {
-            this.classFilter = classFilter;
-        }
-
-        @Override
-        public boolean accept(Visitable visitable) {
-            return classFilter.isInstance(visitable);
-        }
-
-    }
-
-    public class GroupBase extends AbstractValue implements Group {
-
-        protected Value value;
-
-        public GroupBase(Value value) {
-            this.value = value;
-        }
-
-        @Override
-        public Value getValue() {
-            return value;
-        }
-
-        @Override
-        public void accept(Visitor visitor, VisitorFilter filter) {
-            super.accept(visitor, filter);
-            this.value.accept(visitor, filter);
-        }
-
-        @Override
-        public String toString() {
-            return MessageFormat.format(config.getString(Config.group), this.value.toString());
-        }
-    }
-    
     protected class ColumnDescriptorBase implements ColumnDescriptor {
 
         private String name;
@@ -215,7 +118,7 @@
             this.geom_srsdbcode = null;
             this._isIndexed = isIndexed;
         }
-        
+
         public ColumnDescriptorBase(String name, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls) {
             this.name = name;
             this.type = DataTypes.GEOMETRY;
@@ -227,10 +130,10 @@
             this.defaultValue = null;
             this.geom_type = geom_type;
             this.geom_subtype = geom_subtype;
-            this.geom_srsdbcode = getSRSId(proj);
+            this.geom_srsdbcode = srs_id(proj);
             this._isIndexed = isIndexed;
         }
-        
+
         public ColumnDescriptorBase(String name, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls) {
             this.name = name;
             this.type = DataTypes.GEOMETRY;
@@ -245,12 +148,29 @@
             this.geom_srsdbcode = srsdbcode;
             this._isIndexed = isIndexed;
         }
-        
+
+        private ColumnDescriptorBase(FeatureAttributeDescriptor fad) {
+            this(fad.getName(), fad.getType(), fad.getDefaultValue());
+            this.type_p = fad.getPrecision();
+            this.type_s = fad.getSize();
+            this.isPk = fad.isPrimaryKey();
+            this._allowNulls = fad.allowNull();
+            this._isAutomatic = fad.isAutomatic();
+            this._isIndexed = fad.isIndexed();
+
+            if (fad.getType() == org.gvsig.fmap.geom.DataTypes.GEOMETRY) {
+                this.geom_type = fad.getGeomType().getType();
+                this.geom_subtype = fad.getGeomType().getSubType();
+                this.geom_srsdbcode = fad.getSRS();
+            }
+        }
+    
+
         @Override
         public String getName() {
             return this.name;
         }
-        
+
         @Override
         public void setName(String name) {
             this.name = name;
@@ -359,7 +279,7 @@
         @Override
         public void setGeometrySRSId(Object geom_srsid) {
             this.geom_srsdbcode = geom_srsid;
-        }        
+        }
 
         @Override
         public boolean isGeometry() {
@@ -375,513 +295,71 @@
             return this.parameters;
         }
     }
+//
+//    public class ColumnBase extends AbstractValue implements Column {
+//
+//        protected ColumnDescriptor descriptor;
+//        protected String name;
+//
+//        public ColumnBase(ColumnDescriptor descriptor) {
+//            this.name = descriptor.getName();
+//            this.descriptor = descriptor;
+//        }
+//
+//        public ColumnBase(String name) {
+//            this.name = name;
+//            this.descriptor = null;
+//        }
+//
+//        @Override
+//        public ColumnDescriptor getDescriptor() {
+//            return descriptor;
+//        }
+//
+//        @Override
+//        public String name() {
+//            return this.name;
+//        }
+//
+//        @Override
+//        public String toString() {
+//            return this.toString(formatter());
+//        }
+//
+//        @Override
+//        public String toString(Formatter<Value> formatter) {
+//            if (formatter.canApply(this)) {
+//                return formatter.format(this);
+//            }
+//            return as_identifier(this.name);
+//        }
+//
+//        @Override
+//        public int compareTo(ExpressionBuilder.Variable o) {
+//            return this.name.compareTo(o.name());
+//        }
+//
+//        @Override
+//        public boolean equals(Object obj) {
+//            if (!(obj instanceof ExpressionBuilder.Variable)) {
+//                return false;
+//            }
+//            return this.name.equals(((ExpressionBuilder.Variable) obj).name());
+//        }
+//
+//        @Override
+//        public int hashCode() {
+//            int hash = 7;
+//            hash = 37 * hash + Objects.hashCode(this.name);
+//            return hash;
+//        }
+//
+//    }
 
-    public class VariableBase extends AbstractValue implements Column {
+    public class TableNameBuilderBase
+            extends AbstractStatementPart
+            implements TableNameBuilder {
 
-        protected ColumnDescriptor descriptor;
-        protected String name;
-
-
-        public VariableBase(ColumnDescriptor descriptor) {
-            this.name = descriptor.getName();
-            this.descriptor = descriptor;
-        }
-
-        public VariableBase(String name) {
-            this.name = name;
-            this.descriptor = null;
-        }
-
-        @Override
-        public ColumnDescriptor getDescriptor() {
-            return descriptor;
-        }
-
-        @Override
-        public String getName() {
-            return this.name;
-        }
-
-        @Override
-        public String toString() {
-            return identifier(this.name);
-        }
-
-        @Override
-        public int compareTo(ExpressionBuilder.Variable o) {
-            return this.name.compareTo(o.getName());
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (!(obj instanceof ExpressionBuilder.Variable)) {
-                return false;
-            }
-            return this.name.equals(((ExpressionBuilder.Variable) obj).getName());
-        }
-
-        @Override
-        public int hashCode() {
-            int hash = 7;
-            hash = 37 * hash + Objects.hashCode(this.name);
-            return hash;
-        }
-
-    }
-
-    
-    public class ParameterBase extends AbstractValue implements Parameter {
-
-        protected String name;
-        protected Object value;
-        protected ParameterType type;
-        protected Value srs;
-
-        public ParameterBase() {
-            this.type = ParameterType.Constant;
-            this.name = null;
-            this.value = null;
-        }
-
-        @Override
-        public void accept(Visitor visitor, VisitorFilter filter) {
-            super.accept(visitor, filter);
-            if (this.srs != null) {
-                this.srs.accept(visitor, filter);
-            }
-        }
-
-        @Override
-        public Parameter as_geometry_variable() {
-            this.type = ParameterType.Geometry;
-            if (this.value == null && this.name != null) {
-                this.value = this.name;
-            }
-            return this;
-        }
-
-        @Override
-        public Parameter as_constant() {
-            this.type = ParameterType.Constant;
-            if (this.value == null && this.name != null) {
-                this.value = this.name;
-            }
-            return this;
-        }
-
-        @Override
-        public Parameter as_variable() {
-            this.type = ParameterType.Variable;
-            if (this.value != null && this.name == null) {
-                this.name = (String) this.value;
-            }
-            return this;
-        }
-
-        @Override
-        public Parameter srs(Value srs) {
-            this.srs = srs;
-            if( this.type == ParameterType.Variable ) {
-                this.type = ParameterType.Geometry;
-            }
-            return this;
-        }
-
-        @Override
-        public Parameter srs(IProjection srs) {
-            this.srs = constant(getSRSId(srs));
-            if( this.type == ParameterType.Variable ) {
-                this.type = ParameterType.Geometry;
-            }
-            return this;
-        }
-
-        @Override
-        public String getName() {
-            switch (this.type) {
-                case Variable:
-                case Geometry:
-                    return this.name;
-                case Constant:
-                    if (this.value == null) {
-                        return null;
-                    }
-                    return this.value.toString();
-                default:
-                    if (this.name != null) {
-                        return this.name;
-                    }
-                    if (this.value != null) {
-                        return this.value.toString();
-                    }
-                    return null;
-            }
-        }
-
-        @Override
-        public boolean is_constant() {
-            return this.type == ParameterType.Constant;
-        }
-
-        @Override
-        public boolean is_geometry_variable() {
-            return this.type == ParameterType.Geometry;
-        }
-
-        @Override
-        public boolean is_variable() {
-            return this.type == ParameterType.Variable;
-        }
-
-        @Override
-        public Parameter value(Object value) {
-            this.value = value;
-            return this;
-        }
-
-        @Override
-        public Parameter name(String name) {
-            this.type = ParameterType.Variable;
-            this.name = name;
-            return this;
-        }
-
-        @Override
-        public Object getValue() {
-            try {
-                switch (this.type) {
-                    case Constant:
-                        if (this.value instanceof Geometry) {
-                            switch (config.getGeometryTypeSupport()) {
-                                case EWKB:
-                                    return bytearray(((Geometry) this.value).convertToEWKB());
-                                case NATIVE:
-                                case WKB:
-                                    return bytearray(((Geometry) this.value).convertToWKB());
-                                case WKT:
-                                default:
-                                    return ((Geometry) this.value).convertToWKT();
-                            }
-                        } else if (this.value instanceof IProjection) {
-                            return getSRSId((IProjection) this.value);
-                        }
-                        return this.value;
-                    case Variable:
-                    case Geometry:
-                    default:
-                        return this.value;
-                }
-            } catch (Exception ex) {
-                throw new RuntimeException("Can't get value from parameter.", ex);
-            }
-        }
-
-        @Override
-        public ParameterType getType() {
-            return this.type;
-        }
-
-        @Override
-        public Value getSRS() {
-            return this.srs;
-        }
-
-        @Override
-        public String toString() {
-            switch (this.type) {
-                case Constant:
-                case Variable:
-                default:
-                    return "?";
-                case Geometry:
-                    switch (config.getGeometryTypeSupport()) {
-                        case EWKB:
-                            return MessageFormat.format(
-                                    config.getString(Config.ST_GeomFromEWKB),
-                                    "?",
-                                    String.valueOf(this.srs.toString())
-                            );
-                        case WKB:
-                            return MessageFormat.format(
-                                    config.getString(Config.ST_GeomFromWKB),
-                                    "?",
-                                    String.valueOf(this.srs.toString())
-                            );
-                        case WKT:
-                        default:
-                            return MessageFormat.format(
-                                    config.getString(Config.ST_GeomFromText),
-                                    "?",
-                                    String.valueOf(this.srs.toString())
-                            );
-                    }
-            }
-        }
-    }
-
-    public class ConstantBase extends AbstractValue implements Constant {
-
-        protected Object value;
-
-        public ConstantBase(Object value) {
-            this.value = value;
-        }
-
-        @Override
-        public Object getValue() {
-            return this.value;
-        }
-
-        @Override
-        public String toString() {
-            if (this.value instanceof String) {
-                return string((String) this.value);
-            }
-            if (this.value instanceof Boolean) {
-                if (((Boolean) this.value)) {
-                    return config.getString(Config.constant_true);
-                } else {
-                    return config.getString(Config.constant_false);
-                }
-            }
-            return ObjectUtils.toString(this.value, "");
-        }
-    }
-
-    public class CustomBase extends AbstractValue implements Custom {
-
-        protected Object value;
-
-        // Esto es para permitir declarar parametros y columnas en una seccion
-        // custom.
-        protected List<Value> values;
-
-        public CustomBase(Object value) {
-            this.value = value;
-        }
-
-        @Override
-        public void accept(Visitor visitor, VisitorFilter filter) {
-            super.accept(visitor, filter);
-            if (this.values != null) {
-                for (Value value : values) {
-                    value.accept(visitor, filter);
-                }
-            }
-        }
-
-        @Override
-        public Object getValue() {
-            return this.value;
-        }
-
-        @Override
-        public Custom add(Variable variable) {
-            if (this.values == null) {
-                this.values = new ArrayList<>();
-            }
-            this.values.add(variable);
-            return this;
-        }
-
-        @Override
-        public Custom add(Parameter parameter) {
-            if (this.values == null) {
-                this.values = new ArrayList<>();
-            }
-            this.values.add(parameter);
-            return this;
-        }
-
-        @Override
-        public String toString() {
-            return ObjectUtils.toString(this.value, "");
-        }
-    }
-
-    public class GeometryValueBase extends AbstractValue implements GeometryValue {
-
-        protected Geometry geometry;
-        protected IProjection projection;
-
-        public GeometryValueBase(Geometry geometry, IProjection projection) {
-            this.geometry = geometry;
-            this.projection = projection;
-        }
-
-        @Override
-        public Geometry getGeometry() {
-            return this.geometry;
-        }
-
-        @Override
-        public IProjection getSRS() {
-            return this.projection;
-        }
-
-        @Override
-        public String toString() {
-            try {
-                switch (config.getGeometryTypeSupport()) {
-                    case EWKB:
-                        return MessageFormat.format(
-                                config.getString(Config.ST_GeomFromEWKB),
-                                bytearray(this.geometry.convertToEWKB()),
-                                String.valueOf(getSRSId(this.projection))
-                        );
-                    case WKB:
-                        return MessageFormat.format(
-                                config.getString(Config.ST_GeomFromWKB),
-                                bytearray(this.geometry.convertToWKB()),
-                                String.valueOf(getSRSId(this.projection))
-                        );
-                    case WKT:
-                    default:
-                        return MessageFormat.format(
-                                config.getString(Config.ST_GeomFromText),
-                                string(this.geometry.convertToWKT()),
-                                String.valueOf(getSRSId(this.projection))
-                        );
-                }
-            } catch (Exception ex) {
-                throw new RuntimeException("Can't convert geometry to string.", ex);
-            }
-        }
-    }
-
-    public class FunctionBase extends AbstractValue implements Function {
-
-        protected String name;
-        protected String format;
-        protected List<Value> parameters;
-
-        public FunctionBase(String name, String format) {
-            this.name = name;
-            this.format = format;
-        }
-
-        public FunctionBase(String name) {
-            this(name,null);
-        }
-        
-        @Override
-        public List<Value> parameters() {
-            if (this.parameters == null) {
-                this.parameters = new ArrayList<>();
-            }
-            return this.parameters;
-        }
-
-        @Override
-        public Function parameter(Value parameter) {
-            this.parameters().add(parameter);
-            return this;
-        }
-
-        @Override
-        public String getName() {
-            return this.name;
-        }
-
-        @Override
-        public void accept(Visitor visitor, VisitorFilter filter) {
-            super.accept(visitor, filter);
-            for (Value value : this.parameters) {
-                value.accept(visitor, filter);
-            }
-        }
-
-        @Override
-        public String toString() {
-            if( this.format==null ) {
-                StringBuilder builder = new StringBuilder();
-                builder.append(name);
-                builder.append("(");
-                if (this.parameters != null && !this.parameters.isEmpty()) {
-                    boolean first = true;
-                    for (Value value : this.parameters) {
-                        if( first ) {
-                            first=false;
-                            builder.append(value.toString());
-                        } else {
-                            builder.append(", ");
-                            builder.append(value.toString());
-                        }
-                    }
-                }
-                builder.append(")");
-                return builder.toString();
-            }
-            if (this.parameters != null && !this.parameters.isEmpty()) {
-                List<String> values = new ArrayList<>();
-                for (Value value : this.parameters) {
-                    values.add(value.toString());
-                }
-                return MessageFormat.format(format, values.toArray());
-            } else {
-                return this.format;
-            }
-        }
-    }
-
-    public class BinaryOperatorBase extends AbstractValue implements BinaryOperator {
-
-        protected String name;
-        protected String format;
-        protected Value left;
-        protected Value right;
-
-        public BinaryOperatorBase(String name, String format) {
-            this.name = name;
-            this.format = format;
-        }
-
-        @Override
-        public String getName() {
-            return this.name;
-        }
-
-        @Override
-        public void accept(Visitor visitor, VisitorFilter filter) {
-            super.accept(visitor, filter);
-            this.left.accept(visitor, filter);
-            this.right.accept(visitor, filter);
-        }
-
-        @Override
-        public BinaryOperator setLeft(Value operand) {
-            this.left = operand;
-            return this;
-        }
-
-        @Override
-        public BinaryOperator setRight(Value operand) {
-            this.right = operand;
-            return this;
-        }
-
-        @Override
-        public Value getLeft() {
-            return this.left;
-        }
-
-        @Override
-        public Value getRight() {
-            return this.right;
-        }
-
-        @Override
-        public String toString() {
-            return MessageFormat.format(
-                    format,
-                    this.left.toString(),
-                    this.right.toString()
-            );
-        }
-    }
-    
-    public class TableNameBuilderBase implements TableNameBuilder {
-
         public String tableName;
         public String schemaName;
         private String databaseName;
@@ -891,7 +369,7 @@
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
         }
@@ -904,7 +382,7 @@
 
         @Override
         public TableNameBuilder schema(String name) {
-            if( supportSchemas() ) {
+            if (support_schemas()) {
                 this.schemaName = name;
             }
             return this;
@@ -930,10 +408,10 @@
         public String getName() {
             return this.tableName;
         }
-        
+
         @Override
         public boolean has_schema() {
-            if( !supportSchemas() ) {
+            if (!support_schemas()) {
                 return false;
             }
             return !StringUtils.isEmpty(this.schemaName);
@@ -943,38 +421,48 @@
         public boolean has_database() {
             return !StringUtils.isEmpty(this.databaseName);
         }
-        
+
         @Override
         public String toString() {
-            if( this.has_database()) {
-                if( this.has_schema()) {
-                    return identifier(this.databaseName) + "." + 
-                           identifier(this.schemaName) + "." + 
-                           identifier(this.tableName);
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
+            if (this.has_database()) {
+                if (this.has_schema()) {
+                    return as_identifier(this.databaseName) + "."
+                            + as_identifier(this.schemaName) + "."
+                            + as_identifier(this.tableName);
                 }
             } else {
-                if( this.has_schema()) {
-                    return identifier(this.schemaName) + "." + 
-                           identifier(this.tableName);
-                }                
+                if (this.has_schema()) {
+                    return as_identifier(this.schemaName) + "."
+                            + as_identifier(this.tableName);
+                }
             }
-            return identifier(this.tableName);
+            return as_identifier(this.tableName);
         }
 
     }
 
-    public class CountBuilderBase extends AbstractValue implements CountBuilder {
+    public class CountBuilderBase
+            extends AbstractStatementPart
+            implements CountBuilder {
 
         protected Value value;
         protected boolean distinct;
-        protected boolean all ;
-        
+        protected boolean all;
+
         public CountBuilderBase() {
             this.value = null;
             this.distinct = false;
             this.all = false;
         }
-        
+
         @Override
         public CountBuilder all() {
             this.all = true;
@@ -995,36 +483,42 @@
 
         @Override
         public String toString() {
-            if( this.all ) {
-                return MessageFormat.format(
-                    config.getString(SQLConfig.count),
-                    "*"
-                );
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
             }
-            if( this.distinct ) {
+            if (this.all) {
+                return "COUNT(*)";
+            }
+            if (this.distinct) {
                 return MessageFormat.format(
-                    config.getString(SQLConfig.count_distinct),
-                    value.toString()
+                        "COUNT(DISTINCT {0})",
+                        value.toString(formatter)
                 );
             }
             return MessageFormat.format(
-                config.getString(SQLConfig.count),
-                value.toString()
+                    "COUNT({0})",
+                    value.toString(formatter)
             );
         }
-        
-        
+
     }
-    
-    public class FromBuilderBase implements FromBuilder {
 
-        protected TableNameBuilder tableName= null;
+    public class FromBuilderBase
+            extends AbstractStatementPart
+            implements FromBuilder {
+
+        protected TableNameBuilder tableName = null;
         private String subquery = null;
         private String passthrough = null;
 
         @Override
         public TableNameBuilder table() {
-            if( tableName == null ) {
+            if (tableName == null) {
                 this.tableName = createTableNameBuilder();
             }
             return this.tableName;
@@ -1032,10 +526,10 @@
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.tableName != null ) {
+            if (this.tableName != null) {
                 this.tableName.accept(visitor, filter);
             }
         }
@@ -1051,48 +545,58 @@
             this.subquery = subquery;
             return this;
         }
-        
+
         @Override
         public String toString() {
-            if( ! StringUtils.isEmpty(passthrough) ) {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
+            if (!StringUtils.isEmpty(passthrough)) {
                 return passthrough;
             }
-            if( ! StringUtils.isEmpty(subquery) ) {
+            if (!StringUtils.isEmpty(subquery)) {
                 return "( " + this.subquery + ") as _subquery_alias_ ";
             }
-            return this.tableName.toString();
+            return this.tableName.toString(formatter);
         }
 
     }
 
-    public class SelectColumnBuilderBase implements SelectColumnBuilder {
+    public class SelectColumnBuilderBase
+            extends AbstractStatementPart
+            implements SelectColumnBuilder {
 
         private Variable name = null;
         private String alias = null;
         private Value value = null;
         private boolean asGeometry = false;
-        
+
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.name != null ) {
+            if (this.name != null) {
                 this.name.accept(visitor, filter);
             }
-            if( this.value != null ) {
+            if (this.value != null) {
                 this.value.accept(visitor, filter);
             }
         }
 
         @Override
         public SelectColumnBuilder name(String name) {
-            String quote = config.getString(Config.quote_for_identifiers);
+            String quote = quote_for_identifiers();
             if (name.startsWith(quote)) {
                 // Remove quotes
                 name = name.substring(1, name.length() - 1);
             }
-            this.name = variable(name);
+            this.name = expression().variable(name);
             this.value = null;
             this.asGeometry = false;
             return this;
@@ -1101,17 +605,17 @@
         @Override
         public SelectColumnBuilder all() {
             this.name = null;
-            this.value = custom("*");
+            this.value = expression().custom("*");
             this.asGeometry = false;
             return this;
         }
-        
+
         @Override
         public SelectColumnBuilder as_geometry() {
             this.asGeometry = true;
             return this;
         }
-       
+
         @Override
         public SelectColumnBuilder value(Value value) {
             this.value = value;
@@ -1127,14 +631,14 @@
 
         @Override
         public String getName() {
-            return this.name.getName();
+            return this.name.name();
         }
-        
+
         @Override
         public String getAlias() {
             return this.alias;
         }
-        
+
         @Override
         public String getValue() {
             return this.alias;
@@ -1142,36 +646,47 @@
 
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
-            if( this.asGeometry ) {
-                builder.append(getAsGeometry(this.name).toString());
+            if (this.asGeometry) {
+                builder.append(expression().ST_AsBinary(this.name).toString(formatter));
             } else {
-                if( this.name != null ) {
-                    builder.append(this.name.toString());
+                if (this.name != null) {
+                    builder.append(this.name.toString(formatter));
                 } else {
-                    builder.append(this.value.toString());
+                    builder.append(this.value.toString(formatter));
                 }
             }
-            if( this.alias != null ) {
+            if (this.alias != null) {
                 builder.append(" AS ");
-                builder.append(identifier(this.alias));
+                builder.append(as_identifier(this.alias));
             }
             return builder.toString();
         }
     }
 
-    public class OrderByBuilderBase implements OrderByBuilder {
+    public class OrderByBuilderBase
+            extends AbstractStatementPart
+            implements OrderByBuilder {
+
         protected String value;
         protected String custom;
         protected boolean ascending;
-        
+
         public OrderByBuilderBase() {
             this.ascending = true;
         }
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
         }
@@ -1208,18 +723,28 @@
 
         @Override
         public String toString() {
-            if( !StringUtils.isEmpty(this.custom) ) {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
+            if (!StringUtils.isEmpty(this.custom)) {
                 return this.custom;
             }
-            if( this.ascending ) {
-                return identifier(this.value) + " ASC";
+            if (this.ascending) {
+                return as_identifier(this.value) + " ASC";
             }
-            return identifier(this.value) + " DESC";
+            return as_identifier(this.value) + " DESC";
         }
     }
-    
-    public class SelectBuilderBase implements SelectBuilder {
 
+    public class SelectBuilderBase
+            extends AbstractStatement
+            implements SelectBuilder {
+
         protected FromBuilder from;
         protected ExpressionBuilder where;
         protected long limit = -1;
@@ -1235,21 +760,21 @@
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
             for (SelectColumnBuilder column : columns) {
-                column.accept(visitor,filter);
+                column.accept(visitor, filter);
             }
-            if( this.has_from() ) {
-                this.from.accept(visitor,filter);
+            if (this.has_from()) {
+                this.from.accept(visitor, filter);
             }
-            if( this.has_where() ) {
-                this.where.accept(visitor,filter);
+            if (this.has_where()) {
+                this.where.accept(visitor, filter);
             }
-            if( this.has_order_by() ) {
+            if (this.has_order_by()) {
                 for (OrderByBuilder order : order_by) {
-                    order.accept(visitor,filter);
+                    order.accept(visitor, filter);
                 }
             }
         }
@@ -1259,7 +784,7 @@
             this.distinct = true;
             return this;
         }
-        
+
         @Override
         public SelectColumnBuilder column() {
             SelectColumnBuilder builder = createSelectColumnBuilder();
@@ -1270,7 +795,7 @@
         @Override
         public boolean has_column(String name) {
             for (SelectColumnBuilder column : columns) {
-                if( name.equals(column.getName()) ) {
+                if (name.equals(column.getName())) {
                     return true;
                 }
             }
@@ -1289,7 +814,7 @@
         public boolean has_from() {
             return this.from != null;
         }
-        
+
         @Override
         public ExpressionBuilder where() {
             if (this.where == null) {
@@ -1300,12 +825,12 @@
 
         @Override
         public boolean has_where() {
-            if( this.where == null ) {
+            if (this.where == null) {
                 return false;
             }
-            return this.where.getValue() != null;
+            return this.where.value() != null;
         }
-        
+
         @Override
         public SelectBuilder limit(long limit) {
             this.limit = limit;
@@ -1314,7 +839,7 @@
 
         @Override
         public SelectBuilder limit(Long limit) {
-            if( limit == null ) {
+            if (limit == null) {
                 this.limit = 0;
             } else {
                 this.limit = limit;
@@ -1340,7 +865,7 @@
 
         @Override
         public OrderByBuilder order_by() {
-            if( this.order_by == null ) {
+            if (this.order_by == null) {
                 this.order_by = new ArrayList<>();
             }
             OrderByBuilder order = createOrderByBuilder();
@@ -1350,17 +875,17 @@
 
         @Override
         public boolean has_order_by() {
-            if( this.order_by == null ) {
+            if (this.order_by == null) {
                 return false;
             }
             return !this.order_by.isEmpty();
         }
-        
+
         protected boolean isValid(StringBuilder message) {
-            if( message == null ) {
+            if (message == null) {
                 message = new StringBuilder();
             }
-            if( this.has_offset() && !this.has_order_by() ) {
+            if (this.has_offset() && !this.has_order_by()) {
                 // Algunos gestores de BBDD requieren que se especifique un
                 // orden para poder usar OFFSET. Como eso parece buena idea para
                 // asegurar que siempre tengamos los mismo resultados, lo exijimos
@@ -1370,15 +895,23 @@
             }
             return true;
         }
-        
+
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
-            if( !this.isValid(builder) ) {
+            if (!this.isValid(builder)) {
                 throw new IllegalStateException(builder.toString());
             }
             builder.append("SELECT ");
-            if( this.distinct ) {
+            if (this.distinct) {
                 builder.append("DISTINCT ");
             }
             boolean first = true;
@@ -1388,19 +921,19 @@
                 } else {
                     builder.append(", ");
                 }
-                builder.append(column.toString());
+                builder.append(column.toString(formatter));
             }
 
-            if ( this.has_from() ) {
+            if (this.has_from()) {
                 builder.append(" FROM ");
-                builder.append(this.from.toString());
+                builder.append(this.from.toString(formatter));
             }
-            if ( this.has_where() ) {
+            if (this.has_where()) {
                 builder.append(" WHERE ");
-                builder.append(this.where.toString());
+                builder.append(this.where.toString(formatter));
             }
-            
-            if( this.has_order_by() ) {
+
+            if (this.has_order_by()) {
                 builder.append(" ORDER BY ");
                 first = true;
                 for (OrderByBuilder item : this.order_by) {
@@ -1409,15 +942,15 @@
                     } else {
                         builder.append(", ");
                     }
-                    builder.append(item.toString());                    
-                }   
+                    builder.append(item.toString(formatter));
+                }
             }
-            
-            if ( this.has_limit() ) {
+
+            if (this.has_limit()) {
                 builder.append(" LIMIT ");
                 builder.append(this.limit);
             }
-            if ( this.has_offset() ) {
+            if (this.has_offset()) {
                 builder.append(" OFFSET ");
                 builder.append(this.offset);
             }
@@ -1426,13 +959,15 @@
         }
     }
 
-    public class DropTableBuilderBase implements DropTableBuilder {
+    public class DropTableBuilderBase
+            extends AbstractStatement
+            implements DropTableBuilder {
 
         protected TableNameBuilder table;
 
         @Override
         public TableNameBuilder table() {
-            if( table == null ) {
+            if (table == null) {
                 table = createTableNameBuilder();
             }
             return table;
@@ -1440,18 +975,26 @@
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            this.table.accept(visitor,filter);
+            this.table.accept(visitor, filter);
         }
-        
+
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
             boolean first = true;
-            for (String sql : toStrings()) {
-                if( StringUtils.isEmpty(sql) ) {
+            for (String sql : toStrings(formatter)) {
+                if (StringUtils.isEmpty(sql)) {
                     continue;
                 }
                 if (first) {
@@ -1466,29 +1009,34 @@
 
         @Override
         public List<String> toStrings() {
+            return this.toStrings(formatter());
+        }
+
+        @Override
+        public List<String> toStrings(Formatter formatter) {
             List<String> sqls = new ArrayList<>();
 
             sqls.add(
                     MessageFormat.format(
-                            config.getString(SQLConfig.DROP_TABLE_table),
-                            this.table.toString()
+                            STMT_DROP_TABLE_table,
+                            this.table.toString(formatter)
                     )
             );
             String sql;
-            if( config.has_functionality(SQLConfig.DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table) ) {
+            if (!StringUtils.isBlank(STMT_DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table)) {
                 if (this.table.has_schema()) {
                     sql = MessageFormat.format(
-                            config.getString(SQLConfig.DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table),
-                            string(this.table.getSchema()),
-                            string(this.table.getName())
+                            STMT_DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table,
+                            as_string(this.table.getSchema()),
+                            as_string(this.table.getName())
                     );
                 } else {
                     sql = MessageFormat.format(
-                            config.getString(SQLConfig.DELETE_GEOMETRY_COLUMN_FROM_TABLE_table),
-                            identifier(this.table.getName())
+                            STMT_DELETE_GEOMETRY_COLUMN_FROM_TABLE_table,
+                            as_identifier(this.table.getName())
                     );
                 }
-                if( !StringUtils.isEmpty(sql) ) {
+                if (!StringUtils.isEmpty(sql)) {
                     sqls.add(sql);
                 }
             }
@@ -1496,7 +1044,10 @@
         }
     }
 
-    public class GrantRoleBuilderBase implements GrantRoleBuilder {
+    public class GrantRoleBuilderBase
+            extends AbstractStatementPart
+            implements GrantRoleBuilder {
+
         protected TableNameBuilder table;
         protected String role;
         protected Set<Privilege> privileges;
@@ -1512,16 +1063,16 @@
             privileges.add(privilege);
             return this;
         }
-        
+
         @Override
         public GrantRoleBuilder select() {
-             privileges.add(Privilege.SELECT);
+            privileges.add(Privilege.SELECT);
             return this;
         }
 
         @Override
         public GrantRoleBuilder update() {
-             privileges.add(Privilege.UPDATE);
+            privileges.add(Privilege.UPDATE);
             return this;
         }
 
@@ -1562,7 +1113,7 @@
         }
 
         protected String getPrivilegeName(Privilege privilege) {
-            switch(privilege) {
+            switch (privilege) {
                 case DELETE:
                     return "DELETE";
                 case INSERT:
@@ -1582,9 +1133,17 @@
                     return "ALL";
             }
         }
-        
+
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
             boolean first = true;
             for (Privilege privilege : privileges) {
@@ -1593,30 +1152,32 @@
                 } else {
                     builder.append(", ");
                 }
-                builder.append( this.getPrivilegeName(privilege));
+                builder.append(this.getPrivilegeName(privilege));
             }
             String sql = MessageFormat.format(
-                    config.getString(SQLConfig.GRANT_privileges_ON_table_TO_role),
+                    STMT_GRANT_privileges_ON_table_TO_role,
                     builder.toString(),
-                    table.toString(),
+                    table.toString(formatter),
                     role
             );
             return sql;
         }
     }
-    
-    public class GrantBuilderBase implements GrantBuilder {
 
+    public class GrantBuilderBase
+            extends AbstractStatement
+            implements GrantBuilder {
+
         protected TableNameBuilder table;
         protected Map<String, GrantRoleBuilder> roles;
 
         public GrantBuilderBase() {
             this.roles = new HashMap<>();
         }
-        
+
         @Override
         public TableNameBuilder table() {
-            if( table == null ) {
+            if (table == null) {
                 table = createTableNameBuilder();
             }
             return table;
@@ -1624,18 +1185,18 @@
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.table!= null ) {
-                this.table.accept(visitor,filter);
+            if (this.table != null) {
+                this.table.accept(visitor, filter);
             }
         }
-        
+
         @Override
         public GrantRoleBuilder role(String role) {
             GrantRoleBuilder roleBuilder = this.roles.get(role);
-            if( roleBuilder == null ) {
+            if (roleBuilder == null) {
                 roleBuilder = createGrantRoleBuilder(this.table(), role);
                 this.roles.put(role, roleBuilder);
             }
@@ -1644,10 +1205,18 @@
 
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
             boolean first = true;
-            for (String sql : toStrings()) {
-                if( StringUtils.isEmpty(sql) ) {
+            for (String sql : toStrings(formatter)) {
+                if (StringUtils.isEmpty(sql)) {
                     continue;
                 }
                 if (first) {
@@ -1662,16 +1231,23 @@
 
         @Override
         public List<String> toStrings() {
+            return this.toStrings(formatter());
+        }
+
+        @Override
+        public List<String> toStrings(Formatter formatter) {
             List<String> sqls = new ArrayList<>();
             for (GrantRoleBuilder role : roles.values()) {
-                sqls.add(role.toString());
+                sqls.add(role.toString(formatter));
             }
             return sqls;
         }
     }
 
-    public class UpdateColumnBuilderBase extends InsertColumnBuilderBase implements UpdateColumnBuilder {
-        
+    public class UpdateColumnBuilderBase
+            extends InsertColumnBuilderBase
+            implements UpdateColumnBuilder {
+
         public UpdateColumnBuilderBase() {
             super();
         }
@@ -1685,11 +1261,13 @@
         public UpdateColumnBuilder with_value(Value value) {
             return (UpdateColumnBuilder) super.with_value(value);
         }
-        
+
     }
-    
-    public class UpdateBuilderBase implements UpdateBuilder {
 
+    public class UpdateBuilderBase
+            extends AbstractStatement
+            implements UpdateBuilder {
+
         protected ExpressionBuilder where;
         protected List<UpdateColumnBuilder> columns;
         protected TableNameBuilder table;
@@ -1700,16 +1278,16 @@
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.table != null ) {
+            if (this.table != null) {
                 this.table.accept(visitor, filter);
             }
             for (UpdateColumnBuilder column : columns) {
                 column.accept(visitor, filter);
             }
-            if( this.has_where() ) {
+            if (this.has_where()) {
                 this.where.accept(visitor, filter);
             }
         }
@@ -1724,7 +1302,7 @@
 
         @Override
         public TableNameBuilder table() {
-            if( table == null ) {
+            if (table == null) {
                 table = createTableNameBuilder();
             }
             return table;
@@ -1736,7 +1314,7 @@
             this.columns.add(column);
             return column;
         }
-        
+
         @Override
         public boolean has_where() {
             return this.where != null;
@@ -1744,6 +1322,14 @@
 
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             /*
              * UPDATE [ ONLY ] table [ [ AS ] alias ] SET { column = { expression |
              * DEFAULT } | ( column [, ...] ) = ( { expression | DEFAULT } [, ...] )
@@ -1759,23 +1345,23 @@
                 } else {
                     columnsAndValues.append(", ");
                 }
-                columnsAndValues.append(identifier(column.getName()));
+                columnsAndValues.append(as_identifier(column.getName()));
                 columnsAndValues.append(" = ");
-                columnsAndValues.append(column.getValue().toString());
+                columnsAndValues.append(column.getValue().toString(formatter));
             }
-            
+
             String sql;
-            if ( this.has_where() ) {
+            if (this.has_where()) {
                 sql = MessageFormat.format(
-                        config.getString(SQLConfig.UPDATE_table_SET_columnsAndValues_WHERE_expresion),
-                        this.table.toString(),
+                        STMT_UPDATE_table_SET_columnsAndValues_WHERE_expresion,
+                        this.table.toString(formatter),
                         columnsAndValues.toString(),
-                        this.where.toString()
+                        this.where.toString(formatter)
                 );
             } else {
                 sql = MessageFormat.format(
-                        config.getString(SQLConfig.UPDATE_table_SET_columnsAndValues),
-                        this.table.toString(),
+                        STMT_UPDATE_table_SET_columnsAndValues,
+                        this.table.toString(formatter),
                         columnsAndValues.toString()
                 );
             }
@@ -1783,7 +1369,9 @@
         }
     }
 
-    public class DeleteBuilderBase implements DeleteBuilder {
+    public class DeleteBuilderBase
+            extends AbstractStatement
+            implements DeleteBuilder {
 
         protected ExpressionBuilder where;
         protected TableNameBuilder table;
@@ -1793,13 +1381,13 @@
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.table != null ) {
+            if (this.table != null) {
                 this.table.accept(visitor, filter);
             }
-            if( this.has_where() ) {
+            if (this.has_where()) {
                 this.where.accept(visitor, filter);
             }
         }
@@ -1814,7 +1402,7 @@
 
         @Override
         public TableNameBuilder table() {
-            if( table == null ) {
+            if (table == null) {
                 table = createTableNameBuilder();
             }
             return table;
@@ -1827,28 +1415,38 @@
 
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             /*
              * DELETE FROM table_name
              * WHERE some_column=some_value; 
              */
             String sql;
-            if( this.has_where() ) {
+            if (this.has_where()) {
                 sql = MessageFormat.format(
-                        config.getString(SQLConfig.DELETE_FROM_table_WHERE_expresion),
-                        this.table.toString(),
-                        this.where.toString()
+                        STMT_DELETE_FROM_table_WHERE_expresion,
+                        this.table.toString(formatter),
+                        this.where.toString(formatter)
                 );
             } else {
                 sql = MessageFormat.format(
-                        config.getString(SQLConfig.DELETE_FROM_table),
-                        this.table.toString()
+                        STMT_DELETE_FROM_table,
+                        this.table.toString(formatter)
                 );
             }
             return sql;
         }
     }
 
-    public class CreateIndexBuilderBase implements CreateIndexBuilder {
+    public class CreateIndexBuilderBase
+            extends AbstractStatement
+            implements CreateIndexBuilder {
 
         protected boolean ifNotExist = false;
         protected boolean isUnique = false;
@@ -1856,11 +1454,11 @@
         protected boolean isSpatial = false;
         protected TableNameBuilder table;
         protected final List<String> columns;
-        
+
         public CreateIndexBuilderBase() {
             this.columns = new ArrayList<>();
         }
-        
+
         @Override
         public CreateIndexBuilder unique() {
             this.isUnique = true;
@@ -1893,7 +1491,7 @@
 
         @Override
         public TableNameBuilder table() {
-            if( table == null ) {
+            if (table == null) {
                 table = createTableNameBuilder();
             }
             return table;
@@ -1901,35 +1499,66 @@
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.table != null ) {
+            if (this.table != null) {
                 this.table.accept(visitor, filter);
             }
         }
-        
+
         @Override
+        public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
+            StringBuilder builder = new StringBuilder();
+            boolean first = true;
+            for (String sql : toStrings(formatter)) {
+                if (StringUtils.isEmpty(sql)) {
+                    continue;
+                }
+                if (first) {
+                    first = false;
+                } else {
+                    builder.append("; ");
+                }
+                builder.append(sql);
+            }
+            return builder.toString();
+        }
+
+        @Override
         public List<String> toStrings() {
+            return this.toStrings(formatter());
+        }
+
+        @Override
+        public List<String> toStrings(Formatter formatter) {
             StringBuilder builder = new StringBuilder();
             builder.append("CREATE ");
-            if( this.isUnique ) {
+            if (this.isUnique) {
                 builder.append("UNIQUE ");
             }
             builder.append("INDEX ");
-            if( this.ifNotExist ) {
+            if (this.ifNotExist) {
                 builder.append("IF NOT EXISTS ");
             }
-            builder.append(identifier(this.indexName));
+            builder.append(as_identifier(this.indexName));
             builder.append(" ON ");
-            builder.append(this.table.toString());
-            if( this.isSpatial ) {
+            builder.append(this.table.toString(formatter));
+            if (this.isSpatial) {
                 builder.append(" USING GIST ");
             }
             builder.append(" ( ");
             boolean is_first_column = true;
-            for( String column : this.columns) {
-                if( is_first_column ) {
+            for (String column : this.columns) {
+                if (is_first_column) {
                     is_first_column = false;
                 } else {
                     builder.append(", ");
@@ -1937,21 +1566,23 @@
                 builder.append(column);
             }
             builder.append(" )");
-            
+
             List<String> sqls = new ArrayList<>();
             sqls.add(builder.toString());
             return sqls;
         }
 
     }
-    
-    public class AlterTableBuilderBase implements AlterTableBuilder {
 
+    public class AlterTableBuilderBase
+            extends AbstractStatement
+            implements AlterTableBuilder {
+
         protected TableNameBuilder table;
         protected List<String> drops;
         protected List<ColumnDescriptor> adds;
         protected List<ColumnDescriptor> alters;
-        protected List<Pair<String,String>> renames;
+        protected List<Pair<String, String>> renames;
 
         public AlterTableBuilderBase() {
             this.drops = new ArrayList<>();
@@ -1962,25 +1593,25 @@
 
         @Override
         public boolean isEmpty() {
-            return this.drops.isEmpty() && 
-                this.adds.isEmpty() && 
-                this.alters.isEmpty() && 
-                this.renames.isEmpty();
+            return this.drops.isEmpty()
+                    && this.adds.isEmpty()
+                    && this.alters.isEmpty()
+                    && this.renames.isEmpty();
         }
-        
+
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.table != null ) {
+            if (this.table != null) {
                 this.table.accept(visitor, filter);
             }
         }
 
         @Override
         public TableNameBuilder table() {
-            if( table == null ) {
+            if (table == null) {
                 table = createTableNameBuilder();
             }
             return table;
@@ -1991,11 +1622,11 @@
             this.drops.add(columnName);
             return this;
         }
-        
+
         @Override
         public AlterTableBuilder add_column(FeatureAttributeDescriptor fad) {
-            this.adds.add(column(fad).getDescriptor());
-            return this;            
+            this.adds.add(new ColumnDescriptorBase(fad));
+            return this;
         }
 
         @Override
@@ -2009,7 +1640,7 @@
 
         @Override
         public AlterTableBuilder add_geometry_column(String columnName, int type, int subtype, IProjection proj, boolean isIndexed, boolean allowNulls) {
-            if( StringUtils.isEmpty(columnName) ) {
+            if (StringUtils.isEmpty(columnName)) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
             this.adds.add(new ColumnDescriptorBase(columnName, type, subtype, proj, isIndexed, allowNulls));
@@ -2018,19 +1649,19 @@
 
         @Override
         public AlterTableBuilder add_geometry_column(String columnName, int type, int subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls) {
-            if( StringUtils.isEmpty(columnName) ) {
+            if (StringUtils.isEmpty(columnName)) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
             this.adds.add(new ColumnDescriptorBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
             return this;
         }
-        
+
         @Override
         public AlterTableBuilder alter_column(FeatureAttributeDescriptor fad) {
-            this.alters.add(column(fad).getDescriptor());
-            return this;            
+            this.alters.add(new ColumnDescriptorBase(fad));
+            return this;
         }
-        
+
         @Override
         public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
             if (isPk || isAutomatic) {
@@ -2042,7 +1673,7 @@
 
         @Override
         public AlterTableBuilder alter_geometry_column(String columnName, int type, int subtype, IProjection proj, boolean isIndexed, boolean allowNulls) {
-            if( StringUtils.isEmpty(columnName) ) {
+            if (StringUtils.isEmpty(columnName)) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
             this.alters.add(new ColumnDescriptorBase(columnName, type, subtype, proj, isIndexed, allowNulls));
@@ -2051,7 +1682,7 @@
 
         @Override
         public AlterTableBuilder alter_geometry_column(String columnName, int type, int subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls) {
-            if( StringUtils.isEmpty(columnName) ) {
+            if (StringUtils.isEmpty(columnName)) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
             this.alters.add(new ColumnDescriptorBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
@@ -2066,10 +1697,18 @@
 
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
             boolean first = true;
-            for (String sql : toStrings()) {
-                if( StringUtils.isEmpty(sql) ) {
+            for (String sql : toStrings(formatter)) {
+                if (StringUtils.isEmpty(sql)) {
                     continue;
                 }
                 if (first) {
@@ -2084,36 +1723,41 @@
 
         @Override
         public List<String> toStrings() {
+            return this.toStrings(formatter());
+        }
+
+        @Override
+        public List<String> toStrings(Formatter formatter) {
             List<String> sqls = new ArrayList<>();
-            if( this.isEmpty() ) {
+            if (this.isEmpty()) {
                 return sqls;
             }
             for (String column : drops) {
                 StringBuilder builder = new StringBuilder();
                 builder.append("ALTER TABLE ");
-                builder.append(this.table.toString());
+                builder.append(this.table.toString(formatter));
                 builder.append(" DROP COLUMN IF EXISTS ");
-                builder.append(identifier(column)); 
+                builder.append(as_identifier(column));
                 sqls.add(builder.toString());
             }
             for (ColumnDescriptor column : adds) {
                 StringBuilder builder = new StringBuilder();
                 builder.append("ALTER TABLE ");
-                builder.append(this.table.toString());
+                builder.append(this.table.toString(formatter));
                 builder.append(" ADD COLUMN ");
-                builder.append(identifier(column.getName())); 
+                builder.append(as_identifier(column.getName()));
                 builder.append(" ");
-                if( column.getType() == DataTypes.INT && column.isAutomatic() ) {
+                if (column.getType() == DataTypes.INT && column.isAutomatic()) {
                     builder.append(" SERIAL");
                 } else {
                     builder.append(
-                        sqltype(
-                            column.getType(), 
-                            column.getPrecision(), 
-                            column.getSize(),
-                            column.getGeometryType(),
-                            column.getGeometrySubtype()
-                        )
+                            sqltype(
+                                    column.getType(),
+                                    column.getPrecision(),
+                                    column.getSize(),
+                                    column.getGeometryType(),
+                                    column.getGeometrySubtype()
+                            )
                     );
                 }
                 if (column.getDefaultValue() == null) {
@@ -2138,21 +1782,21 @@
             for (ColumnDescriptor column : alters) {
                 StringBuilder builder = new StringBuilder();
                 builder.append("ALTER TABLE ");
-                builder.append(this.table.toString());
+                builder.append(this.table.toString(formatter));
                 builder.append(" ALTER COLUMN ");
-                builder.append(identifier(column.getName())); 
+                builder.append(as_identifier(column.getName()));
                 builder.append(" SET DATA TYPE ");
-                if( column.getType() == DataTypes.INT && column.isAutomatic() ) {
+                if (column.getType() == DataTypes.INT && column.isAutomatic()) {
                     builder.append(" SERIAL");
                 } else {
                     builder.append(
-                        sqltype(
-                            column.getType(), 
-                            column.getPrecision(), 
-                            column.getSize(),
-                            column.getGeometryType(),
-                            column.getGeometrySubtype()
-                        )
+                            sqltype(
+                                    column.getType(),
+                                    column.getPrecision(),
+                                    column.getSize(),
+                                    column.getGeometryType(),
+                                    column.getGeometrySubtype()
+                            )
                     );
                 }
                 if (column.getDefaultValue() == null) {
@@ -2168,14 +1812,14 @@
                 }
                 sqls.add(builder.toString());
             }
-            for (Pair<String,String> pair : renames) {
+            for (Pair<String, String> pair : renames) {
                 StringBuilder builder = new StringBuilder();
                 builder.append("ALTER TABLE ");
-                builder.append(this.table.toString());
+                builder.append(this.table.toString(formatter));
                 builder.append(" RENAME COLUMN ");
-                builder.append(identifier(pair.getLeft())); 
+                builder.append(as_identifier(pair.getLeft()));
                 builder.append(" TO ");
-                builder.append(identifier(pair.getRight())); 
+                builder.append(as_identifier(pair.getRight()));
                 sqls.add(builder.toString());
             }
             return sqls;
@@ -2183,7 +1827,9 @@
 
     }
 
-    public class CreateTableBuilderBase implements CreateTableBuilder {
+    public class CreateTableBuilderBase
+            extends AbstractStatement
+            implements CreateTableBuilder {
 
         protected TableNameBuilder table;
         protected List<ColumnDescriptor> columns;
@@ -2194,17 +1840,17 @@
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.table != null ) {
+            if (this.table != null) {
                 this.table.accept(visitor, filter);
             }
         }
 
         @Override
         public TableNameBuilder table() {
-            if( table == null ) {
+            if (table == null) {
                 table = createTableNameBuilder();
             }
             return table;
@@ -2212,13 +1858,13 @@
 
         @Override
         public CreateTableBuilderBase add_column(FeatureAttributeDescriptor fad) {
-            this.columns.add(column(fad).getDescriptor());
-            return this;            
+            this.columns.add(new ColumnDescriptorBase(fad));
+            return this;
         }
 
         @Override
         public CreateTableBuilderBase add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue) {
-            if( StringUtils.isEmpty(columnName) ) {
+            if (StringUtils.isEmpty(columnName)) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
             if (isPk || isAutomatic) {
@@ -2230,7 +1876,7 @@
 
         @Override
         public CreateTableBuilder add_geometry_column(String columnName, int type, int subtype, IProjection proj, boolean isIndexed, boolean allowNulls) {
-            if( StringUtils.isEmpty(columnName) ) {
+            if (StringUtils.isEmpty(columnName)) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
             this.columns.add(new ColumnDescriptorBase(columnName, type, subtype, proj, isIndexed, allowNulls));
@@ -2239,7 +1885,7 @@
 
         @Override
         public CreateTableBuilder add_geometry_column(String columnName, int type, int subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls) {
-            if( StringUtils.isEmpty(columnName) ) {
+            if (StringUtils.isEmpty(columnName)) {
                 throw new IllegalArgumentException("Argument 'columnName' can't be empty.");
             }
             this.columns.add(new ColumnDescriptorBase(columnName, type, subtype, srsdbcode, isIndexed, allowNulls));
@@ -2248,23 +1894,31 @@
 
         @Override
         public ColumnDescriptor getColumnDescriptor(String columnName) {
-            if( StringUtils.isEmpty(columnName) ) {
+            if (StringUtils.isEmpty(columnName)) {
                 return null;
             }
             for (ColumnDescriptor column : columns) {
-                if( columnName.equals(column.getName()) ) {
+                if (columnName.equals(column.getName())) {
                     return column;
                 }
             }
             return null;
         }
-                
+
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
             boolean first = true;
-            for (String sql : toStrings()) {
-                if( StringUtils.isEmpty(sql) ) {
+            for (String sql : toStrings(formatter)) {
+                if (StringUtils.isEmpty(sql)) {
                     continue;
                 }
                 if (first) {
@@ -2279,6 +1933,11 @@
 
         @Override
         public List<String> toStrings() {
+            return this.toStrings(formatter());
+        }
+
+        @Override
+        public List<String> toStrings(Formatter formatter) {
             List<String> sqls = new ArrayList<>();
             /**
              * CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE
@@ -2308,7 +1967,7 @@
             StringBuilder builder = new StringBuilder();
 
             builder.append("CREATE TABLE ");
-            builder.append(this.table.toString());
+            builder.append(this.table.toString(formatter));
             builder.append(" (");
             boolean first = true;
             for (ColumnDescriptor column : columns) {
@@ -2317,14 +1976,21 @@
                 } else {
                     builder.append(", ");
                 }
-                builder.append(identifier(column.getName()));
+                builder.append(as_identifier(column.getName()));
                 builder.append(" ");
-                if( column.isAutomatic() && column.getType() == DataTypes.INT ) {
+                if (column.isAutomatic() && column.getType() == DataTypes.INT) {
                     builder.append("SERIAL");
-                } else if( column.isAutomatic() && column.getType() == DataTypes.LONG ) {
+                } else if (column.isAutomatic() && column.getType() == DataTypes.LONG) {
                     builder.append("BIGSERIAL");
                 } else {
-                    builder.append(sqltype(column.getType(), column.getPrecision(), column.getSize()));
+                    builder.append(sqltype(
+                            column.getType(),
+                            column.getPrecision(),
+                            column.getSize(),
+                            column.getGeometryType(),
+                            column.getGeometrySubtype()
+                    )
+                    );
                 }
                 if (column.getDefaultValue() == null) {
                     if (column.allowNulls()) {
@@ -2350,29 +2016,32 @@
         }
     }
 
-    public class InsertColumnBuilderBase implements InsertColumnBuilder {
+    public class InsertColumnBuilderBase
+            extends AbstractStatement
+            implements InsertColumnBuilder {
+
         protected Variable name;
         protected Value value;
-        
+
         public InsertColumnBuilderBase() {
         }
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.name != null ) {
+            if (this.name != null) {
                 this.name.accept(visitor, filter);
             }
-            if( this.value != null ) {
+            if (this.value != null) {
                 this.value.accept(visitor, filter);
             }
         }
 
         @Override
         public InsertColumnBuilder name(String name) {
-            this.name = variable(name);
+            this.name = expression().variable(name);
             return this;
         }
 
@@ -2381,25 +2050,35 @@
             this.value = value;
             return this;
         }
-        
+
         @Override
         public String getName() {
-            return this.name.getName();
+            return this.name.name();
         }
-        
+
         @Override
         public Value getValue() {
             return this.value;
         }
-        
+
         @Override
         public String toString() {
-            return this.value.toString();
+            return this.toString(formatter());
         }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
+            return this.value.toString(formatter);
+        }
     }
-    
-    public class InsertBuilderBase implements InsertBuilder {
 
+    public class InsertBuilderBase
+            extends AbstractStatement
+            implements InsertBuilder {
+
         protected List<InsertColumnBuilder> columns;
         protected TableNameBuilder table;
 
@@ -2409,10 +2088,10 @@
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.table != null ) {
+            if (this.table != null) {
                 this.table.accept(visitor, filter);
             }
             for (InsertColumnBuilder column : columns) {
@@ -2422,7 +2101,7 @@
 
         @Override
         public TableNameBuilder table() {
-            if( table == null ) {
+            if (table == null) {
                 table = createTableNameBuilder();
             }
             return table;
@@ -2437,6 +2116,14 @@
 
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             /*
              * INSERT INTO table [ ( column [, ...] ) ] { DEFAULT VALUES | VALUES (
              * { expression | DEFAULT } [, ...] ) [, ...] | query } [ RETURNING * |
@@ -2444,7 +2131,7 @@
              */
             StringBuilder builderColumns = new StringBuilder();
             StringBuilder builderValues = new StringBuilder();
-            
+
             boolean first = true;
             for (InsertColumnBuilder column : columns) {
                 if (first) {
@@ -2452,7 +2139,7 @@
                 } else {
                     builderColumns.append(", ");
                 }
-                builderColumns.append(identifier(column.getName()));
+                builderColumns.append(as_identifier(column.getName()));
             }
             first = true;
             for (InsertColumnBuilder column : columns) {
@@ -2461,12 +2148,12 @@
                 } else {
                     builderValues.append(", ");
                 }
-                builderValues.append(column.toString());
+                builderValues.append(column.toString(formatter));
             }
-            
+
             String sql = MessageFormat.format(
-                    config.getString(SQLConfig.INSERT_INTO_table_columns_VALUES_values),
-                    this.table.toString(),
+                    STMT_INSERT_INTO_table_columns_VALUES_values,
+                    this.table.toString(formatter),
                     builderColumns.toString(),
                     builderValues.toString()
             );
@@ -2475,23 +2162,25 @@
         }
     }
 
-    public class UpdateTableStatisticsBuilderBase implements UpdateTableStatisticsBuilder {
+    public class UpdateTableStatisticsBuilderBase
+            extends AbstractStatement
+            implements UpdateTableStatisticsBuilder {
 
         protected TableNameBuilder table;
 
         @Override
         public void accept(Visitor visitor, VisitorFilter filter) {
-            if( filter.accept(this) ) {
+            if (filter.accept(this)) {
                 visitor.visit(this);
             }
-            if( this.table != null ) {
+            if (this.table != null) {
                 this.table.accept(visitor, filter);
             }
         }
 
         @Override
         public TableNameBuilder table() {
-            if( table == null ) {
+            if (table == null) {
                 table = createTableNameBuilder();
             }
             return table;
@@ -2499,10 +2188,18 @@
 
         @Override
         public String toString() {
+            return this.toString(formatter());
+        }
+
+        @Override
+        public String toString(Formatter<Value> formatter) {
+            if (formatter.canApply(this)) {
+                return formatter.format(this);
+            }
             StringBuilder builder = new StringBuilder();
             boolean first = true;
-            for (String sql : toStrings()) {
-                if( StringUtils.isEmpty(sql) ) {
+            for (String sql : toStrings(formatter)) {
+                if (StringUtils.isEmpty(sql)) {
                     continue;
                 }
                 if (first) {
@@ -2517,14 +2214,19 @@
 
         @Override
         public List<String> toStrings() {
+            return this.toStrings(formatter());
+        }
+
+        @Override
+        public List<String> toStrings(Formatter formatter) {
             List<String> sqls = new ArrayList<>();
-            
-            if( config.has_functionality(SQLConfig.UPDATE_TABLE_STATISTICS_table) ) {
+
+            if (!StringUtils.isBlank(STMT_UPDATE_TABLE_STATISTICS_table)) {
                 String sql = MessageFormat.format(
-                        config.getString(SQLConfig.UPDATE_TABLE_STATISTICS_table),
-                        table.toString()
-                    );
-                if( !StringUtils.isEmpty(sql) ) {
+                        STMT_UPDATE_TABLE_STATISTICS_table,
+                        table.toString(formatter)
+                );
+                if (!StringUtils.isEmpty(sql)) {
                     sqls.add(sql);
                 }
             }
@@ -2532,650 +2234,211 @@
         }
     }
 
+    protected ExpressionBuilder expressionBuilder;
 
-    private static class ParametersBase extends ArrayList<Parameter> implements Parameters {
+    protected String defaultSchema;
+    protected boolean supportSchemas;
+    protected boolean hasSpatialFunctions;
+    protected GeometrySupportType geometrySupportType;
+    protected boolean allowAutomaticValues;
 
-        private static final long serialVersionUID = -2188534574151780470L;
+    private static Map<Pair<Integer, Integer>, String> sqlgeometrytypes = null;
 
-        public ParametersBase() {
-            super();
-        }
+    protected String constant_true = "(1=1)";
+    protected String constant_false = "(1=1)";
 
-        public ParametersBase(Collection parameters) {
-            super(parameters);
-        }
+    protected String type_boolean = "BOOLEAN";
+    protected String type_byte = "TINYINT";
+    protected String type_bytearray = "BYTEA";
+    protected String type_geometry = "TEXT";
+    protected String type_char = "CHARACTER(1)";
+    protected String type_date = "DATE";
+    protected String type_double = "DOUBLE PRECISION"; //float con 53 bits de mantisa, float(54)
+    protected String type_numeric_p = "NUMERIC({0})";
+    protected String type_numeric_ps = "NUMERIC({0},{1})";
+    protected String type_bigdecimal = "NUMERIC({0},{1})";
+    protected String type_float = "REAL"; //float con 24 bits de mantisa, float(24)
+    protected String type_int = "INT";
+    protected String type_long = "BIGINT";
+    protected String type_string = "TEXT";
+    protected String type_string_p = "VARCHAR({0})";
+    protected String type_time = "TIME";
+    protected String type_timestamp = "TIMESTAMP";
+    protected String type_version = "VARCHAR(30)";
+    protected String type_URI = "TEXT";
+    protected String type_URL = "TEXT";
+    protected String type_FILE = "TEXT";
+    protected String type_FOLDER = "TEXT";
 
-        @Override
-        public Parameter get(String name) {
-            if( name == null ) {
-                return null;
-            }
-            for (Parameter param : this) {
-                if( param.is_variable() || param.is_geometry_variable() ) {
-                    if( name.equalsIgnoreCase(param.getName()) ) {
-                        return param;
-                    }
-                }
-            }
-            return null;
-        }
+    protected String STMT_DELETE_FROM_table_WHERE_expresion = "DELETE FROM {0} WHERE {1}";
+    protected String STMT_DELETE_FROM_table = "DELETE FROM {0}";
+    protected String STMT_INSERT_INTO_table_columns_VALUES_values = "INSERT INTO {0} ( {1} ) VALUES ( {2} )";
+    protected String STMT_UPDATE_TABLE_STATISTICS_table = "VACUUM ANALYZE {0}";
+    protected String STMT_DROP_TABLE_table = "DROP TABLE {0}";
+    protected String STMT_DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table = "DELETE FROM GEOMETRY_COLUMNS WHERE f_table_schema = {0} AND f_table_name = {1}";
+    protected String STMT_DELETE_GEOMETRY_COLUMN_FROM_TABLE_table = "DELETE FROM GEOMETRY_COLUMNS WHERE f_table_name = {0}";
+    protected String STMT_UPDATE_table_SET_columnsAndValues_WHERE_expresion = "UPDATE {0} SET {1} WHERE {2}";
+    protected String STMT_UPDATE_table_SET_columnsAndValues = "UPDATE {0} SET {1}";
+    protected String STMT_GRANT_privileges_ON_table_TO_role = "GRANT {0} ON {1} TO {2}";
 
-        
-        @Override
-        public String toString() {
-            boolean first = true;
-            StringBuilder builder = new StringBuilder();
-            builder.append("{ ");
-            for (Parameter param : this) {
-                if (!first) {
-                    builder.append(", ");
-                } else {
-                    first = false;
-                }
-                String s;
-                Object value = param.getValue();
-                if (value == null) {
-                    s = "null";
-                } else if (value instanceof String) {
-                    s = "'" + (String) value + "'";
-                } else {
-                    s = value.toString();
-                }
-                switch (param.getType()) {
-                    case Constant:
-                        builder.append(s);
-                        break;
-                    case Geometry:
-                        builder.append("(Geometry)");
-                    case Variable:
-                    default:
-                        builder.append(param.getName());
-                        builder.append(": ");
-                        builder.append(s);
-                }
-            }
-            builder.append(" }");
-            return builder.toString();
-        }
-    }
-
-    protected Value value;
-    protected Config config;
-  
     public SQLBuilderBase() {
-        
-        this.config = new ConfigBase();
-        this.value = null;
-        
-        config.set(SQLConfig.has_spatial_functions, false);
-        config.set(SQLConfig.support_schemas, true);
-        config.set(SQLConfig.constant_true, "(1=1)");
-        config.set(SQLConfig.constant_false, "(1=2)");
-        config.set(SQLConfig.quote_for_identifiers, "\"");
-        config.set(SQLConfig.quote_for_strings, "'");
-        config.set(SQLConfig.geometry_type_support, GeometrySupportType.WKT);
-        config.set(SQLConfig.group, "( {0} )");
+        this.expressionBuilder = ExpressionEvaluatorLocator.getManager().createExpressionBuilder();
 
-        config.set(SQLConfig.ST_SRID, "ST_SRID({0})");
-        config.set(SQLConfig.ST_AsText, "ST_AsText({0})");
-        config.set(SQLConfig.ST_AsBinary, "ST_AsBinary({0})");
-        config.set(SQLConfig.ST_AsEWKB, "ST_AsEWKB({0})");
-        config.set(SQLConfig.ST_Contains, "ST_Contains(({0}), ({1}))");
-        config.set(SQLConfig.ST_Crosses, "ST_Crosses(({0}), ({1}))");
-        config.set(SQLConfig.ST_Disjoint, "ST_Disjoint(({0}), ({1}))");
-        config.set(SQLConfig.ST_Equals, "ST_Equals(({0}), ({1}))");
-        config.set(SQLConfig.ST_IsClosed, "ST_IsClosed({0})");
-        config.set(SQLConfig.ST_Overlaps, "ST_Overlaps(({0}), ({1}))");
-        config.set(SQLConfig.ST_Touches, "ST_Touches(({0}), ({1}))");
-        config.set(SQLConfig.ST_Within, "ST_Within(({0}), ({1}))");
-        config.set(SQLConfig.ST_Envelope, "ST_Envelope({0})");
-        config.set(SQLConfig.ST_Intersects, "ST_Intersects(({0}), ({1}))");
-        config.set(SQLConfig.ST_GeomFromText, "ST_GeomFromText({0}, ({1}))");
-        config.set(SQLConfig.ST_GeomFromWKB, "ST_GeomFromWKB(({0}), ({1}))");
-        config.set(SQLConfig.ST_GeomFromEWKB, "ST_GeomFromEWKB(({0}), ({1}))");
+        this.hasSpatialFunctions = false;
+        this.supportSchemas = true;
+        this.geometrySupportType = GeometrySupportType.WKT;
 
-        // Por defecto no esta disponible la funcion ST_Simplify
-        // El proveedor que la soporte que la defina.
-        // config.set(SQLConfig.ST_Simplify, "ST_Simplify(({0}), ({1}))");
-        config.remove_functionality(SQLConfig.ST_Simplify);
+        this.defaultSchema = "public";
+        this.allowAutomaticValues = true;
 
-        config.set(SQLConfig.lcase, "LCASE({0})");
-        config.set(SQLConfig.ucase, "UCASE({0})");
-        config.set(SQLConfig.isNull, "( ({0}) IS NULL )");
-        config.set(SQLConfig.notIsNull, "( ({0}) NOT IS NULL )");
-        config.set(SQLConfig.operator_not, "( NOT ({0}) )");
-
-        config.set(SQLConfig.operator_AND, "{0} AND {1}");
-        config.set(SQLConfig.operator_OR, "{0} OR {1}");
-        config.set(SQLConfig.operator_EQ, "( ({0}) = ({1}) )");
-        config.set(SQLConfig.operator_NE, "( ({0}) <> ({1}) )");
-        config.set(SQLConfig.operator_GT, "( ({0}) > ({1}) )");
-        config.set(SQLConfig.operator_GE, "( ({0}) >= ({1}) )");
-        config.set(SQLConfig.operator_LT, "( ({0}) < ({1}) )");
-        config.set(SQLConfig.operator_LE, "( ({0}) <= ({1}) )");
-        config.set(SQLConfig.operator_LIKE, "( ({0}) LIKE ({1}) )");
-        config.set(SQLConfig.operator_ILIKE, "( ({0}) ILIKE ({1}) )");
-
-        config.set(SQLConfig.operator_add, "{0} + {1}");
-        config.set(SQLConfig.operator_subst, "{0} - {1}");
-        config.set(SQLConfig.operator_mult, "{0} * {1}");
-        config.set(SQLConfig.operator_div, "{0} / {1}");
-        config.set(SQLConfig.operator_concat, "{0} || {1}");
-
-
-        config.set(SQLConfig.default_schema, "public");
-        config.set(SQLConfig.allowAutomaticValues, true);
-        
-        config.set(SQLConfig.ST_ExtentAggregate, "ST_Extent({0})");
-        config.set(SQLConfig.ST_UnionAggregate, "ST_Union({0})");
-        config.set(SQLConfig.count, "COUNT({0})");
-        config.set(SQLConfig.count_distinct, "COUNT(DISTINCT {0})");
-
-        config.set(SQLConfig.type_boolean, "BOOLEAN");
-        config.set(SQLConfig.type_byte, "TINYINT");
-        config.set(SQLConfig.type_bytearray, "BYTEA");
-        config.set(SQLConfig.type_geometry, "TEXT");
-        config.set(SQLConfig.type_char, "CHARACTER(1)");
-        config.set(SQLConfig.type_date, "DATE");
-        config.set(SQLConfig.type_double, "DOUBLE PRECISION"); //float con 53 bits de mantisa, float(54)
-        config.set(SQLConfig.type_numeric_p, "NUMERIC({0})");
-        config.set(SQLConfig.type_numeric_ps, "NUMERIC({0},{1})");
-        config.set(SQLConfig.type_bigdecimal, "NUMERIC({0},{1})");
-        config.set(SQLConfig.type_float, "REAL"); //float con 24 bits de mantisa, float(24)
-        config.set(SQLConfig.type_int, "INT");
-        config.set(SQLConfig.type_long, "BIGINT");
-        config.set(SQLConfig.type_string, "TEXT");
-        config.set(SQLConfig.type_string_p, "VARCHAR({0})");
-        config.set(SQLConfig.type_time, "TIME");
-        config.set(SQLConfig.type_timestamp, "TIMESTAMP");
-        config.set(SQLConfig.type_version, "VARCHAR(30)");
-        config.set(SQLConfig.type_URI, "TEXT");
-        config.set(SQLConfig.type_URL, "TEXT");
-        config.set(SQLConfig.type_FILE, "TEXT");
-        config.set(SQLConfig.type_FOLDER, "TEXT");
-
-        config.set(SQLConfig.DELETE_FROM_table_WHERE_expresion, "DELETE FROM {0} WHERE {1}");
-        config.set(SQLConfig.DELETE_FROM_table, "DELETE FROM {0}");
-        config.set(SQLConfig.INSERT_INTO_table_columns_VALUES_values, "INSERT INTO {0} ( {1} ) VALUES ( {2} )");
-        config.set(SQLConfig.UPDATE_TABLE_STATISTICS_table, "VACUUM ANALYZE {0}");
-        config.set(SQLConfig.DROP_TABLE_table, "DROP TABLE {0}");
-        config.set(SQLConfig.DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table, "DELETE FROM GEOMETRY_COLUMNS WHERE f_table_schema = {0} AND f_table_name = {1}");
-        config.set(SQLConfig.DELETE_GEOMETRY_COLUMN_FROM_TABLE_table, "DELETE FROM GEOMETRY_COLUMNS WHERE f_table_name = {0}");
-        config.set(SQLConfig.UPDATE_table_SET_columnsAndValues_WHERE_expresion, "UPDATE {0} SET {1} WHERE {2}");
-        config.set(SQLConfig.UPDATE_table_SET_columnsAndValues, "UPDATE {0} SET {1}");
-        config.set(SQLConfig.GRANT_privileges_ON_table_TO_role, "GRANT {0} ON {1} TO {2}");        
     }
-   
+    
     @Override
-    public ExpressionBuilder createExpressionBuilder() {
-        return ExpressionEvaluatorLocator.getManager().createExpressionBuilder();
+    public void setProperties(Class filter, final Object... values) {
+        this.accept(new Visitor() {
+            @Override
+            public void visit(Visitable v) {
+                for (int i = 0; i < values.length; i+=2) {
+                    ((Value)v).setProperty((String) values[i], values[i+1]);
+                }
+            }
+        }, new ClassVisitorFilter(filter) );
     }
 
-    @Override
-    public Config getConfig() {
-        return this.config;
+    public String quote_for_identifiers() {
+        return "\"";
     }
 
-    @Override
-    public Value getValue() {
-        return this.value;
+    public String quote_for_strings() {
+        return "'";
     }
 
     @Override
-    public ExpressionBuilder setValue(Value value) {
-        this.value = value;
-        return this;
-    }
+    public String as_identifier(String id) {
+        String quote = this.quote_for_identifiers();
+//        No se porque no esta disponible wrapIfMissing
+//        return StringUtils.wrapIfMissing(id,quote);
+        if (id.startsWith(quote)) {
+            return id;
+        }
+        return quote + id + quote;
 
-    @Override
-    public boolean has_spatial_functions() {
-        return this.config.getBoolean(Config.has_spatial_functions);
     }
 
     @Override
-    public GeometrySupportType geometry_support_type() {
-        return (GeometrySupportType) this.config.get(Config.geometry_type_support);
-    }
-
-    @Override
-    public String string(String s) {
-        String quote = this.config.getString(Config.quote_for_strings);
+    public String as_string(String s) {
+        String quote = this.quote_for_strings();
 //        No se porque no esta disponible wrapIfMissing
-//        return StringUtils.wrapIfMissing(s,quote);
+//        return StringUtils.wrapIfMissing(id,quote);
         if (s.startsWith(quote)) {
             return s;
         }
         return quote + s + quote;
-    }
 
-    @Override
-    public String identifier(String id) {
-        String quote = this.config.getString(Config.quote_for_identifiers);
-//        No se porque no esta disponible wrapIfMissing
-//        return StringUtils.wrapIfMissing(id,quote);
-        if (id.startsWith(quote)) {
-            return id;
-        }
-        return quote + id + quote;
     }
 
     @Override
-    public String bytearray(byte[] data) {
-        return bytearray_0x(data);
+    public String as_string(byte[] data) {
+        return this.expressionBuilder.bytearray_0x(data);
+//        return this.expressionBuilder.bytearray_hex(data);
+//        return this.expressionBuilder.bytearray_x(data);
     }
     
-    public String bytearray_hex(byte[] data) {
-        StringBuilder builder = new StringBuilder();
-        for (byte abyte : data) {
-            int v = abyte & 0xff;
-            builder.append(String.format("%02x", v));
-        }
-        return builder.toString();
-    }
-
-    public String bytearray_0x(byte[] data) {
-        return "0x" + bytearray_hex(data);
-    }
-
-    public String bytearray_x(byte[] data) {
-        return "x'" + bytearray_hex(data) + "'";
-    }
-    
     @Override
-    public Object getSRSId(IProjection projection) {
-        String abrev = projection.getAbrev();
-        return abrev.split(":")[1].trim();
+    public String as_string(boolean value) {
+        return value? "TRUE" : "FALSE";
     }
 
     @Override
-    public Constant srs(IProjection projection) {
-        return constant(getSRSId(projection));
+    public String as_string(Number value) {
+        return Objects.toString(value);
     }
-
-    @Override
-    public Variable variable(String name) {
-        return new VariableBase(name);
-    }
-
-    @Override
-    public Column column(String name) {
-        return new VariableBase(name);
-    }
     
     @Override
-    public Parameter parameter(String name) {
-        Parameters parameters = this.getParameters();
-        Parameter parameter = parameters.get(name);
-        if( parameter != null ) {
-            return parameter;
+    public String as_string(Object value) {
+        if( value == null ) {
+            return "NULL";
         }
-        parameter = this.parameter();
-        parameter.name(name);
-        return parameter;
-    }
-    
-    @Override
-    public Parameter parameter() {
-        return new ParameterBase();
-    }
-    
-    @Override
-    public Constant constant(Object value) {
-        return new ConstantBase(value);
-    }
-
-    @Override
-    public Group group(Value value) {
-        return new GroupBase(value);
-    }
-
-    @Override
-    public GeometryValue geometry(Geometry geom, IProjection projection) {
-        return new GeometryValueBase(geom, projection);
-    }
-
-    @Override
-    public GeometryValue geometry(Geometry geom) {
-        if( geom.getProjection()==null ) {
-            throw new IllegalArgumentException("The geometry does not have an associated projection. Use 'geometry(Geometry, IProjection)'.");
+        if( value instanceof CharSequence ) {
+            return as_string(value.toString());
         }
-        return new GeometryValueBase(geom, geom.getProjection());
-    }
-
-    @Override
-    public GeometryValue envelope(Envelope envelope, IProjection projection) {
-        return new GeometryValueBase(envelope.getGeometry(), projection);
-    }
-
-    @Override
-    public GeometryValue envelope(Envelope envelope) {
-        if( envelope.getProjection()==null ) {
-            throw new IllegalArgumentException("The envelope does not have an associated projection. Use 'envelope(Geometry, IProjection)'.");
+        if( value instanceof Number ) {
+            return as_string((Number)value);
         }
-        return new GeometryValueBase(envelope.getGeometry(), envelope.getProjection());
-    }
-
-    @Override
-    public Custom custom(Object value) {
-        return new CustomBase(value);
-    }
-
-    public Function builtin_function(String name, String format, Value... values) {
-        FunctionBase func = new FunctionBase(name, format);
-        for (Value value : values) {
-            func.parameter(value);
+        if( value instanceof Boolean ) {
+            return as_string((boolean)value);
         }
-        return func;
-    }
-
-    public Function function(String name, Value... values) {
-        FunctionBase func = new FunctionBase(name);
-        for (Value theValue : values) {
-            func.parameter(theValue);
+        if( value instanceof byte[] ) {
+            return as_string((byte[])value);
         }
-        return func;
-    }    
-    
-    public BinaryOperator binaryOperator(String name, String format, Value leftOperand, Value rightOperand) {
-        BinaryOperator operator = new BinaryOperatorBase(name, format);
-        operator.setLeft(leftOperand);
-        operator.setRight(rightOperand);
-        return operator;
+        throw new IllegalArgumentException("Can't support type of value '"+value.getClass().getName()+"'.");
     }
-
+    
     @Override
-    public List<Variable> getVariables() {
-        final Set<Variable> vars = new HashSet<>();
-        this.accept(new Visitor() {
-            @Override
-            public void visit(Visitable value) {
-                vars.add((Variable) value);
-            }
-        }, new ClassVisitorFilter(Variable.class));
-        List<Variable> lvars = new ArrayList<>(vars);
-        Collections.sort(lvars);
-        return lvars;
+    public ExpressionBuilder expression() {
+        return this.expressionBuilder;
     }
 
     @Override
-    public Parameters getParameters() {
-        final Parameters params = new ParametersBase();
-        this.accept(new Visitor() {
-            @Override
-            public void visit(Visitable value) {
-                params.add((Parameter) value);
-            }
-        }, new ClassVisitorFilter(Parameter.class));
-        return params;
+    public boolean has_spatial_functions() {
+        return this.hasSpatialFunctions;
     }
 
     @Override
-    public Function getAsGeometry(Value value) {
-        return builtin_function("ST_AsBinary", config.getString(Config.ST_AsBinary), value);
+    public GeometrySupportType geometry_support_type() {
+        return this.geometrySupportType;
     }
 
-    @Override
-    public ExpressionBuilder set(Value value) {
-        this.value = value;
-        return this;
+    protected ExpressionBuilder createExpressionBuilder() {
+        return ExpressionEvaluatorLocator.getManager().createExpressionBuilder();
     }
 
     @Override
-    public ExpressionBuilder and(Value value) {
-        if (this.value == null) {
-            return this.set(value);
-        }
-        BinaryOperator operator = binaryOperator("AND", config.getString(Config.operator_AND), this.value, value);
-        this.value = operator;
-        return this;
+    public Object srs_id(IProjection projection) {
+        String abrev = projection.getAbrev();
+        return abrev.split(":")[1].trim();
     }
 
     @Override
-    public ExpressionBuilder or(Value value) {
-        if (this.value == null) {
-            return this.set(value);
-        }
-        BinaryOperator operator = binaryOperator("OR", config.getString(Config.operator_OR), this.value, value);
-        this.value = operator;
-        return this;
-    }
-
-    @Override
-    public Function ST_Intersects(Value geom1, Value geom2) {
-        return builtin_function("ST_Intersects", config.getString(Config.ST_Intersects), geom1, geom2);
-    }
-
-    @Override
-    public Function ST_SRID(Value geom) {
-        return builtin_function("ST_SRID", config.getString(Config.ST_SRID), geom);
-    }
-
-    @Override
-    public Function ST_Envelope(Value geom) {
-        return builtin_function("ST_Envelope", config.getString(Config.ST_Envelope), geom);
-    }
-
-    @Override
-    public Function ST_AsText(Value geom) {
-        return builtin_function("ST_AsText", config.getString(Config.ST_AsText), geom);
-    }
-
-    @Override
-    public Function ST_AsBinary(Value geom) {
-        return builtin_function("ST_AsBinary", config.getString(Config.ST_AsBinary), geom);
-    }
-
-    @Override
-    public Function ST_AsEWKB(Value geom) {
-        return builtin_function("ST_AsEWKB", config.getString(Config.ST_AsEWKB), geom);
-    }
-
-    @Override
-    public Function ST_GeomFromText(Value geom, Value crs) {
-        return builtin_function("ST_GeomFromText", config.getString(Config.ST_GeomFromText), geom, crs);
-    }
-
-    @Override
-    public Function ST_GeomFromWKB(Value geom, Value crs) {
-        return builtin_function("ST_GeomFromWKB", config.getString(Config.ST_GeomFromWKB), geom, crs);
-    }
-
-    @Override
-    public Function ST_GeomFromEWKB(Value geom, Value crs) {
-        return builtin_function("ST_GeomFromEWKB", config.getString(Config.ST_GeomFromEWKB), geom, crs);
-    }
-
-    @Override
-    public Function ST_Simplify(Value geom, Value tolerance) {
-        return builtin_function("ST_Simplify", config.getString(Config.ST_Simplify), tolerance);
-    }
-
-    @Override
-    public Function ST_Disjoint(Value geom1, Value geom2) {
-        return builtin_function("ST_Disjoint", config.getString(Config.ST_Disjoint), geom1, geom2);
-    }
-
-    @Override
-    public Function ST_Contains(Value geom1, Value geom2) {
-        return builtin_function("ST_Contains", config.getString(Config.ST_Contains), geom1, geom2);
-    }
-
-    @Override
-    public Function ST_Equals(Value geom1, Value geom2) {
-        return builtin_function("ST_Equals", config.getString(Config.ST_Equals), geom1, geom2);
-    }
-
-    @Override
-    public Function ST_Crosses(Value geom1, Value geom2) {
-        return builtin_function("ST_Crosses", config.getString(Config.ST_Crosses), geom1, geom2);
-    }
-
-    @Override
-    public Function ST_IsClosed(Value geom) {
-        return builtin_function("ST_IsClosed", config.getString(Config.ST_IsClosed), geom);
-    }
-
-    @Override
-    public Function ST_Overlaps(Value geom1, Value geom2) {
-        return builtin_function("ST_Overlaps", config.getString(Config.ST_Overlaps), geom1, geom2);
-    }
-
-    @Override
-    public Function ST_Touches(Value geom1, Value geom2) {
-        return builtin_function("ST_Touches", config.getString(Config.ST_Touches), geom1, geom2);
-    }
-
-    @Override
-    public Function ST_Within(Value geom1, Value geom2) {
-        return builtin_function("ST_Within", config.getString(Config.ST_Within), geom1, geom2);
-    }
-
-    @Override
-    public Function isNull(Value value) {
-        return builtin_function("IS NULL", config.getString(Config.isNull), value);
-    }
-
-    @Override
-    public Function notIsNull(Value value) {
-        return builtin_function("NOT IS NULL", config.getString(Config.notIsNull), value);
-    }
-
-    @Override
-    public Function not(Value value) {
-        return builtin_function("NOT", config.getString(Config.operator_not), value);
-    }
-
-    @Override
-    public Function lcase(Value s) {
-        return builtin_function("LCASE", config.getString(Config.lcase), s);
-    }
-
-    @Override
-    public Function ucase(Value s) {
-        return builtin_function("UCASE", config.getString(Config.ucase), s);
-    }
-
-    @Override
-    public BinaryOperator and(Value leftOperand, Value rightOperand) {
-        return binaryOperator("AND", config.getString(Config.operator_AND), leftOperand, rightOperand);
-    }
-
-    @Override
-    public BinaryOperator or(Value leftOperand, Value rightOperand) {
-        return binaryOperator("OR", config.getString(Config.operator_OR), leftOperand, rightOperand);
-    }
-
-    @Override
-    public BinaryOperator eq(Value leftOperand, Value rightOperand) {
-        return binaryOperator("=", config.getString(Config.operator_EQ), leftOperand, rightOperand);
-    }
-
-    @Override
-    public BinaryOperator ne(Value leftOperand, Value rightOperand) {
-        return binaryOperator("<>", config.getString(Config.operator_NE), leftOperand, rightOperand);
-    }
-
-    @Override
-    public BinaryOperator gt(Value op1, Value op2) {
-        return binaryOperator(">", config.getString(Config.operator_GT), op1, op2);
-    }
-
-    @Override
-    public BinaryOperator ge(Value op1, Value op2) {
-        return binaryOperator(">=", config.getString(Config.operator_GE), op1, op2);
-    }
-
-    @Override
-    public BinaryOperator lt(Value op1, Value op2) {
-        return binaryOperator("<", config.getString(Config.operator_LT), op1, op2);
-    }
-
-    @Override
-    public BinaryOperator le(Value op1, Value op2) {
-        return binaryOperator("<=", config.getString(Config.operator_LE), op1, op2);
-    }
-
-    @Override
-    public BinaryOperator like(Value op1, Value op2) {
-        return binaryOperator("LIKE", config.getString(Config.operator_LIKE), op1, op2);
-    }
-
-    @Override
-    public BinaryOperator ilike(Value op1, Value op2) {
-        return binaryOperator("ILIKE", config.getString(Config.operator_ILIKE), op1, op2);
-    }
-
-    @Override
-    public BinaryOperator add(Value op1, Value op2) {
-        return binaryOperator("ADD", config.getString(Config.operator_add), op1, op2);
-    }
-
-    @Override
-    public BinaryOperator subst(Value op1, Value op2) {
-        return binaryOperator("SUBST", config.getString(Config.operator_subst), op1, op2);
-    }
-
-    @Override
-    public BinaryOperator mult(Value op1, Value op2) {
-        return binaryOperator("MULT", config.getString(Config.operator_mult), op1, op2);
-    }
-
-    @Override
-    public BinaryOperator div(Value op1, Value op2) {
-        return binaryOperator("DIV", config.getString(Config.operator_div), op1, op2);
-    }
-
-    @Override
-    public BinaryOperator concat(Value op1, Value op2) {
-        return binaryOperator("CONCAT", config.getString(Config.operator_concat), op1, op2);
-    }
- 
-    @Override
     public String default_schema() {
-        return config.getString(SQLConfig.default_schema);
+        return this.defaultSchema;
     }
 
     @Override
-    public boolean supportSchemas() {
-        return config.getBoolean(Config.support_schemas);
+    public boolean support_schemas() {
+        return this.supportSchemas;
     }
-    
-    @Override
-    @Deprecated
-    public String sqltype(int type, int p, int s) {
-        return this.sqltype(type, p, s, Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.UNKNOWN);
-    }
 
     @Override
     public String sqltype(int type, int p, int s, int geomType, int geomSubtype) {
         switch (type) {
             case DataTypes.BOOLEAN:
-                return config.getString(SQLConfig.type_boolean);
+                return type_boolean;
             case DataTypes.BYTE:
-                return config.getString(SQLConfig.type_byte);
+                return type_byte;
             case DataTypes.BYTEARRAY:
-                return config.getString(SQLConfig.type_bytearray);
+                return type_bytearray;
             case DataTypes.GEOMETRY:
-                return config.getString(SQLConfig.type_geometry);
+                return type_geometry;
             case DataTypes.CHAR:
-                return config.getString(SQLConfig.type_char);
+                return type_char;
             case DataTypes.DATE:
-                return config.getString(SQLConfig.type_date);
+                return type_date;
             case DataTypes.DOUBLE:
-                  // FIXME: Si cargamos la capa "country" al exportarla a
-                  // SQLServer falla por:
-                  //  Error de desbordamiento aritm�tico al convertir float al tipo de datos numeric.
-                  // Al parecer la capa declara la columna sqkm_ctry como Numeric(12,6) y para 
-                  // Algeria intenta asignarle un valor de 2320972.0 y falla.
-                  // Habria que repasar el proveedor de shape.
-                
+                // FIXME: Si cargamos la capa "country" al exportarla a
+                // SQLServer falla por:
+                //  Error de desbordamiento aritm�tico al convertir float al tipo de datos numeric.
+                // Al parecer la capa declara la columna sqkm_ctry como Numeric(12,6) y para 
+                // Algeria intenta asignarle un valor de 2320972.0 y falla.
+                // Habria que repasar el proveedor de shape.
+
 //                if (p > 1) {
 //                    if (s < 0) {
 //                        return MessageFormat.format(config.getString(SQLConfig.type_numeric_p), p);
 //                    }
 //                    return MessageFormat.format(config.getString(SQLConfig.type_numeric_ps), p,s);
 //                }
-                return MessageFormat.format(config.getString(SQLConfig.type_double),p,s);
+                return MessageFormat.format(type_double, p, s);
             case DataTypes.BIGDECIMAL:
                 if (p < 1) {
                     p = 20;
@@ -3183,94 +2446,92 @@
                 if (s < 0) {
                     s = 10;
                 }
-                return MessageFormat.format(config.getString(SQLConfig.type_bigdecimal), p,s);
+                return MessageFormat.format(type_bigdecimal, p, s);
             case DataTypes.FLOAT:
-                return MessageFormat.format(config.getString(SQLConfig.type_float), p,s);
+                return MessageFormat.format(type_float, p, s);
             case DataTypes.INT:
-                return MessageFormat.format(config.getString(SQLConfig.type_int), p,s);
+                return MessageFormat.format(type_int, p, s);
             case DataTypes.LONG:
-                return MessageFormat.format(config.getString(SQLConfig.type_long), p,s);
+                return MessageFormat.format(type_long, p, s);
             case DataTypes.STRING:
                 if (p < 0) {
-                    return config.getString(SQLConfig.type_string);
+                    return type_string;
                 } else if (p < 4096) {
-                    return MessageFormat.format(config.getString(SQLConfig.type_string_p),p);
+                    return MessageFormat.format(type_string_p, p);
                 }
-                return config.getString(SQLConfig.type_string);
+                return type_string;
             case DataTypes.TIME:
-                return config.getString(SQLConfig.type_time);
+                return type_time;
             case DataTypes.TIMESTAMP:
-                return config.getString(SQLConfig.type_timestamp);
+                return type_timestamp;
             case DataTypes.VERSION:
-                return config.getString(SQLConfig.type_version);
+                return type_version;
             case DataTypes.URI:
-                return config.getString(SQLConfig.type_URI);
+                return type_URI;
             case DataTypes.URL:
-                return config.getString(SQLConfig.type_URL);
+                return type_URL;
             case DataTypes.FILE:
-                return config.getString(SQLConfig.type_FILE);
+                return type_FILE;
             case DataTypes.FOLDER:
-                return config.getString(SQLConfig.type_FOLDER);
+                return type_FOLDER;
             default:
                 return null;
         }
     }
 
-    private static Map<Pair<Integer,Integer>,String> sqlgeometrytypes = null;
-    
     @Override
     public Object sqlgeometrytype(int type, int subtype) {
         // Devuelve un Object por que algunos gestores de BBDD utilizan
         // identificadores numericos para el tipo y otros strings.
         // Por defecto vamos a devolver strings.
-        if( sqlgeometrytypes==null ) {
+        if (sqlgeometrytypes == null) {
             sqlgeometrytypes = new HashMap<>();
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM2D), "POINT");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM3D), "POINTZ");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM2DM), "POINTM");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POINT,Geometry.SUBTYPES.GEOM3DM), "POINTZM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.POINT, Geometry.SUBTYPES.GEOM2D), "POINT");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.POINT, Geometry.SUBTYPES.GEOM3D), "POINTZ");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.POINT, Geometry.SUBTYPES.GEOM2DM), "POINTM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.POINT, Geometry.SUBTYPES.GEOM3DM), "POINTZM");
 
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM2D), "LINESTRING");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM3D), "LINESTRINGZ");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM2DM), "LINESTRINGM");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.LINE,Geometry.SUBTYPES.GEOM3DM), "LINESTRINGZM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.LINE, Geometry.SUBTYPES.GEOM2D), "LINESTRING");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.LINE, Geometry.SUBTYPES.GEOM3D), "LINESTRINGZ");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.LINE, Geometry.SUBTYPES.GEOM2DM), "LINESTRINGM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.LINE, Geometry.SUBTYPES.GEOM3DM), "LINESTRINGZM");
 
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM2D), "POLYGON");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM3D), "POLYGONZ");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM2DM), "POLYGONM");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.POLYGON,Geometry.SUBTYPES.GEOM3DM), "POLYGONZM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.POLYGON, Geometry.SUBTYPES.GEOM2D), "POLYGON");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.POLYGON, Geometry.SUBTYPES.GEOM3D), "POLYGONZ");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.POLYGON, Geometry.SUBTYPES.GEOM2DM), "POLYGONM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.POLYGON, Geometry.SUBTYPES.GEOM3DM), "POLYGONZM");
 
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM2D), "MULTIPOINT");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM3D), "MULTIPOINTZ");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM2DM), "MULTIPOINTM");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOINT,Geometry.SUBTYPES.GEOM3DM), "MULTIPOINTZM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTIPOINT, Geometry.SUBTYPES.GEOM2D), "MULTIPOINT");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTIPOINT, Geometry.SUBTYPES.GEOM3D), "MULTIPOINTZ");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTIPOINT, Geometry.SUBTYPES.GEOM2DM), "MULTIPOINTM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTIPOINT, Geometry.SUBTYPES.GEOM3DM), "MULTIPOINTZM");
 
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM2D), "MULTILINESTRING");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM3D), "MULTILINESTRINGZ");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM2DM), "MULTILINESTRINGM");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTILINE,Geometry.SUBTYPES.GEOM3DM), "MULTILINESTRINGZM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTILINE, Geometry.SUBTYPES.GEOM2D), "MULTILINESTRING");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTILINE, Geometry.SUBTYPES.GEOM3D), "MULTILINESTRINGZ");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTILINE, Geometry.SUBTYPES.GEOM2DM), "MULTILINESTRINGM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTILINE, Geometry.SUBTYPES.GEOM3DM), "MULTILINESTRINGZM");
 
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTICURVE,Geometry.SUBTYPES.GEOM2D), "MULTILINESTRING");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTICURVE,Geometry.SUBTYPES.GEOM3D), "MULTILINESTRINGZ");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTICURVE,Geometry.SUBTYPES.GEOM2DM), "MULTILINESTRINGM");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTICURVE,Geometry.SUBTYPES.GEOM3DM), "MULTILINESTRINGZM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTICURVE, Geometry.SUBTYPES.GEOM2D), "MULTILINESTRING");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTICURVE, Geometry.SUBTYPES.GEOM3D), "MULTILINESTRINGZ");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTICURVE, Geometry.SUBTYPES.GEOM2DM), "MULTILINESTRINGM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTICURVE, Geometry.SUBTYPES.GEOM3DM), "MULTILINESTRINGZM");
 
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM2D), "MULTIPOLYGON");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM3D), "MULTIPOLYGONZ");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM2DM), "MULTIPOLYGONM");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON,Geometry.SUBTYPES.GEOM3DM), "MULTIPOLYGONZM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON, Geometry.SUBTYPES.GEOM2D), "MULTIPOLYGON");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON, Geometry.SUBTYPES.GEOM3D), "MULTIPOLYGONZ");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON, Geometry.SUBTYPES.GEOM2DM), "MULTIPOLYGONM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTIPOLYGON, Geometry.SUBTYPES.GEOM3DM), "MULTIPOLYGONZM");
 
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTISURFACE,Geometry.SUBTYPES.GEOM2D), "MULTIPOLYGON");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTISURFACE,Geometry.SUBTYPES.GEOM3D), "MULTIPOLYGONZ");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTISURFACE,Geometry.SUBTYPES.GEOM2DM), "MULTIPOLYGONM");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.MULTISURFACE,Geometry.SUBTYPES.GEOM3DM), "MULTIPOLYGONZM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTISURFACE, Geometry.SUBTYPES.GEOM2D), "MULTIPOLYGON");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTISURFACE, Geometry.SUBTYPES.GEOM3D), "MULTIPOLYGONZ");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTISURFACE, Geometry.SUBTYPES.GEOM2DM), "MULTIPOLYGONM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.MULTISURFACE, Geometry.SUBTYPES.GEOM3DM), "MULTIPOLYGONZM");
 
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2D), "GEOMETRY");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM3D), "GEOMETRYZ");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM2DM), "GEOMETRYM");
-            sqlgeometrytypes.put( new ImmutablePair<>(Geometry.TYPES.GEOMETRY,Geometry.SUBTYPES.GEOM3DM), "GEOMETRYZM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2D), "GEOMETRY");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM3D), "GEOMETRYZ");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM2DM), "GEOMETRYM");
+            sqlgeometrytypes.put(new ImmutablePair<>(Geometry.TYPES.GEOMETRY, Geometry.SUBTYPES.GEOM3DM), "GEOMETRYZM");
         }
-        return sqlgeometrytypes.get(new ImmutablePair<>(type,subtype));
+        return sqlgeometrytypes.get(new ImmutablePair<>(type, subtype));
     }
 
     @Override
@@ -3278,7 +2539,7 @@
         // Devuelve un Object por que algunos gestortes de BBDD utilizan
         // identificadores numericos para las dimensiones y otros strings.
         // Por defecto vamos a devolver enteros.
-        switch(subtype) {
+        switch (subtype) {
             case Geometry.SUBTYPES.GEOM3D:
                 return 3;
             case Geometry.SUBTYPES.GEOM2DM:
@@ -3290,23 +2551,23 @@
                 return 2;
         }
     }
-    
+
     protected TableNameBuilder createTableNameBuilder() {
         return new TableNameBuilderBase();
     }
-    
+
     protected SelectColumnBuilder createSelectColumnBuilder() {
         return new SelectColumnBuilderBase();
     }
-    
+
     protected UpdateColumnBuilder createUpdateColumnBuilder() {
         return new UpdateColumnBuilderBase();
     }
-    
+
     protected InsertColumnBuilder createInsertColumnBuilder() {
         return new InsertColumnBuilderBase();
     }
-    
+
     protected OrderByBuilder createOrderByBuilder() {
         return new OrderByBuilderBase();
     }
@@ -3334,7 +2595,7 @@
     protected GrantRoleBuilder createGrantRoleBuilder(TableNameBuilder table, String role) {
         return new GrantRoleBuilderBase(table, role);
     }
-    
+
     protected DropTableBuilder createDropTableBuilder() {
         return new DropTableBuilderBase();
     }
@@ -3358,7 +2619,7 @@
     protected CreateIndexBuilder createCreateIndexBuilder() {
         return new CreateIndexBuilderBase();
     }
-    
+
     @Override
     public SelectBuilder select() {
         if (this.select == null) {
@@ -3399,7 +2660,6 @@
         return this.create_index;
     }
 
-    
     @Override
     public DeleteBuilder delete() {
         if (this.delete == null) {
@@ -3440,7 +2700,6 @@
         return this.grant;
     }
 
-    @Override
     public void accept(Visitor visitor, VisitorFilter filter) {
         if (this.select != null) {
             this.select.accept(visitor, filter);
@@ -3463,334 +2722,110 @@
         if (this.drop_table != null) {
             this.drop_table.accept(visitor, filter);
         }
-//        if( this.value == null) {
-//            return;
-//        }
-//        this.value.accept(visitor, filter);
     }
 
-    
+    protected Formatter formatter() {
+        return ExpressionBuilder.EMPTY_FORMATTER;
+    }
+
     @Override
     public String toString() {
+        return this.toString(formatter());
+    }
+
+    @Override
+    public String toString(Formatter formatter) {
         if (this.select != null) {
-            return this.select.toString();
+            return this.select.toString(formatter);
         }
         if (this.update != null) {
-            return this.update.toString();
+            return this.update.toString(formatter);
         }
         if (this.insert != null) {
-            return this.insert.toString();
+            return this.insert.toString(formatter);
         }
         if (this.delete != null) {
-            return this.delete.toString();
+            return this.delete.toString(formatter);
         }
         if (this.alter_table != null) {
-            return this.alter_table.toString();
+            return this.alter_table.toString(formatter);
         }
         if (this.create_table != null) {
-            return this.create_table.toString();
+            return this.create_table.toString(formatter);
         }
         if (this.drop_table != null) {
-            return this.drop_table.toString();
+            return this.drop_table.toString(formatter);
         }
         if (this.update_table_statistics != null) {
-            return this.update_table_statistics.toString();
+            return this.update_table_statistics.toString(formatter);
         }
-        if ( this.value != null ) {
-            return this.value.toString();
-        }
-        return ""; 
+        return "";
     }
 
     @Override
-    public Function ST_UnionAggregate(Value geom) {
-        return builtin_function("ST_UnionAggregate", config.getString(SQLConfig.ST_UnionAggregate), geom);
+    public CountBuilder count() {
+        return new CountBuilderBase();
     }
 
     @Override
-    public Function ST_ExtentAggregate(Value geom) {
-        return builtin_function("ST_ExtentAggregate", config.getString(SQLConfig.ST_ExtentAggregate), geom);
+    public List<Parameter> parameters() {
+        final List<Parameter> params = new ArrayList<>();
+        this.accept(new Visitor() {
+            @Override
+            public void visit(Visitable value) {
+                params.add((Parameter) value);
+            }
+        }, new ClassVisitorFilter(Parameter.class));
+        return params;
     }
 
     @Override
-    public CountBuilder count() {
-        return new CountBuilderBase();
+    public List<Variable> variables() {
+        final List<Variable> vars = new ArrayList<>();
+        this.accept(new Visitor() {
+            @Override
+            public void visit(Visitable value) {
+                if (!vars.contains((Variable) value)) {
+                    vars.add((Variable) value);
+                }
+            }
+        }, new ClassVisitorFilter(Variable.class));
+        return vars;
     }
 
     @Override
-    public Column column(FeatureAttributeDescriptor fad) {
-        ColumnDescriptorBase descriptor;
-        if( fad.getType()==org.gvsig.fmap.geom.DataTypes.GEOMETRY ) {
-            descriptor = new ColumnDescriptorBase(
-                    fad.getName(),
-                    fad.getGeomType().getType(),
-                    fad.getGeomType().getSubType(),
-                    fad.getSRS(),
-                    fad.isIndexed(),
-                    fad.allowNull()
-            );
-        } else {
-            descriptor = new ColumnDescriptorBase(
-                    fad.getName(),
-                    fad.getType(),
-                    fad.getSize(),
-                    fad.getPrecision(),
-                    fad.isPrimaryKey(),
-                    fad.isIndexed(),
-                    fad.allowNull(),
-                    fad.isAutomatic(),
-                    fad.getDefaultValue()
-            );
+    public List<String> parameters_names() {
+        List<String> params = new ArrayList<>();
+        for (Parameter param : parameters()) {
+            String s;
+            switch (param.type()) {
+                case Constant:
+                    Object theValue = param.value();
+                    if (theValue == null) {
+                        s = "null";
+                    } else if (theValue instanceof String) {
+                        s = "'" + (String) theValue + "'";
+                    } else {
+                        s = theValue.toString();
+                    }
+                    break;
+                case Geometry:
+                case Variable:
+                default:
+                    s = "\"" + param.name() + "\"";
+            }
+            params.add(s);
         }
-        FeatureStore store = fad.getStore();
-        if( store!=null ) {
-            descriptor.setStoreParameters(store.getParameters());
-        }
-        return new VariableBase(descriptor);
+        return params;
     }
-    
-    @Override
-    public Function Find_SRID(Value schema, Value table, Value column) {
-        return builtin_function("Find_SRID", config.getString(SQLConfig.Find_SRID), schema, table, column);
-    }
 
-
-    public Function iif(Value condition, Value iftrue, Value iffalse) {
-        return builtin_function("IIF", config.getString(Config.iif), condition, iftrue, iffalse);
-    }
-
-    public Function ifnull(Value value, Value iftrue, Value iffalse) {
-        return builtin_function("IFNULL", config.getString(Config.ifnull), value, iftrue, iffalse);
-    }
-    
-    
     @Override
-    public Function left(Value str, Value size) {
-       return function("left", str, size);
-       // return builtin_function("left", "left({1})",str,size);
+    public List<String> variables_names() {
+        List<String> vars = new ArrayList<>();
+        for (Variable var : this.variables()) {
+            vars.add(var.name());
+        }
+        Collections.sort(vars);
+        return vars;
     }
-    
-    @Override
-    public Function right(Value str, Value len) {
-       return function("right", str, len);
-    }
-    
-    @Override
-    public Function locate(Value search, Value str, Value start) {
-       return function("locate", search, str, start);
-    }
-    
-    @Override
-    public Function position(Value search, Value str) {
-       return function("position", search, str);
-    }
-    
-    @Override
-    public Function lpad(Value str, Value len, Value padstr) {
-       return function("lpad", str, len, padstr);
-    }
-    
-    @Override
-    public Function rpad(Value str, Value len, Value padstr) {
-       return function("rpad", str, len, padstr);
-    }
-    
-    @Override
-    public Function ltrim(Value str) {
-       return function("ltrim", str);
-    }
-    
-    @Override
-    public Function rtrim(Value str) {
-       return function("rtrim", str);
-    }
-    
-    @Override
-    public Function trim(Value str) {
-       return function("trim", str);
-    }
-    
-    @Override
-    public Function repeat(Value str, Value size) {
-       return function("repeat", str, size);
-    }
-    
-    @Override
-    public Function replace(Value str, Value search, Value replstr) {
-       return function("replace", str, search, replstr);
-    }
-    
-    @Override
-    public Function ascii(Value str) {
-       return function("ascii", str);
-    }
-    
-    @Override
-    public Function lenght(Value str) {
-       return function("lenght", str);
-    }
-
-    @Override
-    public Function instr(Value str, Value search, Value start) {
-       return function("instr", str, search, start);
-    }
-    
-    @Override
-    public Function lower(Value str) {
-       return function("lower", str);
-    }
-    
-    @Override
-    public Function upper(Value str) {
-       return function("upper", str);
-    }
-    
-    @Override
-    public Function space(Value size) {
-       return function("space", size);
-    }
-    
-    @Override
-    public Function substring(Value str, Value start, Value len) {
-       return function("substring", str, start, len);
-    }
-    
-    @Override
-    public Function acos(Value num) {
-       return function("acos", num);
-    } 
-    
-    @Override
-    public Function asin(Value num) {
-       return function("asin", num);
-    }
-    
-    @Override
-    public Function atan(Value num) {
-       return function("atan", num);
-    }
-    
-    @Override
-    public Function cos(Value num) {
-       return function("cos", num);
-    }
-    
-    @Override
-    public Function cosh(Value num) {
-       return function("cosh", num);
-    }
-    
-    @Override
-    public Function cot(Value num) {
-       return function("cot", num);
-    }  
-    
-    @Override
-    public Function bitand(Value num1, Value num2) {
-       return function("bitand", num1, num2);
-    } 
-    
-    @Override
-    public Function bitor(Value num1, Value num2) {
-       return function("bitor", num1, num2);
-    }
-    
-    @Override
-    public Function bitxor(Value num1, Value num2) {
-       return function("bitxor", num1, num2);
-    }
-    
-    @Override
-    public Function ceil(Value num) {
-       return function("ceil", num);
-    }
-    
-    @Override
-    public Function degrees(Value num) {
-       return function("degrees", num);
-    }  
-    
-    @Override
-    public Function exp(Value num) {
-       return function("exp", num);
-    }  
-    
-    @Override
-    public Function floor(Value num) {
-       return function("floor", num);
-    }  
-    
-    @Override
-    public Function log(Value num) {
-       return function("log", num);
-    }  
-    
-    @Override
-    public Function log10(Value num) {
-       return function("log10", num);
-    }  
-    
-    @Override
-    public Function pi(Value num) {
-       return function("pi", num);
-    }
-    
-    @Override
-    public Function power(Value num) {
-       return function("power", num);
-    }
-    
-    @Override
-    public Function radians(Value num) {
-       return function("radians", num);
-    }
-    
-    @Override
-    public Function rand(Value num) {
-       return function("rand", num);
-    }
-    
-    @Override
-    public Function round(Value num) {
-       return function("round", num);
-    }
-    
-    @Override
-    public Function sqrt(Value num) {
-       return function("sqrt", num);
-    }
-    
-    @Override
-    public Function sign(Value num) {
-       return function("sign", num);
-    }
-    
-    @Override
-    public Function sin(Value num) {
-       return function("sin", num);
-    }
-    
-    @Override
-    public Function sinh(Value num) {
-       return function("sinh", num);
-    }
-    
-    @Override
-    public Function tan(Value num) {
-       return function("tan", num);
-    }
-    @Override
-    public Function tanh(Value num) {
-       return function("cosh", num);
-    }  
-    
-    @Override
-    public Function zero() {
-       return function("zero");
-    }
-    
-    @Override
-    public Function chr(Value num) {
-       return function("chr", num);
-    }
 }
Index: 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/AbstractFeatureStoreProvider.java
===================================================================
--- 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/AbstractFeatureStoreProvider.java	(revision 44197)
+++ 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/AbstractFeatureStoreProvider.java	(revision 44198)
@@ -33,6 +33,7 @@
 import org.cresques.cts.ICRSFactory;
 import org.cresques.cts.IProjection;
 import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -562,7 +563,8 @@
 
     @Override
     public ExpressionBuilder createExpression() {
-        return new SQLBuilderBase();
+        ExpressionBuilder builder = ExpressionEvaluatorLocator.getManager().createExpressionBuilder();
+        return builder;
     }
 
     protected void savePrjFile(File dataFile, IProjection proj){
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/test/java/org/gvsig/fmap/dal/store/SQLBuilderTest.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/test/java/org/gvsig/fmap/dal/store/SQLBuilderTest.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/test/java/org/gvsig/fmap/dal/store/SQLBuilderTest.java	(revision 44198)
@@ -1,11 +1,8 @@
 package org.gvsig.fmap.dal.store;
 
-import java.util.ArrayList;
-import java.util.List;
 import org.apache.commons.lang3.ArrayUtils;
 import org.cresques.cts.IProjection;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
 import org.gvsig.fmap.crs.CRSFactory;
 import org.gvsig.fmap.dal.SQLBuilder;
 import org.gvsig.fmap.dal.SQLBuilder.Privilege;
@@ -23,41 +20,11 @@
     protected void doSetUp() throws Exception {
 
     }
-    
-    List<String> getVariableNames(SQLBuilder builder) {
-        List<String> vars = new ArrayList<>();
-        for (Variable var : builder.getVariables()) {
-            vars.add(var.getName());
-        }
-        return vars;
+        
+    private SQLBuilder createSQLBuilder() {
+        return new SQLBuilderBase();
     }
     
-    List<String> getParameterNames(SQLBuilder builder) {
-        List<String> params = new ArrayList<>();
-        for (Parameter param : builder.getParameters()) {
-            String s;
-            switch(param.getType()) {
-                case Constant:
-                    Object value = param.getValue();
-                    if( value==null ) {
-                        s = "null";
-                    } else if( value instanceof String ) {
-                        s = "'" + (String)value + "'";
-                    } else {
-                        s = value.toString();
-                    }    
-                    break;
-                case Geometry:
-                case Variable:
-                default:
-                    s = "\"" + param.getName() + "\"";
-            }
-            params.add(s);
-        }
-        return params;
-    }
-    
- 
     public void testCalulateEnvelope() throws Exception {
         GeometryManager geometryManager = GeometryLocator.getGeometryManager();
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
@@ -69,60 +36,62 @@
         limit.addVertex(100, 0);
         limit.addVertex(0, 0);
         
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
-        builder.select().column().value(
-            builder.getAsGeometry(
-              builder.ST_ExtentAggregate(
-                builder.column("the_geom")
+        sqlbuilder.select().column().value(
+            expbuilder.as_geometry(
+              expbuilder.ST_ExtentAggregate(
+                expbuilder.column("the_geom")
               )
             )
         ).as("envelope");
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().where().set(
-            builder.ST_Intersects(
-                builder.ST_Envelope(
-                    builder.column("the_geom")
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().where().set(
+            expbuilder.ST_Intersects(
+                expbuilder.ST_Envelope(
+                    expbuilder.column("the_geom")
                 ),
-                builder.geometry(limit, proj)
+                expbuilder.geometry(limit, proj)
             )
         );
-        builder.select().where().and(
-                builder.custom("x = 27")
+        sqlbuilder.select().where().and(
+                expbuilder.custom("x = 27")
         );
         
         // SELECT ST_AsBinary(ST_Extent("the_geom")) AS "envelope" FROM "master"."dbo"."test1" WHERE ST_Intersects((ST_Envelope("the_geom")), (ST_GeomFromText('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))', (4326)))) AND x = 27
         
         System.out.println("# Test:: testCalulateEnvelope");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         assertEquals(
                 "SELECT ST_AsBinary(ST_Extent(\"the_geom\")) AS \"envelope\" FROM \"master\".\"dbo\".\"test1\" WHERE ST_Intersects((ST_Envelope(\"the_geom\")), (ST_GeomFromText('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))', (4326)))) AND x = 27",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[the_geom]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
 
     public void testCount() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
-        builder.select().column().value(builder.count().all());
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().from().subquery(null);
-        builder.select().where().set( builder.custom("pp = 200"));
+        sqlbuilder.select().column().value(sqlbuilder.count().all());
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().from().subquery(null);
+        sqlbuilder.select().where().set( expbuilder.custom("pp = 200"));
 
         System.out.println("# Test:: testCount");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
 
         //# Test:: testCount
         //# SQL:: SELECT COUNT(*) FROM "master"."dbo"."test1" WHERE pp = 200
@@ -131,23 +100,24 @@
 
         assertEquals(
                 "SELECT COUNT(*) FROM \"master\".\"dbo\".\"test1\" WHERE pp = 200",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
     
     public void testCreateTable() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.create_table().table().database("master").schema("dbo").name("test1");
-        builder.create_table().add_column(
+        sqlbuilder.create_table().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.create_table().add_column(
                 "name",
                 DataTypes.STRING,
                 45,
@@ -158,7 +128,7 @@
                 false,
                 null
         );
-        builder.create_table().add_column(
+        sqlbuilder.create_table().add_column(
                 "id",
                 DataTypes.INT,
                 0,
@@ -169,7 +139,7 @@
                 true,
                 0
         );
-        builder.create_table().add_column(
+        sqlbuilder.create_table().add_column(
                 "geom",
                 DataTypes.GEOMETRY,
                 0,
@@ -184,95 +154,98 @@
         
         // CREATE TABLE "master"."dbo"."test1" ("name" VARCHAR(45) DEFAULT NULL NULL, "id" SERIAL DEFAULT '0' NOT NULL PRIMARY KEY, "geom" TEXT DEFAULT NULL NULL )
         System.out.println("# Test:: testCreateTable");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         assertEquals(
                 "CREATE TABLE \"master\".\"dbo\".\"test1\" (\"name\" VARCHAR(45) DEFAULT NULL NULL, \"id\" SERIAL DEFAULT '0' NOT NULL PRIMARY KEY, \"geom\" TEXT DEFAULT NULL NULL )",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
 
     public void testDropTable() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
-        builder.drop_table().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.drop_table().table().database("master").schema("dbo").name("test1");
 
         // DROP TABLE "master"."dbo"."test1"; DELETE FROM GEOMETRY_COLUMNS WHERE f_table_schema = 'dbo' AND f_table_name = 'test1'
         
         System.out.println("# Test:: testDropTable");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         assertEquals(
                 "DROP TABLE \"master\".\"dbo\".\"test1\"; DELETE FROM GEOMETRY_COLUMNS WHERE f_table_schema = 'dbo' AND f_table_name = 'test1'",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
     
     public void testFetchFeatureProviderByReference() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
         String value = "yoyo";
-        builder.select().column().name("name");
-        builder.select().column().name("id");
-        builder.select().column().name("geom").as_geometry();
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().where().set(
-            builder.eq(
-                builder.column("name"),
-                builder.parameter(value).as_constant()
+        sqlbuilder.select().column().name("name");
+        sqlbuilder.select().column().name("id");
+        sqlbuilder.select().column().name("geom").as_geometry();
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().where().set(
+            expbuilder.eq(
+                expbuilder.column("name"),
+                expbuilder.parameter(value).as_constant()
             )
         );
-        builder.select().limit(1);
+        sqlbuilder.select().limit(1);
 
         // SELECT "name", "id", ST_AsBinary("geom") FROM "master"."dbo"."test1" WHERE ( ("name") = (?) ) LIMIT 1
 
         System.out.println("# Test:: testFetchFeatureProviderByReference");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         assertEquals(
                 "SELECT \"name\", \"id\", ST_AsBinary(\"geom\") FROM \"master\".\"dbo\".\"test1\" WHERE ( (\"name\") = (?) ) LIMIT 1",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "['yoyo']",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
     
     public void testFetchFeatureType() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.select().column().all();
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().limit(1);
+        sqlbuilder.select().column().all();
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().limit(1);
 
         System.out.println("# Test:: testFetchFeatureType");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         
         //# Test:: testFetchFeatureType
         //# SQL:: SELECT * FROM [master].[dbo].[test1] LIMMIT 1
@@ -281,203 +254,210 @@
         
         assertEquals(
                 "SELECT * FROM \"master\".\"dbo\".\"test1\" LIMIT 1",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
         
     public void testPerformDeletes() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.delete().table().database("master").schema("dbo").name("test1");
-        builder.delete().where().and(
-            builder.eq( 
-                builder.column("id1"),
-                builder.parameter("id1").as_variable()
+        sqlbuilder.delete().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.delete().where().and(
+            expbuilder.eq( 
+                expbuilder.column("id1"),
+                expbuilder.parameter("id1").as_variable()
             )
         );
-        builder.delete().where().and(
-            builder.eq( 
-                builder.column("id2"),
-                builder.parameter("id2").as_variable()
+        sqlbuilder.delete().where().and(
+            expbuilder.eq( 
+                expbuilder.column("id2"),
+                expbuilder.parameter("id2").as_variable()
             )
         );
 
         // DELETE FROM "master"."dbo"."test1" WHERE ( ("id1") = (?) ) AND ( ("id2") = (?) )
 
         System.out.println("# Test:: testPerformDeletes");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         assertEquals(
                 "DELETE FROM \"master\".\"dbo\".\"test1\" WHERE ( (\"id1\") = (?) ) AND ( (\"id2\") = (?) )",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[id1, id2]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[\"id1\", \"id2\"]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
 
     public void testPerformInserts1() throws Exception {
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.insert().table().database("master").schema("dbo").name("test1");
-        builder.insert().column().name("id").with_value(builder.parameter("id"));
-        builder.insert().column().name("name").with_value(builder.parameter("name"));
-        builder.insert().column().name("geom").with_value(builder.parameter("geom").as_geometry_variable().srs(proj));
+        sqlbuilder.insert().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.insert().column().name("id").with_value(expbuilder.parameter("id"));
+        sqlbuilder.insert().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.insert().column().name("geom").with_value(expbuilder.parameter("geom").as_geometry_variable().srs(proj));
         
         // INSERT INTO "master"."dbo"."test1" ( "id", "name", "geom" ) VALUES ( ?, ?, ST_GeomFromText(?, (4326)) )
         
         System.out.println("# Test:: testPerformInserts1");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         assertEquals(
                 "INSERT INTO \"master\".\"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromText(?, (4326)) )",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[\"id\", \"name\", \"geom\"]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
 
     public void testPerformInserts2() throws Exception {
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.insert().table().database("master").schema("dbo").name("test1");
-        builder.insert().column().name("id").with_value(builder.parameter("id"));
-        builder.insert().column().name("name").with_value(builder.parameter("name"));
-        builder.insert().column().name("geom").with_value(builder.parameter("geom").as_geometry_variable().srs(builder.parameter().value(proj)));
+        sqlbuilder.insert().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.insert().column().name("id").with_value(expbuilder.parameter("id"));
+        sqlbuilder.insert().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.insert().column().name("geom").with_value(expbuilder.parameter("geom").as_geometry_variable().srs(expbuilder.parameter().value(proj)));
         
         System.out.println("# Test:: testPerformInserts2");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         assertEquals(
                 "INSERT INTO \"master\".\"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromText(?, (?)) )",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[\"id\", \"name\", \"geom\", 4326]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
 
     public void testPerformUpdates() throws Exception {
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.update().table().database("master").schema("dbo").name("test1");
-        builder.update().where().and(
-            builder.eq(
-                builder.column("id"), 
-                builder.parameter("id").as_variable()
+        sqlbuilder.update().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.update().where().and(
+            expbuilder.eq(
+                expbuilder.column("id"), 
+                expbuilder.parameter("id").as_variable()
             )
         );
-        builder.update().column().name("name").with_value(builder.parameter("name"));
-        builder.update().column().name("geom").with_value(
-                builder.parameter("geom").as_geometry_variable().srs(builder.parameter().value(proj)) 
+        sqlbuilder.update().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.update().column().name("geom").with_value(
+                expbuilder.parameter("geom").as_geometry_variable()
+                        .srs(expbuilder.parameter().value(proj)) 
         );
 
         // UPDATE "master"."dbo"."test1" SET "name" = ?, "geom" = ST_GeomFromText(?, (?)) WHERE ( ("id") = (?) )
 
         System.out.println("# Test:: testPerformUpdates");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         assertEquals(
                 "UPDATE \"master\".\"dbo\".\"test1\" SET \"name\" = ?, \"geom\" = ST_GeomFromText(?, (?)) WHERE ( (\"id\") = (?) )",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[\"name\", \"geom\", 4326, \"id\"]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
 
     public void testGrant1() throws Exception {
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.grant().table().database("master").schema("dbo").name("test1");
-        builder.grant().role("prueba").select().insert().update();
-        builder.grant().role("gis").all();
+        sqlbuilder.grant().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.grant().role("prueba").select().insert().update();
+        sqlbuilder.grant().role("gis").all();
                 
         
         System.out.println("# Test:: testGrant1");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         assertEquals(
                 "",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
 
     public void testGrant2() throws Exception {
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.grant().table().database("master").schema("dbo").name("test1");
-        builder.grant().role("prueba").privilege(Privilege.SELECT)
+        sqlbuilder.grant().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.grant().role("prueba").privilege(Privilege.SELECT)
                 .privilege(Privilege.INSERT)
                 .privilege(Privilege.UPDATE);
-        builder.grant().role("gis").privilege(Privilege.ALL);
+        sqlbuilder.grant().role("gis").privilege(Privilege.ALL);
                 
         
         System.out.println("# Test:: testGrant2");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(expbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(expbuilder.parameters_names()));
         assertEquals(
                 "",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(expbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(expbuilder.parameters_names())
         );
     }
 
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureStore.java	(revision 44198)
@@ -2913,12 +2913,12 @@
     @Override
     public ExpressionBuilder createExpressionBuilder() {
         ExpressionBuilder builder = null;
-        if( this.provider instanceof FeatureStoreProvider_v2 ) {
-            builder = ((FeatureStoreProvider_v2)this.provider).createExpression();
-        }
-        if( builder==null ) {
+//        if( this.provider instanceof FeatureStoreProvider_v2 ) {
+//            builder = ((FeatureStoreProvider_v2)this.provider).createExpression();
+//        }
+//        if( builder==null ) {
             builder = ExpressionEvaluatorLocator.getManager().createExpressionBuilder();
-        }
+//        }
         return builder;
     }
 
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/.directory
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/.directory	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/.directory	(revision 44198)
@@ -0,0 +1,7 @@
+[Dolphin]
+Timestamp=2019,3,14,15,18,44
+Version=4
+ViewMode=1
+
+[Settings]
+HiddenFilesShown=true
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/impl/JDBCSetProvider.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/impl/JDBCSetProvider.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/impl/JDBCSetProvider.java	(revision 44198)
@@ -133,12 +133,12 @@
     
     @Override
     public boolean canFilter() {
-        return this.getHelper().supportFilter(getQuery().getFilter());
+        return this.getHelper().supportFilter(this.getFeatureType(), getQuery().getFilter());
     }
 
     @Override
     public boolean canOrder() {
-        return this.getHelper().supportOrder(getQuery().getOrder());
+        return this.getHelper().supportOrder(this.getFeatureType(), getQuery().getOrder());
     }
     
     public ResulSetControler getResulSetControler() {
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/JDBCHelper.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/JDBCHelper.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/JDBCHelper.java	(revision 44198)
@@ -8,6 +8,7 @@
 import org.gvsig.fmap.dal.exception.InitializeException;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureQueryOrder;
+import org.gvsig.fmap.dal.feature.FeatureStore;
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
 import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
@@ -93,9 +94,9 @@
      */
     public boolean hasSpatialFunctions();
 
-    public boolean supportFilter(Evaluator evaluator);
+    public boolean supportFilter(FeatureType type, Evaluator evaluator);
     
-    public boolean supportOrder(FeatureQueryOrder order);
+    public boolean supportOrder(FeatureType type, FeatureQueryOrder order);
     
     public boolean allowNestedOperations();
     /**
@@ -179,4 +180,5 @@
 
     public String getSourceId(JDBCStoreParameters parameters);
 
+    public boolean isThreadSafe();
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AbstractConnectionOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AbstractConnectionOperation.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AbstractConnectionOperation.java	(revision 44198)
@@ -39,7 +39,12 @@
     @Override
     public Object perform()  {
         try {
-            return this.perform_operation();
+            if( this.helper.isThreadSafe() ) {
+                return this.perform_operation();
+            } 
+            synchronized(AbstractConnectionOperation.class) {
+                return this.perform_operation();
+            }
         } catch (RuntimeException ex) {
             throw ex;
         } catch (Exception ex) {
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/ResultSetForSetProviderOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/ResultSetForSetProviderOperation.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/ResultSetForSetProviderOperation.java	(revision 44198)
@@ -5,7 +5,8 @@
 import java.util.List;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Config;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureQuery;
@@ -16,6 +17,8 @@
 import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.dal.store.jdbc2.ResulSetControler.ResultSetEntry;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_FEATURE_TYPE;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_TABLE;
 import org.gvsig.fmap.geom.DataTypes;
 import org.gvsig.tools.evaluator.Evaluator;
 
@@ -82,6 +85,7 @@
         
         double tolerance = -1 ; //query.getScale();
         JDBCSQLBuilderBase sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
         List<String> primaryKeys = new ArrayList<>();
         for(FeatureAttributeDescriptor attr : storeType.getPrimaryKey() ) {
@@ -101,16 +105,17 @@
                 forcedColumns.remove(attr.getName());
             }
             if( attr.getType() == DataTypes.GEOMETRY ) {
-                if( tolerance<=0 || !sqlbuilder.getConfig().has_functionality(Config.ST_Simplify)) {
-                    sqlbuilder.select().column().name(attr.getName()).as_geometry();
-                } else {
-                    sqlbuilder.select().column().value(
-                        sqlbuilder.ST_Simplify( 
-                            sqlbuilder.column(attr.getName()),
-                            sqlbuilder.constant(tolerance)
-                        )
-                    ).as_geometry();
-                }
+                sqlbuilder.select().column().name(attr.getName()).as_geometry();
+//                if( tolerance<=0 || !sqlbuilder.getConfig().has_functionality(Config.ST_Simplify)) {
+//                    sqlbuilder.select().column().name(attr.getName()).as_geometry();
+//                } else {
+//                    sqlbuilder.select().column().value(
+//                        sqlbuilder.ST_Simplify( 
+//                            sqlbuilder.column(attr.getName()),
+//                            sqlbuilder.constant(tolerance)
+//                        )
+//                    ).as_geometry();
+//                }
                 columns.add(attr);
             } else {
                 sqlbuilder.select().column().name(attr.getName());
@@ -132,11 +137,13 @@
         if( filter != null ) {
             String sqlfilter = filter.getSQL();
             if( ! StringUtils.isEmpty(sqlfilter) ) {
-                sqlbuilder.select().where().set( sqlbuilder.custom(sqlfilter) );
+                if( this.helper.supportFilter(this.storeType, filter) ) {
+                    sqlbuilder.select().where().set(expbuilder.toValue(sqlfilter));
+                }
             }
         }
         if( ! StringUtils.isEmpty(baseFilter) ) {
-            sqlbuilder.select().where().and(sqlbuilder.custom(baseFilter));
+            sqlbuilder.select().where().and(expbuilder.toValue(baseFilter));
         }
         
         FeatureQueryOrder order = query==null? null:query.getOrder();
@@ -170,7 +177,7 @@
             // obtener los primeros elementos sin importarnos su orden.
             for(String attrName : primaryKeys ) {
                 // Se precisa indicar un orden para usar OFFSET.
-                sqlbuilder.select().order_by().column(sqlbuilder.identifier(attrName)).ascending();
+                sqlbuilder.select().order_by().column(sqlbuilder.as_identifier(attrName)).ascending();
             }
         }        
         if( limit > 0 ) {
@@ -181,7 +188,11 @@
         if( offset>0 ) {
             sqlbuilder.select().offset(offset);
         }
-        
+        sqlbuilder.setProperties(
+                Variable.class, 
+                PROP_FEATURE_TYPE, this.storeType,
+                PROP_TABLE, table
+        );
         String sql = sqlbuilder.toString();
         ResultSetEntry resultSetEntry = this.helper.getResulSetControler().create(
                 sql, fetchSize, columns.toArray(new FeatureAttributeDescriptor[columns.size()])
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CountOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CountOperation.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CountOperation.java	(revision 44198)
@@ -5,12 +5,15 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import org.apache.commons.lang3.StringUtils;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
 import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_FEATURE_TYPE;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_TABLE;
 
 public class CountOperation extends AbstractConnectionOperation {
 
@@ -47,6 +50,7 @@
             String filter) throws DataException {
 
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
         sqlbuilder.select().column().value(sqlbuilder.count().all());
         sqlbuilder.select().from().table()
@@ -55,13 +59,16 @@
                 .name(this.table.getTable());
         sqlbuilder.select().from().subquery(this.table.getSubquery());
         if (!StringUtils.isEmpty(baseFilter)) {
-            sqlbuilder.select().where().set( sqlbuilder.custom(baseFilter) );
+            sqlbuilder.select().where().set( expbuilder.custom(baseFilter) );
         }
         if (!StringUtils.isEmpty(filter)) {
             // El and() hace un set() si no hay un filtro previo
-            sqlbuilder.select().where().and(sqlbuilder.custom(filter));
+            sqlbuilder.select().where().and(expbuilder.custom(filter));
         }
-
+        sqlbuilder.setProperties(
+                ExpressionBuilder.Variable.class, 
+                PROP_TABLE, table
+        );
         String sql = sqlbuilder.select().toString();
 
         Statement st = null;
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureProviderByReferenceOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureProviderByReferenceOperation.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureProviderByReferenceOperation.java	(revision 44198)
@@ -7,6 +7,7 @@
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
@@ -17,6 +18,8 @@
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
 import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_FEATURE_TYPE;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_TABLE;
 import org.gvsig.fmap.geom.DataTypes;
 
 
@@ -61,7 +64,8 @@
         String[] primaryKeys = reference.getKeyNames();
         
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
-        
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
         for (FeatureAttributeDescriptor attr : featureType) {
             if( attr.getType()==DataTypes.GEOMETRY ) {
                 sqlbuilder.select().column().name(attr.getName()).as_geometry();
@@ -83,19 +87,23 @@
             Object value = reference.getKeyValue(name);
             if( value == null ) {
                 sqlbuilder.select().where().and(
-                    sqlbuilder.isNull(sqlbuilder.column(name))
+                    expbuilder.is_null(expbuilder.column(name))
                 );                
             } else {
                 sqlbuilder.select().where().and(
-                    sqlbuilder.eq(
-                        sqlbuilder.column(name), 
-                        sqlbuilder.parameter(name).value(value)
+                    expbuilder.eq(
+                        expbuilder.column(name), 
+                        expbuilder.parameter(name).value(value)
                     )
                 );              
             }
         }
         sqlbuilder.select().limit(1);
-
+        sqlbuilder.setProperties(
+                ExpressionBuilder.Variable.class, 
+                PROP_FEATURE_TYPE, featureType,
+                PROP_TABLE, table
+        );
         String sql = sqlbuilder.select().toString();
 
         PreparedStatement st = null;
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CalculateEnvelopeOfColumnOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CalculateEnvelopeOfColumnOperation.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CalculateEnvelopeOfColumnOperation.java	(revision 44198)
@@ -6,12 +6,15 @@
 import java.sql.Statement;
 import org.apache.commons.lang3.StringUtils;
 import org.cresques.cts.IProjection;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
 import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_TABLE;
 import org.gvsig.fmap.geom.Geometry;
 import org.gvsig.fmap.geom.primitive.Envelope;
 
@@ -70,10 +73,12 @@
         // https://alastaira.wordpress.com/2011/07/26/determining-the-geographic-extent-of-spatial-features-in-a-sql-server-table/
         //
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+        
         sqlbuilder.select().column().value(
-            sqlbuilder.getAsGeometry(
-                sqlbuilder.ST_ExtentAggregate(
-                        sqlbuilder.column(columnName)
+            expbuilder.as_geometry(
+                expbuilder.ST_ExtentAggregate(
+                        expbuilder.column(columnName)
                 )
             )
         );
@@ -87,32 +92,35 @@
         if (StringUtils.isEmpty(baseFilter)) {
             if (limit != null) {
                 sqlbuilder.select().where().set(
-                        sqlbuilder.ST_Intersects(
-                                sqlbuilder.ST_Envelope(
-                                        sqlbuilder.column(columnName)
+                        expbuilder.ST_Intersects(
+                                expbuilder.ST_Envelope(
+                                        expbuilder.column(columnName)
                                 ),
-                                sqlbuilder.ST_Envelope(
-                                        sqlbuilder.geometry(limit.getGeometry(), crs)
+                                expbuilder.ST_Envelope(
+                                        expbuilder.geometry(limit.getGeometry(), crs)
                                 )
                         )
                 );
             }
         } else {
-            sqlbuilder.select().where().set( sqlbuilder.custom(baseFilter) );
+            sqlbuilder.select().where().set( expbuilder.custom(baseFilter) );
             if (limit != null) {
                 sqlbuilder.select().where().and(
-                        sqlbuilder.ST_Intersects(
-                            sqlbuilder.ST_Envelope(
-                                    sqlbuilder.column(columnName)
+                        expbuilder.ST_Intersects(
+                            expbuilder.ST_Envelope(
+                                    expbuilder.column(columnName)
                             ),
-                            sqlbuilder.ST_Envelope(
-                                    sqlbuilder.geometry(limit.getGeometry(), crs)
+                            expbuilder.ST_Envelope(
+                                    expbuilder.geometry(limit.getGeometry(), crs)
                             )
                         )
                 );
             }
         }
-
+        sqlbuilder.setProperties(
+                Variable.class, 
+                PROP_TABLE, table
+        );
         String sql = sqlbuilder.select().toString();
 
         Statement st = null;
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/TableIsEmptyOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/TableIsEmptyOperation.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/TableIsEmptyOperation.java	(revision 44198)
@@ -5,12 +5,15 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import org.apache.commons.lang3.StringUtils;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
 import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_FEATURE_TYPE;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_TABLE;
 
 public class TableIsEmptyOperation extends AbstractConnectionOperation {
 
@@ -48,7 +51,8 @@
         ) throws DataException {
 
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
-
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+        
         sqlbuilder.select().column().all();
         sqlbuilder.select().from().table()
                 .database(this.table.getDatabase())
@@ -56,14 +60,17 @@
                 .name(this.table.getTable());
         sqlbuilder.select().from().subquery(this.table.getSubquery());
         if (!StringUtils.isEmpty(baseFilter)) {
-            sqlbuilder.select().where().set( sqlbuilder.custom(baseFilter) );
+            sqlbuilder.select().where().set( expbuilder.custom(baseFilter) );
         }
         if (!StringUtils.isEmpty(filter)) {
             // El and() hace un set() si no hay un filtro previo
-            sqlbuilder.select().where().and(sqlbuilder.custom(filter));
+            sqlbuilder.select().where().and(expbuilder.custom(filter));
         }
         sqlbuilder.select().limit(1);
-        
+        sqlbuilder.setProperties(
+                ExpressionBuilder.Variable.class, 
+                PROP_TABLE, table
+        );
         String sql = sqlbuilder.select().toString();
 
         Statement st = null;
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/PerformChangesOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/PerformChangesOperation.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/PerformChangesOperation.java	(revision 44198)
@@ -9,6 +9,8 @@
 import java.util.List;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
 import org.gvsig.fmap.dal.DataTypes;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
@@ -24,6 +26,8 @@
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
 import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_FEATURE_TYPE;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_TABLE;
 import org.gvsig.tools.dispose.Disposable;
 import org.gvsig.tools.dispose.DisposeUtils;
 
@@ -88,6 +92,8 @@
             FeatureType type
         ) {
         JDBCSQLBuilderBase sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
         sqlbuilder.delete().table()
                 .database(this.table.getDatabase())
                 .schema(this.table.getSchema())
@@ -95,9 +101,9 @@
         for (FeatureAttributeDescriptor attr : type) {
             if (attr.isPrimaryKey()) {
                 sqlbuilder.delete().where().and(
-                        sqlbuilder.eq(
-                                sqlbuilder.column(attr.getName()),
-                                sqlbuilder.parameter(attr.getName()).as_variable()
+                        expbuilder.eq(
+                                expbuilder.column(attr.getName()),
+                                expbuilder.parameter(attr.getName()).as_variable()
                         )
                 );
             }
@@ -117,6 +123,10 @@
 
         PreparedStatement st = null;
         Disposable paramsDisposer = null;
+        sqlbuilder.setProperties(
+                Variable.class, 
+                PROP_TABLE, table
+        );
         String sql = sqlbuilder.delete().toString();
         try {
             st = conn.prepareStatement(sql);
@@ -149,6 +159,7 @@
             FeatureType type
         ) {
         JDBCSQLBuilderBase sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
         sqlbuilder.insert().table()
                 .database(this.table.getDatabase())
@@ -160,13 +171,15 @@
             }
             if (attr.getType() == DataTypes.GEOMETRY) {
                 sqlbuilder.insert().column().name(attr.getName()).with_value(
-                    sqlbuilder.parameter(attr.getName()).as_geometry_variable().srs(
-                        sqlbuilder.parameter().value(attr.getSRS()).as_constant()
-                    )
+                    expbuilder.parameter(attr.getName()).as_geometry_variable()
+                        .srs(
+                            expbuilder.parameter().value(
+                                attr.getSRS()).as_constant()
+                        )
                 );
             } else {
                 sqlbuilder.insert().column().name(attr.getName()).with_value(
-                        sqlbuilder.parameter(attr.getName())
+                        expbuilder.parameter(attr.getName())
                 );
             }
         }
@@ -181,6 +194,11 @@
 
         PreparedStatement st;
         Disposable paramsDisposer;
+        sqlbuilder.setProperties(
+                Variable.class, 
+                PROP_FEATURE_TYPE, type,
+                PROP_TABLE, table
+        );
         String sql = sqlbuilder.insert().toString();
         try {
             st = conn.prepareStatement(sql);
@@ -210,6 +228,7 @@
             FeatureType type
         ) {
         JDBCSQLBuilderBase sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
         sqlbuilder.update().table()
                 .database(this.table.getDatabase())
@@ -218,21 +237,21 @@
         for (FeatureAttributeDescriptor attr : type) {
             if (attr.isPrimaryKey()) {
                 sqlbuilder.update().where().and(
-                        sqlbuilder.eq(
-                                sqlbuilder.column(attr.getName()),
-                                sqlbuilder.parameter(attr.getName()).as_variable()
+                        expbuilder.eq(
+                                expbuilder.column(attr.getName()),
+                                expbuilder.parameter(attr.getName()).as_variable()
                         )
                 );
             } if ( ! attr.isAutomatic() &&  !attr.isReadOnly() ) {
                 if (attr.getType() == DataTypes.GEOMETRY) {
                     sqlbuilder.update().column().name(attr.getName()).with_value(
-                        sqlbuilder.parameter(attr.getName()).as_geometry_variable().srs(
-                            sqlbuilder.parameter().value(attr.getSRS()).as_constant()
+                        expbuilder.parameter(attr.getName()).as_geometry_variable().srs(
+                            expbuilder.parameter().value(attr.getSRS()).as_constant()
                         )
                     );
                 } else {
                     sqlbuilder.update().column().name(attr.getName()).with_value(
-                        sqlbuilder.parameter(attr.getName()).as_variable()
+                        expbuilder.parameter(attr.getName()).as_variable()
                     );
                 }
             }
@@ -252,6 +271,11 @@
         
         PreparedStatement st = null;
         Disposable paramsDisposer = null;
+        sqlbuilder.setProperties(
+                Variable.class, 
+                PROP_FEATURE_TYPE, type,
+                PROP_TABLE, table
+        );
         String sql = sqlbuilder.update().toString();
         try {
             st = conn.prepareStatement(sql);
@@ -347,6 +371,10 @@
                 }
             }
         }
+        sqlbuilder.setProperties(
+                Variable.class, 
+                PROP_TABLE, table
+        );
         return sqlbuilder.alter_table().toStrings();
     }
     
@@ -421,6 +449,10 @@
                     .database(this.table.getDatabase())
                     .schema(this.table.getSchema())
                     .name(this.table.getTable());
+                sqlbuilder.setProperties(
+                        Variable.class, 
+                        PROP_TABLE, table
+                );
                 sqls.addAll(sqlbuilder.create_index().toStrings());
             }
         }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureTypeOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureTypeOperation.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/FetchFeatureTypeOperation.java	(revision 44198)
@@ -11,6 +11,8 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.cresques.cts.IProjection;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
 import org.gvsig.fmap.dal.DataTypes;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
@@ -19,6 +21,8 @@
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
 import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_FEATURE_TYPE;
+import static org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase.PROP_TABLE;
 import org.gvsig.fmap.geom.Geometry;
 import org.gvsig.fmap.geom.GeometryLocator;
 import org.gvsig.fmap.geom.type.GeometryType;
@@ -256,6 +260,7 @@
             String table
         ) throws SQLException {
         JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
         sqlbuilder.select().column().name("COLUMN_NAME");
         sqlbuilder.select().column().name("CONSTRAINT_TYPE");
@@ -268,31 +273,31 @@
                 + "c.constraint_name = t_cons.constraint_name "
         );
         sqlbuilder.select().where().set(
-                sqlbuilder.like(
-                        sqlbuilder.custom("c.TABLE_NAME"), 
-                        sqlbuilder.constant(table)
+                expbuilder.like(
+                        expbuilder.custom("c.TABLE_NAME"), 
+                        expbuilder.constant(table)
                 )
         );
         if (schema != null) {
             sqlbuilder.select().where().and(
-                    sqlbuilder.like(
-                            sqlbuilder.custom("c.TABLE_SCHEMA"),
-                            sqlbuilder.constant(schema)
+                    expbuilder.like(
+                            expbuilder.custom("c.TABLE_SCHEMA"),
+                            expbuilder.constant(schema)
                     )
             );
         }
         if (catalog != null) {
             sqlbuilder.select().where().and(
-                    sqlbuilder.like(
-                            sqlbuilder.custom("c.CONSTRAINT_CATALOG"),
-                            sqlbuilder.constant(catalog)
+                    expbuilder.like(
+                            expbuilder.custom("c.CONSTRAINT_CATALOG"),
+                            expbuilder.constant(catalog)
                     )
             );
         }
         sqlbuilder.select().where().and(
-                sqlbuilder.eq(
-                        sqlbuilder.column("CONSTRAINT_TYPE"),
-                        sqlbuilder.constant("PRIMARY KEY")
+                expbuilder.eq(
+                        expbuilder.column("CONSTRAINT_TYPE"),
+                        expbuilder.constant("PRIMARY KEY")
                 )
         );
         return sqlbuilder.toString();
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AppendOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AppendOperation.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/AppendOperation.java	(revision 44198)
@@ -4,7 +4,9 @@
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
 import org.gvsig.fmap.dal.DataTypes;
+import org.gvsig.fmap.dal.SQLBuilder;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
@@ -13,7 +15,6 @@
 import org.gvsig.fmap.dal.store.jdbc.exception.JDBCPreparingSQLException;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper;
 import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils;
-import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory;
 import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.tools.dispose.Disposable;
@@ -28,6 +29,8 @@
     protected final FeatureType type;
     
     protected JDBCSQLBuilderBase sqlbuilder = null;
+    protected ExpressionBuilder expbuilder;
+
     protected PreparedStatement preparedStatement;
     protected String sql;
     
@@ -50,6 +53,7 @@
             this.connection = this.helper.getConnectionWritable();
             
             this.sqlbuilder = this.helper.createSQLBuilder();
+            this.expbuilder = this.sqlbuilder.expression();
 
             this.sqlbuilder.insert().table()
                     .database(this.table.getDatabase())
@@ -62,13 +66,13 @@
                 }
                 if (attr.getType() == DataTypes.GEOMETRY) {
                     this.sqlbuilder.insert().column().name(attr.getName()).with_value( 
-                        sqlbuilder.parameter(attr.getName()).as_geometry_variable().srs( 
-                                sqlbuilder.parameter().value(attr.getSRS()) 
+                        expbuilder.parameter(attr.getName()).as_geometry_variable().srs( 
+                                expbuilder.parameter().value(attr.getSRS()) 
                         ) 
                     );
                 } else {
                     this.sqlbuilder.insert().column().name(attr.getName()).with_value(
-                        sqlbuilder.parameter(attr.getName()).as_variable()
+                        expbuilder.parameter(attr.getName()).as_variable()
                     );
                 }
             }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCSQLBuilderBase.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCSQLBuilderBase.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCSQLBuilderBase.java	(revision 44198)
@@ -6,8 +6,11 @@
 import java.util.ArrayList;
 import java.util.List;
 import org.cresques.cts.IProjection;
+import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureReference;
+import org.gvsig.fmap.dal.feature.FeatureStore;
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.dal.feature.spi.SQLBuilderBase;
 import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
@@ -25,8 +28,12 @@
 import org.gvsig.fmap.geom.type.GeometryType;
 import org.gvsig.tools.dispose.Disposable;
 
+@SuppressWarnings("UseSpecificCatch")
 public class JDBCSQLBuilderBase extends SQLBuilderBase {
 
+    public static final String PROP_FEATURE_TYPE = "FeatureType";
+    public static final String PROP_TABLE = "Table";
+    
     private GeometryManager geometryManager = null;
     protected final JDBCHelper helper;
     
@@ -47,7 +54,7 @@
     }
     
     @Override
-    public Object getSRSId(IProjection projection) {
+    public Object srs_id(IProjection projection) {
         Connection conn = null;
         try {
             conn = this.helper.getConnection();
@@ -71,13 +78,13 @@
     public void setParameters(PreparedStatement st) {
         try {
             int columnIndex = 1;
-            for (Parameter parameter : this.getParameters()) {
-                st.setObject(columnIndex++, parameter.getValue());
+            for (Parameter parameter : this.parameters()) {
+                st.setObject(columnIndex++, parameter.value());
             }
         } catch (Exception ex) {
             String p = "unknow";
             try {
-                p =  this.getParameters().toString();
+                p =  this.parameters().toString();
             } catch (Exception ex2) {
                 // Do nothing
             }
@@ -90,12 +97,12 @@
             FeatureType type = feature.getType();
             List<Object> values = new ArrayList<>();
             Object value;
-            for (Parameter parameter : this.getParameters()) {
+            for (Parameter parameter : this.parameters()) {
                 if (parameter.is_constant()) {
-                    value = parameter.getValue();
+                    value = parameter.value();
                     values.add(value);
                 } else {
-                    String name = parameter.getName();
+                    String name = parameter.name();
                     value = feature.get(name);
                     FeatureAttributeDescriptor attrDesc = type.getAttributeDescriptor(name);
                     if( attrDesc.getType()==DataTypes.GEOMETRY ) {
@@ -173,11 +180,11 @@
         try {
             
             List<Object> values = new ArrayList<>();
-            for (Parameter parameter : this.getParameters()) {
+            for (Parameter parameter : this.parameters()) {
                 if (parameter.is_constant()) {
-                    values.add(parameter.getValue());
+                    values.add(parameter.value());
                 } else {
-                    String name = parameter.getName();
+                    String name = parameter.name();
                     values.add(((FeatureReferenceProviderServices)reference).getKeyValue(name));
                 }
             }
@@ -205,7 +212,7 @@
                 }
             };
         }
-        if( logger.isDebugEnabled() ) {
+        if( LOGGER.isDebugEnabled() ) {
             StringBuilder debug = new StringBuilder();
             debug.append("st.set(");
             try {
@@ -219,7 +226,7 @@
                                 debug.append("/*");
                                 debug.append(columnIndex);
                                 debug.append("*/ ");
-                                debug.append(string((String) value));
+                                debug.append(as_string(value));
                                 debug.append(", ");
                                 break;
                             case NATIVE:
@@ -228,7 +235,7 @@
                                 debug.append("/*");
                                 debug.append(columnIndex);
                                 debug.append("*/ ");
-                                debug.append(bytearray(bytes));
+                                debug.append(as_string(bytes));
                                 debug.append(", ");
                                 break;
                             case EWKB:
@@ -236,7 +243,7 @@
                                 debug.append("/*");
                                 debug.append(columnIndex);
                                 debug.append("*/ ");
-                                debug.append(bytearray(bytes));
+                                debug.append(as_string(bytes));
                                 debug.append(", ");
                                 break;
                         }
@@ -245,9 +252,9 @@
                         debug.append(columnIndex);
                         debug.append("*/ ");
                         if( value instanceof String ) {
-                            debug.append(string((String) value));
+                            debug.append(as_string(value));
                         } else if( value instanceof Boolean ) {
-                            debug.append( ((Boolean)value)? config.getString(Config.constant_true):config.getString(Config.constant_false) );
+                            debug.append( ((Boolean)value)? constant_true:constant_false );
                         } else {
                             debug.append(value);
                         }
@@ -256,7 +263,7 @@
                     columnIndex++;
                 }
                 debug.append(")");
-                logger.debug(debug.toString());
+                LOGGER.debug(debug.toString());
             } catch(Exception ex) {
             }        
         }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCStoreProviderBase.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCStoreProviderBase.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCStoreProviderBase.java	(revision 44198)
@@ -219,13 +219,7 @@
         }
     }
 
-    
     @Override
-    public JDBCSQLBuilderBase createExpression() {
-        return this.getHelper().createSQLBuilder();
-    }
-
-    @Override
     public JDBCStoreParameters getParameters() {
         return (JDBCStoreParameters) super.getParameters();
     }  
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCHelperBase.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCHelperBase.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCHelperBase.java	(revision 44198)
@@ -15,11 +15,13 @@
 import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
 import org.gvsig.expressionevaluator.ExpressionEvaluatorManager;
 import org.gvsig.expressionevaluator.Function;
+import org.gvsig.expressionevaluator.SymbolTable;
 import org.gvsig.fmap.dal.DataTypes;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.exception.InitializeException;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureQueryOrder;
+import org.gvsig.fmap.dal.feature.FeatureStore;
 import org.gvsig.fmap.dal.feature.FeatureType;
 
 import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
@@ -159,12 +161,13 @@
     }
 
     @Override
-    public boolean supportFilter(Evaluator filter) {
+    public boolean supportFilter(final FeatureType type, Evaluator filter) {
         // No podemos filtrar cuando:
         // - Hay una subquery especificada en los parametros 
         // - Si hay un filtro y el getSQL devuelbe null.
         // - Si se esta usando alguna funcion no-sql en el getSQL
         // - Si se estan usando funciones OGC y no soportamos funciones espaciales
+        // - Si se esta usando algun campo calculado en la expresion de filtro.
         // 
         // Un proveedor especifico podria sobreescribir el metodo,
         // para hilar mas fino al comprobar si soporta el filtro o no.
@@ -189,32 +192,50 @@
         // Ahora vamos a comprobar que las funciones que se usan son 
         // compatibles sql, y que no se usan funciones OGC si el 
         // proveedor dice que no soporta funciones espaciales.
+        // Tambien comprobaremos que el filtro no usa ningun campo calculado.
         final MutableBoolean isCompatible = new MutableBoolean(true);
         final boolean supportSpatialFunctions = this.hasSpatialFunctions();
         ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
         Code code = manager.compile(sql);
+        SymbolTable symbolTable = manager.createSymbolTable();
+        code.link(symbolTable);
         try {
             code.accept(new Visitor() {
                 @Override
                 public void visit(Object code_obj) throws VisitCanceledException, BaseException {
                     Code code = (Code) code_obj;
-                    if ( code.code()==Code.CALLER ) {
-                        Code.Caller caller = (Code.Caller) code;
-                        Function function = caller.function();
-                        if( function==null ) {
-                            isCompatible.setValue(false);
-                            throw new VisitCanceledException();
-                        }
-                        if( !function.isSQLCompatible() ) {
-                            isCompatible.setValue(false);
-                            throw new VisitCanceledException();
-                        }
-                        if( !supportSpatialFunctions ) {
-                            if( StringUtils.equalsIgnoreCase(function.group(),Function.GROUP_OGC) ) {
+                    switch(code.code()) {
+                        case Code.CALLER:
+                            Code.Caller caller = (Code.Caller) code;
+                            Function function = caller.function();
+                            if( function==null ) {
                                 isCompatible.setValue(false);
                                 throw new VisitCanceledException();
                             }
-                        }
+                            if( !function.isSQLCompatible() ) {
+                                isCompatible.setValue(false);
+                                throw new VisitCanceledException();
+                            }
+                            if( !supportSpatialFunctions ) {
+                                if( StringUtils.equalsIgnoreCase(function.group(),Function.GROUP_OGC) ) {
+                                    isCompatible.setValue(false);
+                                    throw new VisitCanceledException();
+                                }
+                            }
+                            break;
+                            
+                        case Code.IDENTIFIER:
+                            Code.Identifier identifier = (Code.Identifier) code;
+                            if( type!=null ) {
+                                FeatureAttributeDescriptor attrdesc = type.getAttributeDescriptor(identifier.name());
+                                if( attrdesc!=null ) {
+                                    if( attrdesc.isComputed() ) {
+                                        isCompatible.setValue(false);
+                                        throw new VisitCanceledException();
+                                    }
+                                }
+                            }
+                            break;
                     }
                 }
             });
@@ -229,7 +250,7 @@
     }
     
     @Override
-    public boolean supportOrder(FeatureQueryOrder order) {
+    public boolean supportOrder(FeatureType type, FeatureQueryOrder order) {
         if (this.useSubquery()) {
             return false;
         }
@@ -238,7 +259,7 @@
         }
         for( FeatureQueryOrder.FeatureQueryOrderMember member : order.members() ) {
             if (member.hasEvaluator()) {
-                if( !this.supportFilter(member.getEvaluator()) ) {
+                if( !this.supportFilter(type, member.getEvaluator()) ) {
                     return false;
                 }
             }            
@@ -324,6 +345,7 @@
        }
     }
 
+    @Override
     public void closeConnectionQuietly(Connection connection) {
         if( connection != null ) {
             LOGGER.debug("Clossing connection quietly "+connection.hashCode());
@@ -509,5 +531,10 @@
                parameters.getSchema()+ ":" + 
                parameters.tableID();
     }
+
+    @Override
+    public boolean isThreadSafe() {
+        return true;
+    }
     
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/test/java/org/gvsig/fmap/dal/store/jdbc2/SQLBuilderTest.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/test/java/org/gvsig/fmap/dal/store/jdbc2/SQLBuilderTest.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/test/java/org/gvsig/fmap/dal/store/jdbc2/SQLBuilderTest.java	(revision 44198)
@@ -1,11 +1,9 @@
 package org.gvsig.fmap.dal.store.jdbc2;
 
-import java.util.ArrayList;
-import java.util.List;
+import junit.framework.TestCase;
 import org.apache.commons.lang3.ArrayUtils;
 import org.cresques.cts.IProjection;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Variable;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
 import org.gvsig.fmap.crs.CRSFactory;
 import org.gvsig.fmap.dal.SQLBuilder;
 import org.gvsig.fmap.dal.SQLBuilder.Privilege;
@@ -15,48 +13,29 @@
 import org.gvsig.fmap.geom.GeometryLocator;
 import org.gvsig.fmap.geom.GeometryManager;
 import org.gvsig.fmap.geom.primitive.Polygon;
-import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
+import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
 
-public class SQLBuilderTest extends AbstractLibraryAutoInitTestCase {
+public class SQLBuilderTest extends TestCase {
     
+    public SQLBuilderTest(String testName) {
+        super(testName);
+    }
+
     @Override
-    protected void doSetUp() throws Exception {
+    protected void setUp() throws Exception {
+        super.setUp();
+        new DefaultLibrariesInitializer().fullInitialize();
+    }
 
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
     }
-    
-    List<String> getVariableNames(SQLBuilder builder) {
-        List<String> vars = new ArrayList<>();
-        for (Variable var : builder.getVariables()) {
-            vars.add(var.getName());
-        }
-        return vars;
+
+    private SQLBuilder createSQLBuilder() {
+        return new SQLBuilderBase();
     }
     
-    List<String> getParameterNames(SQLBuilder builder) {
-        List<String> params = new ArrayList<>();
-        for (Parameter param : builder.getParameters()) {
-            String s;
-            switch(param.getType()) {
-                case Constant:
-                    Object value = param.getValue();
-                    if( value==null ) {
-                        s = "null";
-                    } else if( value instanceof String ) {
-                        s = "'" + (String)value + "'";
-                    } else {
-                        s = value.toString();
-                    }    
-                    break;
-                case Geometry:
-                case Variable:
-                default:
-                    s = "\"" + param.getName() + "\"";
-            }
-            params.add(s);
-        }
-        return params;
-    }
-    
  
     public void testCalulateEnvelope() throws Exception {
         GeometryManager geometryManager = GeometryLocator.getGeometryManager();
@@ -69,60 +48,60 @@
         limit.addVertex(100, 0);
         limit.addVertex(0, 0);
         
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
-        builder.select().column().value(
-            builder.getAsGeometry(
-              builder.ST_ExtentAggregate(
-                builder.column("the_geom")
+        sqlbuilder.select().column().value(
+            expbuilder.as_geometry(
+              expbuilder.ST_ExtentAggregate(
+                expbuilder.column("the_geom")
               )
             )
         ).as("envelope");
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().where().set(
-            builder.ST_Intersects(
-                builder.ST_Envelope(
-                    builder.column("the_geom")
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().where().set(
+            expbuilder.ST_Intersects(
+                expbuilder.ST_Envelope(
+                    expbuilder.column("the_geom")
                 ),
-                builder.geometry(limit, proj)
+                expbuilder.geometry(limit, proj)
             )
         );
-        builder.select().where().and(
-                builder.custom("x = 27")
+        sqlbuilder.select().where().and(
+                expbuilder.custom("x = 27")
         );
         
-        // SELECT ST_AsBinary(ST_Extent("the_geom")) AS "envelope" FROM "master"."dbo"."test1" WHERE ST_Intersects((ST_Envelope("the_geom")), (ST_GeomFromText('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))', (4326)))) AND x = 27
-        
         System.out.println("# Test:: testCalulateEnvelope");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
-                "SELECT ST_AsBinary(ST_Extent(\"the_geom\")) AS \"envelope\" FROM \"master\".\"dbo\".\"test1\" WHERE ST_Intersects((ST_Envelope(\"the_geom\")), (ST_GeomFromText('POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))', (4326)))) AND x = 27",
-                builder.toString()
+                "SELECT ST_AsBinary(ST_ExtentAggregate(\"the_geom\")) AS \"envelope\" FROM \"master\".\"dbo\".\"test1\" WHERE ST_Intersects((ST_Envelope(\"the_geom\")), (ST_GeomFromWKB((DECODE('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000','hex')), (4326)))) AND x = 27",
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[the_geom]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testCount() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
-        builder.select().column().value(builder.count().all());
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().from().subquery(null);
-        builder.select().where().set( builder.custom("pp = 200"));
+        sqlbuilder.select().column().value(sqlbuilder.count().all());
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().from().subquery(null);
+        sqlbuilder.select().where().set( expbuilder.custom("pp = 200"));
 
         System.out.println("# Test:: testCount");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
 
         //# Test:: testCount
         //# SQL:: SELECT COUNT(*) FROM "master"."dbo"."test1" WHERE pp = 200
@@ -131,23 +110,24 @@
 
         assertEquals(
                 "SELECT COUNT(*) FROM \"master\".\"dbo\".\"test1\" WHERE pp = 200",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
     
     public void testCreateTable() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.create_table().table().database("master").schema("dbo").name("test1");
-        builder.create_table().add_column(
+        sqlbuilder.create_table().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.create_table().add_column(
                 "name",
                 DataTypes.STRING,
                 45,
@@ -158,7 +138,7 @@
                 false,
                 null
         );
-        builder.create_table().add_column(
+        sqlbuilder.create_table().add_column(
                 "id",
                 DataTypes.INT,
                 0,
@@ -169,7 +149,7 @@
                 true,
                 0
         );
-        builder.create_table().add_column(
+        sqlbuilder.create_table().add_column(
                 "geom",
                 DataTypes.GEOMETRY,
                 0,
@@ -184,95 +164,98 @@
         
         // CREATE TABLE "master"."dbo"."test1" ("name" VARCHAR(45) DEFAULT NULL NULL, "id" SERIAL DEFAULT '0' NOT NULL PRIMARY KEY, "geom" TEXT DEFAULT NULL NULL )
         System.out.println("# Test:: testCreateTable");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "CREATE TABLE \"master\".\"dbo\".\"test1\" (\"name\" VARCHAR(45) DEFAULT NULL NULL, \"id\" SERIAL DEFAULT '0' NOT NULL PRIMARY KEY, \"geom\" TEXT DEFAULT NULL NULL )",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testDropTable() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
-        builder.drop_table().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.drop_table().table().database("master").schema("dbo").name("test1");
 
         // DROP TABLE "master"."dbo"."test1"; DELETE FROM GEOMETRY_COLUMNS WHERE f_table_schema = 'dbo' AND f_table_name = 'test1'
         
         System.out.println("# Test:: testDropTable");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "DROP TABLE \"master\".\"dbo\".\"test1\"; DELETE FROM GEOMETRY_COLUMNS WHERE f_table_schema = 'dbo' AND f_table_name = 'test1'",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
     
     public void testFetchFeatureProviderByReference() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
         
         String value = "yoyo";
-        builder.select().column().name("name");
-        builder.select().column().name("id");
-        builder.select().column().name("geom").as_geometry();
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().where().set(
-            builder.eq(
-                builder.column("name"),
-                builder.parameter(value).as_constant()
+        sqlbuilder.select().column().name("name");
+        sqlbuilder.select().column().name("id");
+        sqlbuilder.select().column().name("geom").as_geometry();
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().where().set(
+            expbuilder.eq(
+                expbuilder.column("name"),
+                expbuilder.parameter(value).as_constant()
             )
         );
-        builder.select().limit(1);
+        sqlbuilder.select().limit(1);
 
         // SELECT "name", "id", ST_AsBinary("geom") FROM "master"."dbo"."test1" WHERE ( ("name") = (?) ) LIMIT 1
 
         System.out.println("# Test:: testFetchFeatureProviderByReference");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "SELECT \"name\", \"id\", ST_AsBinary(\"geom\") FROM \"master\".\"dbo\".\"test1\" WHERE ( (\"name\") = (?) ) LIMIT 1",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "['yoyo']",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
     
     public void testFetchFeatureType() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.select().column().all();
-        builder.select().from().table().database("master").schema("dbo").name("test1");
-        builder.select().limit(1);
+        sqlbuilder.select().column().all();
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().limit(1);
 
         System.out.println("# Test:: testFetchFeatureType");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         
         //# Test:: testFetchFeatureType
         //# SQL:: SELECT * FROM [master].[dbo].[test1] LIMMIT 1
@@ -281,205 +264,242 @@
         
         assertEquals(
                 "SELECT * FROM \"master\".\"dbo\".\"test1\" LIMIT 1",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
         
     public void testPerformDeletes() throws Exception {
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.delete().table().database("master").schema("dbo").name("test1");
-        builder.delete().where().and(
-            builder.eq( 
-                builder.column("id1"),
-                builder.parameter("id1").as_variable()
+        sqlbuilder.delete().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.delete().where().and(
+            expbuilder.eq( 
+                expbuilder.column("id1"),
+                expbuilder.parameter("id1").as_variable()
             )
         );
-        builder.delete().where().and(
-            builder.eq( 
-                builder.column("id2"),
-                builder.parameter("id2").as_variable()
+        sqlbuilder.delete().where().and(
+            expbuilder.eq( 
+                expbuilder.column("id2"),
+                expbuilder.parameter("id2").as_variable()
             )
         );
 
         // DELETE FROM "master"."dbo"."test1" WHERE ( ("id1") = (?) ) AND ( ("id2") = (?) )
 
         System.out.println("# Test:: testPerformDeletes");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "DELETE FROM \"master\".\"dbo\".\"test1\" WHERE ( (\"id1\") = (?) ) AND ( (\"id2\") = (?) )",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[id1, id2]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[\"id1\", \"id2\"]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testPerformInserts1() throws Exception {
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.insert().table().database("master").schema("dbo").name("test1");
-        builder.insert().column().name("id").with_value(builder.parameter("id"));
-        builder.insert().column().name("name").with_value(builder.parameter("name"));
-        builder.insert().column().name("geom").with_value(builder.parameter("geom").as_geometry_variable().srs(proj));
+        sqlbuilder.insert().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.insert().column().name("id").with_value(expbuilder.parameter("id"));
+        sqlbuilder.insert().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.insert().column().name("geom").with_value(expbuilder.parameter("geom").as_geometry_variable().srs(proj));
         
-        // INSERT INTO "master"."dbo"."test1" ( "id", "name", "geom" ) VALUES ( ?, ?, ST_GeomFromText(?, (4326)) )
-        
         System.out.println("# Test:: testPerformInserts1");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
-                "INSERT INTO \"master\".\"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromText(?, (4326)) )",
-                builder.toString()
+                "INSERT INTO \"master\".\"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromWKB((?), (4326)) )",
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[\"id\", \"name\", \"geom\"]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testPerformInserts2() throws Exception {
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.insert().table().database("master").schema("dbo").name("test1");
-        builder.insert().column().name("id").with_value(builder.parameter("id"));
-        builder.insert().column().name("name").with_value(builder.parameter("name"));
-        builder.insert().column().name("geom").with_value(builder.parameter("geom").as_geometry_variable().srs(proj));
+        sqlbuilder.insert().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.insert().column().name("id").with_value(expbuilder.parameter("id"));
+        sqlbuilder.insert().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.insert().column().name("geom").with_value(expbuilder.parameter("geom").as_geometry_variable().srs(proj));
         
-        // INSERT INTO "master"."dbo"."test1" ( "id", "name", "geom" ) VALUES ( ?, ?, ST_GeomFromText(?, (?)) )
-        
         System.out.println("# Test:: testPerformInserts2");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
-                "INSERT INTO \"master\".\"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromText(?, (?)) )",
-                builder.toString()
+                "INSERT INTO \"master\".\"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromWKB((?), (4326)) )",
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
-                "[\"id\", \"name\", \"geom\", 4326]",
-                ArrayUtils.toString(getParameterNames(builder))
+                "[\"id\", \"name\", \"geom\"]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
-    public void testPerformUpdates() throws Exception {
+    public void testPerformUpdates1() throws Exception {
         IProjection proj = CRSFactory.getCRS("EPSG:4326");
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.update().table().database("master").schema("dbo").name("test1");
-        builder.update().where().and(
-            builder.eq(
-                builder.column("id"), 
-                builder.parameter("id").as_variable()
+        sqlbuilder.update().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.update().where().and(
+            expbuilder.eq(
+                expbuilder.column("id"), 
+                expbuilder.parameter("id").as_variable()
             )
         );
-        builder.update().column().name("name").with_value(builder.parameter("name"));
-        builder.update().column().name("geom").with_value(
-                builder.parameter("geom").as_geometry_variable().srs(proj) 
+        sqlbuilder.update().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.update().column().name("geom").with_value(
+                expbuilder.parameter("geom").as_geometry_variable().srs(proj) 
         );
 
-        // UPDATE "master"."dbo"."test1" SET "name" = ?, "geom" = ST_GeomFromText(?, (?)) WHERE ( ("id") = (?) )
+        System.out.println("# Test:: testPerformUpdates");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "UPDATE \"master\".\"dbo\".\"test1\" SET \"name\" = ?, \"geom\" = ST_GeomFromWKB((?), (4326)) WHERE ( (\"id\") = (?) )",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[geom, id, name]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[\"name\", \"geom\", \"id\"]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
 
+    public void testPerformUpdates2() throws Exception {
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.update().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.update().where().and(
+            expbuilder.eq(
+                expbuilder.column("id"), 
+                expbuilder.parameter("id").as_variable()
+            )
+        );
+        sqlbuilder.update().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.update().column().name("geom").with_value(
+                expbuilder.parameter("geom").as_geometry_variable()
+                        .srs(expbuilder.parameter().value(proj)) 
+        );
+
         System.out.println("# Test:: testPerformUpdates");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
-                "UPDATE \"master\".\"dbo\".\"test1\" SET \"name\" = ?, \"geom\" = ST_GeomFromText(?, (?)) WHERE ( (\"id\") = (?) )",
-                builder.toString()
+                "UPDATE \"master\".\"dbo\".\"test1\" SET \"name\" = ?, \"geom\" = ST_GeomFromWKB((?), (?)) WHERE ( (\"id\") = (?) )",
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[geom, id, name]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[\"name\", \"geom\", 4326, \"id\"]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testGrant1() throws Exception {
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.grant().table().database("master").schema("dbo").name("test1");
-        builder.grant().role("prueba").select().insert().update();
-        builder.grant().role("gis").all();
+        sqlbuilder.grant().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.grant().role("prueba").select().insert().update();
+        sqlbuilder.grant().role("gis").all();
                 
         
         System.out.println("# Test:: testGrant1");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
     public void testGrant2() throws Exception {
 
-        SQLBuilder builder = new SQLBuilderBase();
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
 
-        builder.grant().table().database("master").schema("dbo").name("test1");
-        builder.grant().role("prueba").privilege(Privilege.SELECT)
+        sqlbuilder.grant().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.grant().role("prueba").privilege(Privilege.SELECT)
                 .privilege(Privilege.INSERT)
                 .privilege(Privilege.UPDATE);
-        builder.grant().role("gis").privilege(Privilege.ALL);
+        sqlbuilder.grant().role("gis").privilege(Privilege.ALL);
                 
         
         System.out.println("# Test:: testGrant2");
-        System.out.println("# SQL:: " + builder.toString());
-        System.out.println("# Variables:: " + ArrayUtils.toString(getVariableNames(builder)));
-        System.out.println("# Parametros:: " + ArrayUtils.toString(getParameterNames(builder)));
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
         assertEquals(
                 "",
-                builder.toString()
+                sqlbuilder.toString()
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getVariableNames(builder))
+                ArrayUtils.toString(sqlbuilder.variables_names())
         );
         assertEquals(
                 "[]",
-                ArrayUtils.toString(getParameterNames(builder))
+                ArrayUtils.toString(sqlbuilder.parameters_names())
         );
     }
 
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/pom.xml
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/pom.xml	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/pom.xml	(revision 44198)
@@ -62,22 +62,32 @@
         <scope>test</scope>
     </dependency>    
     <dependency>
-        <groupId>mysql</groupId>
-        <artifactId>mysql-connector-java</artifactId>
+        <groupId>org.gvsig</groupId>
+        <artifactId>${org.gvsig.fmap.geometry.impl}</artifactId>
         <scope>test</scope>
+    </dependency>    
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>org.gvsig.expressionevaluator.lib.impl</artifactId>
+        <scope>test</scope>
+    </dependency>    
+    <dependency>
+        <groupId>org.gvsig</groupId>
+        <artifactId>${org.gvsig.proj.lib.impl}</artifactId>
+        <scope>test</scope>
     </dependency>
   </dependencies>
 
 
   <build>
     <plugins>
-      <plugin>
+<!--      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <skipTests>true</skipTests>
         </configuration>
-      </plugin>
+      </plugin>-->
 
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/.directory
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/.directory	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/.directory	(revision 44198)
@@ -0,0 +1,6 @@
+[Dolphin]
+Timestamp=2019,3,13,12,31,33
+Version=4
+
+[Settings]
+HiddenFilesShown=true
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilderTest.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilderTest.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilderTest.java	(revision 44198)
@@ -0,0 +1,507 @@
+package org.gvsig.fmap.dal.store.h2;
+
+import junit.framework.TestCase;
+import org.apache.commons.lang3.ArrayUtils;
+import org.cresques.cts.IProjection;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.fmap.crs.CRSFactory;
+import org.gvsig.fmap.dal.SQLBuilder;
+import org.gvsig.fmap.dal.SQLBuilder.Privilege;
+import org.gvsig.fmap.dal.feature.spi.SQLBuilderBase;
+import org.gvsig.fmap.geom.DataTypes;
+import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.GeometryLocator;
+import org.gvsig.fmap.geom.GeometryManager;
+import org.gvsig.fmap.geom.primitive.Polygon;
+import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
+
+public class H2SpatialSQLBuilderTest extends TestCase {
+    
+    public H2SpatialSQLBuilderTest(String testName) {
+        super(testName);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        new DefaultLibrariesInitializer().fullInitialize();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    private SQLBuilder createSQLBuilder() {
+        return new H2SpatialSQLBuilder(new H2SpatialHelper(null));
+    }
+    
+ 
+    public void testCalulateEnvelope() throws Exception {
+        GeometryManager geometryManager = GeometryLocator.getGeometryManager();
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+        
+        Polygon limit = geometryManager.createPolygon(Geometry.SUBTYPES.GEOM2D);
+        limit.addVertex(0, 0);
+        limit.addVertex(0, 100);
+        limit.addVertex(100, 100);
+        limit.addVertex(100, 0);
+        limit.addVertex(0, 0);
+        
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+        
+        sqlbuilder.select().column().value(
+            expbuilder.as_geometry(
+              expbuilder.ST_ExtentAggregate(
+                expbuilder.column("the_geom")
+              )
+            )
+        ).as("envelope");
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().where().set(
+            expbuilder.ST_Intersects(
+                expbuilder.ST_Envelope(
+                    expbuilder.column("the_geom")
+                ),
+                expbuilder.geometry(limit, proj)
+            )
+        );
+        sqlbuilder.select().where().and(
+                expbuilder.custom("x = 27")
+        );
+        
+        System.out.println("# Test:: testCalulateEnvelope");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "SELECT ST_AsBinary(ST_ExtentAggregate(\"the_geom\")) AS \"envelope\" FROM \"test1\" WHERE ( ((ST_Envelope(\"the_geom\")) && (ST_GeomFromWKB((DECODE('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000','hex')), (4326)))) AND ST_Intersects((ST_Envelope(\"the_geom\")),(ST_GeomFromWKB((DECODE('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000','hex')), (4326))) )) AND x = 27",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[the_geom]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+
+    public void testCount() throws Exception {
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+        
+        sqlbuilder.select().column().value(sqlbuilder.count().all());
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().from().subquery(null);
+        sqlbuilder.select().where().set( expbuilder.custom("pp = 200"));
+
+        System.out.println("# Test:: testCount");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+
+        //# Test:: testCount
+        //# SQL:: SELECT COUNT(*) FROM "test1" WHERE pp = 200
+        //# Variables:: []
+        //# Parametros:: []
+
+        assertEquals(
+                "SELECT COUNT(*) FROM \"test1\" WHERE pp = 200",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+    
+    public void testCreateTable() throws Exception {
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.create_table().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.create_table().add_column(
+                "name",
+                DataTypes.STRING,
+                45,
+                0,
+                false,
+                false,
+                true,
+                false,
+                null
+        );
+        sqlbuilder.create_table().add_column(
+                "id",
+                DataTypes.INT,
+                0,
+                0,
+                true,
+                false,
+                false,
+                true,
+                0
+        );
+        sqlbuilder.create_table().add_column(
+                "geom",
+                DataTypes.GEOMETRY,
+                0,
+                0,
+                false,
+                false,
+                true,
+                false,
+                null
+        );
+
+        
+        // CREATE TABLE "test1" ("name" VARCHAR(45) DEFAULT NULL, "id" INTEGER PRIMARY KEY AUTO_INCREMENT DEFAULT '0' NOT NULL, "geom" GEOMETRY ); ALTER TABLE "test1" ADD CONSTRAINT IF NOT EXISTS "constraint_test1_geom_dim" CHECK ST_CoordDim("geom") = 2
+        System.out.println("# Test:: testCreateTable");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "CREATE TABLE \"test1\" (\"name\" VARCHAR(45) DEFAULT NULL, \"id\" INTEGER PRIMARY KEY AUTO_INCREMENT DEFAULT '0' NOT NULL, \"geom\" GEOMETRY ); ALTER TABLE \"test1\" ADD CONSTRAINT IF NOT EXISTS \"constraint_test1_geom_dim\" CHECK ST_CoordDim(\"geom\") = 2",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+
+    public void testDropTable() throws Exception {
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+        
+        sqlbuilder.drop_table().table().database("master").schema("dbo").name("test1");
+
+        // DROP TABLE "test1"
+        
+        System.out.println("# Test:: testDropTable");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "DROP TABLE \"test1\"",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+    
+    public void testFetchFeatureProviderByReference() throws Exception {
+        SQLBuilder sqlbuilder = new SQLBuilderBase();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+        
+        String value = "yoyo";
+        sqlbuilder.select().column().name("name");
+        sqlbuilder.select().column().name("id");
+        sqlbuilder.select().column().name("geom").as_geometry();
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().where().set(
+            expbuilder.eq(
+                expbuilder.column("name"),
+                expbuilder.parameter(value).as_constant()
+            )
+        );
+        sqlbuilder.select().limit(1);
+
+        // SELECT "name", "id", ST_AsBinary("geom") FROM "master"."dbo"."test1" WHERE ( ("name") = (?) ) LIMIT 1
+
+        System.out.println("# Test:: testFetchFeatureProviderByReference");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "SELECT \"name\", \"id\", ST_AsBinary(\"geom\") FROM \"master\".\"dbo\".\"test1\" WHERE ( (\"name\") = (?) ) LIMIT 1",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[geom, id, name]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "['yoyo']",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+    
+    public void testFetchFeatureType() throws Exception {
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.select().column().all();
+        sqlbuilder.select().from().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.select().limit(1);
+
+        System.out.println("# Test:: testFetchFeatureType");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        
+        //# Test:: testFetchFeatureType
+        //# SQL:: SELECT * FROM "test1" LIMIT 1
+        //# Variables:: []
+        //# Parametros:: []        
+        
+        assertEquals(
+                "SELECT * FROM \"test1\" LIMIT 1",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+        
+    public void testPerformDeletes() throws Exception {
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.delete().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.delete().where().and(
+            expbuilder.eq( 
+                expbuilder.column("id1"),
+                expbuilder.parameter("id1").as_variable()
+            )
+        );
+        sqlbuilder.delete().where().and(
+            expbuilder.eq( 
+                expbuilder.column("id2"),
+                expbuilder.parameter("id2").as_variable()
+            )
+        );
+
+        // DELETE FROM "test1" WHERE ( ("id1") = (?) ) AND ( ("id2") = (?) )
+
+        System.out.println("# Test:: testPerformDeletes");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "DELETE FROM \"test1\" WHERE ( (\"id1\") = (?) ) AND ( (\"id2\") = (?) )",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[id1, id2]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[\"id1\", \"id2\"]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+
+    public void testPerformInserts1() throws Exception {
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.insert().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.insert().column().name("id").with_value(expbuilder.parameter("id"));
+        sqlbuilder.insert().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.insert().column().name("geom").with_value(expbuilder.parameter("geom").as_geometry_variable().srs(proj));
+        
+        System.out.println("# Test:: testPerformInserts1");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "INSERT INTO \"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromWKB((?), (4326)) )",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[geom, id, name]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[\"id\", \"name\", \"geom\"]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+
+    public void testPerformInserts2() throws Exception {
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.insert().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.insert().column().name("id").with_value(expbuilder.parameter("id"));
+        sqlbuilder.insert().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.insert().column().name("geom").with_value(expbuilder.parameter("geom").as_geometry_variable().srs(proj));
+        
+        System.out.println("# Test:: testPerformInserts2");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "INSERT INTO \"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, ST_GeomFromWKB((?), (4326)) )",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[geom, id, name]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[\"id\", \"name\", \"geom\"]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+
+    public void testPerformUpdates1() throws Exception {
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.update().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.update().where().and(
+            expbuilder.eq(
+                expbuilder.column("id"), 
+                expbuilder.parameter("id").as_variable()
+            )
+        );
+        sqlbuilder.update().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.update().column().name("geom").with_value(
+                expbuilder.parameter("geom").as_geometry_variable().srs(proj) 
+        );
+
+        System.out.println("# Test:: testPerformUpdates");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "UPDATE \"test1\" SET \"name\" = ?, \"geom\" = ST_GeomFromWKB((?), (4326)) WHERE ( (\"id\") = (?) )",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[geom, id, name]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[\"name\", \"geom\", \"id\"]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+
+    public void testPerformUpdates2() throws Exception {
+        IProjection proj = CRSFactory.getCRS("EPSG:4326");
+
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.update().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.update().where().and(
+            expbuilder.eq(
+                expbuilder.column("id"), 
+                expbuilder.parameter("id").as_variable()
+            )
+        );
+        sqlbuilder.update().column().name("name").with_value(expbuilder.parameter("name"));
+        sqlbuilder.update().column().name("geom").with_value(
+                expbuilder.parameter("geom").as_geometry_variable()
+                        .srs(expbuilder.parameter().value(proj)) 
+        );
+
+        System.out.println("# Test:: testPerformUpdates");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "UPDATE \"test1\" SET \"name\" = ?, \"geom\" = ST_GeomFromWKB((?), (?)) WHERE ( (\"id\") = (?) )",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[geom, id, name]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[\"name\", \"geom\", 4326, \"id\"]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+
+    public void testGrant1() throws Exception {
+
+        SQLBuilder sqlbuilder = createSQLBuilder();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.grant().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.grant().role("prueba").select().insert().update();
+        sqlbuilder.grant().role("gis").all();
+                
+        
+        System.out.println("# Test:: testGrant1");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+
+    public void testGrant2() throws Exception {
+
+        SQLBuilder sqlbuilder = new SQLBuilderBase();
+        ExpressionBuilder expbuilder = sqlbuilder.expression();
+
+        sqlbuilder.grant().table().database("master").schema("dbo").name("test1");
+        sqlbuilder.grant().role("prueba").privilege(Privilege.SELECT)
+                .privilege(Privilege.INSERT)
+                .privilege(Privilege.UPDATE);
+        sqlbuilder.grant().role("gis").privilege(Privilege.ALL);
+                
+        
+        System.out.println("# Test:: testGrant2");
+        System.out.println("# SQL:: " + sqlbuilder.toString());
+        System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names()));
+        System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names()));
+        assertEquals(
+                "",
+                sqlbuilder.toString()
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.variables_names())
+        );
+        assertEquals(
+                "[]",
+                ArrayUtils.toString(sqlbuilder.parameters_names())
+        );
+    }
+
+
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/IsNull.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/IsNull.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/IsNull.java	(revision 44198)
@@ -0,0 +1,49 @@
+package org.gvsig.fmap.dal.store.h2.expressionbuilderformatter;
+
+import java.text.MessageFormat;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.gvsig.expressionevaluator.Code.Constant;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Function;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.OPERATOR_IS;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
+import org.gvsig.expressionevaluator.Formatter;
+import org.gvsig.fmap.dal.SQLBuilder;
+
+/**
+ *
+ * @author jjdelcerro
+ */
+class IsNull implements Formatter<Value> {
+
+    private final Formatter<Value> formatter;
+    private final SQLBuilder builder;
+    
+    public IsNull(SQLBuilder builder, Formatter<Value> formatter) {
+        this.builder = builder;
+        this.formatter = formatter;
+    }
+    
+    @Override
+    public boolean canApply(Value value) {
+        if (value instanceof Function) {
+            if( StringUtils.equalsIgnoreCase(OPERATOR_IS, ((Function) value).name()) ) {
+                List<Value> parameters = ((Function) value).parameters();
+                Value p2 = parameters.get(1);
+                if( p2 instanceof Constant && ((Constant)p2).value()==null ) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public String format(Value function) {
+        List<Value> parameters = ((Function) function).parameters();
+        String p1 = parameters.get(0).toString(formatter);
+        String r = MessageFormat.format("( ({0}) IS NULL )", p1);
+        return r;
+    }
+    
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/IsNotNull.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/IsNotNull.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/IsNotNull.java	(revision 44198)
@@ -0,0 +1,62 @@
+package org.gvsig.fmap.dal.store.h2.expressionbuilderformatter;
+
+import java.text.MessageFormat;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.gvsig.expressionevaluator.Code.Constant;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Function;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.OPERATOR_IS;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.OPERATOR_NOT;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
+import org.gvsig.expressionevaluator.Formatter;
+import org.gvsig.fmap.dal.SQLBuilder;
+
+/**
+ *
+ * @author jjdelcerro
+ */
+class IsNotNull implements Formatter<Value> {
+
+    private final Formatter<Value> formatter;
+    private final SQLBuilder builder;
+    
+    public IsNotNull(SQLBuilder builder, Formatter<Value> formatter) {
+        this.builder = builder;
+        this.formatter = formatter;
+    }
+    
+    @Override
+    public boolean canApply(Value value_not) {
+        if (value_not instanceof Function) {
+            // NOT( IS( p1, NULL) )
+            if( StringUtils.equalsIgnoreCase(OPERATOR_NOT, ((Function) value_not).name()) ) {
+                List<Value> parameters = ((Function) value_not).parameters();
+                Value value_is = parameters.get(0);
+                if( value_is instanceof Function && StringUtils.equalsIgnoreCase(OPERATOR_IS, ((Function)value_is).name()) ) {
+                    List<Value> parameters_is = ((Function)value_is).parameters();
+                    Value is_p2 = parameters_is.get(1);
+                    if( is_p2 instanceof Constant && ((Constant)is_p2).value()==null ) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public String format(Value value_not) {
+        // NOT( IS( p1, NULL) )
+
+        List<Value> parameters = ((Function) value_not).parameters();
+        Value value_is = parameters.get(0);
+        List<Value> parameters_is = ((Function)value_is).parameters();
+        Value is_p1 = parameters_is.get(0);
+        String r = MessageFormat.format(
+                "( ({0}) IS NOT NULL )", 
+                is_p1.toString(formatter)
+        );
+        return r;
+    }
+    
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/IfNull.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/IfNull.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/IfNull.java	(revision 44198)
@@ -0,0 +1,54 @@
+package org.gvsig.fmap.dal.store.h2.expressionbuilderformatter;
+
+import java.text.MessageFormat;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.gvsig.expressionevaluator.Code.Constant;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_IFNULL;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Function;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.OPERATOR_IS;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
+import org.gvsig.expressionevaluator.Formatter;
+import org.gvsig.fmap.dal.SQLBuilder;
+
+/**
+ *
+ * @author jjdelcerro
+ */
+class IfNull implements Formatter<Value> {
+
+    private final Formatter<Value> formatter;
+    private final SQLBuilder builder;
+    
+    public IfNull(SQLBuilder builder, Formatter<Value> formatter) {
+        this.builder = builder;
+        this.formatter = formatter;
+    }
+    
+    @Override
+    public boolean canApply(Value value) {
+        if (value instanceof Function) {
+            if (value instanceof ExpressionBuilder.Function) {
+                return StringUtils.equalsIgnoreCase(FUNCTION_IFNULL, ((Function) value).name());
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public String format(Value function) {
+            List<Value> parameters = ((Function) function).parameters();
+            String p1 = parameters.get(0).toString(formatter);
+            String p2 = parameters.get(1).toString(formatter);
+            String p3 = parameters.get(2).toString(formatter);
+            String r = MessageFormat.format(
+                    "NVL2({0}, {1}, {2})",
+                    p1,
+                    p3,
+                    p2
+            );
+            return r;
+    }
+    
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/ST_Intersects.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/ST_Intersects.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/ST_Intersects.java	(revision 44198)
@@ -0,0 +1,43 @@
+package org.gvsig.fmap.dal.store.h2.expressionbuilderformatter;
+
+import java.text.MessageFormat;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_ST_INTERSECTS;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Function;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
+import org.gvsig.expressionevaluator.Formatter;
+import org.gvsig.fmap.dal.SQLBuilder;
+
+/**
+ *
+ * @author jjdelcerro
+ */
+public class ST_Intersects implements Formatter<Value> {
+    
+    private final SQLBuilder sqlbuilder;
+    private final Formatter<Value> formatter;
+    
+    public ST_Intersects(SQLBuilder sqlbuilder, Formatter<Value> formatter) {
+        this.sqlbuilder = sqlbuilder;
+        this.formatter = formatter;
+    }
+    @Override
+    public boolean canApply(ExpressionBuilder.Value value) {
+        if (value instanceof ExpressionBuilder.Function) {
+            return StringUtils.equalsIgnoreCase(FUNCTION_ST_INTERSECTS, ((Function) value).name());
+        }
+        return false;
+    }
+
+    @Override
+    public String format(Value function) {
+        List<Value> parameters = ((Function) function).parameters();
+        String p1 = parameters.get(0).toString(formatter);
+        String p2 = parameters.get(1).toString(formatter);
+        String r = MessageFormat.format("( (({0}) && ({1})) AND ST_Intersects(({0}),({1}) ))", p1, p2);
+        return r;
+    }
+    
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/ST_GeomFromEWKB.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/ST_GeomFromEWKB.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/ST_GeomFromEWKB.java	(revision 44198)
@@ -0,0 +1,43 @@
+package org.gvsig.fmap.dal.store.h2.expressionbuilderformatter;
+
+import java.text.MessageFormat;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_ST_GEOMFROMEWKB;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Function;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
+import org.gvsig.expressionevaluator.Formatter;
+import org.gvsig.fmap.dal.SQLBuilder;
+
+/**
+ *
+ * @author jjdelcerro
+ */
+class ST_GeomFromEWKB implements Formatter<Value> {
+
+    private final Formatter<Value> formatter;
+    private final SQLBuilder builder;
+    
+    public ST_GeomFromEWKB(SQLBuilder builder, Formatter<Value> formatter) {
+        this.builder = builder;
+        this.formatter = formatter;
+    }
+    
+    @Override
+    public boolean canApply(Value value) {
+        if (value instanceof Function) {
+            return StringUtils.equalsIgnoreCase(FUNCTION_ST_GEOMFROMEWKB, ((Function) value).name());
+        }
+        return false;
+    }
+
+    @Override
+    public String format(Value function) {
+        List<Value> parameters = ((Function) function).parameters();
+        String p1 = parameters.get(0).toString(formatter);
+        String p2 = parameters.get(1).toString(formatter);
+        String r = MessageFormat.format("ST_GeomFromWKB({0}, {1})", p1, p2);
+        return r;
+    }
+    
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/H2SpatialFormatter.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/H2SpatialFormatter.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/H2SpatialFormatter.java	(revision 44198)
@@ -0,0 +1,50 @@
+package org.gvsig.fmap.dal.store.h2.expressionbuilderformatter;
+
+import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
+import org.gvsig.expressionevaluator.Formatter;
+import org.gvsig.fmap.dal.SQLBuilder;
+
+/**
+ *
+ * @author jjdelcerro
+ */
+public class H2SpatialFormatter implements Formatter<Value> {
+
+    private final SQLBuilder builder;
+    private final Formatter<ExpressionBuilder.Value>[] formatters;
+
+    public H2SpatialFormatter(SQLBuilder builder) {
+
+        this.builder = builder;
+        this.formatters = new Formatter[]{
+            new IfNull(this.builder, this),
+            new IsNotNull(this.builder, this),
+            new IsNull(this.builder, this),
+            new ST_AsEWKB(this.builder, this),
+            new ST_GeomFromEWKB(this.builder, this),
+            new ST_Intersects(this.builder, this)
+        };
+    }
+
+    @Override
+    public boolean canApply(Value value) {
+        for (Formatter<Value> formatter : formatters) {
+            if (formatter.canApply(value)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public String format(Value value) {
+        for (Formatter<Value> formatter : formatters) {
+            if (formatter.canApply(value)) {
+                return formatter.format(value);
+            }
+        }
+        return value.toString(this);
+    }
+    
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/ST_AsEWKB.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/ST_AsEWKB.java	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/expressionbuilderformatter/ST_AsEWKB.java	(revision 44198)
@@ -0,0 +1,43 @@
+package org.gvsig.fmap.dal.store.h2.expressionbuilderformatter;
+
+import java.text.MessageFormat;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import static org.gvsig.expressionevaluator.ExpressionBuilder.FUNCTION_ST_ASEWKB;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Function;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Value;
+import org.gvsig.expressionevaluator.Formatter;
+import org.gvsig.fmap.dal.SQLBuilder;
+
+/**
+ *
+ * @author jjdelcerro
+ */
+class ST_AsEWKB implements Formatter<Value> {
+
+    private final Formatter<Value> formatter;
+    private final SQLBuilder builder;
+    
+    public ST_AsEWKB(SQLBuilder builder, Formatter<Value> formatter) {
+        this.builder = builder;
+        this.formatter = formatter;
+    }
+    
+    @Override
+    public boolean canApply(Value value) {
+        if (value instanceof Function) {
+            return StringUtils.equalsIgnoreCase(FUNCTION_ST_ASEWKB, ((Function) value).name());
+        }
+        return false;
+    }
+
+    @Override
+    public String format(Value function) {
+        List<Value> parameters = ((Function) function).parameters();
+        String p1 = parameters.get(0).toString(formatter);
+        String p2 = parameters.get(1).toString(formatter);
+        String r = MessageFormat.format("ST_AsWKB({0}, {1})", p1, p2);
+        return r;
+    }
+    
+}
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialConnectionParametersHelper.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialConnectionParametersHelper.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialConnectionParametersHelper.java	(revision 44198)
@@ -30,9 +30,8 @@
 
     public void validate() throws ValidateDataParametersException {
         if( this.getDynValue(JDBCConnectionParameters.JDBC_DRIVER_CLASS_PARAMTER_NAME) == null ) {
-            this.setDynValue(
-                JDBCConnectionParameters.JDBC_DRIVER_CLASS_PARAMTER_NAME,
-                H2SpatialHelper.H2SpatialJDBCDriver
+            this.setDynValue(JDBCConnectionParameters.JDBC_DRIVER_CLASS_PARAMTER_NAME,
+                H2SpatialHelper.H2SPATIAL_JDBC_DRIVER
             );
         }
         if( getFile() == null ) {
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialLibrary.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialLibrary.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialLibrary.java	(revision 44198)
@@ -53,9 +53,9 @@
                 (DataManagerProviderServices) DALLocator.getDataManager();
 
         try {
-            Class.forName(H2SpatialHelper.H2SpatialJDBCDriver);
+            Class.forName(H2SpatialHelper.H2SPATIAL_JDBC_DRIVER);
         } catch(Throwable th) {
-            H2SpatialHelper.logger.warn("Can't load H2Spatial JDBC Driver.",th);
+            H2SpatialHelper.LOGGER.warn("Can't load H2Spatial JDBC Driver.",th);
         }
         
         DBHelper.registerParametersDefinition(
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilder.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilder.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilder.java	(revision 44198)
@@ -1,21 +1,28 @@
 package org.gvsig.fmap.dal.store.h2;
 
 import java.sql.PreparedStatement;
+import java.sql.SQLException;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import org.apache.commons.lang3.tuple.Pair;
+import org.gvsig.expressionevaluator.ExpressionBuilder.Parameter;
+import org.gvsig.expressionevaluator.Formatter;
 import org.gvsig.fmap.dal.DataTypes;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.dal.feature.spi.FeatureProvider;
+import org.gvsig.fmap.dal.store.h2.expressionbuilderformatter.H2SpatialFormatter;
 import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase;
 import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.exception.CreateGeometryException;
 import org.gvsig.tools.dispose.Disposable;
 
 public class H2SpatialSQLBuilder extends JDBCSQLBuilderBase {
 
+    protected Formatter formatter = null;
+    
     public H2SpatialSQLBuilder(H2SpatialHelper helper) {
         super(helper);
         
@@ -30,54 +37,53 @@
         // http://www.h2database.com/html/datatypes.html
         //
         //
+
         
-        config.set(SQLConfig.default_schema, "");
-        config.set(SQLConfig.support_schemas, false);
-        config.set(SQLConfig.allowAutomaticValues, true);
-        config.set(SQLConfig.geometry_type_support, this.helper.getGeometrySupportType());
-        config.set(SQLConfig.has_spatial_functions, this.helper.hasSpatialFunctions());
+        this.defaultSchema = "";
+        this.supportSchemas = false;
+        this.allowAutomaticValues = true;
+        this.geometrySupportType = this.helper.getGeometrySupportType();
+        this.hasSpatialFunctions = this.helper.hasSpatialFunctions();
 
-        config.remove_functionality(SQLConfig.DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table);
-        config.remove_functionality(SQLConfig.DELETE_GEOMETRY_COLUMN_FROM_TABLE_table);
+        this.STMT_DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table = null;
+        this.STMT_DELETE_GEOMETRY_COLUMN_FROM_TABLE_table = null;
          
-//        config.set(SQLConfig.UPDATE_TABLE_STATISTICS_table,"ANALYZE TABLE {0} SAMPLE_SIZE 0");
-        config.set(SQLConfig.UPDATE_TABLE_STATISTICS_table,"ANALYZE SAMPLE_SIZE 0");
+        this.STMT_UPDATE_TABLE_STATISTICS_table = "ANALYZE SAMPLE_SIZE 0";
 
-        config.set(SQLConfig.ST_GeomFromEWKB, "GeomFromWKB({0}, {1})");
-        config.set(SQLConfig.ST_AsEWKB, "AsWKB(({0}))");        
-        config.set(SQLConfig.ST_Intersects, "( (({0}) && ({1})) AND ST_Intersects(({0}),({1}) ))");  
-        config.set(SQLConfig.ST_AsBinary, "NVL2({0}, ST_AsBinary({0}), null)");
-        
-        config.set(SQLConfig.lcase, "LOWER({0})");
-        config.set(SQLConfig.ucase, "UPPER({0})");
-        config.set(SQLConfig.operator_ILIKE, "({0}) ILIKE ({1})");
-        config.set(SQLConfig.isNull, "( ({0}) IS NULL )");
-        config.set(SQLConfig.notIsNull, "( ({0}) IS NOT NULL )");
+//        config.set(SQLConfig.ST_AsBinary, "NVL2({0}, ST_AsBinary({0}), null)");
 
-        config.set(SQLConfig.type_boolean, "BOOLEAN");
-        config.set(SQLConfig.type_byte, "TINYINT");
-        config.set(SQLConfig.type_bytearray, "TINYINT");
-        config.set(SQLConfig.type_geometry, "GEOMETRY");
-        config.set(SQLConfig.type_char, "CHAR");
-        config.set(SQLConfig.type_date, "DATE");
-        config.set(SQLConfig.type_double, "DOUBLE"); 
-        config.set(SQLConfig.type_numeric_p, "DECIMAL({0})");
-        config.set(SQLConfig.type_numeric_ps, "DECIMAL({0},{1})");
-        config.set(SQLConfig.type_bigdecimal, "DOUBLE");
-        config.set(SQLConfig.type_float, "REAL");
-        config.set(SQLConfig.type_int, "INTEGER");
-        config.set(SQLConfig.type_long, "BIGINT");
-        config.set(SQLConfig.type_string, "VARCHAR");
-        config.set(SQLConfig.type_string_p, "VARCHAR({0})");
-        config.set(SQLConfig.type_time, "TIME");
-        config.set(SQLConfig.type_timestamp, "TIMESTAMP");
-        config.set(SQLConfig.type_version, "VARCHAR");
-        config.set(SQLConfig.type_URI, "VARCHAR");
-        config.set(SQLConfig.type_URL, "VARCHAR");
-        config.set(SQLConfig.type_FILE, "VARCHAR");
-        config.set(SQLConfig.type_FOLDER, "VARCHAR");        
+        this.type_boolean = "BOOLEAN";
+        this.type_byte = "TINYINT";
+        this.type_bytearray = "TINYINT";
+        this.type_geometry = "GEOMETRY";
+        this.type_char = "CHAR";
+        this.type_date = "DATE";
+        this.type_double = "DOUBLE"; 
+        this.type_numeric_p = "DECIMAL({0})";
+        this.type_numeric_ps = "DECIMAL({0},{1})";
+        this.type_bigdecimal = "DOUBLE";
+        this.type_float = "REAL";
+        this.type_int = "INTEGER";
+        this.type_long = "BIGINT";
+        this.type_string = "VARCHAR";
+        this.type_string_p = "VARCHAR({0})";
+        this.type_time = "TIME";
+        this.type_timestamp = "TIMESTAMP";
+        this.type_version = "VARCHAR";
+        this.type_URI = "VARCHAR";
+        this.type_URL = "VARCHAR";
+        this.type_FILE = "VARCHAR";
+        this.type_FOLDER = "VARCHAR";        
     }
 
+    @Override
+    protected Formatter formatter() {
+        if( this.formatter==null ) {
+            this.formatter = new H2SpatialFormatter(this);
+        }
+        return this.formatter;
+    }
+
     public class H2SpatialTableNameBuilderBase extends TableNameBuilderBase {
 
         @Override
@@ -95,7 +101,7 @@
     public class H2SpatialCreateIndexBuilder extends CreateIndexBuilderBase {
     
         @Override
-        public List<String> toStrings() {
+        public List<String> toStrings(Formatter formatter) {
             StringBuilder builder = new StringBuilder();
             builder.append("CREATE ");
             if( this.isUnique ) {
@@ -108,9 +114,9 @@
             if( this.ifNotExist ) {
                 builder.append("IF NOT EXISTS ");
             }
-            builder.append(identifier(this.indexName));
+            builder.append(as_identifier(this.indexName));
             builder.append(" ON ");
-            builder.append(this.table.toString());
+            builder.append(this.table.toString(formatter));
             builder.append(" ( ");
             boolean is_first_column = true;
             for( String column : this.columns) {
@@ -119,7 +125,7 @@
                 } else {
                     builder.append(", ");
                 }
-                builder.append(identifier(column));
+                builder.append(as_identifier(column));
             }
             builder.append(" )");
             
@@ -132,7 +138,7 @@
         
     protected class H2SpatialAlterTableBuilderBase extends AlterTableBuilderBase {
         @Override
-        public List<String> toStrings() {
+        public List<String> toStrings(Formatter formatter) {
             List<String> sqls = new ArrayList<>();
             if( this.isEmpty() ) {
                 return sqls;
@@ -140,17 +146,17 @@
             for (String column : drops) {
                 StringBuilder builder = new StringBuilder();
                 builder.append("ALTER TABLE ");
-                builder.append(this.table.toString());
+                builder.append(this.table.toString(formatter));
                 builder.append(" DROP COLUMN IF EXISTS ");
-                builder.append(identifier(column)); 
+                builder.append(as_identifier(column)); 
                 sqls.add(builder.toString());
             }
             for (ColumnDescriptor column : adds) {
                 StringBuilder builder = new StringBuilder();
                 builder.append("ALTER TABLE ");
-                builder.append(this.table.toString());
+                builder.append(this.table.toString(formatter));
                 builder.append(" ADD COLUMN ");
-                builder.append(identifier(column.getName())); 
+                builder.append(as_identifier(column.getName())); 
                 builder.append(" ");
                 if( column.getType() == DataTypes.INT && column.isAutomatic() ) {
                     builder.append(" SERIAL");
@@ -200,9 +206,9 @@
             for (ColumnDescriptor column : alters) {
                 StringBuilder builder = new StringBuilder();
                 builder.append("ALTER TABLE ");
-                builder.append(this.table.toString());
+                builder.append(this.table.toString(formatter));
                 builder.append(" ALTER COLUMN ");
-                builder.append(identifier(column.getName())); 
+                builder.append(as_identifier(column.getName())); 
                 builder.append(" ");
                 builder.append(
                     sqltype(
@@ -242,11 +248,11 @@
             for (Pair<String,String> pair : renames) {
                 StringBuilder builder = new StringBuilder();
                 builder.append("ALTER TABLE ");
-                builder.append(this.table.toString());
+                builder.append(this.table.toString(formatter));
                 builder.append(" RENAME COLUMN ");
-                builder.append(identifier(pair.getLeft())); 
+                builder.append(as_identifier(pair.getLeft())); 
                 builder.append(" TO ");
-                builder.append(identifier(pair.getRight())); 
+                builder.append(as_identifier(pair.getRight())); 
                 sqls.add(builder.toString());
             }
             return sqls;
@@ -257,13 +263,13 @@
     protected class H2SpatialCreateTableBuilder extends CreateTableBuilderBase {
 
         @Override
-        public List<String> toStrings() {
+        public List<String> toStrings(Formatter formatter) {
 
             List<String> sqls = new ArrayList<>();
             StringBuilder builder = new StringBuilder();
 
             builder.append("CREATE TABLE ");
-            builder.append(this.table.toString());
+            builder.append(this.table.toString(formatter));
             builder.append(" (");
             boolean first = true;
             for (ColumnDescriptor column : columns) {
@@ -273,7 +279,7 @@
                 } else {
                     builder.append(", ");
                 }
-                builder.append(identifier(column.getName()));
+                builder.append(as_identifier(column.getName()));
                 builder.append(" ");
                 builder.append(
                     sqltype(
@@ -364,7 +370,7 @@
         }        
         
         @Override
-        public String toString() {
+        public String toString(Formatter formatter) {
             StringBuilder builder = new StringBuilder();
             if( !isValid(builder) ) {
                 throw new IllegalStateException(builder.toString());
@@ -380,16 +386,16 @@
                 } else {
                     builder.append(", ");
                 }
-                builder.append(column.toString());
+                builder.append(column.toString(formatter));
             }
 
             if ( this.has_from() ) {
                 builder.append(" FROM ");
-                builder.append(this.from.toString());
+                builder.append(this.from.toString(formatter));
             }
             if ( this.has_where() ) {
                 builder.append(" WHERE ");
-                builder.append(this.where.toString());
+                builder.append(this.where.toString(formatter));
             }
             
             if( this.has_order_by() ) {
@@ -401,7 +407,7 @@
                     } else {
                         builder.append(", ");
                     }
-                    builder.append(item.toString());                    
+                    builder.append(item.toString(formatter));                    
                 }   
             }
             
@@ -425,20 +431,6 @@
     }
 
     @Override
-    public String bytearray(byte[] data) {
-        // H2Spatial usa un formato diferencte para especificar un array de 
-        // bytes. En lugar de 0x... usa x'...' .
-        StringBuilder builder = new StringBuilder();
-        builder.append("x'");
-        for (byte abyte : data) {
-            int v = abyte & 0xff;
-            builder.append(String.format("%02x", v));
-        }
-        builder.append("'");
-        return builder.toString();
-    }
-
-    @Override
     public Object sqlgeometrydimension(int type, int subtype) {
         //'XY' or 2: 2D points, identified by X and Y coordinates
         //'XYM': 2D points, identified by X and Y coordinates. Each point stores an M-value (measure) as well
@@ -502,6 +494,7 @@
         return dimensions;
     }
     
+    @Override
     public H2SpatialHelper getHelper() {
         return (H2SpatialHelper) this.helper;
     }
@@ -511,11 +504,11 @@
         try {
             FeatureType featureType = feature.getType();
             List<Object> values = new ArrayList<>();
-            for (Parameter parameter : this.getParameters()) {
+            for (Parameter parameter : this.parameters()) {
                 if (parameter.is_constant()) {
-                    values.add(parameter.getValue());
+                    values.add(parameter.value());
                 } else {
-                    String name = parameter.getName();
+                    String name = parameter.name();
                     FeatureAttributeDescriptor descriptor = featureType.getAttributeDescriptor(name);
                     switch( descriptor.getType() ) {
                     case DataTypes.DATE:
@@ -540,7 +533,7 @@
                 }
             }
             return this.setStatementParameters(st, values, this.geometry_support_type());
-        } catch (Exception ex) {
+        } catch (SQLException | CreateGeometryException ex) {
             String f = "unknow";
             try {
                 f = feature.toString();
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialAppendOperation.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialAppendOperation.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/operations/H2SpatialAppendOperation.java	(revision 44198)
@@ -3,6 +3,7 @@
 
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import org.gvsig.expressionevaluator.ExpressionBuilder;
 import org.gvsig.fmap.dal.DataTypes;
 import org.gvsig.fmap.dal.exception.DataException;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
@@ -20,7 +21,7 @@
 
 @SuppressWarnings("UseSpecificCatch")
 public class H2SpatialAppendOperation extends AppendOperation {
-    
+
     public H2SpatialAppendOperation(
             JDBCHelper helper, 
             TableReference table, 
@@ -39,6 +40,7 @@
             this.connection = this.helper.getConnectionWritable();
             
             this.sqlbuilder = this.helper.createSQLBuilder();
+            this.expbuilder = this.sqlbuilder.expression();
 
             this.sqlbuilder.insert().table()
                 .database(this.table.getDatabase())
@@ -50,13 +52,13 @@
                 }
                 if (attr.getType() == DataTypes.GEOMETRY) {
                     this.sqlbuilder.insert().column().name(attr.getName()).with_value( 
-                        sqlbuilder.parameter(attr.getName()).as_geometry_variable().srs( 
-                                sqlbuilder.parameter().value(attr.getSRS()) 
+                        this.expbuilder.parameter(attr.getName()).as_geometry_variable().srs( 
+                                this.expbuilder.parameter().value(attr.getSRS()) 
                         ) 
                     );
                 } else {
                     this.sqlbuilder.insert().column().name(attr.getName()).with_value(
-                        sqlbuilder.parameter(attr.getName()).as_variable()
+                        this.expbuilder.parameter(attr.getName()).as_variable()
                     );
                 }
             }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialHelper.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialHelper.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/main/java/org/gvsig/fmap/dal/store/h2/H2SpatialHelper.java	(revision 44198)
@@ -27,7 +27,7 @@
 import org.apache.commons.dbcp.BasicDataSource;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.gvsig.fmap.dal.SQLBuilder;
+import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType;
 import org.gvsig.fmap.dal.exception.InitializeException;
 import org.gvsig.fmap.dal.resource.exception.AccessResourceException;
 import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
@@ -48,11 +48,12 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@SuppressWarnings("UseSpecificCatch")
 public class H2SpatialHelper extends JDBCHelperBase {
 
-    static final Logger logger = LoggerFactory.getLogger(H2SpatialHelper.class);
+    static final Logger LOGGER = LoggerFactory.getLogger(H2SpatialHelper.class);
 
-    public static final String H2SpatialJDBCDriver = "org.h2.Driver";
+    public static final String H2SPATIAL_JDBC_DRIVER = "org.h2.Driver";
     
     public static String getConnectionURL(H2SpatialConnectionParameters params) {
         String connectionURL;
@@ -88,7 +89,7 @@
                 dbfilename
             );
         }
-        logger.debug("connectionURL: {}", connectionURL);
+        LOGGER.debug("connectionURL: {}", connectionURL);
         return connectionURL;
     }
 
@@ -115,11 +116,11 @@
                     Server theServer = Server.createTcpServer("-tcpPort", port, /*"-tcpAllowOthers",*/ "-ifExists");
                     theServer.start();
                     server = theServer;
-                    logger.info("H2 Server started" );
-                    logger.info("  port  :"+ server.getPort());
-                    logger.info("  status:"+ server.getStatus());
+                    LOGGER.info("H2 Server started" );
+                    LOGGER.info("  port  :"+ server.getPort());
+                    LOGGER.info("  status:"+ server.getStatus());
                 } catch (SQLException ex) {
-                    logger.warn("H2 Server not started",ex);
+                    LOGGER.warn("H2 Server not started",ex);
                 }
                 // Tanto si consigue lanzar el server como si no, no lo vuelve a intentar
                 startServer = false;
@@ -192,61 +193,6 @@
 
     }
 
-//    private static class ConnectionProvider {
-//
-//        private static boolean needRegisterDriver = true;
-//
-//
-//        private final H2SpatialConnectionParameters connectionParameters;
-//
-//        public ConnectionProvider(H2SpatialConnectionParameters connectionParameters) {
-//            this.connectionParameters = connectionParameters;
-//        }
-//
-//        public Connection getConnection() throws SQLException {
-//            if (!this.isRegistered()) {
-//                this.registerDriver();
-//            }
-//            Connection conn;
-//            if( !StringUtils.isEmpty(connectionParameters.getUser()) ) {
-//                conn = DriverManager.getConnection(
-//                    connectionParameters.getUrl(),
-//                    connectionParameters.getUser(),
-//                    connectionParameters.getPassword()
-//                );
-//            } else {
-//                conn = DriverManager.getConnection(connectionParameters.getUrl());
-//            }
-//            try {
-//                conn.createStatement().execute("SELECT TOP 1 SRID FROM SPATIAL_REF_SYS");
-//            } catch(SQLException ex) {
-//                H2GISExtension.load(conn);
-//            }
-//            return conn;
-//        }
-//
-//        private boolean isRegistered() {
-//            return needRegisterDriver;
-//        }
-//
-//        public void registerDriver() throws SQLException {
-//            String className = this.connectionParameters.getJDBCDriverClassName();
-//            if (className == null) {
-//                return;
-//            }
-//            try {
-//                Class theClass = Class.forName(className);
-//                if (theClass == null) {
-//                    throw new JDBCDriverClassNotFoundException(H2SpatialLibrary.NAME, className);
-//                }
-//            } catch (Exception e) {
-//                throw new SQLException("Can't register JDBC driver '" + className + "'.", e);
-//            }
-//            needRegisterDriver = false;
-//        }
-//
-//    }
-
     private ConnectionProvider connectionProvider = null;
    
     public H2SpatialHelper(JDBCConnectionParameters connectionParameters) {
@@ -261,8 +207,8 @@
                 this.connectionProvider = new ConnectionProvider(this.getConnectionParameters());
             }
             Connection connection = this.connectionProvider.getConnection();
-            if( logger.isDebugEnabled() ) {
-                logger.debug("getConnection: connection = "+connection.hashCode()+ connectionProvider.toString());
+            if( LOGGER.isDebugEnabled() ) {
+                LOGGER.debug("getConnection: connection = "+connection.hashCode()+ connectionProvider.toString());
             }
             return connection;
         } catch (SQLException ex) {
@@ -272,7 +218,7 @@
 
     @Override
     public void closeConnection(Connection connection) {
-        logger.debug("closeConnection: connection = "+connection.hashCode());
+        LOGGER.debug("closeConnection: connection = "+connection.hashCode());
         super.closeConnection(connection);
     }
     
@@ -310,8 +256,8 @@
     }
 
     @Override
-    public SQLBuilder.GeometrySupportType getGeometrySupportType() {
-        return SQLBuilder.GeometrySupportType.WKB;
+    public GeometrySupportType getGeometrySupportType() {
+        return GeometrySupportType.WKB;
     }
 
     @Override
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/pom.xml
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/pom.xml	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/pom.xml	(revision 44198)
@@ -41,22 +41,19 @@
             <artifactId>org.gvsig.fmap.dal.api</artifactId>
             <scope>compile</scope>
         </dependency>
-    
         <dependency>
             <groupId>org.gvsig</groupId>
-            <artifactId>org.gvsig.fmap.dal.db.jdbc</artifactId>
+            <artifactId>org.gvsig.fmap.dal.spi</artifactId>
             <scope>compile</scope>
         </dependency>
-
         <dependency>
             <groupId>org.gvsig</groupId>
             <artifactId>org.gvsig.fmap.dal.db.lib</artifactId>
             <scope>compile</scope>
         </dependency>
-    
         <dependency>
             <groupId>org.gvsig</groupId>
-            <artifactId>org.gvsig.fmap.dal.spi</artifactId>
+            <artifactId>org.gvsig.fmap.dal.db.jdbc</artifactId>
             <scope>compile</scope>
         </dependency>
 
@@ -87,6 +84,21 @@
             <version>1.3.0</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>${org.gvsig.fmap.geometry.impl}</artifactId>
+            <scope>test</scope>
+        </dependency>    
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>org.gvsig.expressionevaluator.lib.impl</artifactId>
+            <scope>test</scope>
+        </dependency>    
+        <dependency>
+            <groupId>org.gvsig</groupId>
+            <artifactId>${org.gvsig.proj.lib.impl}</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/Launcher.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/Launcher.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/Launcher.java	(revision 44198)
@@ -198,8 +198,6 @@
  * </p>
  *
  *
- * @author $author$
- * @version $Revision: 40305 $
  */
 public class Launcher {
 
@@ -989,7 +987,7 @@
 
     /**
      * Obtiene la personalizaci�n de los iconos, splash, fondo y el nombre de
-     * la aplicaci�n.
+     * la aplicacion.
      *
      * @return Theme
      */
@@ -2902,8 +2900,6 @@
      * defined.</li>
      * </ul>
      *
-     * @author cesar
-     * @version $Revision: 40305 $
      */
     private static class ToolComparator implements Comparator<SortableTool> {
 
@@ -3171,8 +3167,6 @@
      * <br>
      * -exclusiveUI={pathToExtensionClass} <br>
      *
-     * @see org.gvsig.andami.plugins.IExtension#isEnabled(IExtension extension)
-     * @see org.gvsig.andami.plugins.IExtension#isVisible(IExtension extension)
      */
     private static void initializeExclusiveUIExtension() {
         String name = PluginServices.getArgumentByName("exclusiveUI");
@@ -3295,7 +3289,6 @@
     /**
      * Manages Andami termination process
      *
-     * @author Cesar Martinez Izquierdo <cesar.martinez@iver.es>
      */
     public class TerminationProcess {
 
@@ -4183,5 +4176,4 @@
         }
         logger.info("Loaded an identity manager from plugin '" + plugin.getPluginName() + ".");
     }
-
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/FilesystemExplorerWizardPanel.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/FilesystemExplorerWizardPanel.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/fmap/dal/serverexplorer/filesystem/swing/FilesystemExplorerWizardPanel.java	(revision 44198)
@@ -15,10 +15,12 @@
 import javax.swing.filechooser.FileFilter;
 
 import org.cresques.cts.IProjection;
+import org.gvsig.andami.PluginsLocator;
+import org.gvsig.andami.PluginsManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.gvsig.andami.Launcher;
+//import org.gvsig.andami.Launcher;
 import org.gvsig.app.ApplicationLocator;
 import org.gvsig.app.ApplicationManager;
 import org.gvsig.app.gui.WizardPanel;
@@ -274,7 +276,8 @@
                         if (isTiled(parameters)) {
                             DynObject tileParameters = dataManager.createStoreParameters("TileCache");
 
-                            File rootFolder = new File(Launcher.getAppHomeDir() + File.separator + "gvsig_rcache");
+                            PluginsManager pluginsManager = PluginsLocator.getManager();
+                            File rootFolder = new File(pluginsManager.getApplicationHomeFolder(),"gvsig_rcache");
 
                             if (tileParameters.getDynClass().getDynField("rootFolder") != null) {
                                 tileParameters.setDynValue("rootFolder", rootFolder);
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/symboltables/functionPanels/fetch/FetchAditionalPanelView.xml
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/symboltables/functionPanels/fetch/FetchAditionalPanelView.xml	(revision 0)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/symboltables/functionPanels/fetch/FetchAditionalPanelView.xml	(revision 44198)
@@ -0,0 +1,1537 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<object classname="com.jeta.forms.store.memento.FormPackage">
+ <at name="fileversion">
+  <object classname="com.jeta.forms.store.memento.FormsVersion2">
+   <at name="major">2</at>
+   <at name="minor">0</at>
+   <at name="sub">0</at>
+  </object>
+ </at>
+ <at name="form">
+  <object classname="com.jeta.forms.store.memento.FormMemento">
+   <super classname="com.jeta.forms.store.memento.ComponentMemento">
+    <at name="cellconstraints">
+     <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+      <at name="column">1</at>
+      <at name="row">1</at>
+      <at name="colspan">1</at>
+      <at name="rowspan">1</at>
+      <at name="halign">default</at>
+      <at name="valign">default</at>
+      <at name="insets" object="insets">0,0,0,0</at>
+     </object>
+    </at>
+    <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
+   </super>
+   <at name="id">/home/jjdelcerro/datos/devel/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/symboltables/functionPanels/fetch/FetchAditionalPanelView.xml</at>
+   <at name="path">datos/devel/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/symboltables/functionPanels/fetch/FetchAditionalPanelView.xml</at>
+   <at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE</at>
+   <at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE</at>
+   <at name="components">
+    <object classname="java.util.LinkedList">
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">2</at>
+           <at name="row">2</at>
+           <at name="colspan">3</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="name">lblTitle</at>
+            <at name="width">855</at>
+            <at name="text">FETCH</at>
+            <at name="fill">
+             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
+              <at name="name">fill</at>
+             </object>
+            </at>
+            <at name="font">
+             <object classname="com.jeta.forms.store.properties.FontProperty">
+              <at name="family">Dialog</at>
+              <at name="style">1</at>
+              <at name="size">11</at>
+             </object>
+            </at>
+            <at name="height">14</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">4</at>
+           <at name="row">20</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">right</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">javax.swing.JButton</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">javax.swing.JButton</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="actionCommand">_Insert_function</at>
+            <at name="name">btnInsertFunction</at>
+            <at name="width">122</at>
+            <at name="text">_Insert_function</at>
+            <at name="height">22</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">2</at>
+           <at name="row">12</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="name">lblValue</at>
+            <at name="width">46</at>
+            <at name="text">_Value</at>
+            <at name="fill">
+             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
+              <at name="name">fill</at>
+             </object>
+            </at>
+            <at name="height">14</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">2</at>
+           <at name="row">14</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="name">lblFilter</at>
+            <at name="width">46</at>
+            <at name="text">_Filter</at>
+            <at name="fill">
+             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
+              <at name="name">fill</at>
+             </object>
+            </at>
+            <at name="height">14</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">2</at>
+           <at name="row">16</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="name">lblOrder</at>
+            <at name="width">46</at>
+            <at name="text">_Order</at>
+            <at name="fill">
+             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
+              <at name="name">fill</at>
+             </object>
+            </at>
+            <at name="height">14</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">2</at>
+           <at name="row">4</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="name">lblSource</at>
+            <at name="width">46</at>
+            <at name="text">_Source</at>
+            <at name="fill">
+             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
+              <at name="name">fill</at>
+             </object>
+            </at>
+            <at name="height">14</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">4</at>
+           <at name="row">4</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">javax.swing.JComboBox</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">javax.swing.JComboBox</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="selectedItem">
+             <object classname="com.jeta.forms.store.properties.ListItemProperty">
+              <at name="name">listitem</at>
+              <at name="label">Table</at>
+              <at name="icon">
+               <object classname="com.jeta.forms.store.properties.IconProperty">
+                <at name="embedded">false</at>
+                <at name="description"></at>
+                <at name="width">0</at>
+                <at name="height">0</at>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="name">cboSourceMode</at>
+            <at name="width">798</at>
+            <at name="items">
+             <object classname="com.jeta.forms.store.properties.ItemsProperty">
+              <at name="name">items</at>
+              <at name="items">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.ListItemProperty">
+                   <at name="name">listitem</at>
+                   <at name="label">Table</at>
+                   <at name="icon">
+                    <object classname="com.jeta.forms.store.properties.IconProperty">
+                     <at name="embedded">false</at>
+                     <at name="description"></at>
+                     <at name="width">0</at>
+                     <at name="height">0</at>
+                    </object>
+                   </at>
+                  </object>
+                 </at>
+                </item>
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.ListItemProperty">
+                   <at name="name">listitem</at>
+                   <at name="label">Layer</at>
+                   <at name="icon">
+                    <object classname="com.jeta.forms.store.properties.IconProperty">
+                     <at name="embedded">false</at>
+                     <at name="description"></at>
+                     <at name="width">0</at>
+                     <at name="height">0</at>
+                    </object>
+                   </at>
+                  </object>
+                 </at>
+                </item>
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.ListItemProperty">
+                   <at name="name">listitem</at>
+                   <at name="label">Other</at>
+                   <at name="icon">
+                    <object classname="com.jeta.forms.store.properties.IconProperty">
+                     <at name="embedded">false</at>
+                     <at name="description"></at>
+                     <at name="width">0</at>
+                     <at name="height">0</at>
+                    </object>
+                   </at>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="height">18</at>
+            <at name="itemCount">3</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">4</at>
+           <at name="row">6</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">javax.swing.JComboBox</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">javax.swing.JComboBox</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="name">cboSource1</at>
+            <at name="width">798</at>
+            <at name="items">
+             <object classname="com.jeta.forms.store.properties.ItemsProperty">
+              <at name="name">items</at>
+             </object>
+            </at>
+            <at name="height">20</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">4</at>
+           <at name="row">8</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">javax.swing.JComboBox</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">javax.swing.JComboBox</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="name">cboSource2</at>
+            <at name="width">798</at>
+            <at name="items">
+             <object classname="com.jeta.forms.store.properties.ItemsProperty">
+              <at name="name">items</at>
+             </object>
+            </at>
+            <at name="height">20</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">2</at>
+           <at name="row">10</at>
+           <at name="colspan">3</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">javax.swing.JCheckBox</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">javax.swing.JCheckBox</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList">
+                <item >
+                 <at name="value">
+                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                  </object>
+                 </at>
+                </item>
+               </object>
+              </at>
+             </object>
+            </at>
+            <at name="actionCommand">_use_selection</at>
+            <at name="horizontalAlignment">11</at>
+            <at name="name">chkUseSelection</at>
+            <at name="width">855</at>
+            <at name="horizontalTextPosition">2</at>
+            <at name="text">_use_selection</at>
+            <at name="height">16</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.BeanMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">2</at>
+           <at name="row">18</at>
+           <at name="colspan">3</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+        </super>
+        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+        <at name="beanclass">javax.swing.JTextField</at>
+        <at name="beanproperties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">javax.swing.JTextField</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList"/>
+              </at>
+             </object>
+            </at>
+            <at name="background" object="color">236,233,216</at>
+            <at name="editable">false</at>
+            <at name="name">txtPreview</at>
+            <at name="width">855</at>
+            <at name="height">14</at>
+           </object>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.FormMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">4</at>
+           <at name="row">12</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
+        </super>
+        <at name="id">embedded.841901615</at>
+        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
+        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
+        <at name="components">
+         <object classname="java.util.LinkedList">
+          <item >
+           <at name="value">
+            <object classname="com.jeta.forms.store.memento.BeanMemento">
+             <super classname="com.jeta.forms.store.memento.ComponentMemento">
+              <at name="cellconstraints">
+               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+                <at name="column">1</at>
+                <at name="row">1</at>
+                <at name="colspan">1</at>
+                <at name="rowspan">1</at>
+                <at name="halign">default</at>
+                <at name="valign">default</at>
+                <at name="insets" object="insets">0,0,0,0</at>
+               </object>
+              </at>
+              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+             </super>
+             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+             <at name="beanclass">javax.swing.JTextField</at>
+             <at name="beanproperties">
+              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+               <at name="classname">javax.swing.JTextField</at>
+               <at name="properties">
+                <object classname="com.jeta.forms.store.support.PropertyMap">
+                 <at name="border">
+                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                   <at name="borders">
+                    <object classname="java.util.LinkedList">
+                     <item >
+                      <at name="value">
+                       <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                        <super classname="com.jeta.forms.store.properties.BorderProperty">
+                         <at name="name">border</at>
+                        </super>
+                       </object>
+                      </at>
+                     </item>
+                    </object>
+                   </at>
+                  </object>
+                 </at>
+                 <at name="name">txtValue</at>
+                 <at name="width">770</at>
+                 <at name="height">20</at>
+                </object>
+               </at>
+              </object>
+             </at>
+            </object>
+           </at>
+          </item>
+          <item >
+           <at name="value">
+            <object classname="com.jeta.forms.store.memento.BeanMemento">
+             <super classname="com.jeta.forms.store.memento.ComponentMemento">
+              <at name="cellconstraints">
+               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+                <at name="column">3</at>
+                <at name="row">1</at>
+                <at name="colspan">1</at>
+                <at name="rowspan">1</at>
+                <at name="halign">default</at>
+                <at name="valign">default</at>
+                <at name="insets" object="insets">0,0,0,0</at>
+               </object>
+              </at>
+              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+             </super>
+             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+             <at name="beanclass">javax.swing.JButton</at>
+             <at name="beanproperties">
+              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+               <at name="classname">javax.swing.JButton</at>
+               <at name="properties">
+                <object classname="com.jeta.forms.store.support.PropertyMap">
+                 <at name="border">
+                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                   <at name="borders">
+                    <object classname="java.util.LinkedList">
+                     <item >
+                      <at name="value">
+                       <object classname="com.jeta.forms.store.properties.EmptyBorderProperty">
+                        <super classname="com.jeta.forms.store.properties.BorderProperty">
+                         <at name="name">border</at>
+                        </super>
+                        <at name="top">2</at>
+                        <at name="left">2</at>
+                        <at name="bottom">2</at>
+                        <at name="right">2</at>
+                       </object>
+                      </at>
+                     </item>
+                    </object>
+                   </at>
+                  </object>
+                 </at>
+                 <at name="name">btnValue</at>
+                 <at name="width">12</at>
+                 <at name="height">12</at>
+                </object>
+               </at>
+              </object>
+             </at>
+            </object>
+           </at>
+          </item>
+         </object>
+        </at>
+        <at name="properties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">com.jeta.forms.gui.form.GridView</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList"/>
+              </at>
+             </object>
+            </at>
+            <at name="name"></at>
+            <at name="fill">
+             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
+              <at name="name">fill</at>
+             </object>
+            </at>
+            <at name="scollBars">
+             <object classname="com.jeta.forms.store.properties.ScrollBarsProperty">
+              <at name="name">scollBars</at>
+              <at name="verticalpolicy">21</at>
+              <at name="horizontalpolicy">31</at>
+              <at name="border">
+               <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+                <super classname="com.jeta.forms.store.properties.BorderProperty">
+                 <at name="name">border</at>
+                </super>
+                <at name="borders">
+                 <object classname="java.util.LinkedList">
+                  <item >
+                   <at name="value">
+                    <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                     <super classname="com.jeta.forms.store.properties.BorderProperty">
+                      <at name="name">border</at>
+                     </super>
+                    </object>
+                   </at>
+                  </item>
+                 </object>
+                </at>
+               </object>
+              </at>
+             </object>
+            </at>
+           </object>
+          </at>
+         </object>
+        </at>
+        <at name="cellpainters">
+         <object classname="com.jeta.forms.store.support.Matrix">
+          <at name="rows">
+           <object classname="[Ljava.lang.Object;" size="1">
+            <at name="item" index="0">
+             <object classname="[Ljava.lang.Object;" size="3"/>
+            </at>
+           </object>
+          </at>
+         </object>
+        </at>
+        <at name="rowgroups">
+         <object classname="com.jeta.forms.store.memento.FormGroupSet">
+          <at name="groups">
+           <object classname="java.util.HashMap"/>
+          </at>
+         </object>
+        </at>
+        <at name="colgroups">
+         <object classname="com.jeta.forms.store.memento.FormGroupSet">
+          <at name="groups">
+           <object classname="java.util.HashMap"/>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.FormMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">4</at>
+           <at name="row">14</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
+        </super>
+        <at name="id">embedded.1158219727</at>
+        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
+        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
+        <at name="components">
+         <object classname="java.util.LinkedList">
+          <item >
+           <at name="value">
+            <object classname="com.jeta.forms.store.memento.BeanMemento">
+             <super classname="com.jeta.forms.store.memento.ComponentMemento">
+              <at name="cellconstraints">
+               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+                <at name="column">1</at>
+                <at name="row">1</at>
+                <at name="colspan">1</at>
+                <at name="rowspan">1</at>
+                <at name="halign">default</at>
+                <at name="valign">default</at>
+                <at name="insets" object="insets">0,0,0,0</at>
+               </object>
+              </at>
+              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+             </super>
+             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+             <at name="beanclass">javax.swing.JTextField</at>
+             <at name="beanproperties">
+              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+               <at name="classname">javax.swing.JTextField</at>
+               <at name="properties">
+                <object classname="com.jeta.forms.store.support.PropertyMap">
+                 <at name="border">
+                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                   <at name="borders">
+                    <object classname="java.util.LinkedList">
+                     <item >
+                      <at name="value">
+                       <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                        <super classname="com.jeta.forms.store.properties.BorderProperty">
+                         <at name="name">border</at>
+                        </super>
+                       </object>
+                      </at>
+                     </item>
+                    </object>
+                   </at>
+                  </object>
+                 </at>
+                 <at name="name">txtFilter</at>
+                 <at name="width">770</at>
+                 <at name="height">20</at>
+                </object>
+               </at>
+              </object>
+             </at>
+            </object>
+           </at>
+          </item>
+          <item >
+           <at name="value">
+            <object classname="com.jeta.forms.store.memento.BeanMemento">
+             <super classname="com.jeta.forms.store.memento.ComponentMemento">
+              <at name="cellconstraints">
+               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+                <at name="column">3</at>
+                <at name="row">1</at>
+                <at name="colspan">1</at>
+                <at name="rowspan">1</at>
+                <at name="halign">default</at>
+                <at name="valign">default</at>
+                <at name="insets" object="insets">0,0,0,0</at>
+               </object>
+              </at>
+              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+             </super>
+             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+             <at name="beanclass">javax.swing.JButton</at>
+             <at name="beanproperties">
+              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+               <at name="classname">javax.swing.JButton</at>
+               <at name="properties">
+                <object classname="com.jeta.forms.store.support.PropertyMap">
+                 <at name="border">
+                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                   <at name="borders">
+                    <object classname="java.util.LinkedList">
+                     <item >
+                      <at name="value">
+                       <object classname="com.jeta.forms.store.properties.EmptyBorderProperty">
+                        <super classname="com.jeta.forms.store.properties.BorderProperty">
+                         <at name="name">border</at>
+                        </super>
+                        <at name="top">2</at>
+                        <at name="left">2</at>
+                        <at name="bottom">2</at>
+                        <at name="right">2</at>
+                       </object>
+                      </at>
+                     </item>
+                    </object>
+                   </at>
+                  </object>
+                 </at>
+                 <at name="name">btnFilter</at>
+                 <at name="width">12</at>
+                 <at name="height">12</at>
+                </object>
+               </at>
+              </object>
+             </at>
+            </object>
+           </at>
+          </item>
+         </object>
+        </at>
+        <at name="properties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">com.jeta.forms.gui.form.GridView</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList"/>
+              </at>
+             </object>
+            </at>
+            <at name="name"/>
+            <at name="fill">
+             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
+              <at name="name">fill</at>
+             </object>
+            </at>
+            <at name="scollBars">
+             <object classname="com.jeta.forms.store.properties.ScrollBarsProperty">
+              <at name="name">scollBars</at>
+              <at name="verticalpolicy">21</at>
+              <at name="horizontalpolicy">31</at>
+              <at name="border">
+               <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+                <super classname="com.jeta.forms.store.properties.BorderProperty">
+                 <at name="name">border</at>
+                </super>
+                <at name="borders">
+                 <object classname="java.util.LinkedList">
+                  <item >
+                   <at name="value">
+                    <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                     <super classname="com.jeta.forms.store.properties.BorderProperty">
+                      <at name="name">border</at>
+                     </super>
+                    </object>
+                   </at>
+                  </item>
+                 </object>
+                </at>
+               </object>
+              </at>
+             </object>
+            </at>
+           </object>
+          </at>
+         </object>
+        </at>
+        <at name="cellpainters">
+         <object classname="com.jeta.forms.store.support.Matrix">
+          <at name="rows">
+           <object classname="[Ljava.lang.Object;" size="1">
+            <at name="item" index="0">
+             <object classname="[Ljava.lang.Object;" size="3"/>
+            </at>
+           </object>
+          </at>
+         </object>
+        </at>
+        <at name="rowgroups">
+         <object classname="com.jeta.forms.store.memento.FormGroupSet">
+          <at name="groups">
+           <object classname="java.util.HashMap"/>
+          </at>
+         </object>
+        </at>
+        <at name="colgroups">
+         <object classname="com.jeta.forms.store.memento.FormGroupSet">
+          <at name="groups">
+           <object classname="java.util.HashMap"/>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+     <item >
+      <at name="value">
+       <object classname="com.jeta.forms.store.memento.FormMemento">
+        <super classname="com.jeta.forms.store.memento.ComponentMemento">
+         <at name="cellconstraints">
+          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+           <at name="column">4</at>
+           <at name="row">16</at>
+           <at name="colspan">1</at>
+           <at name="rowspan">1</at>
+           <at name="halign">default</at>
+           <at name="valign">default</at>
+           <at name="insets" object="insets">0,0,0,0</at>
+          </object>
+         </at>
+         <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
+        </super>
+        <at name="id">embedded.441915799</at>
+        <at name="rowspecs">CENTER:DEFAULT:NONE</at>
+        <at name="colspecs">FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE</at>
+        <at name="components">
+         <object classname="java.util.LinkedList">
+          <item >
+           <at name="value">
+            <object classname="com.jeta.forms.store.memento.BeanMemento">
+             <super classname="com.jeta.forms.store.memento.ComponentMemento">
+              <at name="cellconstraints">
+               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+                <at name="column">1</at>
+                <at name="row">1</at>
+                <at name="colspan">1</at>
+                <at name="rowspan">1</at>
+                <at name="halign">default</at>
+                <at name="valign">default</at>
+                <at name="insets" object="insets">0,0,0,0</at>
+               </object>
+              </at>
+              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+             </super>
+             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+             <at name="beanclass">javax.swing.JTextField</at>
+             <at name="beanproperties">
+              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+               <at name="classname">javax.swing.JTextField</at>
+               <at name="properties">
+                <object classname="com.jeta.forms.store.support.PropertyMap">
+                 <at name="border">
+                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                   <at name="borders">
+                    <object classname="java.util.LinkedList">
+                     <item >
+                      <at name="value">
+                       <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                        <super classname="com.jeta.forms.store.properties.BorderProperty">
+                         <at name="name">border</at>
+                        </super>
+                       </object>
+                      </at>
+                     </item>
+                    </object>
+                   </at>
+                  </object>
+                 </at>
+                 <at name="name">txtOrder</at>
+                 <at name="width">766</at>
+                 <at name="enabled">false</at>
+                 <at name="height">20</at>
+                </object>
+               </at>
+              </object>
+             </at>
+            </object>
+           </at>
+          </item>
+          <item >
+           <at name="value">
+            <object classname="com.jeta.forms.store.memento.BeanMemento">
+             <super classname="com.jeta.forms.store.memento.ComponentMemento">
+              <at name="cellconstraints">
+               <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
+                <at name="column">3</at>
+                <at name="row">1</at>
+                <at name="colspan">1</at>
+                <at name="rowspan">1</at>
+                <at name="halign">default</at>
+                <at name="valign">default</at>
+                <at name="insets" object="insets">0,0,0,0</at>
+               </object>
+              </at>
+              <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
+             </super>
+             <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
+             <at name="beanclass">javax.swing.JButton</at>
+             <at name="beanproperties">
+              <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+               <at name="classname">javax.swing.JButton</at>
+               <at name="properties">
+                <object classname="com.jeta.forms.store.support.PropertyMap">
+                 <at name="border">
+                  <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+                   <super classname="com.jeta.forms.store.properties.BorderProperty">
+                    <at name="name">border</at>
+                   </super>
+                   <at name="borders">
+                    <object classname="java.util.LinkedList">
+                     <item >
+                      <at name="value">
+                       <object classname="com.jeta.forms.store.properties.EmptyBorderProperty">
+                        <super classname="com.jeta.forms.store.properties.BorderProperty">
+                         <at name="name">border</at>
+                        </super>
+                        <at name="top">2</at>
+                        <at name="left">2</at>
+                        <at name="bottom">2</at>
+                        <at name="right">2</at>
+                       </object>
+                      </at>
+                     </item>
+                    </object>
+                   </at>
+                  </object>
+                 </at>
+                 <at name="actionCommand">...</at>
+                 <at name="name">btnOrder</at>
+                 <at name="width">16</at>
+                 <at name="text">...</at>
+                 <at name="enabled">false</at>
+                 <at name="height">18</at>
+                </object>
+               </at>
+              </object>
+             </at>
+            </object>
+           </at>
+          </item>
+         </object>
+        </at>
+        <at name="properties">
+         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+          <at name="classname">com.jeta.forms.gui.form.GridView</at>
+          <at name="properties">
+           <object classname="com.jeta.forms.store.support.PropertyMap">
+            <at name="border">
+             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+              <super classname="com.jeta.forms.store.properties.BorderProperty">
+               <at name="name">border</at>
+              </super>
+              <at name="borders">
+               <object classname="java.util.LinkedList"/>
+              </at>
+             </object>
+            </at>
+            <at name="name">btnOrder</at>
+            <at name="fill">
+             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
+              <at name="name">fill</at>
+             </object>
+            </at>
+            <at name="scollBars">
+             <object classname="com.jeta.forms.store.properties.ScrollBarsProperty">
+              <at name="name">scollBars</at>
+              <at name="verticalpolicy">21</at>
+              <at name="horizontalpolicy">31</at>
+              <at name="border">
+               <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+                <super classname="com.jeta.forms.store.properties.BorderProperty">
+                 <at name="name">border</at>
+                </super>
+                <at name="borders">
+                 <object classname="java.util.LinkedList">
+                  <item >
+                   <at name="value">
+                    <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                     <super classname="com.jeta.forms.store.properties.BorderProperty">
+                      <at name="name">border</at>
+                     </super>
+                    </object>
+                   </at>
+                  </item>
+                 </object>
+                </at>
+               </object>
+              </at>
+             </object>
+            </at>
+           </object>
+          </at>
+         </object>
+        </at>
+        <at name="cellpainters">
+         <object classname="com.jeta.forms.store.support.Matrix">
+          <at name="rows">
+           <object classname="[Ljava.lang.Object;" size="1">
+            <at name="item" index="0">
+             <object classname="[Ljava.lang.Object;" size="3"/>
+            </at>
+           </object>
+          </at>
+         </object>
+        </at>
+        <at name="rowgroups">
+         <object classname="com.jeta.forms.store.memento.FormGroupSet">
+          <at name="groups">
+           <object classname="java.util.HashMap"/>
+          </at>
+         </object>
+        </at>
+        <at name="colgroups">
+         <object classname="com.jeta.forms.store.memento.FormGroupSet">
+          <at name="groups">
+           <object classname="java.util.HashMap"/>
+          </at>
+         </object>
+        </at>
+       </object>
+      </at>
+     </item>
+    </object>
+   </at>
+   <at name="properties">
+    <object classname="com.jeta.forms.store.memento.PropertiesMemento">
+     <at name="classname">com.jeta.forms.gui.form.GridView</at>
+     <at name="properties">
+      <object classname="com.jeta.forms.store.support.PropertyMap">
+       <at name="border">
+        <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+         <super classname="com.jeta.forms.store.properties.BorderProperty">
+          <at name="name">border</at>
+         </super>
+         <at name="borders">
+          <object classname="java.util.LinkedList"/>
+         </at>
+        </object>
+       </at>
+       <at name="name"></at>
+       <at name="fill">
+        <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
+         <at name="name">fill</at>
+        </object>
+       </at>
+       <at name="scollBars">
+        <object classname="com.jeta.forms.store.properties.ScrollBarsProperty">
+         <at name="name">scollBars</at>
+         <at name="verticalpolicy">21</at>
+         <at name="horizontalpolicy">31</at>
+         <at name="border">
+          <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
+           <super classname="com.jeta.forms.store.properties.BorderProperty">
+            <at name="name">border</at>
+           </super>
+           <at name="borders">
+            <object classname="java.util.LinkedList">
+             <item >
+              <at name="value">
+               <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
+                <super classname="com.jeta.forms.store.properties.BorderProperty">
+                 <at name="name">border</at>
+                </super>
+               </object>
+              </at>
+             </item>
+            </object>
+           </at>
+          </object>
+         </at>
+        </object>
+       </at>
+      </object>
+     </at>
+    </object>
+   </at>
+   <at name="cellpainters">
+    <object classname="com.jeta.forms.store.support.Matrix">
+     <at name="rows">
+      <object classname="[Ljava.lang.Object;" size="21">
+       <at name="item" index="0">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="1">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="2">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="3">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="4">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="5">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="6">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="7">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="8">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="9">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="10">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="11">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="12">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="13">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="14">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="15">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="16">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="17">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="18">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="19">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+       <at name="item" index="20">
+        <object classname="[Ljava.lang.Object;" size="5"/>
+       </at>
+      </object>
+     </at>
+    </object>
+   </at>
+   <at name="rowgroups">
+    <object classname="com.jeta.forms.store.memento.FormGroupSet">
+     <at name="groups">
+      <object classname="java.util.HashMap"/>
+     </at>
+    </object>
+   </at>
+   <at name="colgroups">
+    <object classname="com.jeta.forms.store.memento.FormGroupSet">
+     <at name="groups">
+      <object classname="java.util.HashMap"/>
+     </at>
+    </object>
+   </at>
+  </object>
+ </at>
+</object>
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/expressionevaluator/viewcapturerectangle/ViewCaptureRectangleElement.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/expressionevaluator/viewcapturerectangle/ViewCaptureRectangleElement.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/expressionevaluator/viewcapturerectangle/ViewCaptureRectangleElement.java	(revision 44198)
@@ -1,10 +1,9 @@
 package org.gvsig.app.project.documents.view.expressionevaluator.viewcapturerectangle;
 
-import java.awt.Dialog;
-import java.awt.Window;
 import org.gvsig.app.ApplicationLocator;
 import org.gvsig.app.ApplicationManager;
 import org.gvsig.expressionevaluator.ExpressionBuilder;
+import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType;
 import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
 import org.gvsig.expressionevaluator.swing.Element.CalculatedElement;
 import org.gvsig.expressionevaluator.swing.Element.SimpleElement;
@@ -45,22 +44,16 @@
             ExpressionBuilder builder = ExpressionEvaluatorLocator.getManager().createExpressionBuilder();
             if (this.aditionalPanel.insertAsWKT()) {
                 if (this.aditionalPanel.insertAsGeometry()) {
-                    builder.getConfig().set(
-                            ExpressionBuilder.Config.geometry_type_support,
-                            ExpressionBuilder.GeometrySupportType.WKT
-                    );
-                    return builder.geometry(geom, geom.getProjection()).toString();
+                    builder.geometry_support_type(GeometrySupportType.WKT);
+                    return builder.geometry(geom).toString();
                 } else {
                     String wkt = geom.convertToWKT();
                     return "'" + wkt + "'";
                 }
             } else {
                 if (this.aditionalPanel.insertAsGeometry()) {
-                    builder.getConfig().set(
-                            ExpressionBuilder.Config.geometry_type_support,
-                            ExpressionBuilder.GeometrySupportType.WKB
-                    );
-                    return builder.geometry(geom, geom.getProjection()).toString();
+                    builder.geometry_support_type(GeometrySupportType.WKB);
+                    return builder.geometry(geom).toString();
                 } else {
                     byte[] wkb = geom.convertToWKB();
                     return builder.bytearray_hex(wkb);
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/expressionevaluator/viewcapturepoint/ViewCapturePointElement.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/expressionevaluator/viewcapturepoint/ViewCapturePointElement.java	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/expressionevaluator/viewcapturepoint/ViewCapturePointElement.java	(revision 44198)
@@ -1,11 +1,8 @@
 package org.gvsig.app.project.documents.view.expressionevaluator.viewcapturepoint;
 
-import java.awt.Dialog;
-import java.awt.Window;
 import org.gvsig.app.ApplicationLocator;
 import org.gvsig.app.ApplicationManager;
 import org.gvsig.expressionevaluator.ExpressionBuilder;
-import org.gvsig.expressionevaluator.ExpressionBuilder.Config;
 import org.gvsig.expressionevaluator.ExpressionBuilder.GeometrySupportType;
 import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
 import org.gvsig.expressionevaluator.swing.Element.CalculatedElement;
@@ -47,10 +44,7 @@
             ExpressionBuilder builder = ExpressionEvaluatorLocator.getManager().createExpressionBuilder();
             if (this.aditionalPanel.insertAsWKT()) {
                 if (this.aditionalPanel.insertAsGeometry()) {
-                    builder.getConfig().set(
-                            Config.geometry_type_support,
-                            GeometrySupportType.WKT
-                    );
+                    builder.geometry_support_type(GeometrySupportType.WKT);
                     return builder.geometry(geom, geom.getProjection()).toString();
                 } else {
                     String wkt = geom.convertToWKT();
@@ -58,10 +52,7 @@
                 }
             } else {
                 if (this.aditionalPanel.insertAsGeometry()) {
-                    builder.getConfig().set(
-                            Config.geometry_type_support,
-                            GeometrySupportType.WKB
-                    );
+                    builder.geometry_support_type(GeometrySupportType.WKB);
                     return builder.geometry(geom, geom.getProjection()).toString();
                 } else {
                     byte[] wkb = geom.convertToWKB();
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/pom.xml
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/pom.xml	(revision 44197)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/pom.xml	(revision 44198)
@@ -54,7 +54,8 @@
         <dependency>
             <groupId>org.gvsig</groupId>
             <artifactId>org.gvsig.andami</artifactId>
-            <scope>compile</scope>
+            <version>2.0.242-SNAPSHOT</version>
+            <type>jar</type>
         </dependency>
         <dependency>
             <groupId>org.gvsig</groupId>
@@ -309,8 +310,7 @@
         <dependency>
             <groupId>org.gvsig</groupId>
             <artifactId>org.gvsig.expressionevaluator.swing.api</artifactId>
-            <version>2.0.242-SNAPSHOT</version>
-            <type>jar</type>
+            <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.gvsig</groupId>
Index: trunk/org.gvsig.desktop/pom.xml
===================================================================
--- trunk/org.gvsig.desktop/pom.xml	(revision 44197)
+++ trunk/org.gvsig.desktop/pom.xml	(revision 44198)
@@ -349,16 +349,6 @@
                 <artifactId>commons-cli</artifactId>
                 <version>1.4</version>
             </dependency>
-<!--            <dependency>
-                <groupId>commons-io</groupId>
-                <artifactId>commons-io</artifactId>
-                <version>2.4</version>
-            </dependency>-->
-<!--            <dependency>
-                <groupId>org.apache.commons</groupId>
-                <artifactId>commons-lang3</artifactId>
-                <version>3.1</version>
-            </dependency>-->
             <dependency>
                 <groupId>commons-lang</groupId>
                 <artifactId>commons-lang</artifactId>
@@ -390,17 +380,17 @@
                 <artifactId>commons-pool</artifactId>
                 <version>1.6</version>
             </dependency>
-
             <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-text</artifactId>
+                <version>1.6</version>
+            </dependency>
+            
+            <dependency>
                 <groupId>org.dspace</groupId>
                 <artifactId>cql-java</artifactId>
                 <version>1.0</version>
             </dependency>
-<!--            <dependency>
-                <groupId>easymock</groupId>
-                <artifactId>easymock</artifactId>
-                <version>1.2_Java1.3</version>
-            </dependency>-->
             <dependency>
                 <groupId>easymock</groupId>
                 <artifactId>easymockclassextension</artifactId>
@@ -411,16 +401,6 @@
                 <artifactId>flanagan</artifactId>
                 <version>20090616</version>
             </dependency>
-<!--            <dependency>
-                <groupId>net.sf</groupId>
-                <artifactId>flib-jcalendar</artifactId>
-                <version>unknown</version>
-            </dependency>-->
-<!--            <dependency>
-                    <groupId>com.jeta</groupId>
-                    <artifactId>formsrt</artifactId>
-                    <version>2.1.0_M3-1</version>
-            </dependency>-->
             <dependency>
                 <groupId>org.opengis</groupId>
                 <artifactId>geoapi</artifactId>
@@ -638,11 +618,6 @@
                 <artifactId>jzkit2-origin</artifactId>
                 <version>2.0.0</version>
             </dependency>
-<!--            <dependency>
-                <groupId>net.sf.kxml</groupId>
-                <artifactId>kxml2</artifactId>
-                <version>2.2.2</version>
-            </dependency>-->
             <dependency>
                 <groupId>log4j</groupId>
                 <artifactId>log4j</artifactId>
@@ -653,22 +628,7 @@
                 <artifactId>log4jdbc</artifactId>
                 <version>1.2</version>
             </dependency>
-<!--            <dependency>
-                <groupId>com.jgoodies</groupId>
-                <artifactId>jgoodies-common</artifactId>
-                <version>1.4.0</version>
-            </dependency>
             <dependency>
-                <groupId>com.jgoodies</groupId>
-                <artifactId>jgoodies-forms</artifactId>
-                <version>1.6.0</version>
-            </dependency>
-            <dependency>
-                <groupId>com.jgoodies</groupId>
-                <artifactId>looks</artifactId>
-                <version>2.2.2</version>
-            </dependency>-->
-            <dependency>
                 <groupId>com.ostermiller</groupId>
                 <artifactId>ostermillerutils</artifactId>
                 <version>1.4.3</version>
@@ -738,17 +698,7 @@
                 <artifactId>sil</artifactId>
                 <version>0.43b-am1</version>
             </dependency>
-<!--            <dependency>
-                <groupId>org.slf4j</groupId>
-                <artifactId>slf4j-api</artifactId>
-                <version>1.5.5</version>
-            </dependency>
             <dependency>
-                <groupId>org.slf4j</groupId>
-                <artifactId>slf4j-log4j12</artifactId>
-                <version>1.5.5</version>
-            </dependency>-->
-            <dependency>
                 <groupId>net.sf.smc</groupId>
                 <artifactId>smc</artifactId>
                 <version>4.3</version>
@@ -863,53 +813,9 @@
             </dependency>
 <!--            <dependency>
                 <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.tools.lib</artifactId>
-                <version>${gvsig.tools.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.tools.lib</artifactId>
-                <version>${gvsig.tools.version}</version>
-                <type>test-jar</type>
-                <scope>test</test>
-            </dependency>
-            <dependency>
-                <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.tools.swing.api</artifactId>
-                <version>${gvsig.tools.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.tools.swing.impl</artifactId>
-                <version>${gvsig.tools.version}</version>
-            </dependency>-->
-<!--
-            <dependency>
-                <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.tools.dynform.api</artifactId>
-                <version>${gvsig.tools.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.tools.dynform.spi</artifactId>
-                <version>${gvsig.tools.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.tools.dynform.services</artifactId>
-                <version>${gvsig.tools.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.tools.dynform.impl</artifactId>
-                <version>${gvsig.tools.version}</version>
-            </dependency>-->
-
-            <dependency>
-                <groupId>org.gvsig</groupId>
                 <artifactId>org.gvsig.catalog</artifactId>
                 <version>2.0</version>
-            </dependency>
+            </dependency>-->
             <dependency>
                 <groupId>org.gvsig.external</groupId>
                 <artifactId>org.gvsig.external.jump</artifactId>
@@ -1113,11 +1019,11 @@
                 <artifactId>org.gvsig.newlayer.lib.impl</artifactId>
                 <version>2.0.242-SNAPSHOT</version>
             </dependency>
-            <dependency>
+<!--            <dependency>
                 <groupId>org.gvsig</groupId>
                 <artifactId>org.gvsig.newlayer.prov.generic</artifactId>
                 <version>2.0.46-SNAPSHOT</version>
-            </dependency>
+            </dependency>-->
             <dependency>
                 <groupId>org.gvsig</groupId>
                 <artifactId>org.gvsig.newlayer.prov.file</artifactId>
@@ -1153,20 +1059,8 @@
                 <artifactId>org.gvsig.fmap.geometry.api</artifactId>
                 <version>2.0.242-SNAPSHOT</version>
             </dependency>
-            <!--
             <dependency>
                 <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.fmap.geometry.generalpath</artifactId>
-                <version>2.0.103-SNAPSHOT</version>
-            </dependency>
-            <dependency>
-                <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.fmap.geometry.operation</artifactId>
-                <version>2.0.103-SNAPSHOT</version>
-            </dependency>
-            -->
-            <dependency>
-                <groupId>org.gvsig</groupId>
                 <artifactId>org.gvsig.fmap.geometry.jts</artifactId>
                 <version>2.0.242-SNAPSHOT</version>
             </dependency>
@@ -1408,13 +1302,6 @@
                 <artifactId>org.gvsig.installer.app.mainplugin</artifactId>
                 <version>2.0.242-SNAPSHOT</version>
             </dependency>
-            <!--
-                      <dependency>
-                        <groupId>org.gvsig</groupId>
-                        <artifactId>org.gvsig.symbology.app.mainplugin</artifactId>
-                        <version>2.0.10-SNAPSHOT</version>
-                      </dependency>
-            -->
             <dependency>
                 <groupId>org.gvsig</groupId>
                 <artifactId>org.gvsig.i18n.app.mainplugin</artifactId>
@@ -1435,15 +1322,8 @@
                 <artifactId>org.gvsig.newlayer.app.mainplugin</artifactId>
                 <version>2.0.242-SNAPSHOT</version>
             </dependency>
-            <!--
             <dependency>
                 <groupId>org.gvsig</groupId>
-                <artifactId>org.gvsig.help.app.mainplugin</artifactId>
-                <version>2.0.24-SNAPSHOT</version>
-            </dependency>
-            -->
-            <dependency>
-                <groupId>org.gvsig</groupId>
                 <artifactId>org.gvsig.timesupport.lib.api</artifactId>
                 <version>2.0.242-SNAPSHOT</version>
             </dependency>
@@ -2657,7 +2537,7 @@
 
         <jython.artifactId>jython-standalone</jython.artifactId>
         <!-- External project versions -->
-        <gvsig.tools.version>3.0.182</gvsig.tools.version>
+        <gvsig.tools.version>3.0.184-SNAPSHOT</gvsig.tools.version>
         <gvsig.proj.version>1.0.4</gvsig.proj.version>
         <gvsig.projection.api.version>2.0.25</gvsig.projection.api.version>
 
