From 48569a6bbf2914b8b5f094374b525b4f08cf9732 Mon Sep 17 00:00:00 2001
From: gmantele <gmantele@ari.uni-heidelberg.de>
Date: Mon, 4 May 2015 11:31:59 +0200
Subject: [PATCH] [ADQL] Rename UnresolvedJoin and UnresolvedFunction so that
 normalizing all UnresolvedXxx exceptions.

---
 src/adql/db/DBChecker.java                     | 18 +++++++++---------
 src/adql/db/DBCommonColumn.java                | 12 ++++++------
 ...n.java => UnresolvedFunctionException.java} | 12 ++++++------
 .../UnresolvedIdentifiersException.java        |  4 ++--
 ...dJoin.java => UnresolvedJoinException.java} | 11 ++++++-----
 src/adql/query/from/ADQLJoin.java              | 16 ++++++++--------
 src/adql/query/from/FromContent.java           | 10 +++++-----
 src/adql/translator/JDBCTranslator.java        |  6 +++---
 8 files changed, 45 insertions(+), 44 deletions(-)
 rename src/adql/db/exception/{UnresolvedFunction.java => UnresolvedFunctionException.java} (91%)
 rename src/adql/db/exception/{UnresolvedJoin.java => UnresolvedJoinException.java} (85%)

diff --git a/src/adql/db/DBChecker.java b/src/adql/db/DBChecker.java
index 14d8bba..92a59e5 100644
--- a/src/adql/db/DBChecker.java
+++ b/src/adql/db/DBChecker.java
@@ -16,7 +16,7 @@ package adql.db;
  * 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 2011,2013-2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
+ * Copyright 2011,2013-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
  *                            Astronomisches Rechen Institut (ARI)
  */
 
@@ -34,7 +34,7 @@ import adql.db.STCS.CoordSys;
 import adql.db.STCS.Region;
 import adql.db.STCS.RegionType;
 import adql.db.exception.UnresolvedColumnException;
-import adql.db.exception.UnresolvedFunction;
+import adql.db.exception.UnresolvedFunctionException;
 import adql.db.exception.UnresolvedIdentifiersException;
 import adql.db.exception.UnresolvedTableException;
 import adql.parser.ParseException;
@@ -97,7 +97,7 @@ import adql.search.SimpleSearchHandler;
  * </i></p>
  * 
  * @author Gr&eacute;gory Mantelet (CDS;ARI)
