parameters) {
+ this.parameters = parameters;
+ }
+
+ @Override
+ public Object evaluate(Object object) {
+ Function function = ExpressionFactory.createFunction(this.name);
+ if (function != null) {
+ function.getParameters().addAll(this.parameters);
+ return function.evaluate(object);
+ }
+ return this.getFallbackValue();
+ }
+
+ @Override
+ public String toString() {
+ return this.getName();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime
+ * result
+ + ((this.fallbackValue == null) ? 0 : this.fallbackValue
+ .hashCode());
+ result = prime * result
+ + ((this.name == null) ? 0 : this.name.hashCode());
+ result = prime * result
+ + ((this.parameters == null) ? 0 : this.parameters.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (this.getClass() != obj.getClass()) {
+ return false;
+ }
+ FunctionImpl other = (FunctionImpl) obj;
+ if (this.fallbackValue == null) {
+ if (other.fallbackValue != null) {
+ return false;
+ }
+ } else if (!this.fallbackValue.equals(other.fallbackValue)) {
+ return false;
+ }
+ if (this.name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!this.name.equals(other.name)) {
+ return false;
+ }
+ if (this.parameters == null) {
+ if (other.parameters != null) {
+ return false;
+ }
+ } else if (!this.parameters.equals(other.parameters)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/src/main/java/fr/ign/cogit/geoxygene/filter/function/Max.java b/src/main/java/fr/ign/cogit/geoxygene/filter/function/Max.java
new file mode 100644
index 0000000..48e4e16
--- /dev/null
+++ b/src/main/java/fr/ign/cogit/geoxygene/filter/function/Max.java
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the GeOxygene project source files. GeOxygene aims at
+ * providing an open framework which implements OGC/ISO specifications for the
+ * development and deployment of geographic (GIS) applications. It is a open
+ * source contribution of the COGIT laboratory at the Institut Géographique
+ * National (the French National Mapping Agency). See:
+ * http://oxygene-project.sourceforge.net Copyright (C) 2005 Institut
+ * Géographique National This library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License,
+ * or any later version. This library 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 Lesser
+ * General Public License for more details. You should have received a copy of
+ * the GNU Lesser General Public License along with this library (see file
+ * LICENSE if present); if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package fr.ign.cogit.geoxygene.filter.function;
+
+import java.math.BigDecimal;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Julien Perret
+ */
+@XmlRootElement(name = "Function")
+public class Max extends FunctionImpl {
+
+ public Max() {
+ this.name = "Max";} //$NON-NLS-1$
+
+ @Override
+ public Object evaluate(Object object) {
+ return ((BigDecimal) this.getParameters().get(0).evaluate(object))
+ .max((BigDecimal) this.getParameters().get(1).evaluate(object));
+ }
+}
diff --git a/src/main/java/fr/ign/cogit/geoxygene/filter/function/Min.java b/src/main/java/fr/ign/cogit/geoxygene/filter/function/Min.java
new file mode 100644
index 0000000..17a2135
--- /dev/null
+++ b/src/main/java/fr/ign/cogit/geoxygene/filter/function/Min.java
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the GeOxygene project source files.
+ *
+ * GeOxygene aims at providing an open framework which implements OGC/ISO
+ * specifications for the development and deployment of geographic (GIS)
+ * applications. It is a open source contribution of the COGIT laboratory at the
+ * Institut Géographique National (the French National Mapping Agency).
+ *
+ * See: http://oxygene-project.sourceforge.net
+ *
+ * Copyright (C) 2005 Institut Géographique National
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or any later version.
+ *
+ * This library 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 Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library (see file LICENSE if present); if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307 USA
+ */
+
+package fr.ign.cogit.geoxygene.filter.function;
+
+import java.math.BigDecimal;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Julien Perret
+ *
+ */
+@XmlRootElement(name = "Function")
+public class Min extends FunctionImpl {
+
+ public Min() {
+ this.name = "Min";} //$NON-NLS-1$
+
+ @Override
+ public Object evaluate(Object object) {
+ return ((BigDecimal) this.getParameters().get(0).evaluate(object))
+ .min((BigDecimal) this.getParameters().get(1).evaluate(object));
+ }
+
+}
diff --git a/src/main/java/fr/ign/cogit/geoxygene/filter/function/Pow.java b/src/main/java/fr/ign/cogit/geoxygene/filter/function/Pow.java
new file mode 100644
index 0000000..d2745f5
--- /dev/null
+++ b/src/main/java/fr/ign/cogit/geoxygene/filter/function/Pow.java
@@ -0,0 +1,41 @@
+/*
+ * This file is part of the GeOxygene project source files. GeOxygene aims at
+ * providing an open framework which implements OGC/ISO specifications for the
+ * development and deployment of geographic (GIS) applications. It is a open
+ * source contribution of the COGIT laboratory at the Institut Géographique
+ * National (the French National Mapping Agency). See:
+ * http://oxygene-project.sourceforge.net Copyright (C) 2005 Institut
+ * Géographique National This library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License,
+ * or any later version. This library 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 Lesser
+ * General Public License for more details. You should have received a copy of
+ * the GNU Lesser General Public License along with this library (see file
+ * LICENSE if present); if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package fr.ign.cogit.geoxygene.filter.function;
+
+import java.math.BigDecimal;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Julien Perret
+ */
+@XmlRootElement(name = "Function")
+public class Pow extends FunctionImpl {
+
+ public Pow() {
+ this.name = "Pow";} //$NON-NLS-1$
+
+ @Override
+ public Object evaluate(Object object) {
+ return ((BigDecimal) this.getParameters().get(0).evaluate(object))
+ .pow(((BigDecimal) this.getParameters().get(1).evaluate(object))
+ .intValue());
+ }
+}
diff --git a/src/main/java/fr/ign/cogit/geoxygene/filter/package-info.java b/src/main/java/fr/ign/cogit/geoxygene/filter/package-info.java
new file mode 100644
index 0000000..ca27848
--- /dev/null
+++ b/src/main/java/fr/ign/cogit/geoxygene/filter/package-info.java
@@ -0,0 +1,29 @@
+/*
+ * This file is part of the GeOxygene project source files. GeOxygene aims at
+ * providing an open framework which implements OGC/ISO specifications for the
+ * development and deployment of geographic (GIS) applications. It is a open
+ * source contribution of the COGIT laboratory at the Institut Géographique
+ * National (the French National Mapping Agency). See:
+ * http://oxygene-project.sourceforge.net Copyright (C) 2005 Institut
+ * Géographique National This library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License,
+ * or any later version. This library 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 Lesser
+ * General Public License for more details. You should have received a copy of
+ * the GNU Lesser General Public License along with this library (see file
+ * LICENSE if present); if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/**
+ * GeOxygene Filter package.
+ *
+ * It contains GeOxygene OGC Filter Implementation.
+ */
+@XmlSchema(xmlns = { @javax.xml.bind.annotation.XmlNs(prefix = "ogc", namespaceURI = "http://www.opengis.net/ogc") }, namespace = "http://www.opengis.net/ogc")
+package fr.ign.cogit.geoxygene.filter;
+
+import javax.xml.bind.annotation.XmlSchema;
+
diff --git a/src/main/java/fr/ign/cogit/geoxygene/filter/spatial/BinarySpatialOpsType.java b/src/main/java/fr/ign/cogit/geoxygene/filter/spatial/BinarySpatialOpsType.java
new file mode 100644
index 0000000..4c48349
--- /dev/null
+++ b/src/main/java/fr/ign/cogit/geoxygene/filter/spatial/BinarySpatialOpsType.java
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the GeOxygene project source files. GeOxygene aims at
+ * providing an open framework which implements OGC/ISO specifications for the
+ * development and deployment of geographic (GIS) applications. It is a open
+ * source contribution of the COGIT laboratory at the Institut Géographique
+ * National (the French National Mapping Agency). See:
+ * http://oxygene-project.sourceforge.net Copyright (C) 2005 Institut
+ * Géographique National This library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License,
+ * or any later version. This library 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 Lesser
+ * General Public License for more details. You should have received a copy of
+ * the GNU Lesser General Public License along with this library (see file
+ * LICENSE if present); if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package fr.ign.cogit.geoxygene.filter.spatial;
+
+import fr.ign.cogit.geoxygene.filter.SpatialOpsType;
+
+/**
+ * @author Julien Perret
+ */
+public abstract class BinarySpatialOpsType extends SpatialOpsType {
+}
diff --git a/src/test/java/fr/ign/cogit/geoxygene/filter/expression/SimpleTest.java b/src/test/java/fr/ign/cogit/geoxygene/filter/expression/SimpleTest.java
new file mode 100644
index 0000000..c6b33da
--- /dev/null
+++ b/src/test/java/fr/ign/cogit/geoxygene/filter/expression/SimpleTest.java
@@ -0,0 +1,90 @@
+/*
+ * This file is part of the GeOxygene project source files. GeOxygene aims at
+ * providing an open framework which implements OGC/ISO specifications for the
+ * development and deployment of geographic (GIS) applications. It is a open
+ * source contribution of the COGIT laboratory at the Institut Géographique
+ * National (the French National Mapping Agency). See:
+ * http://oxygene-project.sourceforge.net Copyright (C) 2005 Institut
+ * Géographique National This library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the License,
+ * or any later version. This library 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 Lesser
+ * General Public License for more details. You should have received a copy of
+ * the GNU Lesser General Public License along with this library (see file
+ * LICENSE if present); if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package fr.ign.cogit.geoxygene.filter.expression;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+import fr.ign.cogit.geoxygene.filter.function.Max;
+import junit.framework.Assert;
+
+/**
+ * @author Julien Perret
+ */
+public class SimpleTest {
+
+ @Test
+ public void testArithmeticExpressions() {
+ Add add = new Add();
+ Literal literal1 = new Literal();
+ String stringValue1 = new String("5"); //$NON-NLS-1$
+ literal1.setValue(stringValue1);
+ add.getParameters().add(literal1);
+ Literal literal2 = new Literal();
+ String stringValue2 = new String("2.00"); //$NON-NLS-1$
+ literal2.setValue(stringValue2);
+ add.getParameters().add(literal2);
+ Object resultAdd = add.evaluate(null);
+ System.out.println(resultAdd);
+ Assert.assertTrue(resultAdd.equals(new BigDecimal("7.00"))); //$NON-NLS-1$
+ Subtract sub = new Subtract();
+ sub.getParameters().add(literal1);
+ sub.getParameters().add(literal2);
+ Object resultSub = sub.evaluate(null);
+ System.out.println(resultSub);
+ Assert.assertTrue(resultSub.equals(new BigDecimal("3.00"))); //$NON-NLS-1$
+ Multiply mul = new Multiply();
+ mul.getParameters().add(literal1);
+ mul.getParameters().add(literal2);
+ Object resultMul = mul.evaluate(null);
+ System.out.println(resultMul);
+ Assert.assertTrue(resultMul.equals(new BigDecimal("10.00"))); //$NON-NLS-1$
+ Divide div = new Divide();
+ div.getParameters().add(literal1);
+ div.getParameters().add(literal2);
+ Object resultDiv = div.evaluate(null);
+ System.out.println(resultDiv);
+ Assert.assertTrue(resultDiv.equals(new BigDecimal("2.5"))); //$NON-NLS-1$
+ Function function = new Max();
+ Subtract subtract = new Subtract();
+ subtract.getParameters().add(new Literal("100")); //$NON-NLS-1$
+ Multiply multiply = new Multiply();
+ Subtract subtract2 = new Subtract();
+ subtract2.getParameters().add(new Literal("0")); //$NON-NLS-1$
+ subtract2.getParameters().add(new Literal("20")); //$NON-NLS-1$
+ System.out.println("subtract2 = " + subtract2.evaluate(null)); //$NON-NLS-1$
+ multiply.getParameters().add(subtract2);
+ multiply.getParameters().add(new Literal("5")); //$NON-NLS-1$
+ subtract.getParameters().add(multiply);
+ System.out.println("subtract = " + subtract.evaluate(null)); //$NON-NLS-1$
+ List parameters = new ArrayList();
+ parameters.add(subtract);
+ Multiply multiply2 = new Multiply();
+ multiply2.getParameters().add(new Literal("100")); //$NON-NLS-1$
+ multiply2.getParameters().add(new Literal("0")); //$NON-NLS-1$
+ parameters.add(multiply2);
+ function.setParameters(parameters);
+ Object resultFunction = function.evaluate(null);
+ System.out.println(resultFunction);
+ }
+}