Index: branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/integration/EvaluatorDataAdapter.java
===================================================================
--- branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/integration/EvaluatorDataAdapter.java	(revision 0)
+++ branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/integration/EvaluatorDataAdapter.java	(revision 43827)
@@ -0,0 +1,71 @@
+
+package org.gvsig.expressionevaluator.integration;
+
+import java.util.Iterator;
+import org.gvsig.expressionevaluator.Function;
+import org.gvsig.expressionevaluator.SymbolTable;
+import org.gvsig.tools.evaluator.EvaluatorData;
+
+
+public class EvaluatorDataAdapter implements SymbolTable {
+
+    private EvaluatorData data;
+    private final SymbolTable symbolTable;
+
+    EvaluatorDataAdapter(SymbolTable symbolTable) {
+        this.symbolTable = symbolTable;
+    }
+
+    public void setData(EvaluatorData data) {
+        this.data = data;
+    }
+
+    @Override
+    public Function function(String name) {
+        return symbolTable.function(name);
+    }
+
+    @Override
+    @SuppressWarnings("CloneDoesntCallSuperClone")
+    public SymbolTable clone() throws CloneNotSupportedException {
+        throw new CloneNotSupportedException("This class can't be cloned.");
+    }
+    
+    @Override
+    public boolean exists(String name) {
+        if( data.hasDataValue(name) ) {
+            return true;
+        }
+        if( data.hasContextValue(name) ) {
+            return true;
+        }
+        return symbolTable.exists(name);
+    }
+
+    @Override
+    public Object value(String name) {
+        if( data.hasDataValue(name) ) {
+            return data.getDataValue(name);
+        }
+        if( data.hasContextValue(name) ) {
+            return data.getContextValue(name);
+        }
+        return symbolTable.value(name);
+    }
+
+    @Override
+    public Iterator<String> itervars() {
+        return null;
+    }
+
+    @Override
+    public Iterator<Function> iterfuncs() {
+        return symbolTable.iterfuncs();
+    }
+
+    @Override
+    public Iterator<Function> iterator() {
+        return symbolTable.iterfuncs();
+    }
+
+}
Index: branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/integration/DefaultEvaluatorFactory.java
===================================================================
--- branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/integration/DefaultEvaluatorFactory.java	(revision 0)
+++ branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/integration/DefaultEvaluatorFactory.java	(revision 43827)
@@ -0,0 +1,22 @@
+package org.gvsig.expressionevaluator.integration;
+
+import org.gvsig.expressionevaluator.ExpressionEvaluator;
+import org.gvsig.fmap.dal.EvaluatorFactory;
+import org.gvsig.tools.evaluator.Evaluator;
+
+
+public class DefaultEvaluatorFactory implements EvaluatorFactory {
+
+    @Override
+    public Evaluator createEvaluator(String expression) {
+        ExpressionEvaluator evaluator = new DefaultExpressionEvaluator();
+        evaluator.setSource(expression);
+        return evaluator;
+    }
+
+    @Override
+    public String getName() {
+        return "SQL expression evaluator";
+    }
+    
+}
Index: branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/integration/DefaultExpressionEvaluator.java
===================================================================
--- branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/integration/DefaultExpressionEvaluator.java	(revision 0)
+++ branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/integration/DefaultExpressionEvaluator.java	(revision 43827)
@@ -0,0 +1,273 @@
+package org.gvsig.expressionevaluator.integration;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.gvsig.expressionevaluator.Code;
+import org.gvsig.expressionevaluator.Interpreter;
+import org.gvsig.expressionevaluator.LexicalAnalyzer;
+import org.gvsig.expressionevaluator.SymbolTable;
+import org.gvsig.expressionevaluator.Compiler;
+import org.gvsig.expressionevaluator.ExpressionEvaluator;
+import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
+import org.gvsig.expressionevaluator.Function;
+import org.gvsig.expressionevaluator.impl.DefaultCompiler;
+import org.gvsig.expressionevaluator.impl.DefaultInterpreter;
+import org.gvsig.expressionevaluator.impl.SQLLexicalAnalyzer;
+import org.gvsig.expressionevaluator.impl.SQLSymbolTable;
+import org.gvsig.tools.evaluator.AbstractEvaluator;
+import org.gvsig.tools.evaluator.EvaluatorData;
+import org.gvsig.tools.evaluator.EvaluatorException;
+import org.gvsig.tools.evaluator.EvaluatorFieldsInfo;
+import org.gvsig.tools.exception.BaseException;
+import org.gvsig.tools.visitor.VisitCanceledException;
+import org.gvsig.tools.visitor.Visitor;
+import org.gvsig.tools.lang.Cloneable;
+
+public class DefaultExpressionEvaluator extends AbstractEvaluator implements ExpressionEvaluator, Cloneable {
+
+    private static class DescriptionAdapter implements Description {
+
+        Function function;
+        
+        public DescriptionAdapter(Function function) {
+            this.function = function;
+        }
+        
+        @Override
+        public String getName() {
+            return this.function.name();
+        }
+
+        @Override
+        public String getDescription() {
+            return this.function.description();
+        }
+
+        @Override
+        public String getTemplate() {
+            return this.function.template();
+        }
+
+        @Override
+        public int getDataTypeCategories() {
+            switch(this.function.group()) {
+            case Function.GROUP_STRING:
+                return Description.DATATYPE_CATEGORY_STRING;
+            case Function.GROUP_BOOLEAN:
+                return Description.DATATYPE_CATEGORY_BOOLEAN;
+            case Function.GROUP_DATETIME:
+                return Description.DATATYPE_CATEGORY_DATETIME;
+            case Function.GROUP_NUMERIC:
+                return Description.DATATYPE_CATEGORY_NUMBER;
+            case Function.GROUP_OGC:
+                return Description.DATATYPE_CATEGORY_ALL;
+            default:
+                return Description.DATATYPE_CATEGORY_ALL;
+            }
+        }
+        
+    } 
+        
+    private EvaluatorDataAdapter evaluatorData;
+    private SymbolTable symbolTable;
+    private LexicalAnalyzer lexer;
+    private Compiler compiler;
+    private Interpreter interpreter;
+    private Code code;
+    private String source;
+    private Description[] availableOperators;
+    private Description[] availableFunctions;
+    private Double accuracy;
+
+    public DefaultExpressionEvaluator() {
+        super();
+        this.accuracy = ExpressionEvaluatorLocator.getManager().getAccuracy();
+    }
+
+    @Override
+    public Code getCode() {
+        return this.code;
+    }
+
+    @Override
+    public void compile() {
+        if( this.symbolTable == null ) {
+            this.symbolTable = SQLSymbolTable.getInstance();
+        }
+        if( this.lexer == null ) {
+            this.lexer = new SQLLexicalAnalyzer();
+        }
+        if( this.compiler == null ) {
+            this.compiler = new DefaultCompiler();
+            this.compiler.setLexicalAnalyzer(lexer);
+        }        
+        if( this.interpreter == null ) {
+            this.interpreter = new DefaultInterpreter();
+        }
+        this.evaluatorData = new EvaluatorDataAdapter(symbolTable);
+        this.interpreter.setAccuracy(this.accuracy); 
+        this.interpreter.setSymbolTable(this.evaluatorData);
+        this.code = this.compiler.compileExpression(source);
+    }
+    
+    @Override
+    public Object evaluate(EvaluatorData data) throws EvaluatorException {
+        if( this.code == null ) {
+            this.compile();
+        }
+        this.evaluatorData.setData(data);
+        Object v = this.interpreter.run(code);
+        return v;
+    }
+
+    @Override
+    public String getName() {
+        return "Genereric expression";
+    }
+
+    @Override
+    public EvaluatorFieldsInfo getFieldsInfo() {
+        final Set<String> names = new HashSet<>();        
+        try {
+            this.code.accept(new Visitor() {
+                @Override
+                public void visit(Object code) throws VisitCanceledException, BaseException {
+                    if( code instanceof Code.Identifier ) {
+                        Code.Identifier identifier = (Code.Identifier) code;
+                        names.add(identifier.name());
+                    }
+                }
+            });
+            EvaluatorFieldsInfo info = new EvaluatorFieldsInfo();
+            for (String name : names) {
+                info.addFieldValue(name);
+            }
+            return info;
+        } catch (BaseException ex) {
+            throw new RuntimeException("Can't calculate fields information.", ex);
+        }
+    }
+
+    @Override
+    public Description[] getAvailableOperators() {
+        if( availableOperators==null ) {
+            List<Description> l = new ArrayList<>();
+            for( Function function : symbolTable) {
+                if( function.isOperator() ) {
+                    l.add(new DescriptionAdapter(function));
+                }
+            }
+            this.availableOperators = l.toArray(new Description[l.size()]);
+        }
+        return availableOperators;
+    }
+    
+    @Override
+    public Description[] getAvailableFunctions() {
+        if( availableFunctions==null ) {
+            List<Description> l = new ArrayList<>();
+            for( Function function : symbolTable) {
+                if( !function.isOperator() ) {
+                    l.add(new DescriptionAdapter(function));
+                }
+            }
+            this.availableFunctions = l.toArray(new Description[l.size()]);
+        }
+        return availableFunctions;
+    }
+    
+    @Override
+    public SymbolTable getSymbolTable() {
+        return symbolTable;
+    }
+
+    @Override
+    public void setSymbolTable(SymbolTable symbolTable) {
+        this.symbolTable = symbolTable;
+    }
+
+    @Override
+    public LexicalAnalyzer getLexer() {
+        return lexer;
+    }
+
+    @Override
+    public void setLexer(LexicalAnalyzer lexer) {
+        this.lexer = lexer;
+    }
+
+    @Override
+    public Compiler getCompiler() {
+        return compiler;
+    }
+
+    @Override
+    public void setCompiler(Compiler compiler) {
+        this.compiler = compiler;
+    }
+
+    @Override
+    public Interpreter getInterpreter() {
+        return interpreter;
+    }
+
+    @Override
+    public void setInterpreter(Interpreter interpreter) {
+        this.interpreter = interpreter;
+    }
+
+    @Override
+    public String getSource() {
+        return source;
+    }
+
+    @Override
+    public void setSource(String source) {
+        this.source = source;
+        this.code = null;
+    }
+    
+    @Override
+    public Double getAccuracy() {
+        return this.accuracy;
+    }
+    
+    @Override
+    public void setAccuracy(Double accuracy) {
+        this.accuracy = accuracy;
+    }
+
+    @Override
+    public ExpressionEvaluator clone() throws CloneNotSupportedException {
+        DefaultExpressionEvaluator other = (DefaultExpressionEvaluator) super.clone();
+        other.code = this.code;
+        other.source = this.source;
+        other.accuracy = this.accuracy;
+        other.availableFunctions = null;
+        other.availableOperators = null;
+
+        if( this.symbolTable!=null ) {
+            other.symbolTable = this.symbolTable.clone();
+        }
+        if( this.lexer!=null ) {
+            other.lexer = this.lexer.clone();
+        }
+        if( this.evaluatorData!=null ) {
+            // evaluatorData don't support clone.
+            other.evaluatorData = new EvaluatorDataAdapter(other.symbolTable);
+        }
+        if( this.compiler!=null ) {
+            other.compiler = this.compiler.clone();
+            other.compiler.setLexicalAnalyzer(other.lexer);
+        }
+        if( this.interpreter!=null ) {
+            other.interpreter = this.interpreter.clone();
+            other.interpreter.setAccuracy(this.accuracy);
+            other.interpreter.setSymbolTable(other.symbolTable);
+        }
+        return other;
+    }
+
+}
