From fe3d904ecf6b1667d6db1a14def2fd8176c9df81 Mon Sep 17 00:00:00 2001 From: gmantele <gmantele@ari.uni-heidelberg.de> Date: Mon, 11 Sep 2017 12:21:31 +0200 Subject: [PATCH] [ADQL] Fix the automatic name of some operands. The idea is to get rid of special characters such as '-', '+' , '(', ... This commit resolves a part of the Pull Request #14 --- src/adql/query/operand/Concatenation.java | 19 ++++++++++++++++--- src/adql/query/operand/NegativeOperand.java | 6 +++--- src/adql/query/operand/Operation.java | 6 +++--- src/adql/query/operand/WrappedOperand.java | 6 +++--- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/adql/query/operand/Concatenation.java b/src/adql/query/operand/Concatenation.java index 24536c7..2aade65 100644 --- a/src/adql/query/operand/Concatenation.java +++ b/src/adql/query/operand/Concatenation.java @@ -16,7 +16,7 @@ package adql.query.operand; * You should have received a copy of the GNU Lesser General Public License * along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -27,7 +27,7 @@ import adql.query.ADQLObject; * Represents a concatenation in ADQL (ex: <i>"_s_ra" || ':' || "_s_dec"</i>). * * @author Grégory Mantelet (CDS;ARI) - * @version 1.3 (10/2014) + * @version 1.4 (09/2017) */ public final class Concatenation extends ADQLList<ADQLOperand> implements ADQLOperand { @@ -36,7 +36,7 @@ public final class Concatenation extends ADQLList<ADQLOperand> implements ADQLOp * To add operands, use the "add" functions. */ public Concatenation(){ - super((String)null); + super("CONCAT_STR"); } /** @@ -81,4 +81,17 @@ public final class Concatenation extends ADQLList<ADQLOperand> implements ADQLOp return false; } + @Override + public String toADQL(){ + StringBuffer adql = new StringBuffer(); + + for(int i = 0; i < size(); i++){ + if (i > 0) + adql.append(" " + getSeparator(i) + " "); + adql.append(get(i).toADQL()); + } + + return adql.toString(); + } + } \ No newline at end of file diff --git a/src/adql/query/operand/NegativeOperand.java b/src/adql/query/operand/NegativeOperand.java index a524aae..7e3c7fd 100644 --- a/src/adql/query/operand/NegativeOperand.java +++ b/src/adql/query/operand/NegativeOperand.java @@ -16,7 +16,7 @@ package adql.query.operand; * You should have received a copy of the GNU Lesser General Public License * along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -30,7 +30,7 @@ import adql.query.TextPosition; * Lets putting a minus sign in front of any numeric operand. * * @author Grégory Mantelet (CDS;ARI) - * @version 1.4 (06/2015) + * @version 1.4 (09/2017) */ public final class NegativeOperand implements ADQLOperand { @@ -116,7 +116,7 @@ public final class NegativeOperand implements ADQLOperand { @Override public String getName(){ - return "-" + operand.getName(); + return "NEG_" + operand.getName(); } @Override diff --git a/src/adql/query/operand/Operation.java b/src/adql/query/operand/Operation.java index f8a0a73..398bc80 100644 --- a/src/adql/query/operand/Operation.java +++ b/src/adql/query/operand/Operation.java @@ -16,7 +16,7 @@ package adql.query.operand; * You should have received a copy of the GNU Lesser General Public License * along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -30,7 +30,7 @@ import adql.query.TextPosition; * It represents a simple numeric operation (sum, difference, multiplication and division). * * @author Grégory Mantelet (CDS;ARI) - * @version 1.4 (06/2015) + * @version 1.4 (09/2017) * * @see OperationType */ @@ -216,7 +216,7 @@ public class Operation implements ADQLOperand { @Override public String getName(){ - return operation.toString(); + return operation.name(); } @Override diff --git a/src/adql/query/operand/WrappedOperand.java b/src/adql/query/operand/WrappedOperand.java index ff90fe1..15796ea 100644 --- a/src/adql/query/operand/WrappedOperand.java +++ b/src/adql/query/operand/WrappedOperand.java @@ -16,7 +16,7 @@ package adql.query.operand; * You should have received a copy of the GNU Lesser General Public License * along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), + * Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -30,7 +30,7 @@ import adql.query.TextPosition; * Lets wrapping an operand by parenthesis. * * @author Grégory Mantelet (CDS;ARI) - * @version 1.4 (06/2015) + * @version 1.4 (09/2017) */ public class WrappedOperand implements ADQLOperand { @@ -99,7 +99,7 @@ public class WrappedOperand implements ADQLOperand { @Override public String getName(){ - return "(" + operand.getName() + ")"; + return operand.getName(); } @Override -- GitLab