summaryrefslogtreecommitdiffstats
path: root/petascope/src/petascope/wcps/server/core/ReduceScalarExpr.java
diff options
context:
space:
mode:
authorConstantin <jucovschi@gmail.com>2010-06-02 20:11:10 +0200
committerConstantin <jucovschi@gmail.com>2010-06-02 20:11:10 +0200
commit93b5abce94b65529df95670dd45260bc469e120b (patch)
treeb82ce43668fc6053e88d2ec4cc4a91e7527cbd4b /petascope/src/petascope/wcps/server/core/ReduceScalarExpr.java
parent26c676d01aa3995556d83fbee6a84f87a51915a9 (diff)
parent40e12c6af9d05c3413efaf535c35c625b736cbb9 (diff)
downloadrasdaman-upstream-93b5abce94b65529df95670dd45260bc469e120b.tar.gz
rasdaman-upstream-93b5abce94b65529df95670dd45260bc469e120b.tar.xz
rasdaman-upstream-93b5abce94b65529df95670dd45260bc469e120b.zip
Merge branch 'master' of git://kahlua/petascope
Diffstat (limited to 'petascope/src/petascope/wcps/server/core/ReduceScalarExpr.java')
-rw-r--r--petascope/src/petascope/wcps/server/core/ReduceScalarExpr.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/petascope/src/petascope/wcps/server/core/ReduceScalarExpr.java b/petascope/src/petascope/wcps/server/core/ReduceScalarExpr.java
new file mode 100644
index 0000000..d7e343c
--- /dev/null
+++ b/petascope/src/petascope/wcps/server/core/ReduceScalarExpr.java
@@ -0,0 +1,68 @@
+/*
+ * This file is part of PetaScope.
+ *
+ * PetaScope 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 3 of
+ * the License, or (at your option) any later version.
+ *
+ * PetaScope 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 PetaScope. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * For more information please see <http://www.PetaScope.org>
+ * or contact Peter Baumann via <baumann@rasdaman.com>.
+ *
+ * Copyright 2009 Jacobs University Bremen, Peter Baumann.
+ */
+package petascope.wcps.server.core;
+
+import petascope.wcps.server.exceptions.InvalidCrsException;
+import petascope.wcps.server.exceptions.WCPSException;
+import org.w3c.dom.*;
+
+public class ReduceScalarExpr implements IRasNode {
+
+ CoverageExpr expr;
+ String op;
+
+ public ReduceScalarExpr(Node node, XmlQuery xq) throws WCPSException, InvalidCrsException {
+ if (node.getNodeName().equals("reduce")) {
+ node = node.getFirstChild();
+ }
+ while ((node != null) && node.getNodeName().equals("#text")) {
+ node = node.getNextSibling();
+ }
+
+ System.err.println("Trying to parse ReduceScalarExpr ");
+ String nodeName = node.getNodeName();
+
+ if (nodeName.equals("all") || nodeName.equals("some") || nodeName.equals("count")
+ || nodeName.equals("add") || nodeName.equals("avg") || nodeName.equals("min")
+ || nodeName.equals("max")) {
+ op = nodeName;
+
+ if (!op.equals("all") && !op.equals("some")) {
+ op = op + "_cells";
+ }
+
+ node = node.getFirstChild();
+
+ while ((node != null) && (node.getNodeName().equals("#text"))) {
+ node = node.getNextSibling();
+ }
+
+ expr = new CoverageExpr(node, xq);
+ } else {
+ throw new WCPSException("invalid ReduceScalarExprType node : " + nodeName);
+ }
+ }
+
+ public String toRasQL() {
+ return op + "(" + expr.toRasQL() + ")";
+ }
+}