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/ExpressionBuilder.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/ExpressionBuilder.java	(revision 43033)
+++ 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/ExpressionBuilder.java	(revision 43034)
@@ -1,9 +1,9 @@
 package org.gvsig.fmap.dal;
 
-import java.beans.Expression;
 import java.util.List;
 import org.cresques.cts.IProjection;
 import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.primitive.Envelope;
 
 public interface ExpressionBuilder {
 
@@ -49,6 +49,7 @@
         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";
@@ -185,6 +186,8 @@
 
     public GeometryValue geometry(Geometry geom, IProjection projection);
 
+    public GeometryValue envelope(Envelope envelope, IProjection projection);
+
     public Custom custom(Object value);
     
     public Constant srs(IProjection projection);
@@ -199,7 +202,7 @@
     public Function isNull(Value value);
 
     public Function Find_SRID(Value schema, Value table, Value column);
-            
+    
     public Function ST_SRID(Value geom);
     
     public Function ST_AsText(Value geom);
@@ -216,10 +219,14 @@
             
     public Function ST_GeomFromEWKB(Value geom, Value crs);
 
+    public Function ST_Equals(Value geom1, Value geom2);
+
     public Function ST_Intersects(Value geom1, Value geom2);
 
     public Function ST_Contains(Value geom1, Value geom2);
 
+    public Function ST_Disjoint(Value geom1, Value geom2);
+
     public Function ST_Crosses(Value geom1, Value geom2);
 
     public Function ST_IsClosed(Value geom1);
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/ExpressionBuilderBase.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/ExpressionBuilderBase.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/ExpressionBuilderBase.java	(revision 43034)
@@ -29,6 +29,7 @@
 import org.gvsig.fmap.dal.ExpressionBuilder.Visitor;
 import org.gvsig.fmap.dal.ExpressionBuilder.VisitorFilter;
 import org.gvsig.fmap.geom.Geometry;
+import org.gvsig.fmap.geom.primitive.Envelope;
 
 public class ExpressionBuilderBase implements ExpressionBuilder {
     public class ConfigBase implements Config {
@@ -53,7 +54,8 @@
             this.values.put(ST_AsEWKB, "ST_AsWKB({0})");
             this.values.put(ST_Contains, "ST_Contains(({0}), ({1}))");            
             this.values.put(ST_Crosses,  "ST_Crosses(({0}), ({1}))");
-            this.values.put(ST_Disjoint ,  "ST_Disjoint (({0}), ({1}))");
+            this.values.put(ST_Disjoint ,  "ST_Disjoint(({0}), ({1}))");
+            this.values.put(ST_Equals ,  "ST_Equals(({0}), ({1}))");
             this.values.put(ST_IsClosed,  "ST_IsClosed({0})");
             this.values.put(ST_Overlaps,  "ST_Overlaps(({0}), ({1}))");
             this.values.put(ST_Touches,  "ST_Touches(({0}), ({1}))");
@@ -664,6 +666,8 @@
     @Override
     public String string(String s) {
         String quote = this.config.getString(Config.quote_for_strings);
+//        No se porque no esta disponible wrapIfMissing
+//        return StringUtils.wrapIfMissing(s,quote);
         if (s.startsWith(quote)) {
             return s;
         }
@@ -673,6 +677,8 @@
     @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;
         }
@@ -732,6 +738,11 @@
     }
 
     @Override
+    public GeometryValue envelope(Envelope envelope, IProjection projection) {
+        return new GeometryValueBase(envelope.getGeometry(), projection);
+    }
+
+    @Override
     public Custom custom(Object value) {
         return new CustomBase(value);
     }
@@ -859,11 +870,21 @@
     }
 
     @Override
+    public Function ST_Disjoint(Value geom1, Value geom2) {
+        return function("ST_Disjoint", config.getString(Config.ST_Disjoint), geom1, geom2);
+    }
+    
+    @Override
     public Function ST_Contains(Value geom1, Value geom2) {
         return function("ST_Contains", config.getString(Config.ST_Contains), geom1, geom2);
     }
 
     @Override
+    public Function ST_Equals(Value geom1, Value geom2) {
+        return function("ST_Equals", config.getString(Config.ST_Equals), geom1, geom2);
+    }
+
+    @Override
     public Function ST_Crosses(Value geom1, Value geom2) {
         return function("ST_Crosses", config.getString(Config.ST_Crosses), geom1, geom2);
     }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/EqualsGeometryEvaluator.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/EqualsGeometryEvaluator.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/EqualsGeometryEvaluator.java	(revision 43034)
@@ -3,115 +3,110 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.fmap.mapcontext.layers.vectorial;
 
 import org.cresques.cts.ICoordTrans;
 import org.cresques.cts.IProjection;
-import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException;
+import org.gvsig.fmap.dal.ExpressionBuilder;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.geom.Geometry;
-import org.gvsig.fmap.geom.operation.GeometryOperationException;
-import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
 import org.gvsig.tools.evaluator.AbstractEvaluator;
 import org.gvsig.tools.evaluator.EvaluatorData;
 import org.gvsig.tools.evaluator.EvaluatorException;
-/**
- *
- * @author Vicente Caballero Navarro
- *
- */
+
 public class EqualsGeometryEvaluator extends AbstractEvaluator {
 
-	private String geomName;
-	private Geometry geometry;
-	private String geometryWKT = null;
-	private Geometry geometryTrans;
-	private String srs;
-	private boolean isDefault;
+    private final String geomName;
+    private final Geometry geometry;
+    private final Geometry geometryTrans;
+    private final boolean isDefault;
+    private final ExpressionBuilder builder;
+    private final IProjection projection;
 
-	EqualsGeometryEvaluator(Geometry geometry,
-			IProjection projection, FeatureType featureType,
-			String geomName) {
-		FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
-				.get(geomName);
-		this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
-				geomName);
-		this.geometry = geometry;
-		this.geometryTrans = geometry.cloneGeometry();
-		this.srs = projection.getAbrev();
-		
-		IProjection fad_proj = fad.getSRS();
-		ICoordTrans ct = null;
-		
-		if (fad_proj != null && !fad_proj.equals(projection)) {
-		    ct = projection.getCT(fad_proj);
-		}
+    EqualsGeometryEvaluator(
+            Geometry geometry,
+            IProjection projection,
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+    ) {
+        this.builder = builder;
+        this.projection = projection;
+        FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
+                .get(geomName);
+        this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName);
+        this.geometry = geometry;
+        this.geometryTrans = geometry.cloneGeometry();
 
-		if (ct != null) {
-			geometryTrans.reProject(ct);
-		}
-		this.geomName = geomName;
+        IProjection fad_proj = fad.getSRS();
+        ICoordTrans ct = null;
 
-		this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
+        if (fad_proj != null && !fad_proj.equals(projection)) {
+            ct = projection.getCT(fad_proj);
+        }
 
-	}
+        if (ct != null) {
+            geometryTrans.reProject(ct);
+        }
+        this.geomName = geomName;
 
-	public Object evaluate(EvaluatorData data) throws EvaluatorException {
-		try {
-			Geometry geom = null;
-			if (isDefault) {
-				Feature feature = (Feature) data.getContextValue("feature");
-				geom =feature.getDefaultGeometry();
+        this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
 
-			} else {
-				geom = (Geometry) data.getDataValue(geomName);
-			}
-                        if ( geom == null ) {
-                            return Boolean.FALSE;
-                        }
-			return new Boolean(geometryTrans.equals(geom));
+    }
 
-		} catch (Exception e) {
-			throw new EvaluatorException(e);
-		}
-	}
+    @Override
+    public Object evaluate(EvaluatorData data) throws EvaluatorException {
+        try {
+            Geometry geom;
+            if (isDefault) {
+                Feature feature = (Feature) data.getContextValue("feature");
+                geom = feature.getDefaultGeometry();
 
-	public String getName() {
-		return "equals with geometry";
-	}
+            } else {
+                geom = (Geometry) data.getDataValue(geomName);
+            }
+            if (geom == null) {
+                return Boolean.FALSE;
+            }
+            return geometryTrans.equals(geom);
 
-	public String getSQL() {
-		if (geometryWKT == null) {
-			try {
-				geometryWKT = geometry.convertToWKT();
-			} catch (GeometryOperationNotSupportedException e) {
-				throw new DataEvaluatorRuntimeException(e);
-			} catch (GeometryOperationException e) {
-				throw new DataEvaluatorRuntimeException(e);
-			}
-		}
-		return " ST_equals(ST_GeomFromText('" + geometryWKT + "', " + "'"
-				+ srs + "'" + "), " + geomName + ") ";
-	}
+        } catch (Exception e) {
+            throw new EvaluatorException(e);
+        }
+    }
 