- * @version 1.3 (10/2014)
+ * @version 1.3 (05/2015)
  */
 public class DBChecker implements QueryChecker {
 
@@ -790,7 +790,7 @@ public class DBChecker implements QueryChecker {
 		// If no UDF are allowed, throw immediately an error:
 		if (allowedUdfs.length == 0){
 			for(ADQLObject result : sHandler)
-				errors.addException(new UnresolvedFunction((UserDefinedFunction)result));
+				errors.addException(new UnresolvedFunctionException((UserDefinedFunction)result));
 		}
 		// 2. Try to resolve all of them:
 		else{
@@ -816,7 +816,7 @@ public class DBChecker implements QueryChecker {
 				if (match < 0){
 					// ...if the type of all parameters is resolved, add an error (no match is possible):
 					if (isAllParamTypesResolved(udf))
-						errors.addException(new UnresolvedFunction(udf));	// TODO Add the ADQLOperand position!
+						errors.addException(new UnresolvedFunctionException(udf));	// TODO Add the ADQLOperand position!
 					// ...otherwise, try to resolved it later (when other UDFs will be mostly resolved):
 					else
 						toResolveLater.add(udf);
@@ -833,7 +833,7 @@ public class DBChecker implements QueryChecker {
 				match = binSearch.search(udf, allowedUdfs);
 				// if no match, add an error:
 				if (match < 0)
-					errors.addException(new UnresolvedFunction(udf));	// TODO Add the ADQLOperand position!
+					errors.addException(new UnresolvedFunctionException(udf));	// TODO Add the ADQLOperand position!
 				// otherwise, metadata may be attached (particularly if the function is built automatically by the syntactic parser):
 				else if (udf instanceof DefaultUDF)
 					((DefaultUDF)udf).setDefinition(allowedUdfs[match]);
@@ -958,7 +958,7 @@ public class DBChecker implements QueryChecker {
 		if (allowedGeo.length != 0)
 			match = binSearch.search(fctName, allowedGeo);
 		if (match < 0)
-			errors.addException(new UnresolvedFunction("The geometrical function \"" + fctName + "\" is not available in this implementation!", fct));
+			errors.addException(new UnresolvedFunctionException("The geometrical function \"" + fctName + "\" is not available in this implementation!", fct));
 	}
 
 	/**
@@ -1093,7 +1093,7 @@ public class DBChecker implements QueryChecker {
 		// Check that the region type is allowed:
 		if (allowedGeo != null){
 			if (allowedGeo.length == 0)
-				errors.addException(new UnresolvedFunction("The region type \"" + r.type + "\" is not available in this implementation!", fct));
+				errors.addException(new UnresolvedFunctionException("The region type \"" + r.type + "\" is not available in this implementation!", fct));
 			else
 				checkGeometryFunction((r.type == RegionType.POSITION) ? "POINT" : r.type.toString(), fct, binSearch, errors);
 		}
@@ -1350,7 +1350,7 @@ public class DBChecker implements QueryChecker {
 			}catch(Exception ex){
 				// IF NO INSTANCE CAN BE CREATED...
 				// ...keep the error for further report:
-				errors.addException(new UnresolvedFunction("Impossible to represent the function \"" + ((DefaultUDF)objToReplace).getName() + "\": the following error occured while creating this representation: \"" + ((ex instanceof InvocationTargetException) ? "[" + ex.getCause().getClass().getSimpleName() + "] " + ex.getCause().getMessage() : ex.getMessage()) + "\"", (DefaultUDF)objToReplace));
+				errors.addException(new UnresolvedFunctionException("Impossible to represent the function \"" + ((DefaultUDF)objToReplace).getName() + "\": the following error occured while creating this representation: \"" + ((ex instanceof InvocationTargetException) ? "[" + ex.getCause().getClass().getSimpleName() + "] " + ex.getCause().getMessage() : ex.getMessage()) + "\"", (DefaultUDF)objToReplace));
 				// ...keep the same object (i.e. no replacement):
 				return objToReplace;
 			}
diff --git a/src/adql/db/DBCommonColumn.java b/src/adql/db/DBCommonColumn.java
index 8c5d3ba..44c6642 100644
--- a/src/adql/db/DBCommonColumn.java
+++ b/src/adql/db/DBCommonColumn.java
@@ -16,13 +16,13 @@ package adql.db;
  * 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 2014 - Astronomisches Rechen Institut (ARI)
+ * Copyright 2014-2015 - Astronomisches Rechen Institut (ARI)
  */
 
 import java.util.ArrayList;
 import java.util.Iterator;
 
-import adql.db.exception.UnresolvedJoin;
+import adql.db.exception.UnresolvedJoinException;
 import adql.query.ADQLQuery;
 
 /**
@@ -34,7 +34,7 @@ import adql.query.ADQLQuery;
  * in case of several JOINs.
  * 
  * @author Gr&eacute;gory Mantelet (ARI) - gmantele@ari.uni-heidelberg.de
- * @version 1.3 (10/2014)
+ * @version 1.3 (05/2015)
  * @since 1.2
  */
 public class DBCommonColumn implements DBColumn {
@@ -56,12 +56,12 @@ public class DBCommonColumn implements DBColumn {
 	 * @param leftCol	Column of the left join table. May be a {@link DBCommonColumn}.
 	 * @param rightCol	Column of the right join table. May be a {@link DBCommonColumn}.
 	 * 
-	 * @throws UnresolvedJoin	If the type of the two given columns are not roughly (just testing numeric, string or geometry) compatible.
+	 * @throws UnresolvedJoinException	If the type of the two given columns are not roughly (just testing numeric, string or geometry) compatible.
 	 */
-	public DBCommonColumn(final DBColumn leftCol, final DBColumn rightCol) throws UnresolvedJoin{
+	public DBCommonColumn(final DBColumn leftCol, final DBColumn rightCol) throws UnresolvedJoinException{
 		// Test whether type of both columns are compatible:
 		if (leftCol.getDatatype() != null && rightCol.getDatatype() != null && !leftCol.getDatatype().isCompatible(rightCol.getDatatype()))
-			throw new UnresolvedJoin("JOIN impossible: incompatible column types when trying to join the columns " + leftCol.getADQLName() + " (" + leftCol.getDatatype() + ") and " + rightCol.getADQLName() + " (" + rightCol.getDatatype() + ")!");
+			throw new UnresolvedJoinException("JOIN impossible: incompatible column types when trying to join the columns " + leftCol.getADQLName() + " (" + leftCol.getDatatype() + ") and " + rightCol.getADQLName() + " (" + rightCol.getDatatype() + ")!");
 
 		// LEFT COLUMN:
 		if (leftCol instanceof DBCommonColumn){
diff --git a/src/adql/db/exception/UnresolvedFunction.java b/src/adql/db/exception/UnresolvedFunctionException.java
similarity index 91%
rename from src/adql/db/exception/UnresolvedFunction.java
rename to src/adql/db/exception/UnresolvedFunctionException.java
index b6eb459..befb556 100644
--- a/src/adql/db/exception/UnresolvedFunction.java
+++ b/src/adql/db/exception/UnresolvedFunctionException.java
@@ -16,7 +16,7 @@ package adql.db.exception;
  * 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 2014 - Astronomisches Rechen Institut (ARI)
+ * Copyright 2014-2015 - Astronomisches Rechen Institut (ARI)
  */
 
 import adql.parser.ParseException;
@@ -26,10 +26,10 @@ import adql.query.operand.function.ADQLFunction;
  * Exception thrown when a function can not be resolved by the library.
  * 
  * @author Gr&eacute;gory Mantelet (ARI)
- * @version 1.3 (10/2014)
+ * @version 1.3 (05/2015)
  * @since 1.3
  */
-public class UnresolvedFunction extends ParseException {
+public class UnresolvedFunctionException extends ParseException {
 	private static final long serialVersionUID = 1L;
 
 	/** Function which can not be resolved. */
@@ -40,7 +40,7 @@ public class UnresolvedFunction extends ParseException {
 	 * 
 	 * @param message	Description of the error.
 	 */
-	public UnresolvedFunction(final String message){
+	public UnresolvedFunctionException(final String message){
 		super(message);
 		functionInError = null;
 	}
@@ -51,7 +51,7 @@ public class UnresolvedFunction extends ParseException {
 	 * 
 	 * @param fct	The unresolved function.
 	 */
-	public UnresolvedFunction(final ADQLFunction fct){
+	public UnresolvedFunctionException(final ADQLFunction fct){
 		super("Unresolved function: \"" + fct.toADQL() + "\"! No UDF has been defined or found with the signature: " + getFctSignature(fct) + "."); // TODO Add the position of the function in the ADQL query!
 		functionInError = fct;
 	}
@@ -63,7 +63,7 @@ public class UnresolvedFunction extends ParseException {
 	 * @param message	Description of the error.
 	 * @param fct		The unresolved function.
 	 */
-	public UnresolvedFunction(final String message, final ADQLFunction fct){
+	public UnresolvedFunctionException(final String message, final ADQLFunction fct){
 		super(message); // TODO Add the position of the function in the ADQL query!
 		functionInError = fct;
 	}
diff --git a/src/adql/db/exception/UnresolvedIdentifiersException.java b/src/adql/db/exception/UnresolvedIdentifiersException.java
index ab38ec8..2a6c89c 100644
--- a/src/adql/db/exception/UnresolvedIdentifiersException.java
+++ b/src/adql/db/exception/UnresolvedIdentifiersException.java
@@ -72,8 +72,8 @@ public class UnresolvedIdentifiersException extends ParseException implements It
 				String tableName = ((UnresolvedTableException)pe).getTableName();
 				if (tableName != null && !tableName.trim().isEmpty())
 					addIdentifierName(tableName + " " + pe.getPosition());
-			}else if (pe instanceof UnresolvedFunction){
-				String fctName = (((UnresolvedFunction)pe).getFunction() == null) ? null : ((UnresolvedFunction)pe).getFunction().getName() + "(...)";
+			}else if (pe instanceof UnresolvedFunctionException){
+				String fctName = (((UnresolvedFunctionException)pe).getFunction() == null) ? null : ((UnresolvedFunctionException)pe).getFunction().getName() + "(...)";
 				if (fctName != null && !fctName.trim().isEmpty())
 					addIdentifierName(fctName /*+ " " + pe.getPosition()*/);	// TODO Add the position of the function in the ADQL query!
 			}else if (pe instanceof UnresolvedIdentifiersException)
diff --git a/src/adql/db/exception/UnresolvedJoin.java b/src/adql/db/exception/UnresolvedJoinException.java
similarity index 85%
rename from src/adql/db/exception/UnresolvedJoin.java
rename to src/adql/db/exception/UnresolvedJoinException.java
index 819beaa..162bcd0 100644
--- a/src/adql/db/exception/UnresolvedJoin.java
+++ b/src/adql/db/exception/UnresolvedJoinException.java
@@ -16,7 +16,7 @@ package adql.db.exception;
  * 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 2013-2014 - Astronomisches Rechen Institut (ARI)
+ * Copyright 2013-2015 - Astronomisches Rechen Institut (ARI)
  */
 
 import adql.parser.ParseException;
@@ -27,9 +27,10 @@ import adql.query.TextPosition;
  * and particularly because of the join condition (i.e. column names not found, ...).
  * 
  * @author Gr&eacute;gory Mantelet (ARI) - gmantele@ari.uni-heidelberg.de
- * @version 1.2 (11/2013)
+ * @version 1.3 (05/2015)
+ * @since 1.2
  */
-public class UnresolvedJoin extends ParseException {
+public class UnresolvedJoinException extends ParseException {
 	private static final long serialVersionUID = 1L;
 
 	/**
@@ -38,7 +39,7 @@ public class UnresolvedJoin extends ParseException {
 	 * 
 	 * @param message	Message to display explaining why the join can't be resolved.
 	 */
-	public UnresolvedJoin(String message){
+	public UnresolvedJoinException(String message){
 		super(message);
 	}
 
@@ -48,7 +49,7 @@ public class UnresolvedJoin extends ParseException {
 	 * @param message		Message to display explaining why the join can't be resolved.
 	 * @param errorPosition	Position of the wrong part of the join.
 	 */
-	public UnresolvedJoin(String message, TextPosition errorPosition){
+	public UnresolvedJoinException(String message, TextPosition errorPosition){
 		super(message, errorPosition);
 	}
 
diff --git a/src/adql/query/from/ADQLJoin.java b/src/adql/query/from/ADQLJoin.java
index bbc7482..650422c 100644
--- a/src/adql/query/from/ADQLJoin.java
+++ b/src/adql/query/from/ADQLJoin.java
@@ -16,7 +16,7 @@ package adql.query.from;
  * 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-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
  *                       Astronomisches Rechen Institut (ARI)
  */
 
@@ -30,7 +30,7 @@ import java.util.NoSuchElementException;
 import adql.db.DBColumn;
 import adql.db.DBCommonColumn;
 import adql.db.SearchColumnList;
-import adql.db.exception.UnresolvedJoin;
+import adql.db.exception.UnresolvedJoinException;
 import adql.query.ADQLIterator;
 import adql.query.ADQLObject;
 import adql.query.ClauseConstraints;
@@ -41,7 +41,7 @@ import adql.query.operand.ADQLColumn;
  * Defines a join between two "tables".
  * 
  * @author Gr&eacute;gory Mantelet (CDS;ARI)
- * @version 1.2 (11/2013)
+ * @version 1.3 (05/2015)
  */
 public abstract class ADQLJoin implements ADQLObject, FromContent {
 
@@ -340,7 +340,7 @@ public abstract class ADQLJoin implements ADQLObject, FromContent {
 	}
 
 	@Override
-	public SearchColumnList getDBColumns() throws UnresolvedJoin{
+	public SearchColumnList getDBColumns() throws UnresolvedJoinException{
 		SearchColumnList list = new SearchColumnList();
 		SearchColumnList leftList = leftTable.getDBColumns();
 		SearchColumnList rightList = rightTable.getDBColumns();
@@ -408,20 +408,20 @@ public abstract class ADQLJoin implements ADQLObject, FromContent {
 		}
 	}
 
-	public final static DBColumn findExactlyOneColumn(final String columnName, final byte caseSensitive, final SearchColumnList list, final boolean leftList) throws UnresolvedJoin{
+	public final static DBColumn findExactlyOneColumn(final String columnName, final byte caseSensitive, final SearchColumnList list, final boolean leftList) throws UnresolvedJoinException{
 		DBColumn result = findAtMostOneColumn(columnName, caseSensitive, list, leftList);
 		if (result == null)
-			throw new UnresolvedJoin("Column \"" + columnName + "\" specified in USING clause does not exist in " + (leftList ? "left" : "right") + " table!");
+			throw new UnresolvedJoinException("Column \"" + columnName + "\" specified in USING clause does not exist in " + (leftList ? "left" : "right") + " table!");
 		else
 			return result;
 	}
 
-	public final static DBColumn findAtMostOneColumn(final String columnName, final byte caseSensitive, final SearchColumnList list, final boolean leftList) throws UnresolvedJoin{
+	public final static DBColumn findAtMostOneColumn(final String columnName, final byte caseSensitive, final SearchColumnList list, final boolean leftList) throws UnresolvedJoinException{
 		ArrayList<DBColumn> result = list.search(null, null, null, columnName, caseSensitive);
 		if (result.isEmpty())
 			return null;
 		else if (result.size() > 1)
-			throw new UnresolvedJoin("Common column name \"" + columnName + "\" appears more than once in " + (leftList ? "left" : "right") + " table!");
+			throw new UnresolvedJoinException("Common column name \"" + columnName + "\" appears more than once in " + (leftList ? "left" : "right") + " table!");
 		else
 			return result.get(0);
 	}
diff --git a/src/adql/query/from/FromContent.java b/src/adql/query/from/FromContent.java
index 1660ebf..413929c 100644
--- a/src/adql/query/from/FromContent.java
+++ b/src/adql/query/from/FromContent.java
@@ -16,7 +16,7 @@ package adql.query.from;
  * 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-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
  *                       Astronomisches Rechen Institut (ARI)
  */
 
@@ -24,7 +24,7 @@ import java.util.ArrayList;
 
 import adql.db.DBColumn;
 import adql.db.SearchColumnList;
-import adql.db.exception.UnresolvedJoin;
+import adql.db.exception.UnresolvedJoinException;
 import adql.query.ADQLObject;
 
 /**
@@ -32,7 +32,7 @@ import adql.query.ADQLObject;
  * It could be either a table ({@link ADQLTable}) or a join ({@link ADQLJoin}).
  * 
  * @author Gr&eacute;gory Mantelet (CDS;ARI)
- * @version 1.2 (11/2013)
+ * @version 1.3 (05/2015)
  */
 public interface FromContent extends ADQLObject {
 
@@ -42,9 +42,9 @@ public interface FromContent extends ADQLObject {
 	 * <p><i><u>Note:</u> In the most cases, this list is generated on the fly !</i></p>
 	 * 
 	 * @return	All the available {@link DBColumn}s.
-	 * @throws UnresolvedJoin If a join is not possible.
+	 * @throws UnresolvedJoinException If a join is not possible.
 	 */
-	public SearchColumnList getDBColumns() throws UnresolvedJoin;
+	public SearchColumnList getDBColumns() throws UnresolvedJoinException;
 
 	/**
 	 * Gets all {@link ADQLTable} instances contained in this FROM part (itself included, if it is an {@link ADQLTable}).
diff --git a/src/adql/translator/JDBCTranslator.java b/src/adql/translator/JDBCTranslator.java
index d97b4c5..0ba1b0d 100644
--- a/src/adql/translator/JDBCTranslator.java
+++ b/src/adql/translator/JDBCTranslator.java
@@ -28,7 +28,7 @@ import adql.db.DBColumn;
 import adql.db.DBTable;
 import adql.db.DBType;
 import adql.db.STCS.Region;
-import adql.db.exception.UnresolvedJoin;
+import adql.db.exception.UnresolvedJoinException;
 import adql.parser.ParseException;
 import adql.query.ADQLList;
 import adql.query.ADQLObject;
@@ -167,7 +167,7 @@ import adql.query.operand.function.geometry.RegionFunction;
  * </p>
  * 
  * @author Gr&eacute;gory Mantelet (ARI)
- * @version 1.3 (02/2015)
+ * @version 1.3 (05/2015)
  * @since 1.3
  * 
  * @see PostgreSQLTranslator
@@ -457,7 +457,7 @@ public abstract class JDBCTranslator implements ADQLTranslator {
 		}else if (item.getQuery() != null){
 			try{
 				dbCols = item.getQuery().getFrom().getDBColumns();
-			}catch(UnresolvedJoin pe){
+			}catch(UnresolvedJoinException pe){
 				throw new TranslationException("Due to a join problem, the ADQL to SQL translation can not be completed!", pe);
 			}
 			ArrayList<ADQLTable> tables = item.getQuery().getFrom().getTables();
-- 
GitLab