+    @Override
+    public String getName() {
+        return "equals with geometry";
+    }
+
+    @Override
+    public String getSQL() {
+        return this.builder.set(
+                builder.ST_Equals(
+                        builder.geometry(geometry, projection),
+                        builder.column(geomName)
+                )
+        ).toString();
+    }
+
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/OverlapsGeometryEvaluator.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/OverlapsGeometryEvaluator.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/OverlapsGeometryEvaluator.java	(revision 43034)
@@ -3,28 +3,28 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.fmap.mapcontext.layers.vectorial;
 
 import org.cresques.cts.ICoordTrans;
 import org.cresques.cts.IProjection;
+import org.gvsig.fmap.dal.ExpressionBuilder;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
@@ -32,6 +32,7 @@
 import org.gvsig.tools.evaluator.AbstractEvaluator;
 import org.gvsig.tools.evaluator.EvaluatorData;
 import org.gvsig.tools.evaluator.EvaluatorException;
+
 /**
  *
  * @author Vicente Caballero Navarro
@@ -39,67 +40,80 @@
  */
 public class OverlapsGeometryEvaluator extends AbstractEvaluator {
 
-	private String geomName;
-	private Geometry geometry;
-	private Geometry geometryTrans;
-	private String srs;
-	private boolean isDefault;
+    private final String geomName;
+    private final Geometry geometry;
+    private final Geometry geometryTrans;
+    private final boolean isDefault;
+    private final ExpressionBuilder builder;
+    private final IProjection projection;
 
-	OverlapsGeometryEvaluator(Geometry geometry,
-			IProjection envelopeProjection, FeatureType featureType,
-			String geomName) {
-		FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
-				.get(geomName);
-		this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
-				geomName);
-		this.geometry = geometry;
-		this.geometryTrans = geometry.cloneGeometry();
-		this.srs = envelopeProjection.getAbrev();
-		
-		IProjection fad_proj = fad.getSRS();
-		ICoordTrans ct = null;
-		
-		if (fad_proj != null && !fad_proj.equals(envelopeProjection)) {
-		    ct = envelopeProjection.getCT(fad_proj);
-		}
-		
-		if (ct != null) {
-			geometryTrans.reProject(ct);
-		}
-		this.geomName = geomName;
+    OverlapsGeometryEvaluator(
+            Geometry geometry,
+            IProjection projection,
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
+                .get(geomName);
+        this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName);
+        this.geometry = geometry;
+        this.geometryTrans = geometry.cloneGeometry();
+        this.projection = projection;
+        this.builder = builder;
+        
+        IProjection fad_proj = fad.getSRS();
+        ICoordTrans ct = null;
 
-		this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
+        if (fad_proj != null && !fad_proj.equals(projection)) {
+            ct = projection.getCT(fad_proj);
+        }
 
-	}
+        if (ct != null) {
+            geometryTrans.reProject(ct);
+        }
+        this.geomName = geomName;
 
-	public Object evaluate(EvaluatorData data) throws EvaluatorException {
+        this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
 
-		try {
-			Geometry geom = null;
-			if (isDefault) {
-				Feature feature = (Feature) data.getContextValue("feature");
-				geom = feature.getDefaultGeometry();
+    }
 
-			} else {
-				geom = (Geometry) data.getDataValue(geomName);
-			}
-                        if ( geom == null ) {
-                            return Boolean.FALSE;
-                        }
-			return new Boolean(geometryTrans.overlaps(geom));
+    @Override
+    public Object evaluate(EvaluatorData data) throws EvaluatorException {
 
-		} catch (Exception e) {
-			throw new EvaluatorException(e);
-		}
-	}
+        try {
+            Geometry geom;
+            if (isDefault) {
+                Feature feature = (Feature) data.getContextValue("feature");
+                geom = feature.getDefaultGeometry();
 
-	public String getName() {
-		return "overlaps with geometry";
-	}
+            } else {
+                geom = (Geometry) data.getDataValue(geomName);
+            }
+            if (geom == null) {
+                return Boolean.FALSE;
+            }
+            return geometryTrans.overlaps(geom);
 
-	public String getSQL() {
-		return " ST_overlaps(ST_GeomFromText('" + geometry.toString() + "', " + "'"
-				+ srs + "'" + "), " + geomName + ") ";
-	}
+        } catch (Exception e) {
+            throw new EvaluatorException(e);
+        }
+    }
 
+    @Override
+    public String getName() {
+        return "overlaps with geometry";
+    }
+
+    @Override
+    public String getSQL() {
+        return this.builder.set(
+                builder.ST_Overlaps(
+                        builder.geometry(geometry, projection),
+                        builder.column(geomName)
+                )
+        ).toString();
+    }
+    
+    
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/SpatialEvaluatorsFactory.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/SpatialEvaluatorsFactory.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/SpatialEvaluatorsFactory.java	(revision 43034)
@@ -22,27 +22,31 @@
         
     }
     
-    public Evaluator intersects(Geometry geometry,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder) {
+    public Evaluator intersects(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
         return new IntersectsGeometryEvaluator(geometry, projection, featureType, geomName, builder);
     }
     
-    public Evaluator intersects(Envelope envelope,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder) {
+    public Evaluator intersects(
+            Envelope envelope,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
         return new IntersectsEnvelopeEvaluator(envelope, projection, featureType, geomName, builder);
     }
     
-    public Evaluator intersects(Geometry geometry,
-        IProjection projection, 
-        FeatureStore store) {
-        
-        
+    public Evaluator intersects(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
@@ -53,9 +57,11 @@
         }
     }
 
-    public Evaluator intersects(Envelope envelope,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator intersects(
+            Envelope envelope,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
@@ -66,211 +72,251 @@
         }
     }
 
-    public Evaluator contains(Envelope envelope,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder){
+    public Evaluator contains(
+            Envelope envelope,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ){
         return new ContainsEnvelopeEvaluator(envelope, projection, featureType, geomName);
     }
 
-    public Evaluator contains(Geometry geometry,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder){
-        return new ContainsGeometryEvaluator(geometry, projection, featureType, geomName);
+    public Evaluator contains(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ){
+        return new ContainsGeometryEvaluator(geometry, projection, featureType, geomName, builder);
     }
     
-    public Evaluator contains(Geometry geometry,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator contains(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
             ExpressionBuilder builder = store.createExpressionBuilder();
-            return contains(geometry, projection, featureType, geomName,builder);
+            return this.contains(geometry, projection, featureType, geomName,builder);
         } catch (DataException ex) {
             throw new RuntimeException("Can't create contains evaluator.",ex);
         }
     }
 
-    public Evaluator contains(Envelope envelope,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator contains(
+            Envelope envelope,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
             ExpressionBuilder builder = store.createExpressionBuilder();
-            return contains(envelope, projection, featureType, geomName,builder);
+            return this.contains(envelope, projection, featureType, geomName,builder);
         } catch (DataException ex) {
             throw new RuntimeException("Can't create contains evaluator.",ex);
         }
     }
 
-    public Evaluator not_contains(Geometry geometry,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder){
-        return new OutGeometryEvaluator(geometry, projection, featureType, geomName);
+    public Evaluator not_contains(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ){
+        return new OutGeometryEvaluator(geometry, projection, featureType, geomName, builder);
     }
     
-    public Evaluator not_contains(Geometry geometry,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator not_contains(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
             ExpressionBuilder builder = store.createExpressionBuilder();
-            return not_contains(geometry, projection, featureType, geomName,builder);
+            return this.not_contains(geometry, projection, featureType, geomName,builder);
         } catch (DataException ex) {
             throw new RuntimeException("Can't create not_contains evaluator.",ex);
         }
     }
 
-    public Evaluator crosses(Geometry geometry,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder) {
-        return new CrossesGeometryEvaluator(geometry, projection, featureType, geomName);
+    public Evaluator crosses(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        return new CrossesGeometryEvaluator(geometry, projection, featureType, geomName, builder);
     }
 
-    public Evaluator crosses(Envelope envelope,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder) {
-        return new CrossEnvelopeEvaluator(envelope, projection, featureType, geomName);
+    public Evaluator crosses(
+            Envelope envelope,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        return new CrossEnvelopeEvaluator(envelope, projection, featureType, geomName, builder);
     }
 
-    public Evaluator crosses(Geometry geometry,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator crosses(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
             ExpressionBuilder builder = store.createExpressionBuilder();
-            return crosses(geometry, projection, featureType, geomName,builder);
+            return this.crosses(geometry, projection, featureType, geomName,builder);
         } catch (DataException ex) {
             throw new RuntimeException("Can't create crosses evaluator.",ex);
         }
     }
 
-    public Evaluator crosses(Envelope envelope,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator crosses(
+            Envelope envelope,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
             ExpressionBuilder builder = store.createExpressionBuilder();
-            return crosses(envelope, projection, featureType, geomName,builder);
+            return this.crosses(envelope, projection, featureType, geomName,builder);
         } catch (DataException ex) {
             throw new RuntimeException("Can't create crosses evaluator.",ex);
         }
     }
 
-    public Evaluator disjoint(Geometry geometry,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder) {
-        return new DisjointGeometryEvaluator(geometry, projection, featureType, geomName);
+    public Evaluator disjoint(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        return new DisjointGeometryEvaluator(geometry, projection, featureType, geomName, builder);
     }    
 
-    public Evaluator disjoint(Geometry geometry,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator disjoint(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
             ExpressionBuilder builder = store.createExpressionBuilder();
-            return disjoint(geometry, projection, featureType, geomName,builder);
+            return this.disjoint(geometry, projection, featureType, geomName,builder);
         } catch (DataException ex) {
             throw new RuntimeException("Can't create disjoint evaluator.",ex);
         }
     }
     
-    public Evaluator overlaps(Geometry geometry,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder) {
-        return new OverlapsGeometryEvaluator(geometry, projection, featureType, geomName);
+    public Evaluator overlaps(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        return new OverlapsGeometryEvaluator(geometry, projection, featureType, geomName, builder);
     }    
 
-    public Evaluator overlaps(Geometry geometry,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator overlaps(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
             ExpressionBuilder builder = store.createExpressionBuilder();
-            return overlaps(geometry, projection, featureType, geomName,builder);
+            return this.overlaps(geometry, projection, featureType, geomName,builder);
         } catch (DataException ex) {
             throw new RuntimeException("Can't create overlaps evaluator.",ex);
         }
     }
     
-    public Evaluator touches(Geometry geometry,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder) {
-        return new TouchesGeometryEvaluator(geometry, projection, featureType, geomName);
+    public Evaluator touches(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        return new TouchesGeometryEvaluator(geometry, projection, featureType, geomName,builder);
     }    
 
-    public Evaluator touches(Geometry geometry,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator touches(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
             ExpressionBuilder builder = store.createExpressionBuilder();
-            return touches(geometry, projection, featureType, geomName,builder);
+            return this.touches(geometry, projection, featureType, geomName,builder);
         } catch (DataException ex) {
             throw new RuntimeException("Can't create touches evaluator.",ex);
         }
     }
     
-    public Evaluator within(Geometry geometry,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder) {
-        return new WithinGeometryEvaluator(geometry, projection, featureType, geomName);
+    public Evaluator within(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        return new WithinGeometryEvaluator(geometry, projection, featureType, geomName,builder);
     }    
 
-    public Evaluator within(Geometry geometry,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator within(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
             ExpressionBuilder builder = store.createExpressionBuilder();
-            return within(geometry, projection, featureType, geomName,builder);
+            return this.within(geometry, projection, featureType, geomName,builder);
         } catch (DataException ex) {
             throw new RuntimeException("Can't create within evaluator.",ex);
         }
     }
     
-    public Evaluator equals(Geometry geometry,
-        IProjection projection, 
-        FeatureType featureType,
-        String geomName,
-        ExpressionBuilder builder) {
-        return new EqualsGeometryEvaluator(geometry, projection, featureType, geomName);
+    public Evaluator equals(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        return new EqualsGeometryEvaluator(geometry, projection, featureType, geomName,builder);
     }    
     
-    public Evaluator equals(Geometry geometry,
-        IProjection projection, 
-        FeatureStore store) {
+    public Evaluator equals(    
+            Geometry geometry,
+            IProjection projection, 
+            FeatureStore store
+        ) {
         try {
             FeatureType featureType = store.getDefaultFeatureType();
             String geomName = featureType.getDefaultGeometryAttributeName();
             ExpressionBuilder builder = store.createExpressionBuilder();
-            return equals(geometry, projection, featureType, geomName,builder);
+            return this.equals(geometry, projection, featureType, geomName,builder);
         } catch (DataException ex) {
             throw new RuntimeException("Can't create equals evaluator.",ex);
         }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/WithinGeometryEvaluator.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/WithinGeometryEvaluator.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/WithinGeometryEvaluator.java	(revision 43034)
@@ -3,28 +3,28 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.fmap.mapcontext.layers.vectorial;
 
 import org.cresques.cts.ICoordTrans;
 import org.cresques.cts.IProjection;
+import org.gvsig.fmap.dal.ExpressionBuilder;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
@@ -32,73 +32,81 @@
 import org.gvsig.tools.evaluator.AbstractEvaluator;
 import org.gvsig.tools.evaluator.EvaluatorData;
 import org.gvsig.tools.evaluator.EvaluatorException;
-/**
- *
- * @author Vicente Caballero Navarro
- *
- */
+
 public class WithinGeometryEvaluator extends AbstractEvaluator {
 
-	private String geomName;
-	private Geometry geometry;
-	private Geometry geometryTrans;
-	private String srs;
-	private boolean isDefault;
+    private final String geomName;
+    private final Geometry geometry;
+    private final Geometry geometryTrans;
+    private final boolean isDefault;
+    private final ExpressionBuilder builder;
+    private final IProjection projection;
 
-	WithinGeometryEvaluator(Geometry geometry,
-			IProjection envelopeProjection, FeatureType featureType,
-			String geomName) {
-		FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
-				.get(geomName);
-		this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
-				geomName);
-		this.geometry = geometry;
-		this.geometryTrans = geometry.cloneGeometry();
-		this.srs = envelopeProjection.getAbrev();
-		
-		IProjection fad_proj = fad.getSRS();
-		ICoordTrans ct = null;
-		
-		if (fad_proj != null && !fad_proj.equals(envelopeProjection)) {
-		    ct = envelopeProjection.getCT(fad_proj);
-		}
-		
-		if (ct != null) {
-			geometryTrans.reProject(ct);
-		}
-		this.geomName = geomName;
+    WithinGeometryEvaluator(
+            Geometry geometry,
+            IProjection projection,
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
+                .get(geomName);
+        this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
+                geomName);
+        this.geometry = geometry;
+        this.geometryTrans = geometry.cloneGeometry();
+        this.projection = projection;
+        this.builder = builder;
 
-		this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
+        IProjection fad_proj = fad.getSRS();
+        ICoordTrans ct = null;
 
-	}
+        if (fad_proj != null && !fad_proj.equals(projection)) {
+            ct = projection.getCT(fad_proj);
+        }
 
-	public Object evaluate(EvaluatorData data) throws EvaluatorException {
-		try {
-			Geometry geom = null;
-			if (isDefault) {
-				Feature feature = (Feature) data.getContextValue("feature");
-				geom =feature.getDefaultGeometry();
+        if (ct != null) {
+            geometryTrans.reProject(ct);
+        }
+        this.geomName = geomName;
 
-			} else {
-				geom = (Geometry) data.getDataValue(geomName);
-			}
-                        if ( geom == null ) {
-                            return Boolean.FALSE;
-                        }
-			return new Boolean(geometryTrans.within(geom));
+        this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
 
-		} catch (Exception e) {
-			throw new EvaluatorException(e);
-		}
-	}
+    }
 
-	public String getName() {
-		return "within with geometry";
-	}
+    @Override
+    public Object evaluate(EvaluatorData data) throws EvaluatorException {
+        try {
+            Geometry geom;
+            if (isDefault) {
+                Feature feature = (Feature) data.getContextValue("feature");
+                geom = feature.getDefaultGeometry();
 
-	public String getSQL() {
-		return " ST_within(ST_GeomFromText('" + geometry.toString() + "', " + "'"
-				+ srs + "'" + "), " + geomName + ") ";
-	}
+            } else {
+                geom = (Geometry) data.getDataValue(geomName);
+            }
+            if (geom == null) {
+                return false;
+            }
+            return geometryTrans.within(geom);
 
+        } catch (Exception e) {
+            throw new EvaluatorException(e);
+        }
+    }
+
+    @Override
+    public String getName() {
+        return "within with geometry";
+    }
+
+    @Override
+    public String getSQL() {
+        return this.builder.set(
+                builder.ST_Within(
+                        builder.geometry(geometry, projection),
+                        builder.column(geomName)
+                )
+        ).toString();
+    }
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/OutGeometryEvaluator.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/OutGeometryEvaluator.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/OutGeometryEvaluator.java	(revision 43034)
@@ -3,28 +3,28 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.fmap.mapcontext.layers.vectorial;
 
 import org.cresques.cts.ICoordTrans;
 import org.cresques.cts.IProjection;
+import org.gvsig.fmap.dal.ExpressionBuilder;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
@@ -32,73 +32,83 @@
 import org.gvsig.tools.evaluator.AbstractEvaluator;
 import org.gvsig.tools.evaluator.EvaluatorData;
 import org.gvsig.tools.evaluator.EvaluatorException;
-/**
- *
- * @author Vicente Caballero Navarro
- *
- */
+
 public class OutGeometryEvaluator extends AbstractEvaluator {
 
-	private String geomName;
-	private Geometry geometry;
-	private Geometry geometryTrans;
-	private String srs;
-	private boolean isDefault;
+    private final String geomName;
+    private final Geometry geometry;
+    private final Geometry geometryTrans;
+    private final boolean isDefault;
+    private final ExpressionBuilder builder;
+    private final IProjection projection;
 
-	OutGeometryEvaluator(Geometry geometry,
-			IProjection envelopeProjection, FeatureType featureType,
-			String geomName) {
-		FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
-				.get(geomName);
-		this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
-				geomName);
-		this.geometry = geometry;
-		this.geometryTrans = geometry.cloneGeometry();
-		this.srs = envelopeProjection.getAbrev();
-		
-		IProjection fad_proj = fad.getSRS();
-		ICoordTrans ct = null;
-		
-		if (fad_proj != null && !fad_proj.equals(envelopeProjection)) {
-		    ct = envelopeProjection.getCT(fad_proj);
-		}
+    OutGeometryEvaluator(
+            Geometry geometry,
+            IProjection envelopeProjection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
+                .get(geomName);
+        this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName);
+        this.geometry = geometry;
+        this.geometryTrans = geometry.cloneGeometry();
+        this.projection = envelopeProjection;
+        this.builder = builder;
 
-		if (ct != null) {
-			geometryTrans.reProject(ct);
-		}
-		this.geomName = geomName;
+        IProjection fad_proj = fad.getSRS();
+        ICoordTrans ct = null;
 
-		this.getFieldsInfo().addFieldValue(geomName);
+        if (fad_proj != null && !fad_proj.equals(envelopeProjection)) {
+            ct = envelopeProjection.getCT(fad_proj);
+        }
 
-	}
+        if (ct != null) {
+            geometryTrans.reProject(ct);
+        }
+        this.geomName = geomName;
 
-	public Object evaluate(EvaluatorData data) throws EvaluatorException {
-		try {
-			Geometry geom = null;
-			if (isDefault) {
-				Feature feature = (Feature) data.getContextValue("feature");
-				geom = feature.getDefaultGeometry();
+        this.getFieldsInfo().addFieldValue(geomName);
 
-			} else {
-				geom = (Geometry) data.getDataValue(geomName);
-			}
-                        if ( geom == null ) {
-                            return Boolean.FALSE;
-                        }
-			return new Boolean(!geometryTrans.contains(geom) && !geometryTrans.intersects(geom));
+    }
 
-		} catch (Exception e) {
-			throw new EvaluatorException(e);
-		}
-	}
+    @Override
+    public Object evaluate(EvaluatorData data) throws EvaluatorException {
+        try {
+            Geometry geom;
+            if (isDefault) {
+                Feature feature = (Feature) data.getContextValue("feature");
+                geom = feature.getDefaultGeometry();
 
-	public String getName() {
-		return "out of geometry";
-	}
+            } else {
+                geom = (Geometry) data.getDataValue(geomName);
+            }
+            if (geom == null) {
+                return Boolean.FALSE;
+            }
+            return !geometryTrans.contains(geom) && !geometryTrans.intersects(geom);
 
-	public String getSQL() {
-		return " not ST_contains(ST_GeomFromText('" + geometry.toString() + "', " + "'"
-				+ srs + "'" + "), " + geomName + ") ";
-	}
+        } catch (Exception e) {
+            throw new EvaluatorException(e);
+        }
+    }
 
+    @Override
+    public String getName() {
+        return "out of geometry";
+    }
+
+    @Override
+    public String getSQL() {
+        return this.builder.set(
+                builder.not(
+                    builder.ST_Contains(
+                            builder.geometry(geometry, projection),
+                            builder.column(geomName)
+                    )
+                )
+        ).toString();
+    }
+
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/TouchesGeometryEvaluator.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/TouchesGeometryEvaluator.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/TouchesGeometryEvaluator.java	(revision 43034)
@@ -3,28 +3,28 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.fmap.mapcontext.layers.vectorial;
 
 import org.cresques.cts.ICoordTrans;
 import org.cresques.cts.IProjection;
+import org.gvsig.fmap.dal.ExpressionBuilder;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
@@ -32,73 +32,80 @@
 import org.gvsig.tools.evaluator.AbstractEvaluator;
 import org.gvsig.tools.evaluator.EvaluatorData;
 import org.gvsig.tools.evaluator.EvaluatorException;
-/**
- *
- * @author Vicente Caballero Navarro
- *
- */
+
 public class TouchesGeometryEvaluator extends AbstractEvaluator {
 
-	private String geomName;
-	private Geometry geometry;
-	private Geometry geometryTrans;
-	private String srs;
-	private boolean isDefault;
+    private final String geomName;
+    private final Geometry geometry;
+    private final Geometry geometryTrans;
+    private final boolean isDefault;
+    private final ExpressionBuilder builder;
+    private final IProjection projection;
 
-	TouchesGeometryEvaluator(Geometry geometry,
-			IProjection envelopeProjection, FeatureType featureType,
-			String geomName) {
-		FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
-				.get(geomName);
-		this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
-				geomName);
-		this.geometry = geometry;
-		this.geometryTrans = geometry.cloneGeometry();
-		this.srs = envelopeProjection.getAbrev();
-		
-		IProjection fad_proj = fad.getSRS();
-		ICoordTrans ct = null;
-		
-		if (fad_proj != null && !fad_proj.equals(envelopeProjection)) {
-		    ct = envelopeProjection.getCT(fad_proj);
-		}
-		
-		if (ct != null) {
-			geometryTrans.reProject(ct);
-		}
-		this.geomName = geomName;
+    TouchesGeometryEvaluator(Geometry geometry,
+            IProjection projection,
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
+                .get(geomName);
+        this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
+                geomName);
+        this.geometry = geometry;
+        this.geometryTrans = geometry.cloneGeometry();
+        this.projection = projection;
+        this.builder = builder;
 
-		this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
+        IProjection fad_proj = fad.getSRS();
+        ICoordTrans ct = null;
 
-	}
+        if (fad_proj != null && !fad_proj.equals(projection)) {
+            ct = projection.getCT(fad_proj);
+        }
 
-	public Object evaluate(EvaluatorData data) throws EvaluatorException {
-		try {
-			Geometry geom = null; 
-			if (isDefault) {
-				Feature feature = (Feature) data.getContextValue("feature");
-				geom = feature.getDefaultGeometry();
+        if (ct != null) {
+            geometryTrans.reProject(ct);
+        }
+        this.geomName = geomName;
 
-			} else {
-				geom = (Geometry) data.getDataValue(geomName);
-			}
-                        if ( geom == null ) {
-                            return Boolean.FALSE;
-                        }
-			return new Boolean(geometryTrans.touches(geom));
+        this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
 
-		} catch (Exception e) {
-			throw new EvaluatorException(e);
-		}
-	}
+    }
 
-	public String getName() {
-		return "touches with geometry";
-	}
+    @Override
+    public Object evaluate(EvaluatorData data) throws EvaluatorException {
+        try {
+            Geometry geom;
+            if (isDefault) {
+                Feature feature = (Feature) data.getContextValue("feature");
+                geom = feature.getDefaultGeometry();
 
-	public String getSQL() {
-		return " ST_touches(ST_GeomFromText('" + geometry.toString() + "', " + "'"
-				+ srs + "'" + "), " + geomName + ") ";
-	}
+            } else {
+                geom = (Geometry) data.getDataValue(geomName);
+            }
+            if (geom == null) {
+                return Boolean.FALSE;
+            }
+            return geometryTrans.touches(geom);
 
+        } catch (Exception e) {
+            throw new EvaluatorException(e);
+        }
+    }
+
+    @Override
+    public String getName() {
+        return "touches with geometry";
+    }
+
+    @Override
+    public String getSQL() {
+        return this.builder.set(
+                builder.ST_Touches(
+                        builder.geometry(geometry, projection),
+                        builder.column(geomName)
+                )
+        ).toString();
+    }
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/CrossEnvelopeEvaluator.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/CrossEnvelopeEvaluator.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/CrossEnvelopeEvaluator.java	(revision 43034)
@@ -3,35 +3,32 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.fmap.mapcontext.layers.vectorial;
 
 import org.cresques.cts.IProjection;
+import org.gvsig.fmap.dal.ExpressionBuilder;
 
-import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.geom.Geometry;
-import org.gvsig.fmap.geom.operation.GeometryOperationException;
-import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
 import org.gvsig.fmap.geom.primitive.Envelope;
 import org.gvsig.tools.evaluator.AbstractEvaluator;
 import org.gvsig.tools.evaluator.EvaluatorData;
@@ -39,25 +36,30 @@
 
 public class CrossEnvelopeEvaluator extends AbstractEvaluator {
 
-	private Envelope envelope;
-	private String geomName;
-	private Envelope envelopeTrans;
-	private boolean isDefault;
-	private String srs;
-	private String envelopeWKT;
+    private final Envelope envelope;
+    private final String geomName;
+    private final Envelope envelopeTrans;
+    private final boolean isDefault;
+    private final ExpressionBuilder builder;
+    private final IProjection projection;
 
-	CrossEnvelopeEvaluator(Envelope envelope,
-			IProjection envelopeProjection, FeatureType featureType,
-			String geomName) {
-		FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
-				.get(geomName);
+    CrossEnvelopeEvaluator(
+            Envelope envelope,
+            IProjection envelopeProjection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
+                .get(geomName);
 
-		this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
-				geomName);
-		this.envelope = envelope;
-		// this.srs = envelopeProjection.getAbrev();
-		// this.projection=CRSFactory.getCRS(fad.getSRS());
-		// this.envelopeProjection=envelopeProjection;
+        this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName);
+        this.envelope = envelope;
+        this.projection = envelopeProjection;
+        this.builder = builder;
+        // this.srs = envelopeProjection.getAbrev();
+        // this.projection=CRSFactory.getCRS(fad.getSRS());
+        // this.envelopeProjection=envelopeProjection;
 //		ICoordTrans ct = null;
 //		if (!this.srs.equals(fad.getSRS())) { // FIXME comparaci�n
 //			ct = envelopeProjection.getCT(fad.getSRS());
@@ -65,52 +67,47 @@
 //		if (ct != null) {
 //			this.envelopeTrans = envelope.convert(ct);
 //		} else {
-			this.envelopeTrans = envelope;
+        this.envelopeTrans = envelope;
 //		}
-		this.geomName = geomName;
-		this.srs = envelopeProjection.getAbrev();
+        this.geomName = geomName;
 
-		this.getFieldsInfo().addMatchFieldValue(geomName, envelopeTrans);
+        this.getFieldsInfo().addMatchFieldValue(geomName, envelopeTrans);
 
-	}
+    }
 
-	public Object evaluate(EvaluatorData data) throws EvaluatorException {
-		if (isDefault) {
-			Feature feature = (Feature) data.getContextValue("feature");
-			Envelope featureEnvelope = feature.getDefaultEnvelope();
-                        if( featureEnvelope == null ) {
-                            return Boolean.FALSE;
-                        }
-			Boolean r = new Boolean(envelopeTrans.intersects(featureEnvelope));
-			return r;
+    @Override
+    public Object evaluate(EvaluatorData data) throws EvaluatorException {
+        if (isDefault) {
+            Feature feature = (Feature) data.getContextValue("feature");
+            Envelope featureEnvelope = feature.getDefaultEnvelope();
+            if (featureEnvelope == null) {
+                return Boolean.FALSE;
+            }
+            Boolean r = envelopeTrans.intersects(featureEnvelope);
+            return r;
 
-		} else {
-			Geometry geom = (Geometry) data.getDataValue(geomName);
-                        if( geom == null ) {
-                            return Boolean.FALSE;
-                        }
-			return new Boolean(envelopeTrans.intersects(geom.getEnvelope()));
+        } else {
+            Geometry geom = (Geometry) data.getDataValue(geomName);
+            if (geom == null) {
+                return Boolean.FALSE;
+            }
+            return envelopeTrans.intersects(geom.getEnvelope());
 
-		}
-	}
+        }
+    }
 
-	public String getName() {
-		return "contains in envelope";
-	}
+    @Override
+    public String getName() {
+        return "contains in envelope";
+    }
 
-	public String getSQL() {
-		if (envelopeWKT == null) {
-			try {
-				envelopeWKT = envelope.getGeometry().convertToWKT();
-			} catch (GeometryOperationNotSupportedException e) {
-				throw new DataEvaluatorRuntimeException(e);
-			} catch (GeometryOperationException e) {
-				throw new DataEvaluatorRuntimeException(e);
-			}
-		}
-
-		return " ST_intersects(ST_GeomFromText('" + envelopeWKT + "', '" + srs
-				+ "'), ST_envelope(" + geomName + ")) ";
-	}
-
+    @Override
+    public String getSQL() {
+        return this.builder.set(
+                builder.ST_Intersects(
+                        builder.envelope(envelope, projection),
+                        builder.ST_Envelope(builder.column(geomName))
+                )
+        ).toString();
+    }
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/ContainsGeometryEvaluator.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/ContainsGeometryEvaluator.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/ContainsGeometryEvaluator.java	(revision 43034)
@@ -3,115 +3,111 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.fmap.mapcontext.layers.vectorial;
 
 import org.cresques.cts.ICoordTrans;
 import org.cresques.cts.IProjection;
-import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException;
+import org.gvsig.fmap.dal.ExpressionBuilder;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.geom.Geometry;
-import org.gvsig.fmap.geom.operation.GeometryOperationException;
-import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
 import org.gvsig.tools.evaluator.AbstractEvaluator;
 import org.gvsig.tools.evaluator.EvaluatorData;
 import org.gvsig.tools.evaluator.EvaluatorException;
-/**
- *
- * @author Vicente Caballero Navarro
- *
- */
+
+
 public class ContainsGeometryEvaluator extends AbstractEvaluator {
 
-	private String geomName;
-	private Geometry geometry;
-	private Geometry geometryTrans;
-	private String srs;
-	private boolean isDefault;
-	private String geometryWKT;
+    private final String geomName;
+    private final Geometry geometry;
+    private final Geometry geometryTrans;
+    private final boolean isDefault;
+    private final ExpressionBuilder builder;
+    private final IProjection projection;
 
-	ContainsGeometryEvaluator(Geometry geometry,
-			IProjection projection, FeatureType featureType,
-			String geomName) {
-		FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
-				.get(geomName);
-		this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
-				geomName);
-		this.geometry = geometry;
-		this.geometryTrans = geometry.cloneGeometry();
-		this.srs = projection.getAbrev();
-		
-		IProjection fad_proj = fad.getSRS();
-		ICoordTrans ct = null;
-		if (fad_proj != null && !fad_proj.equals(projection)) {
-		    ct = projection.getCT(fad_proj);
-		}
+    ContainsGeometryEvaluator(
+            Geometry geometry,
+            IProjection projection,
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+    ) {
+        FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
+                .get(geomName);
+        this.projection = projection;
+        this.builder = builder;
+        this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
+                geomName);
+        this.geometry = geometry;
+        this.geometryTrans = geometry.cloneGeometry();
 
-		if (ct != null) {
-			geometryTrans.reProject(ct);
-		}
-		this.geomName = geomName;
+        IProjection fad_proj = fad.getSRS();
+        ICoordTrans ct = null;
+        if (fad_proj != null && !fad_proj.equals(projection)) {
+            ct = projection.getCT(fad_proj);
+        }
 
-		this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
+        if (ct != null) {
+            geometryTrans.reProject(ct);
+        }
+        this.geomName = geomName;
 
-	}
+        this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
 
-	public Object evaluate(EvaluatorData data) throws EvaluatorException {
-		try {
-                    Geometry geom = null;
-                    if ( isDefault ) {
-                        Feature feature = (Feature) data.getContextValue("feature");
-                        geom = feature.getDefaultGeometry();
+    }
 
-                    } else {
-                        geom = (Geometry) data.getDataValue(geomName);
-                    }
-                    if ( geom == null ) {
-                        return Boolean.FALSE;
-                    }
-                    return new Boolean(geometryTrans.contains(geom));
+    @Override
+    public Object evaluate(EvaluatorData data) throws EvaluatorException {
+        try {
+            Geometry geom;
+            if (isDefault) {
+                Feature feature = (Feature) data.getContextValue("feature");
+                geom = feature.getDefaultGeometry();
 
-		} catch (Exception e) {
-			throw new EvaluatorException(e);
-		}
-	}
+            } else {
+                geom = (Geometry) data.getDataValue(geomName);
+            }
+            if (geom == null) {
+                return false;
+            }
+            return geometryTrans.contains(geom);
 
-	public String getName() {
-		return "contains with geometry";
-	}
+        } catch (Exception e) {
+            throw new EvaluatorException(e);
+        }
+    }
 
-	public String getSQL() {
-		if (geometryWKT == null) {
-			try {
-				geometryWKT = geometry.convertToWKT();
-			} catch (GeometryOperationNotSupportedException e) {
-				throw new DataEvaluatorRuntimeException(e);
-			} catch (GeometryOperationException e) {
-				throw new DataEvaluatorRuntimeException(e);
-			}
-		}
+    @Override
+    public String getName() {
+        return "contains with geometry";
+    }
 
-		return " ST_contains(ST_GeomFromText('" + geometryWKT + "', " + "'"
-				+ srs + "'" + "), " + geomName + ") ";
-	}
+    @Override
+    public String getSQL() {
+        return this.builder.set(
+                builder.ST_Contains(
+                        builder.geometry(geometry, projection),
+                        builder.column(geomName)
+                )
+        ).toString();
+    }
 
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/CrossesGeometryEvaluator.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/CrossesGeometryEvaluator.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/CrossesGeometryEvaluator.java	(revision 43034)
@@ -3,116 +3,109 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.fmap.mapcontext.layers.vectorial;
 
 import org.cresques.cts.ICoordTrans;
 import org.cresques.cts.IProjection;
-import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException;
+import org.gvsig.fmap.dal.ExpressionBuilder;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.geom.Geometry;
-import org.gvsig.fmap.geom.operation.GeometryOperationException;
-import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
 import org.gvsig.tools.evaluator.AbstractEvaluator;
 import org.gvsig.tools.evaluator.EvaluatorData;
 import org.gvsig.tools.evaluator.EvaluatorException;
-/**
- *
- * @author Vicente Caballero Navarro
- *
- */
+
 public class CrossesGeometryEvaluator extends AbstractEvaluator {
 
-	private String geomName;
-	private Geometry geometry;
-	private Geometry geometryTrans;
-	private String srs;
-	private boolean isDefault;
-	private String geometryWKT;
+    private final String geomName;
+    private final Geometry geometry;
+    private final Geometry geometryTrans;
+    private final boolean isDefault;
+    private final ExpressionBuilder builder;
+    private final IProjection projection;
+    
+    CrossesGeometryEvaluator(
+            Geometry geometry,
+            IProjection projection, 
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
+                .get(geomName);
+        this.projection = projection;
+        this.builder = builder;
+        this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName);
+        this.geometry = geometry;
+        this.geometryTrans = geometry.cloneGeometry();
 
-	CrossesGeometryEvaluator(Geometry geometry,
-			IProjection projection, FeatureType featureType,
-			String geomName) {
-		FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
-				.get(geomName);
-		this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
-				geomName);
-		this.geometry = geometry;
-		this.geometryTrans = geometry.cloneGeometry();
-		this.srs = projection.getAbrev();
-		
-		ICoordTrans ct = null;
-		IProjection fad_proj = fad.getSRS();
-		
-		if (fad_proj != null && !fad_proj.equals(projection)) {
-		    ct = projection.getCT(fad_proj);
-		}
+        ICoordTrans ct = null;
+        IProjection fad_proj = fad.getSRS();
 
-		if (ct != null) {
-			geometryTrans.reProject(ct);
-		}
-		this.geomName = geomName;
+        if (fad_proj != null && !fad_proj.equals(projection)) {
+            ct = projection.getCT(fad_proj);
+        }
 
-		this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
+        if (ct != null) {
+            geometryTrans.reProject(ct);
+        }
+        this.geomName = geomName;
 
-	}
+        this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
 
-	public Object evaluate(EvaluatorData data) throws EvaluatorException {
-		
-		try {
-			Geometry geom = null;
-			if (isDefault) {
-				Feature feature = (Feature) data.getContextValue("feature");
-				geom = feature.getDefaultGeometry();
-			} else {
-				geom = (Geometry) data.getDataValue(geomName);
-			}
-                        if ( geom == null ) {
-                            return Boolean.FALSE;
-                        }
-			return new Boolean(geometryTrans.crosses(geom));
+    }
 
-		} catch (Exception e) {
-			throw new EvaluatorException(e);
-		}
-	}
+    @Override
+    public Object evaluate(EvaluatorData data) throws EvaluatorException {
 
-	public String getName() {
-		return "crosses with geometry";
-	}
+        try {
+            Geometry geom;
+            if (isDefault) {
+                Feature feature = (Feature) data.getContextValue("feature");
+                geom = feature.getDefaultGeometry();
+            } else {
+                geom = (Geometry) data.getDataValue(geomName);
+            }
+            if (geom == null) {
+                return Boolean.FALSE;
+            }
+            return geometryTrans.crosses(geom);
 
-	public String getSQL() {
-		if (geometryWKT == null) {
-			try {
-				geometryWKT = geometry.convertToWKT();
-			} catch (GeometryOperationNotSupportedException e) {
-				throw new DataEvaluatorRuntimeException(e);
-			} catch (GeometryOperationException e) {
-				throw new DataEvaluatorRuntimeException(e);
-			}
-		}
+        } catch (Exception e) {
+            throw new EvaluatorException(e);
+        }
+    }
 
-		return " ST_crosses(ST_GeomFromText('" + geometryWKT + "', " + "'"
-				+ srs + "'" + "), " + geomName + ") ";
-	}
+    @Override
+    public String getName() {
+        return "crosses with geometry";
+    }
 
+    @Override
+    public String getSQL() {
+        return this.builder.set(
+                builder.ST_Crosses(
+                        builder.geometry(geometry, projection),
+                        builder.column(geomName)
+                )
+        ).toString();
+    }
 }
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/DisjointGeometryEvaluator.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/DisjointGeometryEvaluator.java	(revision 43033)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/DisjointGeometryEvaluator.java	(revision 43034)
@@ -3,116 +3,110 @@
  *
  * Copyright (C) 2007-2013 gvSIG Association.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3 of the License, or (at your option) any later
+ * version.
  *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * For any additional information, do not hesitate to contact us
- * at info AT gvsig.com, or visit our website www.gvsig.com.
+ * For any additional information, do not hesitate to contact us at info AT
+ * gvsig.com, or visit our website www.gvsig.com.
  */
 package org.gvsig.fmap.mapcontext.layers.vectorial;
 
 import org.cresques.cts.ICoordTrans;
 import org.cresques.cts.IProjection;
-import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException;
+import org.gvsig.fmap.dal.ExpressionBuilder;
 import org.gvsig.fmap.dal.feature.Feature;
 import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureType;
 import org.gvsig.fmap.geom.Geometry;
-import org.gvsig.fmap.geom.operation.GeometryOperationException;
-import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
 import org.gvsig.tools.evaluator.AbstractEvaluator;
 import org.gvsig.tools.evaluator.EvaluatorData;
 import org.gvsig.tools.evaluator.EvaluatorException;
-/**
- *
- * @author Vicente Caballero Navarro
- *
- */
-public class DisjointGeometryEvaluator extends AbstractEvaluator {
 
-	private String geomName;
-	private Geometry geometry;
-	private Geometry geometryTrans;
-	private String srs;
-	private boolean isDefault;
-	private String geometryWKT;
 
-	DisjointGeometryEvaluator(Geometry geometry,
-			IProjection projection,
-			FeatureType featureType,
-			String geomName) {
-		FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
-				.get(geomName);
-		this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
-				geomName);
-		this.geometry = geometry;
-		this.geometryTrans = geometry.cloneGeometry();
-		this.srs = projection.getAbrev();
-		
-		IProjection fad_proj = fad.getSRS();
-		ICoordTrans ct = null;
-		
-		if (fad_proj != null && !fad_proj.equals(projection)) {
-		    ct = projection.getCT(fad_proj);
-		}
+public class DisjointGeometryEvaluator extends AbstractEvaluator {
 
-		if (ct != null) {
-			geometryTrans.reProject(ct);
-		}
-		this.geomName = geomName;
+    private final String geomName;
+    private final Geometry geometry;
+    private final Geometry geometryTrans;
+    private final boolean isDefault;
+    private final ExpressionBuilder builder;
+    private final IProjection projection;
+    
+    DisjointGeometryEvaluator(
+            Geometry geometry,
+            IProjection projection,
+            FeatureType featureType,
+            String geomName,
+            ExpressionBuilder builder
+        ) {
+        FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType
+                .get(geomName);
+        this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName);
+        this.geometry = geometry;
+        this.geometryTrans = geometry.cloneGeometry();
+        this.projection = projection;
+        this.builder = builder;
+        
+        IProjection fad_proj = fad.getSRS();
+        ICoordTrans ct = null;
 
-		this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
+        if (fad_proj != null && !fad_proj.equals(projection)) {
+            ct = projection.getCT(fad_proj);
+        }
 
-	}
+        if (ct != null) {
+            geometryTrans.reProject(ct);
+        }
+        this.geomName = geomName;
 
-	public Object evaluate(EvaluatorData data) throws EvaluatorException {
-		try {
-			Geometry geom = null;
-			if (isDefault) {
-				Feature feature = (Feature) data.getContextValue("feature");
-				geom = feature.getDefaultGeometry();
+        this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
 
-			} else {
-				geom = (Geometry) data.getDataValue(geomName);
-			}
-                        if ( geom == null ) {
-                            return Boolean.FALSE;
-                        }
-			return new Boolean(geometryTrans.disjoint(geom));
+    }
 
-		} catch (Exception e) {
-			throw new EvaluatorException(e);
-		}
-	}
+    @Override
+    public Object evaluate(EvaluatorData data) throws EvaluatorException {
+        try {
+            Geometry geom;
+            if (isDefault) {
+                Feature feature = (Feature) data.getContextValue("feature");
+                geom = feature.getDefaultGeometry();
 
-	public String getName() {
-		return "disjoint with geometry";
-	}
+            } else {
+                geom = (Geometry) data.getDataValue(geomName);
+            }
+            if (geom == null) {
+                return Boolean.FALSE;
+            }
+            return geometryTrans.disjoint(geom);
 
-	public String getSQL() {
-		if (geometryWKT == null) {
-			try {
-				geometryWKT = geometry.convertToWKT();
-			} catch (GeometryOperationNotSupportedException e) {
-				throw new DataEvaluatorRuntimeException(e);
-			} catch (GeometryOperationException e) {
-				throw new DataEvaluatorRuntimeException(e);
-			}
-		}
-		return " ST_disjoint(ST_GeomFromText('" + geometryWKT + "', " + "'"
-				+ srs + "'" + "), " + geomName + ") ";
-	}
+        } catch (Exception e) {
+            throw new EvaluatorException(e);
+        }
+    }
 
+    @Override
+    public String getName() {
+        return "disjoint with geometry";
+    }
+
+    @Override
+    public String getSQL() {
+        return this.builder.set(
+                builder.ST_Disjoint(
+                        builder.geometry(geometry, projection),
+                        builder.column(geomName)
+                )
+        ).toString();
+    }
 }
